diff mbox series

[02/24] Input: gpio_keys - Simplify with dev_err_probe()

Message ID 20200826181706.11098-2-krzk@kernel.org (mailing list archive)
State Superseded
Headers show
Series [01/24] Input: bcm-keypad - Simplify with dev_err_probe() | expand

Commit Message

Krzysztof Kozlowski Aug. 26, 2020, 6:16 p.m. UTC
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/input/keyboard/gpio_keys.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Andy Shevchenko Aug. 26, 2020, 7:13 p.m. UTC | #1
On Wed, Aug 26, 2020 at 08:16:44PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and also it prints the error value.

> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -505,10 +505,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>  				 */
>  				bdata->gpiod = NULL;

gpiod_get_optional()?
Do not see much context though (but please double check your series for these
kind of things).

>  			} else {
> -				if (error != -EPROBE_DEFER)
> -					dev_err(dev, "failed to get gpio: %d\n",
> -						error);
> -				return error;
> +				return dev_err_probe(dev, error, "failed to get gpio\n");
>  			}
>  		}
>  	} else if (gpio_is_valid(button->gpio)) {
Krzysztof Kozlowski Aug. 26, 2020, 7:22 p.m. UTC | #2
On Wed, Aug 26, 2020 at 10:13:34PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 26, 2020 at 08:16:44PM +0200, Krzysztof Kozlowski wrote:
> > Common pattern of handling deferred probe can be simplified with
> > dev_err_probe().  Less code and also it prints the error value.
> 
> > --- a/drivers/input/keyboard/gpio_keys.c
> > +++ b/drivers/input/keyboard/gpio_keys.c
> > @@ -505,10 +505,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
> >  				 */
> >  				bdata->gpiod = NULL;
> 
> gpiod_get_optional()?
> Do not see much context though (but please double check your series for these
> kind of things).

It would fit except it is devm_fwnode_gpiod_get() which does not have
optional yet.

I can add it although the scope of the patch grows from simple
defer-path-simplification.

Thanks for the feedback.

Best regards,
Krzysztof
Andy Shevchenko Aug. 26, 2020, 7:39 p.m. UTC | #3
On Wed, Aug 26, 2020 at 10:23 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> On Wed, Aug 26, 2020 at 10:13:34PM +0300, Andy Shevchenko wrote:
> > On Wed, Aug 26, 2020 at 08:16:44PM +0200, Krzysztof Kozlowski wrote:
> > > Common pattern of handling deferred probe can be simplified with
> > > dev_err_probe().  Less code and also it prints the error value.
> >
> > > --- a/drivers/input/keyboard/gpio_keys.c
> > > +++ b/drivers/input/keyboard/gpio_keys.c
> > > @@ -505,10 +505,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
> > >                              */
> > >                             bdata->gpiod = NULL;
> >
> > gpiod_get_optional()?
> > Do not see much context though (but please double check your series for these
> > kind of things).
>
> It would fit except it is devm_fwnode_gpiod_get() which does not have
> optional yet.
>
> I can add it although the scope of the patch grows from simple
> defer-path-simplification.

No need. My comment only about existing API per individual cases. SO,
here it's fine then.

> Thanks for the feedback.

You're welcome!
Krzysztof Kozlowski Aug. 26, 2020, 7:58 p.m. UTC | #4
On Wed, Aug 26, 2020 at 10:39:12PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 26, 2020 at 10:23 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > On Wed, Aug 26, 2020 at 10:13:34PM +0300, Andy Shevchenko wrote:
> > > On Wed, Aug 26, 2020 at 08:16:44PM +0200, Krzysztof Kozlowski wrote:
> > > > Common pattern of handling deferred probe can be simplified with
> > > > dev_err_probe().  Less code and also it prints the error value.
> > >
> > > > --- a/drivers/input/keyboard/gpio_keys.c
> > > > +++ b/drivers/input/keyboard/gpio_keys.c
> > > > @@ -505,10 +505,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
> > > >                              */
> > > >                             bdata->gpiod = NULL;
> > >
> > > gpiod_get_optional()?
> > > Do not see much context though (but please double check your series for these
> > > kind of things).
> >
> > It would fit except it is devm_fwnode_gpiod_get() which does not have
> > optional yet.
> >
> > I can add it although the scope of the patch grows from simple
> > defer-path-simplification.
> 
> No need. My comment only about existing API per individual cases. SO,
> here it's fine then.

I checked the others and I didn't see such pattern anymore.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index f2d4e4daa818..6f670cbe8a8b 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -505,10 +505,7 @@  static int gpio_keys_setup_key(struct platform_device *pdev,
 				 */
 				bdata->gpiod = NULL;
 			} else {
-				if (error != -EPROBE_DEFER)
-					dev_err(dev, "failed to get gpio: %d\n",
-						error);
-				return error;
+				return dev_err_probe(dev, error, "failed to get gpio\n");
 			}
 		}
 	} else if (gpio_is_valid(button->gpio)) {