All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Andrew Lunn <andrew@lunn.ch>, davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 05/12] net: dsa: Consistently set and use ps->num_ports
Date: Wed, 01 Apr 2015 18:35:33 -0700	[thread overview]
Message-ID: <551C9CE5.1040806@roeck-us.net> (raw)
In-Reply-To: <1427937719-11630-6-git-send-email-andrew@lunn.ch>

On 04/01/2015 06:21 PM, Andrew Lunn wrote:
> As a step towards consolidating code, consistently set the
> number of ports in the private state structure, and make use of it in
> loops.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> Tested-by: Guenter Roeck <linux@roeck-us.net>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/net/dsa/mv88e6171.c | 23 +++++++++++++++--------
>   drivers/net/dsa/mv88e6352.c | 10 +++++++---
>   2 files changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
> index 639bd83b76c7..5a295533ff20 100644
> --- a/drivers/net/dsa/mv88e6171.c
> +++ b/drivers/net/dsa/mv88e6171.c
> @@ -38,12 +38,13 @@ static char *mv88e6171_probe(struct device *host_dev, int sw_addr)
>
>   static int mv88e6171_switch_reset(struct dsa_switch *ds)
>   {
> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>   	int i;
>   	int ret;
>   	unsigned long timeout;
>
>   	/* Set all ports to the disabled state. */
> -	for (i = 0; i < 8; i++) {
> +	for (i = 0; i < ps->num_ports; i++) {
>   		ret = REG_READ(REG_PORT(i), 0x04);
>   		REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
>   	}
> @@ -70,7 +71,7 @@ static int mv88e6171_switch_reset(struct dsa_switch *ds)
>   		return -ETIMEDOUT;
>
>   	/* Enable ports not under DSA, e.g. WAN port */
> -	for (i = 0; i < 8; i++) {
> +	for (i = 0; i < ps->num_ports; i++) {
>   		if (dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i))
>   			continue;
>
> @@ -83,6 +84,7 @@ static int mv88e6171_switch_reset(struct dsa_switch *ds)
>
>   static int mv88e6171_setup_global(struct dsa_switch *ds)
>   {
> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>   	int ret;
>   	int i;
>
> @@ -147,7 +149,7 @@ static int mv88e6171_setup_global(struct dsa_switch *ds)
>   	}
>
>   	/* Clear all trunk masks. */
> -	for (i = 0; i < 8; i++)
> +	for (i = 0; i < ps->num_ports; i++)
>   		REG_WRITE(REG_GLOBAL2, 0x07, 0x8000 | (i << 12) | 0xff);
>
>   	/* Clear all trunk mappings. */
> @@ -270,6 +272,7 @@ static int mv88e6171_setup_port(struct dsa_switch *ds, int p)
>
>   static int mv88e6171_setup(struct dsa_switch *ds)
>   {
> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>   	int i;
>   	int ret;
>
> @@ -277,6 +280,8 @@ static int mv88e6171_setup(struct dsa_switch *ds)
>   	if (ret < 0)
>   		return ret;
>
> +	ps->num_ports = 7;
> +
>   	ret = mv88e6171_switch_reset(ds);
>   	if (ret < 0)
>   		return ret;
> @@ -287,7 +292,7 @@ static int mv88e6171_setup(struct dsa_switch *ds)
>   	if (ret < 0)
>   		return ret;
>
> -	for (i = 0; i < 8; i++) {
> +	for (i = 0; i < ps->num_ports; i++) {
>   		if (!(dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i)))
>   			continue;
>
> @@ -299,9 +304,11 @@ static int mv88e6171_setup(struct dsa_switch *ds)
>   	return 0;
>   }
>
> -static int mv88e6171_port_to_phy_addr(int port)
> +static int mv88e6171_port_to_phy_addr(struct dsa_switch *ds, int port)
>   {
> -	if (port >= 0 && port <= 4)
> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
> +
> +	if (port >= 0 && port < ps->num_ports)
>   		return port;
>   	return -1;
>   }
> @@ -310,7 +317,7 @@ static int
>   mv88e6171_phy_read(struct dsa_switch *ds, int port, int regnum)
>   {
>   	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
> -	int addr = mv88e6171_port_to_phy_addr(port);
> +	int addr = mv88e6171_port_to_phy_addr(ds, port);
>   	int ret;
>
>   	mutex_lock(&ps->phy_mutex);
> @@ -324,7 +331,7 @@ mv88e6171_phy_write(struct dsa_switch *ds,
>   		    int port, int regnum, u16 val)
>   {
>   	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
> -	int addr = mv88e6171_port_to_phy_addr(port);
> +	int addr = mv88e6171_port_to_phy_addr(ds, port);
>   	int ret;
>
>   	mutex_lock(&ps->phy_mutex);
> diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
> index 41fe3a6a72d1..040027fcd013 100644
> --- a/drivers/net/dsa/mv88e6352.c
> +++ b/drivers/net/dsa/mv88e6352.c
> @@ -47,12 +47,13 @@ static char *mv88e6352_probe(struct device *host_dev, int sw_addr)
>
>   static int mv88e6352_switch_reset(struct dsa_switch *ds)
>   {
> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>   	unsigned long timeout;
>   	int ret;
>   	int i;
>
>   	/* Set all ports to the disabled state. */
> -	for (i = 0; i < 7; i++) {
> +	for (i = 0; i < ps->num_ports; i++) {
>   		ret = REG_READ(REG_PORT(i), 0x04);
>   		REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
>   	}
> @@ -82,6 +83,7 @@ static int mv88e6352_switch_reset(struct dsa_switch *ds)
>
>   static int mv88e6352_setup_global(struct dsa_switch *ds)
>   {
> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>   	int ret;
>   	int i;
>
> @@ -152,7 +154,7 @@ static int mv88e6352_setup_global(struct dsa_switch *ds)
>   	/* Disable ingress rate limiting by resetting all ingress
>   	 * rate limit registers to their initial state.
>   	 */
> -	for (i = 0; i < 7; i++)
> +	for (i = 0; i < ps->num_ports; i++)
>   		REG_WRITE(REG_GLOBAL2, 0x09, 0x9000 | (i << 8));
>
>   	/* Initialise cross-chip port VLAN table to reset defaults. */
> @@ -367,6 +369,8 @@ static int mv88e6352_setup(struct dsa_switch *ds)
>   	if (ret < 0)
>   		return ret;
>
> +	ps->num_ports = 7;
> +
>   	mutex_init(&ps->eeprom_mutex);
>
>   	ret = mv88e6352_switch_reset(ds);
> @@ -379,7 +383,7 @@ static int mv88e6352_setup(struct dsa_switch *ds)
>   	if (ret < 0)
>   		return ret;
>
> -	for (i = 0; i < 7; i++) {
> +	for (i = 0; i < ps->num_ports; i++) {
>   		ret = mv88e6352_setup_port(ds, i);
>   		if (ret < 0)
>   			return ret;
>

  reply	other threads:[~2015-04-02  1:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02  1:21 [PATCH 00/12] DSA Mavell drivers refactoring and cleanup Andrew Lunn
2015-04-02  1:21 ` [PATCH 01/12] net: dsa: mv88e6131: Use common initialization functions Andrew Lunn
2015-04-02  1:39   ` Guenter Roeck
2015-04-02  1:51     ` Andrew Lunn
2015-04-02  2:01       ` David Miller
2015-04-02  2:00     ` David Miller
2015-04-02  1:21 ` [PATCH 02/12] net: dsa: mv88e6xxx: Move switch product IDs into common include file Andrew Lunn
2015-04-02  1:21 ` [PATCH 03/12] net: dsa: mv88e6131: Determine and use number of switch ports Andrew Lunn
2015-04-02  1:21 ` [PATCH 04/12] net: dsa: mv88e6123_61_65: " Andrew Lunn
2015-04-02  1:21 ` [PATCH 05/12] net: dsa: Consistently set and use ps->num_ports Andrew Lunn
2015-04-02  1:35   ` Guenter Roeck [this message]
2015-04-02  1:21 ` [PATCH 06/12] net: dsa: Centralize Marvell switch reset Andrew Lunn
2015-04-02  1:21 ` [PATCH 07/12] net: dsa: Move phy page access functions into shared code Andrew Lunn
2015-04-02  1:21 ` [PATCH 08/12] net: dsa: Consolidate phy read and write functions Andrew Lunn
2015-04-02  1:21 ` [PATCH 09/12] net: dsa: mv88e6xxx: Add missing mutex's in EEE operations Andrew Lunn
2015-04-02  1:21 ` [PATCH 10/12] net: dsa: Consolidate getting the statistics Andrew Lunn
2015-04-02  1:21 ` [PATCH 11/12] net: dsa: Use mnemonics rather than register numbers Andrew Lunn
2015-04-02  1:21 ` [PATCH 12/12] net: dsa: mv88e6xxx: Fix stats counters for 6352 family Andrew Lunn

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=551C9CE5.1040806@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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.