gpiolib: Defer failed gpio requests by default
PATCH 1/1 gpiolib: Defer failed gpio requests by default
Since users must be explicitly provided with a GPIO number in order to request one the overwhelmingly common case for failing to request will be that the required GPIO driver has not yet registered and we should therefore defer until it has registered.
In order to avoid having to code this logic in individual drivers have gpio_request() return -EPROBE_DEFER when failing to look up the GPIO. Drivers which don't want this behaviour can override it if they desire.
--- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib.c +1 -1
@@ -1186,7 +1186,7 @@ int gpio_request(unsigned gpio, const char *label) {struct gpio_desc *desc;struct gpio_chip *chip; -int status = -EINVAL ; +int status = -EPROBE_DEFER ;unsigned long flags;spin_lock_irqsave (&gpio_lock, flags);
Signature · 1 line
1.7.10
Quoted 10 lines · Mark Brown
Since users must be explicitly provided with a GPIO number in order to request one the overwhelmingly common case for failing to request will be that the required GPIO driver has not yet registered and we should therefore defer until it has registered.
In order to avoid having to code this logic in individual drivers have
gpio_request()return -EPROBE_DEFER when failing to look up the GPIO. Drivers which don't want this behaviour can override it if they desire.Signed-off-by Mark Brown <[email protected]>
While this makes perfect sense to me I would *really* like to wait for Grants opinion on this one patch, him having devised the deferral and being GPIO maintainer.
Is any deferral of this deferral mechanism causing you to defer important work right now?
Yours,
Linus Walleij
Quoted 12 lines · Linus Walleij
Quoted 9 lines · Mark Brown
Since users must be explicitly provided with a GPIO number in order to request one the overwhelmingly common case for failing to request will be that the required GPIO driver has not yet registered and we should therefore defer until it has registered.
In order to avoid having to code this logic in individual drivers have
gpio_request()return -EPROBE_DEFER when failing to look up the GPIO. Drivers which don't want this behaviour can override it if they desire.
Quoted 8 lines
Quoted 1 line
Signed-off-by Mark Brown <[email protected]>While this makes perfect sense to me I would *really* like to wait for Grants opinion on this one patch, him having devised the deferral and being GPIO maintainer.
Is any deferral of this deferral mechanism causing you to defer important work right now?
I'm fine with this patch, but the patch that adds the twizzling of the dpm_list when probing needs some tweaking, and this patch must be applied after that one. I'll go and reply to that patch now (and cc you if you're not already).
g.
Quoted 4 lines · Grant Likely
I'm fine with this patch, but the patch that adds the twizzling of the
dpm_listwhen probing needs some tweaking, and this patch must be applied after that one. I'll go and reply to that patch now (and cc you if you're not already).
Given how many subsystems are already doing the -EPROBE_DEFER stuff it seems like we're already at the point where the core logic needs to be bugfixes I'm not sure it's worth holding off, any system that's hitting this is already buggy anyway so at worst we're just shifting the bug around.
Quoted 10 lines · Mark Brown
Since users must be explicitly provided with a GPIO number in order to request one the overwhelmingly common case for failing to request will be that the required GPIO driver has not yet registered and we should therefore defer until it has registered.
In order to avoid having to code this logic in individual drivers have
gpio_request()return -EPROBE_DEFER when failing to look up the GPIO. Drivers which don't want this behaviour can override it if they desire.Signed-off-by Mark Brown <[email protected]>
Following Greg's application of the required prerequisite patch I have merged this patch.
Grant, shout if you feel bad about it, ACK if you like it :-)
Linus Walleij