Skip to contentSkip to conversation

input:touchscreen:Properly check touchscreen information is read in ads7846_probe

PATCH Dmitry Torokhov 1 participant 1 message Dec 22, 2015 1 message not in the archive HID

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 19 lines · Nicholas Krause

This properly checks if touchscreen information is read before allocating a sysfs_group of files for this device's device structure's kobject(s) and if we fail to read the information successfully then we must continue with the error path for the error occurred by freeing up resources allocating by ads7846_probe before returning the error code returned by this function call to the caller of ads7846_probe.

---
 drivers/input/touchscreen/ads7846.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/input/touchscreen/ads7846.c +0 -0
index a61b215..d8150a9 100644
@@ -1412,9 +1412,12 @@ static int ads7846_probe(struct spi_device *spi)
         * the touchscreen, in case it's not connected.

drivers/input/touchscreen/ads7846.c static int ads7846_probe(struct spi_device *spi) · line 1420

Quoted 10 lines
drivers/input/touchscreen/ads7846.c +5 -2
         */
        if (ts->model == 7845)
-               ads7845_read12_ser(&spi->dev, PWRDOWN);
+               err = ads7845_read12_ser(&spi->dev, PWRDOWN);
        else
-               (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux));
+               err = ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux));
+
+       if (err)
+               goto err_remove_hwmon;

Positive return value from ads784*_read12_ser() does not indicate error. Also note that when someone takes care annotating an expressions as "(void)" they explicitly indicate that return value should be ignored. For details about why it has been done here you'd have to ask Anatolij Gustschin.

Quoted 6 lines
drivers/input/touchscreen/ads7846.c +0 -1
        err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
        if (err)
--

2.5.0

Nick, it has been proven time and again that your submissions are not useful, please refrain from sending me patches.

Thanks.

Signature · 1 line
Dmitry