Skip to content

Commit

Permalink
Input: ads7846 - use PTR_ERR_OR_ZERO()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Javier Martinez Canillas authored and Dmitry Torokhov committed Oct 2, 2015
1 parent e5e66ed commit c4517f8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/input/touchscreen/ads7846.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c4517f8

Please sign in to comment.