linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/5] Dynamic ID addition doesn't need get_driver()
@ 2012-01-24 18:34 Alan Stern
  2012-01-25 19:33 ` Dominik Brodowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alan Stern @ 2012-01-24 18:34 UTC (permalink / raw)
  To: Greg KH
  Cc: Dmitry Torokhov, Jiri Kosina, Jesse Barnes, Dominik Brodowski,
	linux-input, linux-pci, linux-pcmcia, USB list,
	Kernel development list

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>

---

 drivers/hid/hid-core.c    |    6 +-----
 drivers/pci/pci-driver.c  |    2 --
 drivers/pcmcia/ds.c       |    5 +----
 drivers/usb/core/driver.c |    5 +----
 4 files changed, 3 insertions(+), 15 deletions(-)

Index: usb-3.3/drivers/hid/hid-core.c
===================================================================
--- usb-3.3.orig/drivers/hid/hid-core.c
+++ usb-3.3/drivers/hid/hid-core.c
@@ -1619,11 +1619,7 @@ static ssize_t store_new_id(struct devic
 	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;
 }
Index: usb-3.3/drivers/pci/pci-driver.c
===================================================================
--- usb-3.3.orig/drivers/pci/pci-driver.c
+++ usb-3.3/drivers/pci/pci-driver.c
@@ -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;
 }
Index: usb-3.3/drivers/pcmcia/ds.c
===================================================================
--- usb-3.3.orig/drivers/pcmcia/ds.c
+++ usb-3.3/drivers/pcmcia/ds.c
@@ -127,10 +127,7 @@ pcmcia_store_new_id(struct device_driver
 	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;
Index: usb-3.3/drivers/usb/core/driver.c
===================================================================
--- usb-3.3.orig/drivers/usb/core/driver.c
+++ usb-3.3/drivers/usb/core/driver.c
@@ -71,10 +71,7 @@ ssize_t usb_store_new_id(struct usb_dyni
 	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;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/5] Dynamic ID addition doesn't need get_driver()
  2012-01-24 18:34 [PATCH 2/5] Dynamic ID addition doesn't need get_driver() Alan Stern
@ 2012-01-25 19:33 ` Dominik Brodowski
  2012-01-27 18:40 ` Jesse Barnes
  2012-02-01 13:15 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Dominik Brodowski @ 2012-01-25 19:33 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg KH, linux-input, linux-pcmcia, Jiri Kosina, Dmitry Torokhov,
	Kernel development list, USB list, Jesse Barnes, linux-pci

On Tue, Jan 24, 2012 at 01:34:41PM -0500, Alan Stern wrote:
> 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>

For the PCMCIA part: Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>

Thanks,
	Dominik

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/5] Dynamic ID addition doesn't need get_driver()
  2012-01-24 18:34 [PATCH 2/5] Dynamic ID addition doesn't need get_driver() Alan Stern
  2012-01-25 19:33 ` Dominik Brodowski
@ 2012-01-27 18:40 ` Jesse Barnes
  2012-02-01 13:15 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Jesse Barnes @ 2012-01-27 18:40 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg KH, Dmitry Torokhov, Jiri Kosina, Dominik Brodowski,
	linux-input, linux-pci, linux-pcmcia, USB list,
	Kernel development list

[-- Attachment #1: Type: text/plain, Size: 799 bytes --]

On Tue, 24 Jan 2012 13:34:41 -0500 (EST)
Alan Stern <stern@rowland.harvard.edu> wrote:

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

Looks fine, you can add my ack too.

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/5] Dynamic ID addition doesn't need get_driver()
  2012-01-24 18:34 [PATCH 2/5] Dynamic ID addition doesn't need get_driver() Alan Stern
  2012-01-25 19:33 ` Dominik Brodowski
  2012-01-27 18:40 ` Jesse Barnes
@ 2012-02-01 13:15 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2012-02-01 13:15 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg KH, Dmitry Torokhov, Jesse Barnes, Dominik Brodowski,
	linux-input, linux-pci, linux-pcmcia, USB list,
	Kernel development list

On Tue, 24 Jan 2012, Alan Stern wrote:

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

Acked-by: Jiri Kosina <jkosina@suse.cz>

for the drivers/hid part. Thanks,

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-01 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 18:34 [PATCH 2/5] Dynamic ID addition doesn't need get_driver() Alan Stern
2012-01-25 19:33 ` Dominik Brodowski
2012-01-27 18:40 ` Jesse Barnes
2012-02-01 13:15 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).