Input: ads7846 - use PTR_ERR_OR_ZERO()
authorJavier Martinez Canillas <javier@osg.samsung.com>
Fri, 2 Oct 2015 18:20:40 +0000 (11:20 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 2 Oct 2015 18:44:19 +0000 (11:44 -0700)
The PTR_ERR_OR_ZERO() helper function checks if a pointer contains an
errno code and returns it or return 0 if that's not the case. Use the
helper instead of open coding the same logic in the driver. This was
found with make coccicheck that complains with the following warning:

drivers/input/touchscreen/ads7846.c:532:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/ads7846.c

index 0f5f968592bd02afd9c5381a8839b3428c3bcbea..727d88c900c1da57f9922d0eeafc0d579cf050f2 100644 (file)
@@ -529,10 +529,8 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
 
        ts->hwmon = hwmon_device_register_with_groups(&spi->dev, spi->modalias,
                                                      ts, ads7846_attr_groups);
-       if (IS_ERR(ts->hwmon))
-               return PTR_ERR(ts->hwmon);
 
-       return 0;
+       return PTR_ERR_OR_ZERO(ts->hwmon);
 }
 
 static void ads784x_hwmon_unregister(struct spi_device *spi,