Thread (16 messages) read the whole thread 16 messages, 4 authors, 2021-01-14

Re: [PATCH net-next v4 2/3] net: dsa: add Arrow SpeedChips XRS700x driver

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-01-14 18:13:53
Also in: netdev

quoted
quoted
+static int xrs700x_detect(struct xrs700x *dev)
+{
+     const struct xrs700x_info *info;
+     unsigned int id;
+     int ret;
+
+     ret = regmap_read(dev->regmap, XRS_DEV_ID0, &id);
+     if (ret) {
+             dev_err(dev->dev, "error %d while reading switch id.\n",
+                     ret);
+             return ret;
+     }
+
+     info = of_device_get_match_data(dev->dev);
+     if (!info)
+             return -EINVAL;
+
+     if (info->id == id) {
+             dev->ds->num_ports = info->num_ports;
+             dev_info(dev->dev, "%s detected.\n", info->name);
+             return 0;
+     }
+
+     dev_err(dev->dev, "expected switch id 0x%x but found 0x%x.\n",
+             info->id, id);
I've been there too, not the smartest of decisions in the long run. See
commit 0b0e299720bb ("net: dsa: sja1105: use detected device id instead
of DT one on mismatch") if you want a sneak preview of how this is going
to feel two years from now. If you can detect the device id you're
probably better off with a single compatible string.
Previously Andrew said:
"Either you need to verify the compatible from day one so it is not
wrong, or you just use a single compatible "arrow,xrs700x", which
cannot be wrong."

I did it the first way he suggested, if you would have replied at that
time to use a single that's the way I would have done it that way.

If you two can agree I should change it to a single string I'd be
happy to do so.
I'm happy both ways. Marvell uses just on compatible, and has worked
fine. Other drivers have specific compatible strings, and enforce the
match, and that has also worked fine.

So it is really up to you.

   Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help