On Tue, Jun 08, 2021 at 06:59:10AM +0100, Christoph Hellwig wrote: > This looks good as-is, but a suggestions for incremental improvements > below: > > > @@ -1032,10 +1035,10 @@ int device_driver_attach(struct device_driver *drv, struct device *dev) > > __device_driver_lock(dev, dev->parent); > > > > /* > > - * If device has been removed or someone has already successfully > > - * bound a driver before us just skip the driver probe call. > > + * If device someone has already successfully bound a driver before us > > + * just skip the driver probe call. > > */ > > - if (!dev->p->dead && !dev->driver) > > + if (!dev->driver) > > ret = driver_probe_device(drv, dev); > > > > __device_driver_unlock(dev, dev->parent); > > It is kinda silly to keep the ->driver check here given that one caller > completely ignores the return value, and the other turns a 0 return into > -ENODEV anyway. Later patches revise this though, I think you noticed it > So I think this check can go away, turning device_driver_attach into > a trivial wrapper for driver_probe_device that adds locking, which > might be useful to reflect in the naming. I was scared to change this because "0 on already bound" is uAPI in sysfs at this point. And what you noticed in bind_store: dev = bus_find_device_by_name(bus, NULL, buf); if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { err = device_driver_attach(drv, dev); Seems troublesome as the driver_lock isn't held for that dev->driver read. So I'm inclined to delete the above, keep the check in device_driver_attach and not change the uAPI? Or the APIs need to be more complicated to support locked and unlocked callers/etc Jason