Message ID | 20200907204045.95530-4-sebastian.reichel@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Rotary Encoder Push Button Support | expand |
On Mon, Sep 7, 2020 at 2:40 PM Sebastian Reichel <sebastian.reichel@collabora.com> wrote: > > Simplify driver a bit by making use of dev_err_probe. > > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> > --- > drivers/input/misc/rotary_encoder.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c > index e9a5dbb10513..16ad86fad7cb 100644 > --- a/drivers/input/misc/rotary_encoder.c > +++ b/drivers/input/misc/rotary_encoder.c > @@ -241,12 +241,8 @@ static int rotary_encoder_probe(struct platform_device *pdev) > device_property_read_bool(dev, "rotary-encoder,relative-axis"); > > encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); > - if (IS_ERR(encoder->gpios)) { > - err = PTR_ERR(encoder->gpios); > - if (err != -EPROBE_DEFER) > - dev_err(dev, "unable to get gpios: %d\n", err); > - return err; > - } > + if (IS_ERR(encoder->gpios)) > + return dev_err_probe(dev, PTR_ERR(encoder->gpios), "unable to get gpios\n"); I hadn't seen dev_err_probe... Just FYI, I'm working on a different fix here which is to print errors in the subsystems instead. We already do this for IRQs, so why not everything else? The original reason was no resource is sometimes not an error, but now we have *_optional calls to handle this case for most all subsystems. It's a coccinelle script (hacked up from platform_get_irq.cocci) to convert all the drivers. Rob
Hi Rob, On Wed, Sep 09, 2020 at 01:48:49PM -0600, Rob Herring wrote: > On Mon, Sep 7, 2020 at 2:40 PM Sebastian Reichel > <sebastian.reichel@collabora.com> wrote: > > > > Simplify driver a bit by making use of dev_err_probe. > > > > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> > > --- > > drivers/input/misc/rotary_encoder.c | 8 ++------ > > 1 file changed, 2 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c > > index e9a5dbb10513..16ad86fad7cb 100644 > > --- a/drivers/input/misc/rotary_encoder.c > > +++ b/drivers/input/misc/rotary_encoder.c > > @@ -241,12 +241,8 @@ static int rotary_encoder_probe(struct platform_device *pdev) > > device_property_read_bool(dev, "rotary-encoder,relative-axis"); > > > > encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); > > - if (IS_ERR(encoder->gpios)) { > > - err = PTR_ERR(encoder->gpios); > > - if (err != -EPROBE_DEFER) > > - dev_err(dev, "unable to get gpios: %d\n", err); > > - return err; > > - } > > + if (IS_ERR(encoder->gpios)) > > + return dev_err_probe(dev, PTR_ERR(encoder->gpios), "unable to get gpios\n"); > > I hadn't seen dev_err_probe... It got added in 5.8. > Just FYI, I'm working on a different fix here which is to print errors > in the subsystems instead. We already do this for IRQs, so why not > everything else? The original reason was no resource is sometimes not > an error, but now we have *_optional calls to handle this case for > most all subsystems. It's a coccinelle script (hacked up from > platform_get_irq.cocci) to convert all the drivers. Makes sense. I suppose dev_err_probe could be used within the framework(s) and is still useful for those resource frameworks not having _optional variants. FYI: There is a bunch of dev_err_probe for all kind of drivers being send out at the moment. I already received quite a few for the power-supply subsystem. Be prepared for conflicts. If this is about this specific instance: No hard feelings, I only cleaned up the driver a bit while adding new features and being able to easily test the cleanups on real HW. With some luck patch 4/4 applies without this one. -- Sebastian
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index e9a5dbb10513..16ad86fad7cb 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c @@ -241,12 +241,8 @@ static int rotary_encoder_probe(struct platform_device *pdev) device_property_read_bool(dev, "rotary-encoder,relative-axis"); encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); - if (IS_ERR(encoder->gpios)) { - err = PTR_ERR(encoder->gpios); - if (err != -EPROBE_DEFER) - dev_err(dev, "unable to get gpios: %d\n", err); - return err; - } + if (IS_ERR(encoder->gpios)) + return dev_err_probe(dev, PTR_ERR(encoder->gpios), "unable to get gpios\n"); if (encoder->gpios->ndescs < 2) { dev_err(dev, "not enough gpios found\n"); return -EINVAL;
Simplify driver a bit by making use of dev_err_probe. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> --- drivers/input/misc/rotary_encoder.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)