Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>
Subject: Re: [net-next PATCH 2/2] net: dsa: rtl8366: Refactor VLAN/PVID init
Date: Sun, 23 Aug 2020 19:06:10 -0700	[thread overview]
Message-ID: <6757c233-b072-837b-e1ce-f88d8819b396@gmail.com> (raw)
In-Reply-To: <20200823205944.127796-3-linus.walleij@linaro.org>



On 8/23/2020 1:59 PM, Linus Walleij wrote:
> The VLANs and PVIDs on the RTL8366 utilizes a "member
> configuration" (MC) which is largely unexplained in the
> code.
> 
> This set-up requires a special ordering: rtl8366_set_pvid()
> must be called first, followed by rtl8366_set_vlan(),
> else the MC will not be properly allocated. Relax this
> by factoring out the code obtaining an MC and reuse
> the helper in both rtl8366_set_pvid() and
> rtl8366_set_vlan() so we remove this strict ordering
> requirement.
> 
> In the process, add some better comments and debug prints
> so people who read the code understand what is going on.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---

[snip]
> +/**
> + * rtl8366_obtain_mc() - retrieve or allocate a VLAN member configuration
> + * @smi: the Realtek SMI device instance
> + * @vid: the VLAN ID to look up or allocate
> + * @vlanmc: the pointer will be assigned to a pointer to a valid member config
> + * if successful
> + * @index: the pointer will be assigned to the index of the valid member config
> + * if successful
> + * @return: 0 or error number

You could return the index directly, since only negative error codes are 
of interest to deal with failures?

[snip]

> +
> +	dev_err(smi->dev, "all VLAN member configurations are in use\n");
> +	return -EINVAL;

Maybe -ENOSPC?

[snip]

   				vid);
> +
> +		ret = rtl8366_set_pvid(smi, port, vid);
> +		if (ret)
> +			dev_err(smi->dev,
> +				"failed to set PVID on port %d to VLAN %04x",
> +				port, vid);
> +
> +		if (!ret)
> +			dev_dbg(smi->dev, "VLAN add: added VLAN %04x with PVID on port %d\n",
> +				vid, port);

Since you are changing this message to a debug print, can we bring some 
consistency along the way and print the VID as decimal (not hexadecimal) 
to match the prior instances?
-- 
Florian

      reply	other threads:[~2020-08-24  2:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-23 20:59 [net-next PATCH 0/2] RTL8366 stabilization Linus Walleij
2020-08-23 20:59 ` [net-next PATCH 1/2] net: dsa: rtl8366: Check validity of passed VLANs Linus Walleij
2020-08-23 20:59 ` [net-next PATCH 2/2] net: dsa: rtl8366: Refactor VLAN/PVID init Linus Walleij
2020-08-24  2:06   ` Florian Fainelli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6757c233-b072-837b-e1ce-f88d8819b396@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=linus.walleij@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --subject='Re: [net-next PATCH 2/2] net: dsa: rtl8366: Refactor VLAN/PVID init' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).