diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2012-01-24 13:34:41 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-24 19:00:35 -0500 |
commit | cef9bc56e1e944afd11f96de569657117a138c6d (patch) | |
tree | 45923c4dec748e82a05313c9c7d443aa11e02a5f /drivers | |
parent | fde25a9b63b9a3dc91365c394a426ebe64cfc2da (diff) |
Dynamic ID addition doesn't need get_driver()
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/hid-core.c | 6 | ||||
-rw-r--r-- | drivers/pci/pci-driver.c | 2 | ||||
-rw-r--r-- | drivers/pcmcia/ds.c | 5 | ||||
-rw-r--r-- | drivers/usb/core/driver.c | 5 |
4 files changed, 3 insertions, 15 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index af08ce7207d9..bce53fa0e166 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1619,11 +1619,7 @@ static ssize_t store_new_id(struct device_driver *drv, const char *buf, | |||
1619 | list_add_tail(&dynid->list, &hdrv->dyn_list); | 1619 | list_add_tail(&dynid->list, &hdrv->dyn_list); |
1620 | spin_unlock(&hdrv->dyn_lock); | 1620 | spin_unlock(&hdrv->dyn_lock); |
1621 | 1621 | ||
1622 | ret = 0; | 1622 | ret = driver_attach(&hdrv->driver); |
1623 | if (get_driver(&hdrv->driver)) { | ||
1624 | ret = driver_attach(&hdrv->driver); | ||
1625 | put_driver(&hdrv->driver); | ||
1626 | } | ||
1627 | 1623 | ||
1628 | return ret ? : count; | 1624 | return ret ? : count; |
1629 | } | 1625 | } |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 3623d65f8b86..ff540477fe8b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -72,9 +72,7 @@ int pci_add_dynid(struct pci_driver *drv, | |||
72 | list_add_tail(&dynid->node, &drv->dynids.list); | 72 | list_add_tail(&dynid->node, &drv->dynids.list); |
73 | spin_unlock(&drv->dynids.lock); | 73 | spin_unlock(&drv->dynids.lock); |
74 | 74 | ||
75 | get_driver(&drv->driver); | ||
76 | retval = driver_attach(&drv->driver); | 75 | retval = driver_attach(&drv->driver); |
77 | put_driver(&drv->driver); | ||
78 | 76 | ||
79 | return retval; | 77 | return retval; |
80 | } | 78 | } |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 749c2a16012c..059699f6363d 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -127,10 +127,7 @@ pcmcia_store_new_id(struct device_driver *driver, const char *buf, size_t count) | |||
127 | list_add_tail(&dynid->node, &pdrv->dynids.list); | 127 | list_add_tail(&dynid->node, &pdrv->dynids.list); |
128 | mutex_unlock(&pdrv->dynids.lock); | 128 | mutex_unlock(&pdrv->dynids.lock); |
129 | 129 | ||
130 | if (get_driver(&pdrv->drv)) { | 130 | retval = driver_attach(&pdrv->drv); |
131 | retval = driver_attach(&pdrv->drv); | ||
132 | put_driver(&pdrv->drv); | ||
133 | } | ||
134 | 131 | ||
135 | if (retval) | 132 | if (retval) |
136 | return retval; | 133 | return retval; |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index d40ff9568813..54c493b4226b 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -71,10 +71,7 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
71 | list_add_tail(&dynid->node, &dynids->list); | 71 | list_add_tail(&dynid->node, &dynids->list); |
72 | spin_unlock(&dynids->lock); | 72 | spin_unlock(&dynids->lock); |
73 | 73 | ||
74 | if (get_driver(driver)) { | 74 | retval = driver_attach(driver); |
75 | retval = driver_attach(driver); | ||
76 | put_driver(driver); | ||
77 | } | ||
78 | 75 | ||
79 | if (retval) | 76 | if (retval) |
80 | return retval; | 77 | return retval; |