Re: Dangerous devm_request_irq() conversions
From: 'Tejun Heo'
Date: Fri Feb 22 2013 - 13:24:41 EST
On Fri, Feb 22, 2013 at 12:05:48AM -0800, Dmitry Torokhov wrote:
> > Please, argue that it would be better to deprecate devm_request_irq()
> > or devm_request_threaded_irq().
> No, they do have their use. But probably people doing the conversion
> should be required to put $100 in escrow ;)
So, what devm does is simple - it records resources being allocated
using devm and releases them in the reverse order when the driver
detaches from the device. If all or most resources are covered by
devm, this is the right thing to do most of the time and there's
nothing much to worry about.
However, singling out one resource and converting only that one to
devm is likely to break something if the resource in question has
release ordering dependency and irqs do definitely have ordering
requirements while tearing down, so, no, one can't single out
request_irq() and change only that one to devm_request_irq(). It's
like mixing managed objects with manual new/delete objects. You can't
do that willy-nilly and it generaly isn't a good idea as evidenced by
only c++ doing it.
The recommended way to do devm conversion is doing it all the way.
Look at the whole subsystem, identify resources used by various
drivers (they usually aren't that diverse in a single subsystem),
identify the pattern and implement helpers in the subsystem as
appropriate and convert the whole thing, preferably to the point where
->remove() almost doesn't have to worry about freeing resources other
than shutting down devices or doing one-off cleanups not covered by
If there are resources which are frequently used by a group of drivers
but devm interface doesn't currently exist, add a devm interface
either as a generic or subsystem-specific helper. devm is
specifically designed to allow such extensions.
So, in summary, no, please don't single out irq requests and convert
only those to devm. That's bound to break stuff.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/