On Tuesday 30 August 2005 16.14, Alan Stern wrote: > On Tue, 30 Aug 2005, Daniel Ritz wrote: > > > if i didn't miss anything usb's check for knode_bus is also workaround > > to avoid a double device_bind_driver()... > > That's not really right. The actual reason usb_driver_claim_interface > calls klist_node_attached is to avoid calling device_bind_driver for a > device that hasn't been registered yet. It's not meant for avoiding > double binds (and in fact it won't prevent them). >
but nonetheless it does avoid a double bind. > Similarly, the test in usb_driver_release_interface is to avoid calling > device_release_driver for a device that hasn't been registered yet. > > > > Have I missed something here? Since when has the .driver member been > > > removed from usb_interface? > > > > > > > 18 months ago. see: > > http://linux.bkbits.net:8080/linux-2.6/diffs/drivers/usb/core/usb.c%401.157?nav=index.html|src/.|src/drivers|src/drivers/usb|src/drivers/usb/core|hist/drivers/usb/core/usb.c > > That patch didn't remove any fields from any structures. > well, it's the patch removing the usage of the field. the definition is of course in the header file. but since i didn't find a link in bkweb to go from a file change to the whole changeset.... anyway here goes the header file change: http://linux.bkbits.net:8080/linux-2.6/diffs/include/linux/usb.h%401.102?nav=index.html|src/|src/include|src/include/linux|hist/include/linux/usb.h > > > but i still think it's damn ugly to check for knode_bus (layering > > violation?) > > I agree. The other patch I've been working on adds a new routine to > include/linux/device.h: > > +static inline int > +device_is_registered (struct device *dev) > +{ > + return klist_node_attached(&dev->knode_bus); > +} > > At least it makes things look more logical. i like that one. something like the attached one and i shut up... rgds -daniel --- diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -293,7 +293,7 @@ int usb_driver_claim_interface(struct us /* if interface was already added, bind now; else let * the future device_add() bind it, bypassing probe() */ - if (klist_node_attached(&dev->knode_bus)) + if (device_is_registered(dev)) device_bind_driver(dev); return 0; diff --git a/include/linux/device.h b/include/linux/device.h --- a/include/linux/device.h +++ b/include/linux/device.h @@ -317,6 +317,12 @@ dev_set_drvdata (struct device *dev, voi dev->driver_data = data; } +static inline int +device_is_registered(struct device *dev) +{ + return klist_node_attached(&dev->knode_bus); +} + /* * High level routines for use by the bus drivers */ diff --git a/include/linux/usb.h b/include/linux/usb.h --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -89,7 +89,6 @@ enum usb_interface_condition { * endpoint configurations. They will be in no particular order. * @num_altsetting: number of altsettings defined. * @cur_altsetting: the current altsetting. - * @driver: the USB driver that is bound to this interface. * @minor: the minor number assigned to this interface, if this * interface is bound to a driver that uses the USB major number. * If this interface does not use the USB major, this field should ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel