Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1422203 > unrolled thread
| Started by | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| First post | 2016-06-14 20:40 +0200 |
| Last post | 2016-06-15 00:20 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-06-14 20:40 +0200
Re: [PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-06-14 21:40 +0200
Re: [PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info Andrew Lunn <andrew@lunn.ch> - 2016-06-14 23:50 +0200
Re: [PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-06-15 00:20 +0200
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-06-14 20:40 +0200 |
| Subject | [PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info |
| Message-ID | <rK1pN-88-49@gated-at.bofh.it> |
With legacy probing, we cannot have a compatible info structure. We have
to guess it. Instead of using only the first info structure of the info
table, iterate over the compatible data.
That way, the legacy code will support new compatible chips with
different register access without requiring any code change.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 2f36d01..88c09d5 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3668,6 +3668,25 @@ mv88e6xxx_smi_detect(struct device *dev, struct mii_bus *bus, int sw_addr,
return ps;
}
+static struct mv88e6xxx_priv_state *
+mv88e6xxx_drv_detect(struct device *dev, struct mii_bus *bus, int sw_addr)
+{
+ struct mv88e6xxx_priv_state *ps = NULL;
+ const struct mv88e6xxx_info *info;
+ const struct of_device_id *id;
+
+ /* Iterate over compatible info to detect the chip */
+ for (id = &mv88e6xxx_of_id_table[0]; id && id->data; ++id) {
+ info = (const struct mv88e6xxx_info *)id->data;
+
+ ps = mv88e6xxx_smi_detect(dev, bus, sw_addr, info);
+ if (ps)
+ break;
+ }
+
+ return ps;
+}
+
static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
struct device *host_dev, int sw_addr,
void **priv)
@@ -3680,7 +3699,7 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
if (!bus)
return NULL;
- ps = mv88e6xxx_smi_detect(dsa_dev, bus, sw_addr, &mv88e6xxx_table[0]);
+ ps = mv88e6xxx_drv_detect(dsa_dev, bus, sw_addr);
if (!ps)
return NULL;
--
2.8.3
[toc] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2016-06-14 21:40 +0200 |
| Subject | Re: [PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info |
| Message-ID | <rK2lQ-Kt-15@gated-at.bofh.it> |
| In reply to | #1422203 |
On 06/14/2016 09:31 PM, Vivien Didelot wrote:
> With legacy probing, we cannot have a compatible info structure. We have
> to guess it. Instead of using only the first info structure of the info
> table, iterate over the compatible data.
>
> That way, the legacy code will support new compatible chips with
> different register access without requiring any code change.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> ---
> drivers/net/dsa/mv88e6xxx.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 2f36d01..88c09d5 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -3668,6 +3668,25 @@ mv88e6xxx_smi_detect(struct device *dev, struct mii_bus *bus, int sw_addr,
> return ps;
> }
>
> +static struct mv88e6xxx_priv_state *
> +mv88e6xxx_drv_detect(struct device *dev, struct mii_bus *bus, int sw_addr)
> +{
> + struct mv88e6xxx_priv_state *ps = NULL;
> + const struct mv88e6xxx_info *info;
> + const struct of_device_id *id;
> +
> + /* Iterate over compatible info to detect the chip */
> + for (id = &mv88e6xxx_of_id_table[0]; id && id->data; ++id) {
> + info = (const struct mv88e6xxx_info *)id->data;
The explicit cast shouldn't be needed...
[...]
MBR, Sergei
[toc] | [prev] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2016-06-14 23:50 +0200 |
| Subject | Re: [PATCH v2 net-next v2 10/12] net: dsa: mv88e6xxx: iterate on compatible info |
| Message-ID | <rK4nE-20k-11@gated-at.bofh.it> |
| In reply to | #1422203 |
On Tue, Jun 14, 2016 at 02:31:51PM -0400, Vivien Didelot wrote: > With legacy probing, we cannot have a compatible info structure. We have > to guess it. Instead of using only the first info structure of the info > table, iterate over the compatible data. > > That way, the legacy code will support new compatible chips with > different register access without requiring any code change. I don't think this is safe when used in combination with multi-chip addresses. This code will perform writes on various addresses, addresses which could be real registers on a device. I don't see a need to support guessing. The new binding will work, without any guessing. So use that. Andrew
[toc] | [prev] | [next] | [standalone]
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-06-15 00:20 +0200 |
| Message-ID | <rK4QG-2oZ-29@gated-at.bofh.it> |
| In reply to | #1422365 |
Hi Andrew,
Andrew Lunn <andrew@lunn.ch> writes:
> On Tue, Jun 14, 2016 at 02:31:51PM -0400, Vivien Didelot wrote:
>> With legacy probing, we cannot have a compatible info structure. We have
>> to guess it. Instead of using only the first info structure of the info
>> table, iterate over the compatible data.
>>
>> That way, the legacy code will support new compatible chips with
>> different register access without requiring any code change.
>
> I don't think this is safe when used in combination with multi-chip
> addresses. This code will perform writes on various addresses,
> addresses which could be real registers on a device.
>
> I don't see a need to support guessing. The new binding will work,
> without any guessing. So use that.
OK, I drop this patch and limit the detection in the legacy probing
against the 6085 chip info.
Thanks,
Vivien
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web