All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@savoirfairelinux.com,
	"David S. Miller" <davem@davemloft.net>,
	Kevin Smith <kevin.smith@elecsyscorp.com>
Subject: Re: [PATCH net-next] net: dsa: mv88e6xxx: read then write PVID
Date: Tue, 8 Mar 2016 15:37:04 +0100	[thread overview]
Message-ID: <20160308143704.GF351@lunn.ch> (raw)
In-Reply-To: <1457393079-22740-1-git-send-email-vivien.didelot@savoirfairelinux.com>

On Mon, Mar 07, 2016 at 06:24:39PM -0500, Vivien Didelot wrote:
> The port register 0x07 contains more options than just the default VID,
> even though they are not used yet. So prefer a read then write operation
> over a direct write.
> 
> This also allows to keep track of the change through dynamic debug.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Tested-by: Andrew Lunn <andrew@lunn.ch>

Thanks
        Andrew


> ---
>  drivers/net/dsa/mv88e6xxx.c | 30 ++++++++++++++++++++++++++----
>  1 file changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 3a58a8a..1aee42d 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -1166,23 +1166,45 @@ int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
>  	return 0;
>  }
>  
> -static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
> +static int _mv88e6xxx_port_pvid(struct dsa_switch *ds, int port, u16 *new,
> +				u16 *old)
>  {
> +	u16 pvid;
>  	int ret;
>  
>  	ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN);
>  	if (ret < 0)
>  		return ret;
>  
> -	*pvid = ret & PORT_DEFAULT_VLAN_MASK;
> +	pvid = ret & PORT_DEFAULT_VLAN_MASK;
> +
> +	if (new) {
> +		ret &= ~PORT_DEFAULT_VLAN_MASK;
> +		ret |= *new & PORT_DEFAULT_VLAN_MASK;
> +
> +		ret = _mv88e6xxx_reg_write(ds, REG_PORT(port),
> +					   PORT_DEFAULT_VLAN, ret);
> +		if (ret < 0)
> +			return ret;
> +
> +		netdev_dbg(ds->ports[port], "DefaultVID %d (was %d)\n", *new,
> +			   pvid);
> +	}
> +
> +	if (old)
> +		*old = pvid;
>  
>  	return 0;
>  }
>  
> +static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
> +{
> +	return _mv88e6xxx_port_pvid(ds, port, NULL, pvid);
> +}
> +
>  static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid)
>  {
> -	return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_DEFAULT_VLAN,
> -				   pvid & PORT_DEFAULT_VLAN_MASK);
> +	return _mv88e6xxx_port_pvid(ds, port, &pvid, NULL);
>  }
>  
>  static int _mv88e6xxx_vtu_wait(struct dsa_switch *ds)
> -- 
> 2.7.2
> 

  reply	other threads:[~2016-03-08 14:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 23:24 [PATCH net-next] net: dsa: mv88e6xxx: read then write PVID Vivien Didelot
2016-03-08 14:37 ` Andrew Lunn [this message]
2016-03-10 21:11 ` David Miller

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=20160308143704.GF351@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kernel@savoirfairelinux.com \
    --cc=kevin.smith@elecsyscorp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.