Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1380643 > unrolled thread
| Started by | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| First post | 2016-04-17 00:50 +0200 |
| Last post | 2016-04-17 17:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH net-next v3 0/8] net: dsa: mv88e6xxx: factorize switch info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-17 00:50 +0200
[PATCH net-next v3 3/8] net: dsa: mv88e6xxx: read switch ID in probe Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-17 00:50 +0200
Re: [PATCH net-next v3 3/8] net: dsa: mv88e6xxx: read switch ID in probe Andrew Lunn <andrew@lunn.ch> - 2016-04-17 17:30 +0200
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-04-17 00:50 +0200 |
| Subject | [PATCH net-next v3 0/8] net: dsa: mv88e6xxx: factorize switch info |
| Message-ID | <roHcm-2nN-3@gated-at.bofh.it> |
This patchset factorizes the mv88e6xxx code by sharing a new extendable info structure to store static data such as switch family, product number, number of ports, number of databases and the name. The next step is to add a "flags" bitmap member to the info structure in order to simplify the shared code with a feature-based logic instead of checking their family/ID. This is a step forward having a single mv88e6xxx driver supporting many similar devices, like any usual Linux driver. Changes v2 -> v3: - update commit messages and add Andrew's tags - keep the info lookup code in a separated function - split the single switch ID reading in probe in a new commit Changes v1 -> v2: - define PORT_SWITCH_ID_PROD_NUM_* values - use plain struct mv88e6xxx_info - remove non used yet ps->rev Vivien Didelot (8): net: dsa: mv88e6xxx: drop double ds assignment net: dsa: mv88e6xxx: drop revision probing net: dsa: mv88e6xxx: read switch ID in probe net: dsa: mv88e6xxx: add switch info net: dsa: mv88e6xxx: add family to info net: dsa: mv88e6xxx: add number of ports to info net: dsa: mv88e6xxx: add number of db to info net: dsa: mv88e6xxx: remove switch ID from ps drivers/net/dsa/mv88e6123.c | 45 +++++----- drivers/net/dsa/mv88e6131.c | 53 ++++++------ drivers/net/dsa/mv88e6171.c | 36 +++++--- drivers/net/dsa/mv88e6352.c | 55 ++++++++---- drivers/net/dsa/mv88e6xxx.c | 206 ++++++++++++++------------------------------ drivers/net/dsa/mv88e6xxx.h | 92 ++++++++------------ 6 files changed, 214 insertions(+), 273 deletions(-) -- 2.8.0
[toc] | [next] | [standalone]
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-04-17 00:50 +0200 |
| Subject | [PATCH net-next v3 3/8] net: dsa: mv88e6xxx: read switch ID in probe |
| Message-ID | <roHcn-2nN-43@gated-at.bofh.it> |
| In reply to | #1380643 |
Read the switch ID only once, at probe time, to avoid multiple read
accesses and MII bus checking.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx.c | 54 +++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index b63e985..af5ae70 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2667,8 +2667,6 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
ps->ds = ds;
mutex_init(&ps->smi_mutex);
- ps->id = REG_READ(REG_PORT(0), PORT_SWITCH_ID) & 0xfff0;
-
INIT_WORK(&ps->bridge_work, mv88e6xxx_bridge_work);
return 0;
@@ -3068,21 +3066,14 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
}
#endif /* CONFIG_NET_DSA_HWMON */
-static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
+static char *mv88e6xxx_lookup_name(unsigned int id,
const struct mv88e6xxx_switch_id *table,
unsigned int num)
{
- int i, ret;
-
- if (!bus)
- return NULL;
-
- ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
- if (ret < 0)
- return NULL;
+ int i;
for (i = 0; i < num; ++i)
- if (table[i].id == (ret & 0xfff0))
+ if (table[i].id == (id & 0xfff0))
return table[i].name;
return NULL;
@@ -3094,23 +3085,38 @@ char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
unsigned int num)
{
struct mv88e6xxx_priv_state *ps;
- struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
+ struct mii_bus *bus;
+ int id, prod_num, rev;
char *name;
+ bus = dsa_host_dev_to_mii_bus(host_dev);
if (!bus)
return NULL;
- name = mv88e6xxx_lookup_name(bus, sw_addr, table, num);
- if (name) {
- ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
- if (!ps)
- return NULL;
- *priv = ps;
- ps->bus = dsa_host_dev_to_mii_bus(host_dev);
- if (!ps->bus)
- return NULL;
- ps->sw_addr = sw_addr;
- }
+ id = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
+ if (id < 0)
+ return NULL;
+
+ prod_num = (id & 0xfff0) >> 4;
+ rev = id & 0x000f;
+
+ name = mv88e6xxx_lookup_name(id, table, num);
+ if (!name)
+ return NULL;
+
+ ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
+ if (!ps)
+ return NULL;
+
+ ps->bus = bus;
+ ps->sw_addr = sw_addr;
+ ps->id = id & 0xfff0;
+
+ *priv = ps;
+
+ dev_info(&ps->bus->dev, "switch 0x%x probed: %s, revision %u\n",
+ prod_num, name, rev);
+
return name;
}
--
2.8.0
[toc] | [prev] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2016-04-17 17:30 +0200 |
| Subject | Re: [PATCH net-next v3 3/8] net: dsa: mv88e6xxx: read switch ID in probe |
| Message-ID | <roWO6-6uI-11@gated-at.bofh.it> |
| In reply to | #1380644 |
On Sat, Apr 16, 2016 at 06:41:40PM -0400, Vivien Didelot wrote:
> Read the switch ID only once, at probe time, to avoid multiple read
> accesses and MII bus checking.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Thanks
Andrew
> ---
> drivers/net/dsa/mv88e6xxx.c | 54 +++++++++++++++++++++++++--------------------
> 1 file changed, 30 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index b63e985..af5ae70 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -2667,8 +2667,6 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
> ps->ds = ds;
> mutex_init(&ps->smi_mutex);
>
> - ps->id = REG_READ(REG_PORT(0), PORT_SWITCH_ID) & 0xfff0;
> -
> INIT_WORK(&ps->bridge_work, mv88e6xxx_bridge_work);
>
> return 0;
> @@ -3068,21 +3066,14 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
> }
> #endif /* CONFIG_NET_DSA_HWMON */
>
> -static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
> +static char *mv88e6xxx_lookup_name(unsigned int id,
> const struct mv88e6xxx_switch_id *table,
> unsigned int num)
> {
> - int i, ret;
> -
> - if (!bus)
> - return NULL;
> -
> - ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
> - if (ret < 0)
> - return NULL;
> + int i;
>
> for (i = 0; i < num; ++i)
> - if (table[i].id == (ret & 0xfff0))
> + if (table[i].id == (id & 0xfff0))
> return table[i].name;
>
> return NULL;
> @@ -3094,23 +3085,38 @@ char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
> unsigned int num)
> {
> struct mv88e6xxx_priv_state *ps;
> - struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
> + struct mii_bus *bus;
> + int id, prod_num, rev;
> char *name;
>
> + bus = dsa_host_dev_to_mii_bus(host_dev);
> if (!bus)
> return NULL;
>
> - name = mv88e6xxx_lookup_name(bus, sw_addr, table, num);
> - if (name) {
> - ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
> - if (!ps)
> - return NULL;
> - *priv = ps;
> - ps->bus = dsa_host_dev_to_mii_bus(host_dev);
> - if (!ps->bus)
> - return NULL;
> - ps->sw_addr = sw_addr;
> - }
> + id = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
> + if (id < 0)
> + return NULL;
> +
> + prod_num = (id & 0xfff0) >> 4;
> + rev = id & 0x000f;
> +
> + name = mv88e6xxx_lookup_name(id, table, num);
> + if (!name)
> + return NULL;
> +
> + ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
> + if (!ps)
> + return NULL;
> +
> + ps->bus = bus;
> + ps->sw_addr = sw_addr;
> + ps->id = id & 0xfff0;
> +
> + *priv = ps;
> +
> + dev_info(&ps->bus->dev, "switch 0x%x probed: %s, revision %u\n",
> + prod_num, name, rev);
> +
> return name;
> }
>
> --
> 2.8.0
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web