Skip to content

Commit

Permalink
Dynamic ID addition doesn't need get_driver()
Browse files Browse the repository at this point in the history
As part of the removal of get_driver()/put_driver(), this patch
(as1511) changes all the places that add dynamic IDs for drivers.
Since these additions are done by writing to the drivers' sysfs
attribute files, and the attributes are removed when the drivers are
unregistered, there is no reason to take an extra reference to the
drivers.

The one exception is the pci-stub driver, which calls pci_add_dynid()
as part of its registration.  But again, there's no reason to take an
extra reference here, because the driver can't be unloaded while it is
being registered.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: Jiri Kosina <jkosina@suse.cz>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jan 25, 2012
1 parent fde25a9 commit cef9bc5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
6 changes: 1 addition & 5 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,11 +1619,7 @@ static ssize_t store_new_id(struct device_driver *drv, const char *buf,
list_add_tail(&dynid->list, &hdrv->dyn_list);
spin_unlock(&hdrv->dyn_lock);

ret = 0;
if (get_driver(&hdrv->driver)) {
ret = driver_attach(&hdrv->driver);
put_driver(&hdrv->driver);
}
ret = driver_attach(&hdrv->driver);

return ret ? : count;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/pci/pci-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ int pci_add_dynid(struct pci_driver *drv,
list_add_tail(&dynid->node, &drv->dynids.list);
spin_unlock(&drv->dynids.lock);

get_driver(&drv->driver);
retval = driver_attach(&drv->driver);
put_driver(&drv->driver);

return retval;
}
Expand Down
5 changes: 1 addition & 4 deletions drivers/pcmcia/ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ pcmcia_store_new_id(struct device_driver *driver, const char *buf, size_t count)
list_add_tail(&dynid->node, &pdrv->dynids.list);
mutex_unlock(&pdrv->dynids.lock);

if (get_driver(&pdrv->drv)) {
retval = driver_attach(&pdrv->drv);
put_driver(&pdrv->drv);
}
retval = driver_attach(&pdrv->drv);

if (retval)
return retval;
Expand Down
5 changes: 1 addition & 4 deletions drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids,
list_add_tail(&dynid->node, &dynids->list);
spin_unlock(&dynids->lock);

if (get_driver(driver)) {
retval = driver_attach(driver);
put_driver(driver);
}
retval = driver_attach(driver);

if (retval)
return retval;
Expand Down

0 comments on commit cef9bc5

Please sign in to comment.