mirror of https://lore.kernel.org/lkml/
 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>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next v4 5/9] net: dsa: mv88e6xxx: add switch info
Date: Sun, 17 Apr 2016 19:54:28 +0200	[thread overview]
Message-ID: <20160417175428.GB4071@lunn.ch> (raw)
In-Reply-To: <1460913843-7459-6-git-send-email-vivien.didelot@savoirfairelinux.com>

On Sun, Apr 17, 2016 at 01:23:59PM -0400, Vivien Didelot wrote:
> Add a new switch info structure which is meant to store switch models
> static information, such as product number, name, number of ports,
> number of databases, etc.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

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

Thanks
	Andrew

> ---
>  drivers/net/dsa/mv88e6123.c | 15 +++++++++++----
>  drivers/net/dsa/mv88e6131.c | 19 ++++++++++++++-----
>  drivers/net/dsa/mv88e6171.c | 19 ++++++++++++++-----
>  drivers/net/dsa/mv88e6352.c | 27 ++++++++++++++++++++-------
>  drivers/net/dsa/mv88e6xxx.c | 18 +++++++++++-------
>  drivers/net/dsa/mv88e6xxx.h | 27 +++++++++++++++++++++++----
>  6 files changed, 93 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
> index d6921ba..62dffcf 100644
> --- a/drivers/net/dsa/mv88e6123.c
> +++ b/drivers/net/dsa/mv88e6123.c
> @@ -17,10 +17,17 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
> -	{ PORT_SWITCH_ID_6123, "Marvell 88E6123" },
> -	{ PORT_SWITCH_ID_6161, "Marvell 88E6161" },
> -	{ PORT_SWITCH_ID_6165, "Marvell 88E6165" },
> +static const struct mv88e6xxx_info mv88e6123_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
> +		.name = "Marvell 88E6123",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
> +		.name = "Marvell 88E6161",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
> +		.name = "Marvell 88E6165",
> +	}
>  };
>  
>  static const char *mv88e6123_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
> index 8dc1365..0056715 100644
> --- a/drivers/net/dsa/mv88e6131.c
> +++ b/drivers/net/dsa/mv88e6131.c
> @@ -17,11 +17,20 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
> -	{ PORT_SWITCH_ID_6085, "Marvell 88E6085" },
> -	{ PORT_SWITCH_ID_6095, "Marvell 88E6095/88E6095F" },
> -	{ PORT_SWITCH_ID_6131, "Marvell 88E6131" },
> -	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
> +static const struct mv88e6xxx_info mv88e6131_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
> +		.name = "Marvell 88E6095/88E6095F",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
> +		.name = "Marvell 88E6085",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
> +		.name = "Marvell 88E6131",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
> +		.name = "Marvell 88E6185",
> +	}
>  };
>  
>  static const char *mv88e6131_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
> index ae32875..ea14ab2 100644
> --- a/drivers/net/dsa/mv88e6171.c
> +++ b/drivers/net/dsa/mv88e6171.c
> @@ -17,11 +17,20 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
> -	{ PORT_SWITCH_ID_6171, "Marvell 88E6171" },
> -	{ PORT_SWITCH_ID_6175, "Marvell 88E6175" },
> -	{ PORT_SWITCH_ID_6350, "Marvell 88E6350" },
> -	{ PORT_SWITCH_ID_6351, "Marvell 88E6351" },
> +static const struct mv88e6xxx_info mv88e6171_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
> +		.name = "Marvell 88E6171",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
> +		.name = "Marvell 88E6175",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
> +		.name = "Marvell 88E6350",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
> +		.name = "Marvell 88E6351",
> +	}
>  };
>  
>  static const char *mv88e6171_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
> index 34f92b1..2f72606 100644
> --- a/drivers/net/dsa/mv88e6352.c
> +++ b/drivers/net/dsa/mv88e6352.c
> @@ -22,13 +22,26 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
> -	{ PORT_SWITCH_ID_6172, "Marvell 88E6172" },
> -	{ PORT_SWITCH_ID_6176, "Marvell 88E6176" },
> -	{ PORT_SWITCH_ID_6240, "Marvell 88E6240" },
> -	{ PORT_SWITCH_ID_6320, "Marvell 88E6320" },
> -	{ PORT_SWITCH_ID_6321, "Marvell 88E6321" },
> -	{ PORT_SWITCH_ID_6352, "Marvell 88E6352" },
> +static const struct mv88e6xxx_info mv88e6352_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
> +		.name = "Marvell 88E6320",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
> +		.name = "Marvell 88E6321",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
> +		.name = "Marvell 88E6172",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
> +		.name = "Marvell 88E6176",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
> +		.name = "Marvell 88E6240",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
> +		.name = "Marvell 88E6352",
> +	}
>  };
>  
>  static const char *mv88e6352_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 49f085a..5fb21e0 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -3169,24 +3169,25 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
>  }
>  #endif /* CONFIG_NET_DSA_HWMON */
>  
> -static const char *
> -mv88e6xxx_lookup_name(unsigned int id, const struct mv88e6xxx_switch_id *table,
> +static const struct mv88e6xxx_info *
> +mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table,
>  		      unsigned int num)
>  {
>  	int i;
>  
>  	for (i = 0; i < num; ++i)
> -		if (table[i].id == (id & 0xfff0))
> -			return table[i].name;
> +		if (table[i].prod_num == prod_num)
> +			return &table[i];
>  
>  	return NULL;
>  }
>  
>  const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  				int sw_addr, void **priv,
> -				const struct mv88e6xxx_switch_id *table,
> +				const struct mv88e6xxx_info *table,
>  				unsigned int num)
>  {
> +	const struct mv88e6xxx_info *info;
>  	struct mv88e6xxx_priv_state *ps;
>  	struct mii_bus *bus;
>  	const char *name;
> @@ -3203,16 +3204,19 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  	prod_num = (id & 0xfff0) >> 4;
>  	rev = id & 0x000f;
>  
> -	name = mv88e6xxx_lookup_name(id, table, num);
> -	if (!name)
> +	info = mv88e6xxx_lookup_info(prod_num, table, num);
> +	if (!info)
>  		return NULL;
>  
> +	name = info->name;
> +
>  	ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
>  	if (!ps)
>  		return NULL;
>  
>  	ps->bus = bus;
>  	ps->sw_addr = sw_addr;
> +	ps->info = info;
>  	ps->id = id & 0xfff0;
>  
>  	*priv = ps;
> diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
> index 6513450..b87f574 100644
> --- a/drivers/net/dsa/mv88e6xxx.h
> +++ b/drivers/net/dsa/mv88e6xxx.h
> @@ -68,6 +68,23 @@
>  #define PORT_PCS_CTRL_UNFORCED		0x03
>  #define PORT_PAUSE_CTRL		0x02
>  #define PORT_SWITCH_ID		0x03
> +#define PORT_SWITCH_ID_PROD_NUM_6085	0x04a
> +#define PORT_SWITCH_ID_PROD_NUM_6095	0x095
> +#define PORT_SWITCH_ID_PROD_NUM_6131	0x106
> +#define PORT_SWITCH_ID_PROD_NUM_6320	0x115
> +#define PORT_SWITCH_ID_PROD_NUM_6123	0x121
> +#define PORT_SWITCH_ID_PROD_NUM_6161	0x161
> +#define PORT_SWITCH_ID_PROD_NUM_6165	0x165
> +#define PORT_SWITCH_ID_PROD_NUM_6171	0x171
> +#define PORT_SWITCH_ID_PROD_NUM_6172	0x172
> +#define PORT_SWITCH_ID_PROD_NUM_6175	0x175
> +#define PORT_SWITCH_ID_PROD_NUM_6176	0x176
> +#define PORT_SWITCH_ID_PROD_NUM_6185	0x1a7
> +#define PORT_SWITCH_ID_PROD_NUM_6240	0x240
> +#define PORT_SWITCH_ID_PROD_NUM_6321	0x310
> +#define PORT_SWITCH_ID_PROD_NUM_6352	0x352
> +#define PORT_SWITCH_ID_PROD_NUM_6350	0x371
> +#define PORT_SWITCH_ID_PROD_NUM_6351	0x375
>  #define PORT_SWITCH_ID_6031	0x0310
>  #define PORT_SWITCH_ID_6035	0x0350
>  #define PORT_SWITCH_ID_6046	0x0480
> @@ -352,9 +369,9 @@
>  
>  #define MV88E6XXX_N_FID		4096
>  
> -struct mv88e6xxx_switch_id {
> -	u16 id;
> -	char *name;
> +struct mv88e6xxx_info {
> +	u16 prod_num;
> +	const char *name;
>  };
>  
>  struct mv88e6xxx_atu_entry {
> @@ -382,6 +399,8 @@ struct mv88e6xxx_priv_port {
>  };
>  
>  struct mv88e6xxx_priv_state {
> +	const struct mv88e6xxx_info *info;
> +
>  	/* The dsa_switch this private structure is related to */
>  	struct dsa_switch *ds;
>  
> @@ -449,7 +468,7 @@ struct mv88e6xxx_hw_stat {
>  int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
>  const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  				int sw_addr, void **priv,
> -				const struct mv88e6xxx_switch_id *table,
> +				const struct mv88e6xxx_info *table,
>  				unsigned int num);
>  
>  int mv88e6xxx_setup_ports(struct dsa_switch *ds);
> -- 
> 2.8.0
> 

  reply	other threads:[~2016-04-17 17:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-17 17:23 [PATCH net-next v4 0/9] net: dsa: mv88e6xxx: factorize " Vivien Didelot
2016-04-17 17:23 ` [PATCH net-next v4 1/9] net: dsa: constify probed name Vivien Didelot
2016-04-17 17:53   ` Andrew Lunn
2016-04-17 17:23 ` [PATCH net-next v4 2/9] net: dsa: mv88e6xxx: drop double ds assignment Vivien Didelot
2016-04-17 17:23 ` [PATCH net-next v4 3/9] net: dsa: mv88e6xxx: drop revision probing Vivien Didelot
2016-04-17 17:23 ` [PATCH net-next v4 4/9] net: dsa: mv88e6xxx: read switch ID in probe Vivien Didelot
2016-04-17 17:23 ` [PATCH net-next v4 5/9] net: dsa: mv88e6xxx: add switch info Vivien Didelot
2016-04-17 17:54   ` Andrew Lunn [this message]
2016-04-17 17:24 ` [PATCH net-next v4 6/9] net: dsa: mv88e6xxx: add family to info Vivien Didelot
2016-04-17 17:24 ` [PATCH net-next v4 7/9] net: dsa: mv88e6xxx: add number of ports " Vivien Didelot
2016-04-17 17:24 ` [PATCH net-next v4 8/9] net: dsa: mv88e6xxx: add number of db " Vivien Didelot
2016-04-17 17:24 ` [PATCH net-next v4 9/9] net: dsa: mv88e6xxx: remove switch ID from ps Vivien Didelot
2016-04-17 22:54 ` [PATCH net-next v4 0/9] net: dsa: mv88e6xxx: factorize switch info 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=20160417175428.GB4071@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@savoirfairelinux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®