misc: atmel_pwm: add deferred-probing support
authorJohan Hovold <jhovold@gmail.com>
Tue, 22 Oct 2013 16:32:39 +0000 (18:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Oct 2013 23:22:57 +0000 (16:22 -0700)
Two drivers (atmel-pwm-bl and leds-atmel-pwm) currently depend on the
atmel_pwm driver to have bound to any pwm-device before their devices
are probed.

Support deferred probing of such devices by making sure to return
-EPROBE_DEFER from pwm_channel_alloc when no pwm-device has yet been
bound.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/atmel_pwm.c

index 494d0500bda6483a9f3d93f6287075d5f0825448..a6dc56e1bc58e70566bd6321bca1ae1191519b3b 100644 (file)
@@ -90,8 +90,10 @@ int pwm_channel_alloc(int index, struct pwm_channel *ch)
        unsigned long   flags;
        int             status = 0;
 
-       /* insist on PWM init, with this signal pinned out */
-       if (!pwm || !(pwm->mask & 1 << index))
+       if (!pwm)
+               return -EPROBE_DEFER;
+
+       if (!(pwm->mask & 1 << index))
                return -ENODEV;
 
        if (index < 0 || index >= PWM_NCHAN || !ch)