net: dsa: mv88e6xxx: add switch info

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
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 @@
 }
 #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 @@
 	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;