Input: ad7879 - make sure we set up drvdata
Subsystems (3)
Dmitry Torokhov
maintainerPATCH 1/4 Input: ad7879 - make sure we set up drvdata
The conversion to devm accidentally removed setting up of I2C client data upon successful probe of the touchscreen. Let's move this setting into the core, so we do not forger about it again.
--- drivers/input/touchscreen/ad7879-spi.c | 2 -- drivers/input/touchscreen/ad7879.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/touchscreen/ad7879-spi.c +0 -2
@@ -49,8 +49,6 @@ static int ad7879_spi_probe(struct spi_device *spi)if (IS_ERR (ts))return PTR_ERR (ts); -spi_set_drvdata (spi, ts); -return 0 ; }
drivers/input/touchscreen/ad7879.c +2 -0
@@ -680,6 +680,8 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,if (err)return ERR_PTR (err); +dev_set_drvdata (dev, ts); +return 0 ; }EXPORT_SYMBOL (ad7879_probe);
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Dmitry Torokhov
maintainerPATCH 2/4 Input: ad7879 - return plain error code from ad7879_probe()
With the switch to devm, there is no need for ad7879_probe() to return the touchscreen structure, we can use plain error code. This also fixes issue introduced with devm concersion, where we returned 0 on success (which worked OK since IS_ERR(0) would not trigger, but was not correct regardless).
--- drivers/input/touchscreen/ad7879-i2c.c | 9 ++------- drivers/input/touchscreen/ad7879-spi.c | 7 +------ drivers/input/touchscreen/ad7879.c | 28 ++++++++++++++-------------- drivers/input/touchscreen/ad7879.h | 5 ++--- 4 files changed, 19 insertions(+), 30 deletions(-)
drivers/input/touchscreen/ad7879-i2c.c +2 -7
@@ -27,7 +27,6 @@ static const struct regmap_config ad7879_i2c_regmap_config = { static int ad7879_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct ad7879 *ts; struct regmap *regmap; if (!i2c_check_functionality(client->adapter,
@@ -40,12 +39,8 @@ static int ad7879_i2c_probe(struct i2c_client *client,if (IS_ERR (regmap))return PTR_ERR (regmap); - ts =ad7879_probe (&client->dev, regmap, client->irq, -BUS_I2C ,AD7879_DEVID ); -if (IS_ERR (ts)) -return PTR_ERR (ts); - -return 0 ; +return ad7879_probe (&client->dev, regmap, client->irq, +BUS_I2C ,AD7879_DEVID ); }static const struct i2c_device_id ad7879_id[] = {
drivers/input/touchscreen/ad7879-spi.c +1 -6
@@ -32,7 +32,6 @@ static const struct regmap_config ad7879_spi_regmap_config = {static int ad7879_spi_probe (struct spi_device *spi) { -struct ad7879 *ts;struct regmap *regmap;/* don't exceed max specified SPI CLK frequency */
@@ -45,11 +44,7 @@ static int ad7879_spi_probe(struct spi_device *spi)if (IS_ERR (regmap))return PTR_ERR (regmap); - ts =ad7879_probe (&spi->dev, regmap, spi->irq,BUS_SPI ,AD7879_DEVID ); -if (IS_ERR (ts)) -return PTR_ERR (ts); - -return 0 ; +return ad7879_probe (&spi->dev, regmap, spi->irq,BUS_SPI ,AD7879_DEVID ); }#ifdef CONFIG_OF
drivers/input/touchscreen/ad7879.c +14 -14
@@ -531,8 +531,8 @@ static void ad7879_cleanup_sysfs(void *_ts)sysfs_remove_group (&ts->dev->kobj, &ad7879_attr_group); } -struct ad7879 *ad7879_probe (struct device *dev,struct regmap *regmap, -int irq,u16 bustype,u8 devid) +int ad7879_probe (struct device *dev,struct regmap *regmap, +int irq,u16 bustype,u8 devid) {struct ad7879_platform_data *pdata =dev_get_platdata (dev);struct ad7879 *ts;
@@ -542,12 +542,12 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,if (irq <=0 ) {dev_err (dev,"No IRQ specified\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } ts =devm_kzalloc (dev,sizeof (*ts),GFP_KERNEL );if (!ts) -return ERR_PTR (-ENOMEM ); +return -ENOMEM ;if (pdata) {/* Platform data use swapped axis (backward compatibility) */
@@ -564,13 +564,13 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,ad7879_parse_dt (dev, ts); }else {dev_err (dev,"No platform data\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } input_dev =devm_input_allocate_device (dev);if (!input_dev) {dev_err (dev,"Failed to allocate input device\n" ); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; } ts->dev = dev;
@@ -618,14 +618,14 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,touchscreen_parse_properties (input_dev, false,NULL );if (!input_abs_get_max (input_dev,ABS_PRESSURE )) {dev_err (dev,"Touchscreen pressure is not specified\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } } err =ad7879_write (ts,AD7879_REG_CTRL2 ,AD7879_RESET );if (err <0 ) {dev_err (dev,"Failed to write %s\n" , input_dev->name); -return ERR_PTR (err); +return err; } revid =ad7879_read (ts,AD7879_REG_REVID );
@@ -634,7 +634,7 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,if (input_dev->id.product != devid) {dev_err (dev,"Failed to probe %s (%x vs %x)\n" , input_dev->name, devid, revid); -return ERR_PTR (-ENODEV ); +return -ENODEV ; } ts->cmd_crtl3 = AD7879_YPLUS_BIT |
@@ -659,26 +659,26 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap, dev_name(dev), ts);if (err) {dev_err (dev,"Failed to request IRQ: %d\n" , err); -return ERR_PTR (err); +return err; }__ad7879_disable (ts); err =sysfs_create_group (&dev->kobj, &ad7879_attr_group);if (err) -return ERR_PTR (err); +return err; err =devm_add_action_or_reset (dev, ad7879_cleanup_sysfs, ts);if (err) -return ERR_PTR (err); +return err; err =ad7879_gpio_add (ts, pdata);if (err) -return ERR_PTR (err); +return err; err =input_register_device (input_dev);if (err) -return ERR_PTR (err); +return err;dev_set_drvdata (dev, ts);
drivers/input/touchscreen/ad7879.h +2 -3
@@ -11,13 +11,12 @@#include <linux/types.h> -struct ad7879 ;struct device ;struct regmap ;extern const struct dev_pm_ops ad7879_pm_ops; -struct ad7879 *ad7879_probe (struct device *dev,struct regmap *regmap, -int irq,u16 bustype,u8 devid); +int ad7879_probe (struct device *dev,struct regmap *regmap, +int irq,u16 bustype,u8 devid);#endif
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Re: [PATCH 2/4] Input: ad7879 - return plain error code from ad7879_probe()
Quoted 8 lines · Dmitry Torokhov
With the switch to devm, there is no need for
ad7879_probe()to return the touchscreen structure, we can use plain error code. This also fixes issue introduced with devm concersion, where we returned 0 on success (which worked OK sinceIS_ERR(0)would not trigger, but was not correct regardless).Fixes 381f688eee3d ("Input: ad7879 - use more devm interfaces")Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 184 lines
--- drivers/input/touchscreen/ad7879-i2c.c | 9 ++------- drivers/input/touchscreen/ad7879-spi.c | 7 +------ drivers/input/touchscreen/ad7879.c | 28 ++++++++++++++-------------- drivers/input/touchscreen/ad7879.h | 5 ++--- 4 files changed, 19 insertions(+), 30 deletions(-)drivers/input/touchscreen/ad7879-i2c.c +2
-7@@ -27,7 +27,6 @@ static const struct regmap_config ad7879_i2c_regmap_config = { static int ad7879_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct ad7879 *ts; struct regmap *regmap; if (!i2c_check_functionality(client->adapter,@@ -40,12 +39,8 @@ static int ad7879_i2c_probe(struct i2c_client *client,if (IS_ERR (regmap))return PTR_ERR (regmap); - ts =ad7879_probe (&client->dev, regmap, client->irq, -BUS_I2C ,AD7879_DEVID ); -if (IS_ERR (ts)) -return PTR_ERR (ts); - -return 0 ; +return ad7879_probe (&client->dev, regmap, client->irq, +BUS_I2C ,AD7879_DEVID ); }static const struct i2c_device_id ad7879_id[] = {drivers/input/touchscreen/ad7879-spi.c +1
-6@@ -32,7 +32,6 @@ static const struct regmap_config ad7879_spi_regmap_config = {static int ad7879_spi_probe (struct spi_device *spi) { -struct ad7879 *ts;struct regmap *regmap;/* don't exceed max specified SPI CLK frequency */ @@ -45,11 +44,7 @@ static int ad7879_spi_probe(struct spi_device *spi)if (IS_ERR (regmap))return PTR_ERR (regmap); - ts =ad7879_probe (&spi->dev, regmap, spi->irq,BUS_SPI ,AD7879_DEVID ); -if (IS_ERR (ts)) -return PTR_ERR (ts); - -return 0 ; +return ad7879_probe (&spi->dev, regmap, spi->irq,BUS_SPI ,AD7879_DEVID ); }#ifdef CONFIG_OF drivers/input/touchscreen/ad7879.c +14
-14@@ -531,8 +531,8 @@ static void ad7879_cleanup_sysfs(void *_ts)sysfs_remove_group (&ts->dev->kobj, &ad7879_attr_group); } -struct ad7879 *ad7879_probe (struct device *dev,struct regmap *regmap, -int irq,u16 bustype,u8 devid) +int ad7879_probe (struct device *dev,struct regmap *regmap, +int irq,u16 bustype,u8 devid) {struct ad7879_platform_data *pdata =dev_get_platdata (dev);struct ad7879 *ts;@@ -542,12 +542,12 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,if (irq <=0 ) {dev_err (dev,"No IRQ specified\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } ts =devm_kzalloc (dev,sizeof (*ts),GFP_KERNEL );if (!ts) -return ERR_PTR (-ENOMEM ); +return -ENOMEM ;if (pdata) {/* Platform data use swapped axis (backward compatibility) */ @@ -564,13 +564,13 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,ad7879_parse_dt (dev, ts); }else {dev_err (dev,"No platform data\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } input_dev =devm_input_allocate_device (dev);if (!input_dev) {dev_err (dev,"Failed to allocate input device\n" ); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; } ts->dev = dev;@@ -618,14 +618,14 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,touchscreen_parse_properties (input_dev, false,NULL );if (!input_abs_get_max (input_dev,ABS_PRESSURE )) {dev_err (dev,"Touchscreen pressure is not specified\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } } err =ad7879_write (ts,AD7879_REG_CTRL2 ,AD7879_RESET );if (err <0 ) {dev_err (dev,"Failed to write %s\n" , input_dev->name); -return ERR_PTR (err); +return err; } revid =ad7879_read (ts,AD7879_REG_REVID );@@ -634,7 +634,7 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,if (input_dev->id.product != devid) {dev_err (dev,"Failed to probe %s (%x vs %x)\n" , input_dev->name, devid, revid); -return ERR_PTR (-ENODEV ); +return -ENODEV ; } ts->cmd_crtl3 = AD7879_YPLUS_BIT |@@ -659,26 +659,26 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap, dev_name(dev), ts);if (err) {dev_err (dev,"Failed to request IRQ: %d\n" , err); -return ERR_PTR (err); +return err; }__ad7879_disable (ts); err =sysfs_create_group (&dev->kobj, &ad7879_attr_group);if (err) -return ERR_PTR (err); +return err; err =devm_add_action_or_reset (dev, ad7879_cleanup_sysfs, ts);if (err) -return ERR_PTR (err); +return err; err =ad7879_gpio_add (ts, pdata);if (err) -return ERR_PTR (err); +return err; err =input_register_device (input_dev);if (err) -return ERR_PTR (err); +return err;dev_set_drvdata (dev, ts);drivers/input/touchscreen/ad7879.h +2
-3@@ -11,13 +11,12 @@#include <linux/types.h> -struct ad7879 ;struct device ;struct regmap ;extern const struct dev_pm_ops ad7879_pm_ops; -struct ad7879 *ad7879_probe (struct device *dev,struct regmap *regmap, -int irq,u16 bustype,u8 devid); +int ad7879_probe (struct device *dev,struct regmap *regmap, +int irq,u16 bustype,u8 devid);#endif
Signature · 7 lines
Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 München Sitz der Gesellschaft München, Registergericht München HRB 40368, Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne
Dmitry Torokhov
maintainerPATCH 3/4 Input: ad7879 - try parsing properties on non-DT systems
In reply to Dmitry TorokhovWe have switched the driver to use generic device properties API, so there is no need to check for presence of DT node before trying parse properties.
--- drivers/input/touchscreen/ad7879.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/input/touchscreen/ad7879.c +3 -4
@@ -560,11 +560,10 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, ts->averaging = pdata->averaging; ts->pen_down_acc_interval = pdata->pen_down_acc_interval; ts->median = pdata->median; - }else if (dev->of_node) { -ad7879_parse_dt (dev, ts); }else { -dev_err (dev,"No platform data\n" ); -return -EINVAL ; + err =ad7879_parse_dt (dev, ts); +if (err) +return err; } input_dev =devm_input_allocate_device (dev);
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Re: [PATCH 3/4] Input: ad7879 - try parsing properties on non-DT systems
Quoted 4 lines · Dmitry Torokhov
We have switched the driver to use generic device properties API, so there is no need to check for presence of DT node before trying parse properties.
Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 24 lines
--- drivers/input/touchscreen/ad7879.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/input/touchscreen/ad7879.c +3
-4@@ -560,11 +560,10 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, ts->averaging = pdata->averaging; ts->pen_down_acc_interval = pdata->pen_down_acc_interval; ts->median = pdata->median; - }else if (dev->of_node) { -ad7879_parse_dt (dev, ts); }else { -dev_err (dev,"No platform data\n" ); -return -EINVAL ; + err =ad7879_parse_dt (dev, ts); +if (err) +return err; } input_dev =devm_input_allocate_device (dev);
Signature · 7 lines
Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 München Sitz der Gesellschaft München, Registergericht München HRB 40368, Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne
Dmitry Torokhov
maintainerPATCH 4/4 Input: ad7879 - do not manipulate capability bits directly
In reply to Dmitry TorokhovInstead of manipulating capabilities bits of input device directly, let's use input_set_capability() API.
Also, stop setting ABS_X/Y bits explicitly as input_set_abs_params() does this for us.
--- drivers/input/touchscreen/ad7879.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/input/touchscreen/ad7879.c +2 -7
@@ -590,13 +590,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,input_set_drvdata (input_dev, ts); -__set_bit (EV_ABS , input_dev->evbit); -__set_bit (ABS_X , input_dev->absbit); -__set_bit (ABS_Y , input_dev->absbit); -__set_bit (ABS_PRESSURE , input_dev->absbit); - -__set_bit (EV_KEY , input_dev->evbit); -__set_bit (BTN_TOUCH , input_dev->keybit); +input_set_capability (input_dev,EV_KEY ,BTN_TOUCH );if (pdata) { input_set_abs_params(input_dev, ABS_X,
@@ -614,6 +608,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, }else {input_set_abs_params (input_dev,ABS_X ,0 ,MAX_12BIT ,0 ,0 );input_set_abs_params (input_dev,ABS_Y ,0 ,MAX_12BIT ,0 ,0 ); +input_set_capability (input_dev,EV_ABS ,ABS_PRESSURE );touchscreen_parse_properties (input_dev, false,NULL );if (!input_abs_get_max (input_dev,ABS_PRESSURE )) {dev_err (dev,"Touchscreen pressure is not specified\n" );
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Re: [PATCH 4/4] Input: ad7879 - do not manipulate capability bits directly
Quoted 7 lines · Dmitry Torokhov
Instead of manipulating capabilities bits of input device directly, let's use
input_set_capability()API.Also, stop setting ABS_X/Y bits explicitly as
input_set_abs_params()does this for us.Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 32 lines
--- drivers/input/touchscreen/ad7879.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/input/touchscreen/ad7879.c +2
-7@@ -590,13 +590,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,input_set_drvdata (input_dev, ts); -__set_bit (EV_ABS , input_dev->evbit); -__set_bit (ABS_X , input_dev->absbit); -__set_bit (ABS_Y , input_dev->absbit); -__set_bit (ABS_PRESSURE , input_dev->absbit); - -__set_bit (EV_KEY , input_dev->evbit); -__set_bit (BTN_TOUCH , input_dev->keybit); +input_set_capability (input_dev,EV_KEY ,BTN_TOUCH );if (pdata) { input_set_abs_params(input_dev, ABS_X,@@ -614,6 +608,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, }else {input_set_abs_params (input_dev,ABS_X ,0 ,MAX_12BIT ,0 ,0 );input_set_abs_params (input_dev,ABS_Y ,0 ,MAX_12BIT ,0 ,0 ); +input_set_capability (input_dev,EV_ABS ,ABS_PRESSURE );touchscreen_parse_properties (input_dev, false,NULL );if (!input_abs_get_max (input_dev,ABS_PRESSURE )) {dev_err (dev,"Touchscreen pressure is not specified\n" );
Signature · 7 lines
Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 München Sitz der Gesellschaft München, Registergericht München HRB 40368, Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne
Quoted 6 lines · Dmitry Torokhov
The conversion to devm accidentally removed setting up of I2C client data upon successful probe of the touchscreen. Let's move this setting into the core, so we do not forger about it again.
Fixes 381f688eee3d ("Input: ad7879 - use more devm interfaces")Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 32 lines
--- drivers/input/touchscreen/ad7879-spi.c | 2 -- drivers/input/touchscreen/ad7879.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)drivers/input/touchscreen/ad7879-spi.c +0
-2@@ -49,8 +49,6 @@ static int ad7879_spi_probe(struct spi_device *spi)if (IS_ERR (ts))return PTR_ERR (ts); -spi_set_drvdata (spi, ts); -return 0 ; }drivers/input/touchscreen/ad7879.c +2
-0@@ -680,6 +680,8 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,if (err)return ERR_PTR (err); +dev_set_drvdata (dev, ts); +return 0 ; }EXPORT_SYMBOL (ad7879_probe);
Signature · 7 lines
Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 München Sitz der Gesellschaft München, Registergericht München HRB 40368, Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne