* [PATCH 0/5] Get rid of get_driver() and put_driver()
@ 2012-01-24 18:33 Alan Stern
2012-01-25 0:06 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Alan Stern @ 2012-01-24 18:33 UTC (permalink / raw)
To: Greg KH
Cc: Dmitry Torokhov, Kyungmin Park, Andy Walls, Martin Schwidefsky,
Jiri Kosina, Jesse Barnes, Dominik Brodowski, Sebastian Ott,
David S. Miller, Konrad Rzeszutek Wilk, Michael Buesch,
Joerg Roedel, linux-input, linux-media, netdev, linux-pcmcia,
linux-s390, USB list, xen-devel, Kernel development list
Greg:
This patch series removes the get_driver() and put_driver() routines
from the kernel.
Those routines don't do anything useful. Their comments say that they
increment and decrement the driver's reference count, just like
get_device()/put_device() and a lot of other utility routines. But a
struct driver is _not_ like a struct device! It resembles a piece of
code more than a piece of data -- it acts as an encapsulation of a
driver. Incrementing its refcount doesn't have much meaning because a
driver's lifetime isn't determined by the structure's refcount; it's
determined by when the driver's module gets unloaded.
What really matters for a driver is whether or not it is registered.
Drivers expect, for example, that none of their methods will be called
after driver_unregister() returns. It doesn't matter if some other
thread still holds a reference to the driver structure; that reference
mustn't be used for accessing the driver code after unregistration.
get_driver() does not do any checking for this.
People may have been misled by the kerneldoc into thinking that the
references obtained by get_driver() do somehow pin the driver structure
in memory. This simply isn't true; all it pins is the associated
private structure. Code that needs to pin a driver must do it some
other way (probably by calling try_module_get()).
In short, these routines don't do anything useful and they can actively
mislead people. Removing them won't introduce any bugs that aren't
already present. There is no reason to keep them.
Alan Stern
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 0/5] Get rid of get_driver() and put_driver()
2012-01-24 18:33 [PATCH 0/5] Get rid of get_driver() and put_driver() Alan Stern
@ 2012-01-25 0:06 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2012-01-25 0:06 UTC (permalink / raw)
To: Alan Stern
Cc: Dmitry Torokhov, Kyungmin Park, Andy Walls, Martin Schwidefsky,
Jiri Kosina, Jesse Barnes, Dominik Brodowski, Sebastian Ott,
David S. Miller, Konrad Rzeszutek Wilk, Michael Buesch,
Joerg Roedel, linux-input, linux-media, netdev, linux-pcmcia,
linux-s390, USB list, xen-devel, Kernel development list
On Tue, Jan 24, 2012 at 01:33:37PM -0500, Alan Stern wrote:
> Greg:
>
> This patch series removes the get_driver() and put_driver() routines
> from the kernel.
>
> Those routines don't do anything useful. Their comments say that they
> increment and decrement the driver's reference count, just like
> get_device()/put_device() and a lot of other utility routines. But a
> struct driver is _not_ like a struct device! It resembles a piece of
> code more than a piece of data -- it acts as an encapsulation of a
> driver. Incrementing its refcount doesn't have much meaning because a
> driver's lifetime isn't determined by the structure's refcount; it's
> determined by when the driver's module gets unloaded.
>
> What really matters for a driver is whether or not it is registered.
> Drivers expect, for example, that none of their methods will be called
> after driver_unregister() returns. It doesn't matter if some other
> thread still holds a reference to the driver structure; that reference
> mustn't be used for accessing the driver code after unregistration.
> get_driver() does not do any checking for this.
>
> People may have been misled by the kerneldoc into thinking that the
> references obtained by get_driver() do somehow pin the driver structure
> in memory. This simply isn't true; all it pins is the associated
> private structure. Code that needs to pin a driver must do it some
> other way (probably by calling try_module_get()).
>
> In short, these routines don't do anything useful and they can actively
> mislead people. Removing them won't introduce any bugs that aren't
> already present. There is no reason to keep them.
Very nice work, all now applied, thanks for doing this.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-25 0:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-24 18:33 [PATCH 0/5] Get rid of get_driver() and put_driver() Alan Stern
2012-01-25 0:06 ` Greg KH
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).