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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > > +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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux