Skip to contentSkip to conversation

Input: Automated coccinelle cleanup

PATCH Applied Guenter Roeck 6 participants 62 messages Jan 18, 2017 – Mar 14, 2017

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

cover Input: Automated coccinelle cleanup

This patch series is the result of applying a set of coccinelle semantic patches to the input subsystem. The patches are only cleanup patches; there is little or no change in functionality.

A more complex series of patches making actual code changes will be sent separately. This patch series is a fallout from this more complex series. It may be questionable if the patches in this series, or any of them, are worth it. I'll leave that up to the maintainers to decide.

A surprising aspect of this patch series is the number of removed calls to platform_set_drvdata() and i2c_set_clientdata(). While I have not found any problems with those removals, this deserves some extra scrutiny from reviewers.

The conversion was done automatically with coccinelle using several semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches.
A few files had to be edited manually to fix checkpatch issues. Those edits were also handled automatically with fixup patches included in the repository.

The series was build tested on kerneltests.org and by the 0day build system.

To reproduce this series of patches, checkout the tree above, then run the following commands from the Linux source tree.

sh ~coccinelle-patches/input/make-base.sh
sh ~coccinelle-patches/input/do-commit-base.sh

The patch series is based on v4.10-rc3. For convenience, the series
is available at:
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git input-base

The semantic patches used in this series were written with substantial help from Julia Lawall. Without her support, this effort would not have been possible.

----------------------------------------------------------------
Guenter Roeck (33):
Input: adp5520-keys - Drop unnecessary error messages and other changes
Input: bcm-keypad - Drop unnecessary call to platform_set_drvdata and other changes
Input: cap11xx - Drop unnecessary call to i2c_set_clientdata and other changes
Input: cros_ec_keyb - Drop unnecessary call to dev_set_drvdata and other changes
Input: imx_keypad - Drop unnecessary error messages and other changes
Input: samsung-keypad - Drop unnecessary error messages and other changes
Input: sh_keysc - Drop unnecessary error messages and other changes
Input: spear-keyboard - Drop unnecessary error messages and other changes
Input: sun4i-lradc-keys - Drop unnecessary call to platform_set_drvdata and other changes
Input: twl4030_keypad - Drop unnecessary call to platform_set_drvdata and other changes
Input: ab8500-ponkey - Drop unnecessary call to platform_set_drvdata and other changes
Input: axp20x-pek - Use devm_add_action_or_reset and other changes
Input: bfin_rotary - Use 'dev' instead of dereferencing it and other changes
Input: gpio_decoder - Drop unnecessary call to platform_set_drvdata and other changes
Input: kxtj9 - Drop unnecessary error messages and other changes
Input: mma8450 - Drop unnecessary call to i2c_set_clientdata and other changes
Input: retu-pwrbutton - Simplify error return and other changes
Input: soc_button_array - Use 'dev' instead of dereferencing it and other changes
Input: tps65218-pwrbutton - Drop unnecessary call to platform_set_drvdata and other changes
Input: elan_i2c_core - Use 'dev' instead of dereferencing it and other changes
Input: arc_ps2 - Drop unnecessary error messages and other changes
Input: at32psif - Drop unnecessary error messages and other changes
Input: xilinx_ps2 - Use 'dev' instead of dereferencing it and other changes
Input: ar1021_i2c - Drop unnecessary call to i2c_set_clientdata and other changes
Input: atmel-wm97xx - Drop unnecessary error messages and other changes
Input: atmel_mxt_ts - Drop unnecessary error messages and other changes
Input: eeti_ts - Drop unnecessary error messages and other changes
Input: egalax_ts - Drop unnecessary call to i2c_set_clientdata and other changes
Input: melfas_mip4 - Use devm_add_action_or_reset and other changes
Input: raydium_i2c_ts - Simplify error return and other changes
Input: rohm_bu21023 - Use 'dev' instead of dereferencing it and other changes
Input: sis_i2c - Drop unnecessary call to i2c_set_clientdata and other changes
Input: sx8654 - Drop unnecessary call to i2c_set_clientdata and other changes

 drivers/input/keyboard/adp5520-keys.c      |  4 +-
 drivers/input/keyboard/bcm-keypad.c        |  2 -
 drivers/input/keyboard/cap11xx.c           | 14 ++-----
 drivers/input/keyboard/cros_ec_keyb.c      |  3 +-
 drivers/input/keyboard/imx_keypad.c        |  4 +-
 drivers/input/keyboard/samsung-keypad.c    | 12 ++----
 drivers/input/keyboard/sh_keysc.c          | 15 +++-----
 drivers/input/keyboard/spear-keyboard.c    |  4 +-
 drivers/input/keyboard/sun4i-lradc-keys.c  |  7 +---
 drivers/input/keyboard/twl4030_keypad.c    |  1 -
 drivers/input/misc/ab8500-ponkey.c         |  1 -
 drivers/input/misc/axp20x-pek.c            |  6 +--
 drivers/input/misc/bfin_rotary.c           | 18 ++++-----
 drivers/input/misc/gpio_decoder.c          |  1 -
 drivers/input/misc/kxtj9.c                 | 12 ++----
 drivers/input/misc/mma8450.c               |  2 -
 drivers/input/misc/retu-pwrbutton.c        | 12 +-----
 drivers/input/misc/soc_button_array.c      |  6 +--
 drivers/input/misc/tps65218-pwrbutton.c    | 11 ++----
 drivers/input/mouse/elan_i2c_core.c        | 59 +++++++++++-------------------
 drivers/input/serio/arc_ps2.c              |  4 +-
 drivers/input/serio/at32psif.c             | 12 ++----
 drivers/input/serio/xilinx_ps2.c           |  7 ++--
 drivers/input/touchscreen/ar1021_i2c.c     |  6 +--
 drivers/input/touchscreen/atmel-wm97xx.c   |  4 +-
 drivers/input/touchscreen/atmel_mxt_ts.c   | 47 +++++-------------------
 drivers/input/touchscreen/eeti_ts.c        |  7 +---
 drivers/input/touchscreen/egalax_ts.c      | 21 ++---------
 drivers/input/touchscreen/melfas_mip4.c    | 10 ++---
 drivers/input/touchscreen/raydium_i2c_ts.c | 18 +++------
 drivers/input/touchscreen/rohm_bu21023.c   | 12 +++---
 drivers/input/touchscreen/sis_i2c.c        |  1 -
 drivers/input/touchscreen/sx8654.c         | 14 ++-----
 33 files changed, 105 insertions(+), 252 deletions(-)
#2 lore raw

PATCH 2/33 Input: bcm-keypad - Drop unnecessary call to platform_set_drvdata and other changes

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

---
 drivers/input/keyboard/bcm-keypad.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/keyboard/bcm-keypad.c +0 -2
index 86a8b723ae15..2b4e63d81e6d 100644
@@ -352,8 +352,6 @@ static int bcm_kp_probe(struct platform_device *pdev)
 
 	kp->input_dev = input_dev;
 
-	platform_set_drvdata(pdev, kp);
-
 	error = bcm_kp_matrix_key_parse_dt(kp);
 	if (error)
 		return error;
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/33 Input: cap11xx - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Other relevant changes:
Simplify error return

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/keyboard/cap11xx.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/input/keyboard/cap11xx.c +4 -10
index 4401be225d64..9cbba2dd0e29 100644
@@ -189,11 +189,11 @@ static irqreturn_t cap11xx_thread_func(int irq_num, void *data)
 	 */
 	ret = regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL, 1, 0);
 	if (ret < 0)
-		goto out;
+		return IRQ_HANDLED;
 
 	ret = regmap_read(priv->regmap, CAP11XX_REG_SENSOR_INPUT, &status);
 	if (ret < 0)
-		goto out;
+		return IRQ_HANDLED;
 
 	for (i = 0; i < priv->idev->keycodemax; i++)
 		input_report_key(priv->idev, priv->keycodes[i],
@@ -201,7 +201,6 @@ static irqreturn_t cap11xx_thread_func(int irq_num, void *data)
 
 	input_sync(priv->idev);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -392,7 +391,6 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
 		return error;
 
 	dev_info(dev, "CAP11XX detected, revision 0x%02x\n", rev);
-	i2c_set_clientdata(i2c_client, priv);
 	node = dev->of_node;
 
 	if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) {
@@ -476,12 +474,8 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
 		return -ENXIO;
 	}
 
-	error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
-					  IRQF_ONESHOT, dev_name(dev), priv);
-	if (error)
-		return error;
-
-	return 0;
+	return devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
+					 IRQF_ONESHOT, dev_name(dev), priv);
 }
 
 static const struct of_device_id cap11xx_dt_ids[] = {
Signature · 1 line
2.7.4
#7 lore raw

PATCH 6/33 Input: samsung-keypad - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/keyboard/samsung-keypad.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/input/keyboard/samsung-keypad.c +3 -9
index 4e319eb9e19d..b6ea0cd3542b 100644
@@ -258,10 +258,8 @@ samsung_keypad_parse_dt(struct device *dev)
 	}
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		dev_err(dev, "could not allocate memory for platform data\n");
+	if (!pdata)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows);
 	of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols);
@@ -273,19 +271,15 @@ samsung_keypad_parse_dt(struct device *dev)
 	pdata->cols = num_cols;
 
 	keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL);
-	if (!keymap_data) {
-		dev_err(dev, "could not allocate memory for keymap data\n");
+	if (!keymap_data)
 		return ERR_PTR(-ENOMEM);
-	}
 	pdata->keymap_data = keymap_data;
 
 	key_count = of_get_child_count(np);
 	keymap_data->keymap_size = key_count;
 	keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
-	if (!keymap) {
-		dev_err(dev, "could not allocate memory for keymap\n");
+	if (!keymap)
 		return ERR_PTR(-ENOMEM);
-	}
 	keymap_data->keymap = keymap;
 
 	for_each_child_of_node(np, key_np) {
Signature · 1 line
2.7.4
#8 lore raw

PATCH 7/33 Input: sh_keysc - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'val = e; return val;' with 'return e;'

---
 drivers/input/keyboard/sh_keysc.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/input/keyboard/sh_keysc.c +5 -10
index 7abf03b4cc9c..63ea707df193 100644
@@ -172,29 +172,25 @@ static int sh_keysc_probe(struct platform_device *pdev)
 
 	if (!dev_get_platdata(&pdev->dev)) {
 		dev_err(&pdev->dev, "no platform data defined\n");
-		error = -EINVAL;
-		goto err0;
+		return -EINVAL;
 	}
 
 	error = -ENXIO;
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res == NULL) {
 		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		goto err0;
+		return error;
 	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		goto err0;
+		return error;
 	}
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (priv == NULL) {
-		dev_err(&pdev->dev, "failed to allocate driver data\n");
-		error = -ENOMEM;
-		goto err0;
-	}
+	if (priv == NULL)
+		return -ENOMEM;
 
 	platform_set_drvdata(pdev, priv);
 	memcpy(&priv->pdata, dev_get_platdata(&pdev->dev), sizeof(priv->pdata));
@@ -266,7 +262,6 @@ static int sh_keysc_probe(struct platform_device *pdev)
 	iounmap(priv->iomem_base);
  err1:
 	kfree(priv);
- err0:
 	return error;
 }
 
Signature · 1 line
2.7.4
#11 lore raw

PATCH 9/33 Input: sun4i-lradc-keys - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata(). Other relevant changes:
Simplify error return

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop platform_set_drvdata()

---
 drivers/input/keyboard/sun4i-lradc-keys.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/input/keyboard/sun4i-lradc-keys.c +1 -6
index cc8f7ddcee53..c153d956778c 100644
@@ -257,12 +257,7 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
-	error = input_register_device(lradc->input);
-	if (error)
-		return error;
-
-	platform_set_drvdata(pdev, lradc);
-	return 0;
+	return input_register_device(lradc->input);
 }
 
 static const struct of_device_id sun4i_lradc_of_match[] = {
Signature · 1 line
2.7.4
#13 lore raw

PATCH 10/33 Input: twl4030_keypad - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

---
 drivers/input/keyboard/twl4030_keypad.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/keyboard/twl4030_keypad.c +0 -1
index 323a0fb575a4..29396ca69416 100644
@@ -441,7 +441,6 @@ static int twl4030_kp_probe(struct platform_device *pdev)
 		return -EIO;
 	}
 
-	platform_set_drvdata(pdev, kp);
 	return 0;
 }
 
Signature · 1 line
2.7.4
#17 lore raw

PATCH 12/33 Input: axp20x-pek - Use devm_add_action_or_reset and other changes

In reply to Guenter Roeck

Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

---
 drivers/input/misc/axp20x-pek.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/misc/axp20x-pek.c +3 -3
index 1ac898db303a..419ca97b051b 100644
@@ -260,10 +260,10 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	error = devm_add_action(&pdev->dev,
-				axp20x_remove_sysfs_group, &pdev->dev);
+	error = devm_add_action_or_reset(&pdev->dev,
+					 axp20x_remove_sysfs_group,
+					 &pdev->dev);
 	if (error) {
-		axp20x_remove_sysfs_group(&pdev->dev);
 		dev_err(&pdev->dev, "Failed to add sysfs cleanup action: %d\n",
 			error);
 		return error;
Signature · 1 line
2.7.4
#24 lore raw

PATCH 14/33 Input: gpio_decoder - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

---
 drivers/input/misc/gpio_decoder.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/misc/gpio_decoder.c +0 -1
index ca7e0bacb2d8..1dca526e6f1a 100644
@@ -110,7 +110,6 @@ static int gpio_decoder_probe(struct platform_device *pdev)
 		dev_err(dev, "failed to register polled  device\n");
 		return err;
 	}
-	platform_set_drvdata(pdev, decoder);
 
 	return 0;
 }
Signature · 1 line
2.7.4
#26 lore raw

PATCH 15/33 Input: kxtj9 - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.
Other relevant changes:
Simplify error return

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'if (e) return e; return 0;' with 'return e;'

---
 drivers/input/misc/kxtj9.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/input/misc/kxtj9.c +3 -9
index efaffcc57e36..1c96e30834fc 100644
@@ -196,11 +196,8 @@ static int kxtj9_update_odr(struct kxtj9_data *tj9, unsigned int poll_interval)
 	if (err < 0)
 		return err;
 
-	err = i2c_smbus_write_byte_data(tj9->client, CTRL_REG1, tj9->ctrl_reg1);
-	if (err < 0)
-		return err;
-
-	return 0;
+	return i2c_smbus_write_byte_data(tj9->client, CTRL_REG1,
+					 tj9->ctrl_reg1);
 }
 
 static int kxtj9_device_power_on(struct kxtj9_data *tj9)
@@ -526,11 +523,8 @@ static int kxtj9_probe(struct i2c_client *client,
 	}
 
 	tj9 = kzalloc(sizeof(*tj9), GFP_KERNEL);
-	if (!tj9) {
-		dev_err(&client->dev,
-			"failed to allocate memory for module data\n");
+	if (!tj9)
 		return -ENOMEM;
-	}
 
 	tj9->client = client;
 	tj9->pdata = *pdata;
Signature · 1 line
2.7.4
#27 lore raw

PATCH 16/33 Input: mma8450 - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop i2c_set_clientdata()

---
 drivers/input/misc/mma8450.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/misc/mma8450.c +0 -2
index 19c73574458e..b60cdea73826 100644
@@ -205,8 +205,6 @@ static int mma8450_probe(struct i2c_client *c,
 		return err;
 	}
 
-	i2c_set_clientdata(c, m);
-
 	return 0;
 }
 
Signature · 1 line
2.7.4
#29 lore raw

PATCH 17/33 Input: retu-pwrbutton - Simplify error return and other changes

In reply to Guenter Roeck

Simplify error return if the code returns anyway.
Other relevant changes:
Drop empty remove function

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop empty remove function
- Replace 'if (e) return e; return 0;' with 'return e;'

---
 drivers/input/misc/retu-pwrbutton.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/input/misc/retu-pwrbutton.c +1 -11
index 30b459b6b344..97d39a965a65 100644
@@ -69,21 +69,11 @@ static int retu_pwrbutton_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
-	error = input_register_device(idev);
-	if (error)
-		return error;
-
-	return 0;
-}
-
-static int retu_pwrbutton_remove(struct platform_device *pdev)
-{
-	return 0;
+	return input_register_device(idev);
 }
 
 static struct platform_driver retu_pwrbutton_driver = {
 	.probe		= retu_pwrbutton_probe,
-	.remove		= retu_pwrbutton_remove,
 	.driver		= {
 		.name	= "retu-pwrbutton",
 	},
Signature · 1 line
2.7.4
#30 lore raw

PATCH 18/33 Input: soc_button_array - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Use local variable 'struct device *dev' consistently

---
 drivers/input/misc/soc_button_array.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/misc/soc_button_array.c +3 -3
index 908b51089dee..fb3219a8d3c0 100644
@@ -167,12 +167,12 @@ static int soc_button_probe(struct platform_device *pdev)
 
 	button_info = (struct soc_button_info *)id->driver_data;
 
-	if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) {
-		dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n");
+	if (gpiod_count(dev, KBUILD_MODNAME) <= 0) {
+		dev_dbg(dev, "no GPIO attached, ignoring...\n");
 		return -ENODEV;
 	}
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
Signature · 1 line
2.7.4
#34 lore raw

PATCH 20/33 Input: elan_i2c_core - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times. Other relevant changes:
Simplify error return
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'if (e) return e; return 0;' with 'return e;'
- Use local variable 'struct device *dev' consistently

---
 drivers/input/mouse/elan_i2c_core.c | 59 +++++++++++++------------------------
 1 file changed, 21 insertions(+), 38 deletions(-)
drivers/input/mouse/elan_i2c_core.c +21 -38
index fa598f7f4372..806f304e6356 100644
@@ -210,10 +210,7 @@ static int elan_query_product(struct elan_tp_data *data)
 
 	error = data->ops->get_sm_version(data->client, &data->ic_type,
 					  &data->sm_version);
-	if (error)
-		return error;
-
-	return 0;
+	return error;
 }
 
 static int elan_check_ASUS_special_fw(struct elan_tp_data *data)
@@ -926,12 +923,12 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
 	*/
 	if (data->in_fw_update) {
 		complete(&data->fw_completion);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	error = data->ops->get_report(data->client, report);
 	if (error)
-		goto out;
+		return IRQ_HANDLED;
 
 	if (report[ETP_REPORT_ID_OFFSET] != ETP_REPORT_ID)
 		dev_err(dev, "invalid report id data (%x)\n",
@@ -939,7 +936,6 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
 	else
 		elan_report_absolute(data, report);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -1041,8 +1037,7 @@ static int elan_probe(struct i2c_client *client,
 		return -EIO;
 	}
 
-	data = devm_kzalloc(&client->dev, sizeof(struct elan_tp_data),
-			    GFP_KERNEL);
+	data = devm_kzalloc(dev, sizeof(struct elan_tp_data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -1053,29 +1048,24 @@ static int elan_probe(struct i2c_client *client,
 	init_completion(&data->fw_completion);
 	mutex_init(&data->sysfs_mutex);
 
-	data->vcc = devm_regulator_get(&client->dev, "vcc");
+	data->vcc = devm_regulator_get(dev, "vcc");
 	if (IS_ERR(data->vcc)) {
 		error = PTR_ERR(data->vcc);
 		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get 'vcc' regulator: %d\n",
+			dev_err(dev, "Failed to get 'vcc' regulator: %d\n",
 				error);
 		return error;
 	}
 
 	error = regulator_enable(data->vcc);
 	if (error) {
-		dev_err(&client->dev,
-			"Failed to enable regulator: %d\n", error);
+		dev_err(dev, "Failed to enable regulator: %d\n", error);
 		return error;
 	}
 
-	error = devm_add_action(&client->dev,
-				elan_disable_regulator, data);
+	error = devm_add_action_or_reset(dev, elan_disable_regulator, data);
 	if (error) {
-		regulator_disable(data->vcc);
-		dev_err(&client->dev,
-			"Failed to add disable regulator action: %d\n",
+		dev_err(dev, "Failed to add disable regulator action: %d\n",
 			error);
 		return error;
 	}
@@ -1093,15 +1083,14 @@ static int elan_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
-	dev_info(&client->dev,
+	dev_info(dev,
 		 "Elan Touchpad: Module ID: 0x%04x, Firmware: 0x%04x, Sample: 0x%04x, IAP: 0x%04x\n",
 		 data->product_id,
 		 data->fw_version,
 		 data->sm_version,
 		 data->iap_version);
 
-	dev_dbg(&client->dev,
-		"Elan Touchpad Extra Information:\n"
+	dev_dbg(dev, "Elan Touchpad Extra Information:\n"
 		"    Max ABS X,Y:   %d,%d\n"
 		"    Width X,Y:   %d,%d\n"
 		"    Resolution X,Y:   %d,%d (dots/mm)\n",
@@ -1118,38 +1107,32 @@ static int elan_probe(struct i2c_client *client,
 	 * Systems using device tree should set up interrupt via DTS,
 	 * the rest will use the default falling edge interrupts.
 	 */
-	irqflags = client->dev.of_node ? 0 : IRQF_TRIGGER_FALLING;
+	irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING;
 
-	error = devm_request_threaded_irq(&client->dev, client->irq,
-					  NULL, elan_isr,
+	error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr,
 					  irqflags | IRQF_ONESHOT,
 					  client->name, data);
 	if (error) {
-		dev_err(&client->dev, "cannot register irq=%d\n", client->irq);
+		dev_err(dev, "cannot register irq=%d\n", client->irq);
 		return error;
 	}
 
-	error = sysfs_create_groups(&client->dev.kobj, elan_sysfs_groups);
+	error = sysfs_create_groups(&dev->kobj, elan_sysfs_groups);
 	if (error) {
-		dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
-			error);
+		dev_err(dev, "failed to create sysfs attributes: %d\n", error);
 		return error;
 	}
 
-	error = devm_add_action(&client->dev,
-				elan_remove_sysfs_groups, data);
+	error = devm_add_action_or_reset(dev, elan_remove_sysfs_groups, data);
 	if (error) {
-		elan_remove_sysfs_groups(data);
-		dev_err(&client->dev,
-			"Failed to add sysfs cleanup action: %d\n",
+		dev_err(dev, "Failed to add sysfs cleanup action: %d\n",
 			error);
 		return error;
 	}
 
 	error = input_register_device(data->input);
 	if (error) {
-		dev_err(&client->dev, "failed to register input device: %d\n",
-			error);
+		dev_err(dev, "failed to register input device: %d\n", error);
 		return error;
 	}
 
@@ -1157,8 +1140,8 @@ static int elan_probe(struct i2c_client *client,
 	 * Systems using device tree should set up wakeup via DTS,
 	 * the rest will configure device as wakeup source by default.
 	 */
-	if (!client->dev.of_node)
-		device_init_wakeup(&client->dev, true);
+	if (!dev->of_node)
+		device_init_wakeup(dev, true);
 
 	return 0;
 }
Signature · 1 line
2.7.4
#35 lore raw

PATCH 21/33 Input: arc_ps2 - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/serio/arc_ps2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/serio/arc_ps2.c +1 -3
index 99e57a418753..9860b1c1e67a 100644
@@ -197,10 +197,8 @@ static int arc_ps2_probe(struct platform_device *pdev)
 
 	arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(struct arc_ps2_data),
 				GFP_KERNEL);
-	if (!arc_ps2) {
-		dev_err(&pdev->dev, "out of memory\n");
+	if (!arc_ps2)
 		return -ENOMEM;
-	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	arc_ps2->addr = devm_ioremap_resource(&pdev->dev, res);
Signature · 1 line
2.7.4
#36 lore raw

PATCH 22/33 Input: at32psif - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'val = e; return val;' with 'return e;'

---
 drivers/input/serio/at32psif.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/input/serio/at32psif.c +3 -9
index 2e4ff5bac754..e420fd781d44 100644
@@ -159,13 +159,12 @@ static int psif_open(struct serio *io)
 
 	retval = clk_enable(psif->pclk);
 	if (retval)
-		goto out;
+		return retval;
 
 	psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN));
 	psif_writel(psif, IER, PSIF_BIT(RXRDY));
 
 	psif->open = true;
-out:
 	return retval;
 }
 
@@ -210,16 +209,12 @@ static int __init psif_probe(struct platform_device *pdev)
 	int ret;
 
 	psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
-	if (!psif) {
-		dev_dbg(&pdev->dev, "out of memory\n");
-		ret = -ENOMEM;
-		goto out;
-	}
+	if (!psif)
+		return -ENOMEM;
 	psif->pdev = pdev;
 
 	io = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (!io) {
-		dev_dbg(&pdev->dev, "out of memory\n");
 		ret = -ENOMEM;
 		goto out_free_psif;
 	}
@@ -297,7 +292,6 @@ static int __init psif_probe(struct platform_device *pdev)
 	kfree(io);
 out_free_psif:
 	kfree(psif);
-out:
 	return ret;
 }
 
Signature · 1 line
2.7.4
#38 lore raw

PATCH 23/33 Input: xilinx_ps2 - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Use local variable 'struct device *dev' consistently

---
 drivers/input/serio/xilinx_ps2.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/input/serio/xilinx_ps2.c +3 -4
index 5223cbf94262..14c40892ed82 100644
@@ -243,18 +243,17 @@ static int xps2_of_probe(struct platform_device *ofdev)
 	unsigned int irq;
 	int error;
 
-	dev_info(dev, "Device Tree Probing \'%s\'\n",
-			ofdev->dev.of_node->name);
+	dev_info(dev, "Device Tree Probing \'%s\'\n", dev->of_node->name);
 
 	/* Get iospace for the device */
-	error = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
+	error = of_address_to_resource(dev->of_node, 0, &r_mem);
 	if (error) {
 		dev_err(dev, "invalid address\n");
 		return error;
 	}
 
 	/* Get IRQ for the device */
-	irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+	irq = irq_of_parse_and_map(dev->of_node, 0);
 	if (!irq) {
 		dev_err(dev, "no IRQ found\n");
 		return -ENODEV;
Signature · 1 line
2.7.4
#40 lore raw

PATCH 24/33 Input: ar1021_i2c - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'goto l; ... l: return e;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/ar1021_i2c.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/touchscreen/ar1021_i2c.c +2 -4
index 71b5a634cf6d..b289eca2b797 100644
@@ -35,11 +35,11 @@ static irqreturn_t ar1021_i2c_irq(int irq, void *dev_id)
 	retval = i2c_master_recv(ar1021->client,
 				ar1021->data, sizeof(ar1021->data));
 	if (retval != sizeof(ar1021->data))
-		goto out;
+		return IRQ_HANDLED;
 
 	/* sync bit set ? */
 	if ((data[0] & 0x80) == 0)
-		goto out;
+		return IRQ_HANDLED;
 
 	button = data[0] & BIT(0);
 	x = ((data[2] & 0x1f) << 7) | (data[1] & 0x7f);
@@ -50,7 +50,6 @@ static irqreturn_t ar1021_i2c_irq(int irq, void *dev_id)
 	input_report_key(input, BTN_TOUCH, button);
 	input_sync(input);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -127,7 +126,6 @@ static int ar1021_i2c_probe(struct i2c_client *client,
 		return error;
 	}
 
-	i2c_set_clientdata(client, ar1021);
 	return 0;
 }
 
Signature · 1 line
2.7.4
#42 lore raw

PATCH 25/33 Input: atmel-wm97xx - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/touchscreen/atmel-wm97xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/atmel-wm97xx.c +1 -3
index 7ec0421c0dd8..8cf0b2be2df4 100644
@@ -339,10 +339,8 @@ static int __init atmel_wm97xx_probe(struct platform_device *pdev)
 	int ret;
 
 	atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL);
-	if (!atmel_wm97xx) {
-		dev_dbg(&pdev->dev, "out of memory\n");
+	if (!atmel_wm97xx)
 		return -ENOMEM;
-	}
 
 	atmel_wm97xx->wm	= wm;
 	atmel_wm97xx->regs	= (void *)ATMEL_WM97XX_AC97C_IOMEM;
Signature · 1 line
2.7.4
#44 lore raw

PATCH 26/33 Input: atmel_mxt_ts - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.
Other relevant changes:
Simplify error return

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unused variables
- Drop unnecessary braces around conditional return statements
- Use local structure pointers consistently
- Drop error message after devm_kzalloc() failure
- Replace 'if (e) return e; return 0;' with 'return e;'

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 47 +++++++-------------------------
 1 file changed, 10 insertions(+), 37 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +10 -37
index e5d185fe69b9..ca027503627e 100644
@@ -585,7 +585,6 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state,
 
 static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
 {
-	int ret;
 	u8 buf[2];
 
 	if (unlock) {
@@ -596,11 +595,7 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
 		buf[1] = 0x01;
 	}
 
-	ret = mxt_bootloader_write(data, buf, 2);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mxt_bootloader_write(data, buf, 2);
 }
 
 static int __mxt_read_reg(struct i2c_client *client,
@@ -1167,15 +1162,9 @@ static int mxt_t6_command(struct mxt_data *data, u16 cmd_offset,
 
 static int mxt_acquire_irq(struct mxt_data *data)
 {
-	int error;
-
 	enable_irq(data->irq);
 
-	error = mxt_process_messages_until_invalid(data);
-	if (error)
-		return error;
-
-	return 0;
+	return mxt_process_messages_until_invalid(data);
 }
 
 static int mxt_soft_reset(struct mxt_data *data)
@@ -1198,12 +1187,8 @@ static int mxt_soft_reset(struct mxt_data *data)
 
 	mxt_acquire_irq(data);
 
-	ret = mxt_wait_for_completion(data, &data->reset_completion,
-				      MXT_RESET_TIMEOUT);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mxt_wait_for_completion(data, &data->reset_completion,
+				       MXT_RESET_TIMEOUT);
 }
 
 static void mxt_update_crc(struct mxt_data *data, u8 cmd, u8 value)
@@ -1504,10 +1489,8 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
 			MXT_INFO_CHECKSUM_SIZE;
 	config_mem_size = data->mem_size - cfg_start_ofs;
 	config_mem = kzalloc(config_mem_size, GFP_KERNEL);
-	if (!config_mem) {
-		dev_err(dev, "Failed to allocate memory\n");
+	if (!config_mem)
 		return -ENOMEM;
-	}
 
 	ret = mxt_prepare_cfg_mem(data, cfg, data_pos, cfg_start_ofs,
 				  config_mem, config_mem_size);
@@ -1555,14 +1538,9 @@ static int mxt_get_info(struct mxt_data *data)
 {
 	struct i2c_client *client = data->client;
 	struct mxt_info *info = &data->info;
-	int error;
 
 	/* Read 7-byte info block starting at address 0 */
-	error = __mxt_read_reg(client, 0, sizeof(*info), info);
-	if (error)
-		return error;
-
-	return 0;
+	return __mxt_read_reg(client, 0, sizeof(*info), info);
 }
 
 static void mxt_free_input_device(struct mxt_data *data)
@@ -1609,10 +1587,8 @@ static int mxt_get_object_table(struct mxt_data *data)
 
 	table_size = data->info.object_num * sizeof(struct mxt_object);
 	object_table = kzalloc(table_size, GFP_KERNEL);
-	if (!object_table) {
-		dev_err(&data->client->dev, "Failed to allocate memory\n");
+	if (!object_table)
 		return -ENOMEM;
-	}
 
 	error = __mxt_read_reg(client, MXT_OBJECT_START, table_size,
 			object_table);
@@ -2045,10 +2021,9 @@ static int mxt_initialize(struct mxt_data *data)
 		if (error) {
 			dev_info(&client->dev, "Trying alternate bootloader address\n");
 			error = mxt_probe_bootloader(data, true);
-			if (error) {
+			if (error)
 				/* Chip is not in appmode or bootloader mode */
 				return error;
-			}
 		}
 
 		/* OK, we are in bootloader, see if we can recover */
@@ -2509,7 +2484,7 @@ static void mxt_debug_init(struct mxt_data *data)
 		dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN;
 	else
 		dbg->t37_pages = DIV_ROUND_UP(data->xsize *
-					      data->info.matrix_ysize *
+					      info->matrix_ysize *
 					      sizeof(u16),
 					      sizeof(dbg->t37_buf->data));
 
@@ -3117,10 +3092,8 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		return PTR_ERR(pdata);
 
 	data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL);
-	if (!data) {
-		dev_err(&client->dev, "Failed to allocate memory\n");
+	if (!data)
 		return -ENOMEM;
-	}
 
 	snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0",
 		 client->adapter->nr, client->addr);
Signature · 1 line
2.7.4
#45 lore raw

PATCH 27/33 Input: eeti_ts - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'goto l; ... l: return e;' with 'return e;'

---
 drivers/input/touchscreen/eeti_ts.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/input/touchscreen/eeti_ts.c +2 -5
index 09be6ced7151..de3f4a1e8416 100644
@@ -171,10 +171,8 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 */
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		dev_err(&client->dev, "failed to allocate driver data\n");
-		goto err0;
-	}
+	if (!priv)
+		return err;
 
 	mutex_init(&priv->mutex);
 	input = input_allocate_device();
@@ -243,7 +241,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 err1:
 	input_free_device(input);
 	kfree(priv);
-err0:
 	return err;
 }
 
Signature · 1 line
2.7.4
#47 lore raw

PATCH 28/33 Input: egalax_ts - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Other relevant changes:
Simplify error return
Drop error messages after memory allocation failures

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unused variables
- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/egalax_ts.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/input/touchscreen/egalax_ts.c +4 -17
index 1afc08b08155..05ba1a6dc7fc 100644
@@ -82,10 +82,9 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
 	if (ret < 0)
 		return IRQ_HANDLED;
 
-	if (buf[0] != REPORT_MODE_MTTOUCH) {
+	if (buf[0] != REPORT_MODE_MTTOUCH)
 		/* ignore mouse events and vendor events */
 		return IRQ_HANDLED;
-	}
 
 	state = buf[1];
 	x = (buf[3] << 8) | buf[2];
@@ -155,13 +154,8 @@ static int egalax_wake_up_device(struct i2c_client *client)
 static int egalax_firmware_version(struct i2c_client *client)
 {
 	static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
-	int ret;
-
-	ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);
-	if (ret < 0)
-		return ret;
 
-	return 0;
+	return i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);
 }
 
 static int egalax_ts_probe(struct i2c_client *client,
@@ -172,10 +166,8 @@ static int egalax_ts_probe(struct i2c_client *client,
 	int error;
 
 	ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL);
-	if (!ts) {
-		dev_err(&client->dev, "Failed to allocate memory\n");
+	if (!ts)
 		return -ENOMEM;
-	}
 
 	input_dev = devm_input_allocate_device(&client->dev);
 	if (!input_dev) {
@@ -225,12 +217,7 @@ static int egalax_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = input_register_device(ts->input_dev);
-	if (error)
-		return error;
-
-	i2c_set_clientdata(client, ts);
-	return 0;
+	return input_register_device(ts->input_dev);
 }
 
 static const struct i2c_device_id egalax_ts_id[] = {
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/33 Input: adp5520-keys - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/keyboard/adp5520-keys.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/adp5520-keys.c +1 -3
index db1004dad108..de69d415c2b5 100644
@@ -91,10 +91,8 @@ static int adp5520_keys_probe(struct platform_device *pdev)
 		return -EINVAL;
 
 	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		dev_err(&pdev->dev, "failed to alloc memory\n");
+	if (!dev)
 		return -ENOMEM;
-	}
 
 	input = devm_input_allocate_device(&pdev->dev);
 	if (!input)
Signature · 1 line
2.7.4
#6 lore raw

PATCH 5/33 Input: imx_keypad - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/keyboard/imx_keypad.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/imx_keypad.c +1 -3
index 2165f3dd328b..eb273ade822f 100644
@@ -447,10 +447,8 @@ static int imx_keypad_probe(struct platform_device *pdev)
 	}
 
 	keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL);
-	if (!keypad) {
-		dev_err(&pdev->dev, "not enough memory for driver data\n");
+	if (!keypad)
 		return -ENOMEM;
-	}
 
 	keypad->input_dev = input_dev;
 	keypad->irq = irq;
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/33 Input: cros_ec_keyb - Drop unnecessary call to dev_set_drvdata and other changes

In reply to Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to dev_set_drvdata().
Other relevant changes:
Use existing variable 'dev' instead of dereferencing it several times

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop dev_set_drvdata()
- Use local variable 'struct device *dev' consistently

---
 drivers/input/keyboard/cros_ec_keyb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/keyboard/cros_ec_keyb.c +1 -2
index 25943e9bc8bf..87d071ae21da 100644
@@ -222,7 +222,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
 	struct device_node *np;
 	int err;
 
-	np = pdev->dev.of_node;
+	np = dev->of_node;
 	if (!np)
 		return -ENODEV;
 
@@ -248,7 +248,6 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
 	ckdev->ec = ec;
 	ckdev->notifier.notifier_call = cros_ec_keyb_work;
 	ckdev->dev = dev;
-	dev_set_drvdata(dev, ckdev);
 
 	idev->name = CROS_EC_DEV_NAME;
 	idev->phys = ec->phys_name;
Signature · 1 line
2.7.4
#15 lore raw

PATCH 11/33 Input: ab8500-ponkey - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

---
 drivers/input/misc/ab8500-ponkey.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/misc/ab8500-ponkey.c +0 -1
index 4f5ef5bb535b..a33ed5710b15 100644
@@ -109,7 +109,6 @@ static int ab8500_ponkey_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	platform_set_drvdata(pdev, ponkey);
 	return 0;
 }
 
Signature · 1 line
2.7.4
#9 lore raw

PATCH 8/33 Input: spear-keyboard - Drop unnecessary error messages and other changes

In reply to Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/keyboard/spear-keyboard.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/spear-keyboard.c +1 -3
index 8083eaa0524a..21357ee854c9 100644
@@ -197,10 +197,8 @@ static int spear_kbd_probe(struct platform_device *pdev)
 	}
 
 	kbd = devm_kzalloc(&pdev->dev, sizeof(*kbd), GFP_KERNEL);
-	if (!kbd) {
-		dev_err(&pdev->dev, "not enough memory for driver data\n");
+	if (!kbd)
 		return -ENOMEM;
-	}
 
 	input_dev = devm_input_allocate_device(&pdev->dev);
 	if (!input_dev) {
Signature · 1 line
2.7.4
#19 lore raw

PATCH 13/33 Input: bfin_rotary - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times. Other relevant changes:
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Drop unnecessary braces around conditional return statements
- Use local variable 'struct device *dev' consistently

---
 drivers/input/misc/bfin_rotary.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/input/misc/bfin_rotary.c +8 -10
index a0fc18fdfc0c..9f5790c6e06b 100644
@@ -141,25 +141,23 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
 	/* Basic validation */
 	if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
-	    (!pdata->rotary_up_key && pdata->rotary_down_key)) {
+	    (!pdata->rotary_up_key && pdata->rotary_down_key))
 		return -EINVAL;
-	}
 
 	if (pdata->pin_list) {
 		error = peripheral_request_list(pdata->pin_list,
-						dev_name(&pdev->dev));
+						dev_name(dev));
 		if (error) {
 			dev_err(dev, "requesting peripherals failed: %d\n",
 				error);
 			return error;
 		}
 
-		error = devm_add_action(dev, bfin_rotary_free_action,
-					pdata->pin_list);
+		error = devm_add_action_or_reset(dev, bfin_rotary_free_action,
+						 pdata->pin_list);
 		if (error) {
 			dev_err(dev, "setting cleanup action failed: %d\n",
 				error);
-			peripheral_free_list(pdata->pin_list);
 			return error;
 		}
 	}
@@ -189,7 +187,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
 	input->name = pdev->name;
 	input->phys = "bfin-rotary/input0";
-	input->dev.parent = &pdev->dev;
+	input->dev.parent = dev;
 
 	input_set_drvdata(input, rotary);
 
@@ -224,8 +222,8 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr,
-				 0, dev_name(dev), rotary);
+	error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr, 0,
+				 dev_name(dev), rotary);
 	if (error) {
 		dev_err(dev, "unable to claim irq %d; error %d\n",
 			rotary->irq, error);
@@ -239,7 +237,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, rotary);
-	device_init_wakeup(&pdev->dev, 1);
+	device_init_wakeup(dev, 1);
 
 	return 0;
 }
Signature · 1 line
2.7.4
#32 lore raw

PATCH 19/33 Input: tps65218-pwrbutton - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().
Other relevant changes:
Use existing variable 'dev' instead of dereferencing it several times

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'goto l; ... l: return e;' with 'return e;'
- Drop platform_set_drvdata()
- Use local variable 'struct device *dev' consistently

---
 drivers/input/misc/tps65218-pwrbutton.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/input/misc/tps65218-pwrbutton.c +4 -7
index cc74a41bdb0d..33f48a622fc6 100644
@@ -70,7 +70,7 @@ static irqreturn_t tps6521x_pb_irq(int irq, void *_pwr)
 	error = regmap_read(pwr->regmap, tps_data->reg_status, &reg);
 	if (error) {
 		dev_err(pwr->dev, "can't read register: %d\n", error);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	if (reg & tps_data->pb_mask) {
@@ -82,7 +82,6 @@ static irqreturn_t tps6521x_pb_irq(int irq, void *_pwr)
 
 	input_sync(pwr->idev);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -95,7 +94,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
 	int error;
 	int irq;
 
-	match = of_match_node(of_tps6521x_pb_match, pdev->dev.of_node);
+	match = of_match_node(of_tps6521x_pb_match, dev->of_node);
 	if (!match)
 		return -ENXIO;
 
@@ -118,10 +117,9 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
 
 	input_set_capability(idev, EV_KEY, KEY_POWER);
 
-	pwr->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+	pwr->regmap = dev_get_regmap(dev->parent, NULL);
 	pwr->dev = dev;
 	pwr->idev = idev;
-	platform_set_drvdata(pdev, pwr);
 	device_init_wakeup(dev, true);
 
 	irq = platform_get_irq(pdev, 0);
@@ -136,8 +134,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
 						IRQF_ONESHOT,
 					  pwr->data->name, pwr);
 	if (error) {
-		dev_err(dev, "failed to request IRQ #%d: %d\n",
-			irq, error);
+		dev_err(dev, "failed to request IRQ #%d: %d\n", irq, error);
 		return error;
 	}
 
Signature · 1 line
2.7.4
#50 lore raw

PATCH 29/33 Input: melfas_mip4 - Use devm_add_action_or_reset and other changes

In reply to Guenter Roeck

Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Replace 'goto l; ... l: return e;' with 'return e;'

---
 drivers/input/touchscreen/melfas_mip4.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/input/touchscreen/melfas_mip4.c +4 -6
index 703d7f983d0a..3cad6f72dbf8 100644
@@ -594,7 +594,7 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 	if (error) {
 		dev_err(&client->dev,
 			"Failed to read packet info: %d\n", error);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	size = ts->buf[0] & 0x7F;
@@ -604,7 +604,7 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 	/* Check size */
 	if (!size) {
 		dev_err(&client->dev, "Empty packet\n");
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	/* Read packet data */
@@ -614,7 +614,7 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 	if (error) {
 		dev_err(&client->dev,
 			"Failed to read packet data: %d\n", error);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	if (alert) {
@@ -629,7 +629,6 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 		input_sync(ts->input);
 	}
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -1531,9 +1530,8 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		return error;
 	}
 
-	error = devm_add_action(&client->dev, mip4_sysfs_remove, ts);
+	error = devm_add_action_or_reset(&client->dev, mip4_sysfs_remove, ts);
 	if (error) {
-		mip4_sysfs_remove(ts);
 		dev_err(&client->dev,
 			"Failed to install sysfs remoce action: %d\n", error);
 		return error;
Signature · 1 line
2.7.4
maintainer Applied
#5 lore raw

Re: [PATCH 04/33] Input: cros_ec_keyb - Drop unnecessary call to dev_set_drvdata and other changes

In reply to Guenter Roeck
Quoted 10 lines · Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to dev_set_drvdata().
Other relevant changes:
Use existing variable 'dev' instead of dereferencing it several times

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

Quoted 4 lines

- Drop dev_set_drvdata()
- Use local variable 'struct device *dev' consistently

Applied, thank you.

Quoted 28 lines
---
 drivers/input/keyboard/cros_ec_keyb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/keyboard/cros_ec_keyb.c +1 -2
index 25943e9bc8bf..87d071ae21da 100644
@@ -222,7 +222,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
 	struct device_node *np;
 	int err;
 
-	np = pdev->dev.of_node;
+	np = dev->of_node;
 	if (!np)
 		return -ENODEV;
 
@@ -248,7 +248,6 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
 	ckdev->ec = ec;
 	ckdev->notifier.notifier_call = cros_ec_keyb_work;
 	ckdev->dev = dev;
-	dev_set_drvdata(dev, ckdev);
 
 	idev->name = CROS_EC_DEV_NAME;
 	idev->phys = ec->phys_name;
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer Applied
#37 lore raw

Re: [PATCH 22/33] Input: at32psif - Drop unnecessary error messages and other changes

In reply to Guenter Roeck
Quoted 38 lines · Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'val = e; return val;' with 'return e;'

---
 drivers/input/serio/at32psif.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/input/serio/at32psif.c +1 -2
index 2e4ff5bac754..e420fd781d44 100644
@@ -159,13 +159,12 @@ static int psif_open(struct serio *io)
 
 	retval = clk_enable(psif->pclk);
 	if (retval)
-		goto out;
+		return retval;
 
 	psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN));
 	psif_writel(psif, IER, PSIF_BIT(RXRDY));
 
 	psif->open = true;
-out:
 	return retval;
 }
 

drivers/input/serio/at32psif.c static int __init psif_probe(struct platform_device *pdev) · line 214

Quoted 5 lines
drivers/input/serio/at32psif.c +0 -2
@@ -210,16 +209,12 @@ static int __init psif_probe(struct platform_device *pdev)
 	int ret;
 
 	psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
-	if (!psif) {
-		dev_dbg(&pdev->dev, "out of memory\n");

I guess nobody will see these messages unless actively debugging, so I'm OK with these gone.

Quoted 24 lines
drivers/input/serio/at32psif.c +2 -5
-		ret = -ENOMEM;
-		goto out;
-	}
+	if (!psif)
+		return -ENOMEM;
 	psif->pdev = pdev;
 
 	io = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (!io) {
-		dev_dbg(&pdev->dev, "out of memory\n");
 		ret = -ENOMEM;
 		goto out_free_psif;
 	}
@@ -297,7 +292,6 @@ static int __init psif_probe(struct platform_device *pdev)
 	kfree(io);
 out_free_psif:
 	kfree(psif);
-out:
 	return ret;
 }
 
Signature · 1 line
2.7.4

Applied, thanks.

Signature · 1 line
Dmitry
maintainer Applied
#39 lore raw

Re: [PATCH 23/33] Input: xilinx_ps2 - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck
Quoted 10 lines · Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Use local variable 'struct device *dev' consistently

Applied, thank you.

Quoted 33 lines
---
 drivers/input/serio/xilinx_ps2.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/input/serio/xilinx_ps2.c +3 -4
index 5223cbf94262..14c40892ed82 100644
@@ -243,18 +243,17 @@ static int xps2_of_probe(struct platform_device *ofdev)
 	unsigned int irq;
 	int error;
 
-	dev_info(dev, "Device Tree Probing \'%s\'\n",
-			ofdev->dev.of_node->name);
+	dev_info(dev, "Device Tree Probing \'%s\'\n", dev->of_node->name);
 
 	/* Get iospace for the device */
-	error = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
+	error = of_address_to_resource(dev->of_node, 0, &r_mem);
 	if (error) {
 		dev_err(dev, "invalid address\n");
 		return error;
 	}
 
 	/* Get IRQ for the device */
-	irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+	irq = irq_of_parse_and_map(dev->of_node, 0);
 	if (!irq) {
 		dev_err(dev, "no IRQ found\n");
 		return -ENODEV;
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer
#43 lore raw

Re: [PATCH 25/33] Input: atmel-wm97xx - Drop unnecessary error messages and other changes

In reply to Guenter Roeck
Quoted 10 lines · Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

OK since it was emitted as dev_dbg() anyway, applied.

Quoted 25 lines
---
 drivers/input/touchscreen/atmel-wm97xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/atmel-wm97xx.c +1 -3
index 7ec0421c0dd8..8cf0b2be2df4 100644
@@ -339,10 +339,8 @@ static int __init atmel_wm97xx_probe(struct platform_device *pdev)
 	int ret;
 
 	atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL);
-	if (!atmel_wm97xx) {
-		dev_dbg(&pdev->dev, "out of memory\n");
+	if (!atmel_wm97xx)
 		return -ENOMEM;
-	}
 
 	atmel_wm97xx->wm	= wm;
 	atmel_wm97xx->regs	= (void *)ATMEL_WM97XX_AC97C_IOMEM;
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer
#41 lore raw

Re: [PATCH 24/33] Input: ar1021_i2c - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck
Quoted 2 lines · Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata().

Kept just this part and applied.

Quoted 51 lines

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'goto l; ... l: return e;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/ar1021_i2c.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/touchscreen/ar1021_i2c.c +2 -4
index 71b5a634cf6d..b289eca2b797 100644
@@ -35,11 +35,11 @@ static irqreturn_t ar1021_i2c_irq(int irq, void *dev_id)
 	retval = i2c_master_recv(ar1021->client,
 				ar1021->data, sizeof(ar1021->data));
 	if (retval != sizeof(ar1021->data))
-		goto out;
+		return IRQ_HANDLED;
 
 	/* sync bit set ? */
 	if ((data[0] & 0x80) == 0)
-		goto out;
+		return IRQ_HANDLED;
 
 	button = data[0] & BIT(0);
 	x = ((data[2] & 0x1f) << 7) | (data[1] & 0x7f);
@@ -50,7 +50,6 @@ static irqreturn_t ar1021_i2c_irq(int irq, void *dev_id)
 	input_report_key(input, BTN_TOUCH, button);
 	input_sync(input);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -127,7 +126,6 @@ static int ar1021_i2c_probe(struct i2c_client *client,
 		return error;
 	}
 
-	i2c_set_clientdata(client, ar1021);
 	return 0;
 }
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer
#46 lore raw

Re: [PATCH 27/33] Input: eeti_ts - Drop unnecessary error messages and other changes

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'goto l; ... l: return e;' with 'return e;'

Kept just the last part and applied, thank you.

Quoted 34 lines
---
 drivers/input/touchscreen/eeti_ts.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/input/touchscreen/eeti_ts.c +2 -5
index 09be6ced7151..de3f4a1e8416 100644
@@ -171,10 +171,8 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 */
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		dev_err(&client->dev, "failed to allocate driver data\n");
-		goto err0;
-	}
+	if (!priv)
+		return err;
 
 	mutex_init(&priv->mutex);
 	input = input_allocate_device();
@@ -243,7 +241,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 err1:
 	input_free_device(input);
 	kfree(priv);
-err0:
 	return err;
 }
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer
#51 lore raw

Re: [PATCH 29/33] Input: melfas_mip4 - Use devm_add_action_or_reset and other changes

In reply to Guenter Roeck
Quoted 10 lines · Guenter Roeck

Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

I am planning on using devm_sysfs_create_group() here (to be [re]submitted to Greg).

Quoted 60 lines

- Replace 'goto l; ... l: return e;' with 'return e;'

---
 drivers/input/touchscreen/melfas_mip4.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/input/touchscreen/melfas_mip4.c +4 -6
index 703d7f983d0a..3cad6f72dbf8 100644
@@ -594,7 +594,7 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 	if (error) {
 		dev_err(&client->dev,
 			"Failed to read packet info: %d\n", error);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	size = ts->buf[0] & 0x7F;
@@ -604,7 +604,7 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 	/* Check size */
 	if (!size) {
 		dev_err(&client->dev, "Empty packet\n");
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	/* Read packet data */
@@ -614,7 +614,7 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 	if (error) {
 		dev_err(&client->dev,
 			"Failed to read packet data: %d\n", error);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	if (alert) {
@@ -629,7 +629,6 @@ static irqreturn_t mip4_interrupt(int irq, void *dev_id)
 		input_sync(ts->input);
 	}
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -1531,9 +1530,8 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		return error;
 	}
 
-	error = devm_add_action(&client->dev, mip4_sysfs_remove, ts);
+	error = devm_add_action_or_reset(&client->dev, mip4_sysfs_remove, ts);
 	if (error) {
-		mip4_sysfs_remove(ts);
 		dev_err(&client->dev,
 			"Failed to install sysfs remoce action: %d\n", error);
 		return error;
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer
#48 lore raw

Re: [PATCH 28/33] Input: egalax_ts - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck
Quoted 27 lines · Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Other relevant changes:
Simplify error return
Drop error messages after memory allocation failures

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unused variables
- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/egalax_ts.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/input/touchscreen/egalax_ts.c +0 -0
index 1afc08b08155..05ba1a6dc7fc 100644

drivers/input/touchscreen/egalax_ts.c static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) · line 88

Quoted 8 lines
drivers/input/touchscreen/egalax_ts.c +1 -2
@@ -82,10 +82,9 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
 	if (ret < 0)
 		return IRQ_HANDLED;
 
-	if (buf[0] != REPORT_MODE_MTTOUCH) {
+	if (buf[0] != REPORT_MODE_MTTOUCH)
 		/* ignore mouse events and vendor events */
 		return IRQ_HANDLED;
-	}

These are not unnecessary braces, as there are more than 1 line. I.e. comments are counted along statements, at least by myself. Also, if there is a single statement spanning several lines I also prefer to have braces around it.

Quoted 5 lines
drivers/input/touchscreen/egalax_ts.c +0 -0
 	state = buf[1];
 	x = (buf[3] << 8) | buf[2];
@@ -155,13 +154,8 @@ static int egalax_wake_up_device(struct i2c_client *client)
 static int egalax_firmware_version(struct i2c_client *client)

drivers/input/touchscreen/egalax_ts.c static int egalax_wake_up_device(struct i2c_client *client) · line 158

Quoted 10 lines
drivers/input/touchscreen/egalax_ts.c +1 -6
 {
 	static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
-	int ret;
-
-	ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);
-	if (ret < 0)
-		return ret;
 
-	return 0;
+	return i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);

This is not an equivalent transformation, as now callers need to check for negative return value instead of non-zero. i2c_master_send() returns number of bytes written on success.

Quoted 32 lines
drivers/input/touchscreen/egalax_ts.c +2 -9
 }
 
 static int egalax_ts_probe(struct i2c_client *client,
@@ -172,10 +166,8 @@ static int egalax_ts_probe(struct i2c_client *client,
 	int error;
 
 	ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL);
-	if (!ts) {
-		dev_err(&client->dev, "Failed to allocate memory\n");
+	if (!ts)
 		return -ENOMEM;
-	}
 
 	input_dev = devm_input_allocate_device(&client->dev);
 	if (!input_dev) {
@@ -225,12 +217,7 @@ static int egalax_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = input_register_device(ts->input_dev);
-	if (error)
-		return error;
-
-	i2c_set_clientdata(client, ts);
-	return 0;
+	return input_register_device(ts->input_dev);
 }
 
 static const struct i2c_device_id egalax_ts_id[] = {
Signature · 1 line
2.7.4

Thanks.

Signature · 1 line
Dmitry
maintainer
#20 lore raw

Re: [PATCH 13/33] Input: bfin_rotary - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck
Quoted 24 lines · Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times. Other relevant changes:
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Drop unnecessary braces around conditional return statements
- Use local variable 'struct device *dev' consistently

---
 drivers/input/misc/bfin_rotary.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/input/misc/bfin_rotary.c +0 -0
index a0fc18fdfc0c..9f5790c6e06b 100644

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 146

Quoted 7 lines
drivers/input/misc/bfin_rotary.c +1 -2
@@ -141,25 +141,23 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
 	/* Basic validation */
 	if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
-	    (!pdata->rotary_up_key && pdata->rotary_down_key)) {
+	    (!pdata->rotary_up_key && pdata->rotary_down_key))
 		return -EINVAL;
-	}

This is complex "if" statement, would prefer keep the braces.

Quoted 32 lines
drivers/input/misc/bfin_rotary.c +4 -5
 	if (pdata->pin_list) {
 		error = peripheral_request_list(pdata->pin_list,
-						dev_name(&pdev->dev));
+						dev_name(dev));
 		if (error) {
 			dev_err(dev, "requesting peripherals failed: %d\n",
 				error);
 			return error;
 		}
 
-		error = devm_add_action(dev, bfin_rotary_free_action,
-					pdata->pin_list);
+		error = devm_add_action_or_reset(dev, bfin_rotary_free_action,
+						 pdata->pin_list);
 		if (error) {
 			dev_err(dev, "setting cleanup action failed: %d\n",
 				error);
-			peripheral_free_list(pdata->pin_list);
 			return error;
 		}
 	}
@@ -189,7 +187,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
 	input->name = pdev->name;
 	input->phys = "bfin-rotary/input0";
-	input->dev.parent = &pdev->dev;
+	input->dev.parent = dev;
 
 	input_set_drvdata(input, rotary);
 

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 226

Quoted 7 lines
drivers/input/misc/bfin_rotary.c +2 -2
@@ -224,8 +222,8 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr,
-				 0, dev_name(dev), rotary);
+	error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr, 0,
+				 dev_name(dev), rotary);

Do not see point of this change.

Quoted 15 lines
drivers/input/misc/bfin_rotary.c +1 -1
 	if (error) {
 		dev_err(dev, "unable to claim irq %d; error %d\n",
 			rotary->irq, error);
@@ -239,7 +237,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, rotary);
-	device_init_wakeup(&pdev->dev, 1);
+	device_init_wakeup(dev, 1);
 
 	return 0;
 }
Signature · 1 line
2.7.4

Dropped the above 2 chunks and applied.

Signature · 1 line
Dmitry
maintainer Applied
#25 lore raw

Re: [PATCH 14/33] Input: gpio_decoder - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

Applied, thank you.

Quoted 19 lines
---
 drivers/input/misc/gpio_decoder.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/misc/gpio_decoder.c +0 -1
index ca7e0bacb2d8..1dca526e6f1a 100644
@@ -110,7 +110,6 @@ static int gpio_decoder_probe(struct platform_device *pdev)
 		dev_err(dev, "failed to register polled  device\n");
 		return err;
 	}
-	platform_set_drvdata(pdev, decoder);
 
 	return 0;
 }
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer Applied
#28 lore raw

Re: [PATCH 16/33] Input: mma8450 - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop i2c_set_clientdata()

Applied, thank you.

Quoted 20 lines
---
 drivers/input/misc/mma8450.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/misc/mma8450.c +0 -2
index 19c73574458e..b60cdea73826 100644
@@ -205,8 +205,6 @@ static int mma8450_probe(struct i2c_client *c,
 		return err;
 	}
 
-	i2c_set_clientdata(c, m);
-
 	return 0;
 }
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer Applied
#31 lore raw

Re: [PATCH 18/33] Input: soc_button_array - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck
Quoted 8 lines · Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Use local variable 'struct device *dev' consistently

Applied, thank you.

Quoted 29 lines
---
 drivers/input/misc/soc_button_array.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/misc/soc_button_array.c +3 -3
index 908b51089dee..fb3219a8d3c0 100644
@@ -167,12 +167,12 @@ static int soc_button_probe(struct platform_device *pdev)
 
 	button_info = (struct soc_button_info *)id->driver_data;
 
-	if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) {
-		dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n");
+	if (gpiod_count(dev, KBUILD_MODNAME) <= 0) {
+		dev_dbg(dev, "no GPIO attached, ignoring...\n");
 		return -ENODEV;
 	}
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer
#33 lore raw

Re: [PATCH 19/33] Input: tps65218-pwrbutton - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck
Quoted 33 lines · Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().
Other relevant changes:
Use existing variable 'dev' instead of dereferencing it several times

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'goto l; ... l: return e;' with 'return e;'
- Drop platform_set_drvdata()
- Use local variable 'struct device *dev' consistently

---
 drivers/input/misc/tps65218-pwrbutton.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/input/misc/tps65218-pwrbutton.c +1 -1
index cc74a41bdb0d..33f48a622fc6 100644
@@ -70,7 +70,7 @@ static irqreturn_t tps6521x_pb_irq(int irq, void *_pwr)
 	error = regmap_read(pwr->regmap, tps_data->reg_status, &reg);
 	if (error) {
 		dev_err(pwr->dev, "can't read register: %d\n", error);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	if (reg & tps_data->pb_mask) {

drivers/input/misc/tps65218-pwrbutton.c static irqreturn_t tps6521x_pb_irq(int irq, void *_pwr) · line 86

Quoted 6 lines
drivers/input/misc/tps65218-pwrbutton.c +0 -1
@@ -82,7 +82,6 @@ static irqreturn_t tps6521x_pb_irq(int irq, void *_pwr)
 
 	input_sync(pwr->idev);
 
-out:
 	return IRQ_HANDLED;
 }

Applied except for the above chunks, thank you.

Quoted 35 lines
drivers/input/misc/tps65218-pwrbutton.c +3 -5
@@ -95,7 +94,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
 	int error;
 	int irq;
 
-	match = of_match_node(of_tps6521x_pb_match, pdev->dev.of_node);
+	match = of_match_node(of_tps6521x_pb_match, dev->of_node);
 	if (!match)
 		return -ENXIO;
 
@@ -118,10 +117,9 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
 
 	input_set_capability(idev, EV_KEY, KEY_POWER);
 
-	pwr->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+	pwr->regmap = dev_get_regmap(dev->parent, NULL);
 	pwr->dev = dev;
 	pwr->idev = idev;
-	platform_set_drvdata(pdev, pwr);
 	device_init_wakeup(dev, true);
 
 	irq = platform_get_irq(pdev, 0);
@@ -136,8 +134,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
 						IRQF_ONESHOT,
 					  pwr->data->name, pwr);
 	if (error) {
-		dev_err(dev, "failed to request IRQ #%d: %d\n",
-			irq, error);
+		dev_err(dev, "failed to request IRQ #%d: %d\n", irq, error);
 		return error;
 	}
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer Applied
#16 lore raw

Re: [PATCH 11/33] Input: ab8500-ponkey - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

Applied, thank you.

Quoted 19 lines
---
 drivers/input/misc/ab8500-ponkey.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/misc/ab8500-ponkey.c +0 -1
index 4f5ef5bb535b..a33ed5710b15 100644
@@ -109,7 +109,6 @@ static int ab8500_ponkey_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	platform_set_drvdata(pdev, ponkey);
 	return 0;
 }
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
maintainer Applied
#14 lore raw

Re: [PATCH 10/33] Input: twl4030_keypad - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop platform_set_drvdata()

Applied, thank you.

Quoted 19 lines
---
 drivers/input/keyboard/twl4030_keypad.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/keyboard/twl4030_keypad.c +0 -1
index 323a0fb575a4..29396ca69416 100644
@@ -441,7 +441,6 @@ static int twl4030_kp_probe(struct platform_device *pdev)
 		return -EIO;
 	}
 
-	platform_set_drvdata(pdev, kp);
 	return 0;
 }
 
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
#49 lore raw

Re: [PATCH 28/33] Input: egalax_ts - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Dmitry Torokhov
Quoted 31 lines · Dmitry Torokhov
Quoted 30 lines · Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Other relevant changes:
Simplify error return
Drop error messages after memory allocation failures

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unused variables
- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure
- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/egalax_ts.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/input/touchscreen/egalax_ts.c +0 -0
index 1afc08b08155..05ba1a6dc7fc 100644
@@ -82,10 +82,9 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
 	if (ret < 0)
 		return IRQ_HANDLED;
 
Quoted 11 lines

drivers/input/touchscreen/egalax_ts.c static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) · line 88

Quoted 5 lines
drivers/input/touchscreen/egalax_ts.c +1 -2
-	if (buf[0] != REPORT_MODE_MTTOUCH) {
+	if (buf[0] != REPORT_MODE_MTTOUCH)
 		/* ignore mouse events and vendor events */
 		return IRQ_HANDLED;
-	}

These are not unnecessary braces, as there are more than 1 line. I.e. comments are counted along statements, at least by myself. Also, if there is a single statement spanning several lines I also prefer to have braces around it.

Makes sense, and agreed. I'll have to figure out how to tell coccinelle about situations like this.

Quoted 13 lines
Quoted 13 lines
drivers/input/touchscreen/egalax_ts.c +0 -5
 	state = buf[1];
 	x = (buf[3] << 8) | buf[2];
@@ -155,13 +154,8 @@ static int egalax_wake_up_device(struct i2c_client *client)
 static int egalax_firmware_version(struct i2c_client *client)
 {
 	static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
-	int ret;
-
-	ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);
-	if (ret < 0)
-		return ret;
 
Quoted 7 lines

drivers/input/touchscreen/egalax_ts.c static int egalax_wake_up_device(struct i2c_client *client) · line 158

Quoted 2 lines
drivers/input/touchscreen/egalax_ts.c +1 -1
-	return 0;
+	return i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);

This is not an equivalent transformation, as now callers need to check for negative return value instead of non-zero. i2c_master_send() returns number of bytes written on success.

Oops, yes. Excellent point. I am way too agressive here. Thanks for pointing this out.

Thanks,
Guenter

#21 lore raw

Re: [PATCH 13/33] Input: bfin_rotary - Use 'dev' instead of dereferencing it and other changes

In reply to Dmitry Torokhov
Quoted 26 lines · Dmitry Torokhov
Quoted 25 lines · Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times. Other relevant changes:
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Drop unnecessary braces around conditional return statements
- Use local variable 'struct device *dev' consistently

---
 drivers/input/misc/bfin_rotary.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/input/misc/bfin_rotary.c +0 -0
index a0fc18fdfc0c..9f5790c6e06b 100644
@@ -141,25 +141,23 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
Quoted 9 lines

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 146

Quoted 6 lines
drivers/input/misc/bfin_rotary.c +1 -2
 	/* Basic validation */
 	if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
-	    (!pdata->rotary_up_key && pdata->rotary_down_key)) {
+	    (!pdata->rotary_up_key && pdata->rotary_down_key))
 		return -EINVAL;
-	}

This is complex "if" statement, would prefer keep the braces.

Agreed.

Quoted 35 lines
Quoted 35 lines
drivers/input/misc/bfin_rotary.c +4 -5
 	if (pdata->pin_list) {
 		error = peripheral_request_list(pdata->pin_list,
-						dev_name(&pdev->dev));
+						dev_name(dev));
 		if (error) {
 			dev_err(dev, "requesting peripherals failed: %d\n",
 				error);
 			return error;
 		}
 
-		error = devm_add_action(dev, bfin_rotary_free_action,
-					pdata->pin_list);
+		error = devm_add_action_or_reset(dev, bfin_rotary_free_action,
+						 pdata->pin_list);
 		if (error) {
 			dev_err(dev, "setting cleanup action failed: %d\n",
 				error);
-			peripheral_free_list(pdata->pin_list);
 			return error;
 		}
 	}
@@ -189,7 +187,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
 	input->name = pdev->name;
 	input->phys = "bfin-rotary/input0";
-	input->dev.parent = &pdev->dev;
+	input->dev.parent = dev;
 
 	input_set_drvdata(input, rotary);
 
@@ -224,8 +222,8 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
Quoted 7 lines

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 226

Quoted 4 lines
drivers/input/misc/bfin_rotary.c +2 -2
-	error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr,
-				 0, dev_name(dev), rotary);
+	error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr, 0,
+				 dev_name(dev), rotary);

Do not see point of this change.

Me fighting with coccinelle ;-). Diffficult to tell it to avoid non-changes like this. I need to figure out to tell it to ...

Quoted 9 lines

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 240

Quoted 9 lines
drivers/input/misc/bfin_rotary.c +1 -1
 	if (error) {
 		dev_err(dev, "unable to claim irq %d; error %d\n",
 			rotary->irq, error);
@@ -239,7 +237,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, rotary);
-	device_init_wakeup(&pdev->dev, 1);
+	device_init_wakeup(dev, 1);

... only reformat a line when it is actually doing something on that line, not on the entire function.

Thanks,
Guenter

#53 lore raw

PATCH 31/33 Input: rohm_bu21023 - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck

Use local variable 'dev' instead of dereferencing it several times. Other relevant changes:
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Use local variable 'struct device *dev' consistently

---
 drivers/input/touchscreen/rohm_bu21023.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/input/touchscreen/rohm_bu21023.c +5 -7
index 611156a2ef80..cce3ef94c1ab 100644
@@ -1166,9 +1166,9 @@ static int rohm_bu21023_i2c_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = devm_request_threaded_irq(dev, client->irq,
-					  NULL, rohm_ts_soft_irq,
-					  IRQF_ONESHOT, client->name, ts);
+	error = devm_request_threaded_irq(dev, client->irq, NULL,
+					  rohm_ts_soft_irq, IRQF_ONESHOT,
+					  client->name, ts);
 	if (error) {
 		dev_err(dev, "failed to request IRQ: %d\n", error);
 		return error;
@@ -1186,11 +1186,9 @@ static int rohm_bu21023_i2c_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev);
+	error = devm_add_action_or_reset(dev, rohm_ts_remove_sysfs_group, dev);
 	if (error) {
-		rohm_ts_remove_sysfs_group(dev);
-		dev_err(&client->dev,
-			"Failed to add sysfs cleanup action: %d\n",
+		dev_err(dev, "Failed to add sysfs cleanup action: %d\n",
 			error);
 		return error;
 	}
Signature · 1 line
2.7.4
#54 lore raw

PATCH 32/33 Input: sis_i2c - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/sis_i2c.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/touchscreen/sis_i2c.c +0 -1
index 8d93f8c9a403..67c2563031d6 100644
@@ -316,7 +316,6 @@ static int sis_ts_probe(struct i2c_client *client,
 		return -ENOMEM;
 
 	ts->client = client;
-	i2c_set_clientdata(client, ts);
 
 	ts->attn_gpio = devm_gpiod_get_optional(&client->dev,
 						"attn", GPIOD_IN);
Signature · 1 line
2.7.4
#56 lore raw

PATCH 33/33 Input: sx8654 - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Other relevant changes:
Simplify error return

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop i2c_set_clientdata()

---
 drivers/input/touchscreen/sx8654.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/input/touchscreen/sx8654.c +4 -10
index 642f4a53de50..c6ce3352da21 100644
@@ -89,7 +89,7 @@ static irqreturn_t sx8654_irq(int irq, void *handle)
 	dev_dbg(&sx8654->client->dev, "irqsrc = 0x%x", irqsrc);
 
 	if (irqsrc < 0)
-		goto out;
+		return IRQ_HANDLED;
 
 	if (irqsrc & IRQ_PENRELEASE) {
 		dev_dbg(&sx8654->client->dev, "pen release interrupt");
@@ -103,11 +103,11 @@ static irqreturn_t sx8654_irq(int irq, void *handle)
 
 		retval = i2c_master_recv(sx8654->client, data, sizeof(data));
 		if (retval != sizeof(data))
-			goto out;
+			return IRQ_HANDLED;
 
 		/* invalid data */
 		if (unlikely(data[0] & 0x80 || data[2] & 0x80))
-			goto out;
+			return IRQ_HANDLED;
 
 		x = ((data[0] & 0xf) << 8) | (data[1]);
 		y = ((data[2] & 0xf) << 8) | (data[3]);
@@ -120,7 +120,6 @@ static irqreturn_t sx8654_irq(int irq, void *handle)
 		dev_dbg(&sx8654->client->dev, "point(%4d,%4d)\n", x, y);
 	}
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -249,12 +248,7 @@ static int sx8654_probe(struct i2c_client *client,
 	/* Disable the IRQ, we'll enable it in sx8654_open() */
 	disable_irq(client->irq);
 
-	error = input_register_device(sx8654->input);
-	if (error)
-		return error;
-
-	i2c_set_clientdata(client, sx8654);
-	return 0;
+	return input_register_device(sx8654->input);
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.7.4
#52 lore raw

PATCH 30/33 Input: raydium_i2c_ts - Simplify error return and other changes

In reply to Guenter Roeck

Simplify error return if the code returns anyway. Other relevant changes:
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'if (e) return e; return 0;' with 'return e;'

---
 drivers/input/touchscreen/raydium_i2c_ts.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/input/touchscreen/raydium_i2c_ts.c +6 -12
index 2658afa016c9..84507a882fa1 100644
@@ -741,11 +741,7 @@ static int raydium_i2c_do_update_firmware(struct raydium_data *ts,
 
 	fw_checksum = raydium_calc_chksum(fw->data, fw->size);
 
-	error = raydium_i2c_write_checksum(client, fw->size, fw_checksum);
-	if (error)
-		return error;
-
-	return 0;
+	return raydium_i2c_write_checksum(client, fw->size, fw_checksum);
 }
 
 static int raydium_i2c_fw_update(struct raydium_data *ts)
@@ -831,12 +827,12 @@ static irqreturn_t raydium_i2c_irq(int irq, void *_dev)
 	u16 calc_crc;
 
 	if (ts->boot_mode != RAYDIUM_TS_MAIN)
-		goto out;
+		return IRQ_HANDLED;
 
 	error = raydium_i2c_read_message(ts->client, ts->data_bank_addr,
 					 ts->report_data, ts->pkg_size);
 	if (error)
-		goto out;
+		return IRQ_HANDLED;
 
 	fw_crc = get_unaligned_le16(&ts->report_data[ts->report_size]);
 	calc_crc = raydium_calc_chksum(ts->report_data, ts->report_size);
@@ -844,12 +840,11 @@ static irqreturn_t raydium_i2c_irq(int irq, void *_dev)
 		dev_warn(&ts->client->dev,
 			 "%s: invalid packet crc %#04x vs %#04x\n",
 			 __func__, calc_crc, fw_crc);
-		goto out;
+		return IRQ_HANDLED;
 	}
 
 	raydium_mt_event(ts);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -1130,10 +1125,9 @@ static int raydium_i2c_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = devm_add_action(&client->dev,
-				raydium_i2c_remove_sysfs_group, ts);
+	error = devm_add_action_or_reset(&client->dev,
+					 raydium_i2c_remove_sysfs_group, ts);
 	if (error) {
-		raydium_i2c_remove_sysfs_group(ts);
 		dev_err(&client->dev,
 			"Failed to add sysfs cleanup action: %d\n", error);
 		return error;
Signature · 1 line
2.7.4
maintainer Applied
#55 lore raw

Re: [PATCH 32/33] Input: sis_i2c - Drop unnecessary call to i2c_set_clientdata and other changes

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata().

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop i2c_set_clientdata()

Applied, thank you.

Quoted 19 lines
---
 drivers/input/touchscreen/sis_i2c.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/touchscreen/sis_i2c.c +0 -1
index 8d93f8c9a403..67c2563031d6 100644
@@ -316,7 +316,6 @@ static int sis_ts_probe(struct i2c_client *client,
 		return -ENOMEM;
 
 	ts->client = client;
-	i2c_set_clientdata(client, ts);
 
 	ts->attn_gpio = devm_gpiod_get_optional(&client->dev,
 						"attn", GPIOD_IN);
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
Acked-by on v1 8/33
#10 lore raw

Re: [PATCH 08/33] Input: spear-keyboard - Drop unnecessary error messages and other changes

In reply to Guenter Roeck
Quoted 8 lines · Guenter Roeck

Error messages after memory allocation failures are unnecessary and can be dropped.

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

Quoted 7 lines

- Drop unnecessary braces around conditional return statements
- Drop error message after devm_kzalloc() failure

---
 drivers/input/keyboard/spear-keyboard.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
#22 lore raw

Re: [PATCH 13/33] Input: bfin_rotary - Use 'dev' instead of dereferencing it and other changes

In reply to Guenter Roeck
Quoted 2 lines · Guenter Roeck
Quoted 1 line · Dmitry Torokhov

On Wed, Jan 18, 2017 at 09:46:34AM -0800, Guenter Roeck wrote:

[]

Quoted 1 line
Quoted 1 line

drivers/input/misc/bfin_rotary.c

Quoted 1 line
drivers/input/misc/bfin_rotary.c +0 -0

[]

Quoted 6 lines
Quoted 6 lines

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 144

Quoted 6 lines
drivers/input/misc/bfin_rotary.c +1 -1
@@ -141,25 +141,23 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
 	/* Basic validation */
 	if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
-	    (!pdata->rotary_up_key && pdata->rotary_down_key)) {
+	    (!pdata->rotary_up_key && pdata->rotary_down_key))

maybe just use ^

	if (!pdata->rotary_up_key ^ !pdata->rotary_down_key)
#59 lore raw
In reply to Joe Perches
Quoted 8 lines · Joe Perches
Quoted 3 lines · Guenter Roeck

The conversion was done automatically with coccinelle using several semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches.

It'd be better to include the script in this 0/n patch so that if github entry changes, the 0/n patch is useful.

For this set it would have been possible, though even the rules used here add up to more than 1,000 lines. The underlying larger set (the one I am using to generate devm transformations) currently has ~5,000 lines of coccinelle rules. Are you sure you want to see that in an e-mail ? It might make more sense if I add the reference SHA from the repository.

Thanks,
Guenter

#60 lore raw
Quoted 11 lines · Guenter Roeck
Quoted 8 lines · Joe Perches
Quoted 3 lines · Guenter Roeck

The conversion was done automatically with coccinelle using several semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches.

It'd be better to include the script in this 0/n patch so that if github entry changes, the 0/n patch is useful.

For this set it would have been possible, though even the rules used here add up to more than 1,000 lines.

How many errors do you think are in the script?
1000+ lines, likely there 10+ errors/defects.

#61 lore raw
Quoted 7 lines · Joe Perches
Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Joe Perches
Quoted 3 lines · Guenter Roeck

The conversion was done automatically with coccinelle using several semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

It'd be better to include the script in this 0/n patch so that if github entry changes, the 0/n patch is useful.

For this set it would have been possible, though even the rules used here add up to more than 1,000 lines.

How many errors do you think are in the script?
1000+ lines, likely there 10+ errors/defects.

Most of it is to limit the scope to ensure that there are none, so in this case the argument is a bit self-defeating.

Guenter

#23 lore raw

Re: [PATCH 13/33] Input: bfin_rotary - Use 'dev' instead of dereferencing it and other changes

In reply to Joe Perches
Quoted 8 lines · Joe Perches
Quoted 2 lines · Guenter Roeck
Quoted 1 line · Dmitry Torokhov

On Wed, Jan 18, 2017 at 09:46:34AM -0800, Guenter Roeck wrote:

[]

Quoted 1 line
Quoted 1 line

drivers/input/misc/bfin_rotary.c

Quoted 1 line
drivers/input/misc/bfin_rotary.c +0 -0

[]

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/input/misc/bfin_rotary.c +0 -0
@@ -141,25 +141,23 @@ static int bfin_rotary_probe(struct platform_device *pdev)
 
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

drivers/input/misc/bfin_rotary.c static int bfin_rotary_probe(struct platform_device *pdev) · line 144

Quoted 4 lines
drivers/input/misc/bfin_rotary.c +1 -1
 	/* Basic validation */
 	if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
-	    (!pdata->rotary_up_key && pdata->rotary_down_key)) {
+	    (!pdata->rotary_up_key && pdata->rotary_down_key))

maybe just use ^

	if (!pdata->rotary_up_key ^ !pdata->rotary_down_key)

Interesting use case for a coccinelle rule.

To address the coccinelle related problem, I modified the rule to only apply if the expression is in one line, and if the return statement is in the next line. That works pretty well.

Guenter

Acked-by on v1 12/33
#18 lore raw

Re: [PATCH 12/33] Input: axp20x-pek - Use devm_add_action_or_reset and other changes

In reply to Guenter Roeck
Quoted 8 lines · Guenter Roeck

Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

Quoted 4 lines

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

Acked-by on v1 9/33
#12 lore raw

Re: [PATCH 09/33] Input: sun4i-lradc-keys - Drop unnecessary call to platform_set_drvdata and other changes

In reply to Guenter Roeck
Quoted 10 lines · Guenter Roeck

There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata(). Other relevant changes:
Simplify error return

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

Quoted 4 lines

- Replace 'if (e) return e; return 0;' with 'return e;'
- Drop platform_set_drvdata()

#57 lore raw

RE: [PATCH 30/33] Input: raydium_i2c_ts - Simplify error return and other changes

In reply to Guenter Roeck

Hi sirs:
We're found raydium I2C driver not been kernel version v4.4, just found in v3.18. Should I commit again to V4.4??

Best Regards
----------------------------------------------------------------------
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-----Original Message-----
From: Guenter Roeck [mailto:[email protected]]
Sent: Thursday, January 19, 2017 4:37 AM
To: Dmitry Torokhov
Cc: [email protected]; [email protected]; Guenter Roeck; Colin Ian King; Jeffrey Lin (林義章); Rob Herring
Subject: [PATCH 30/33] Input: raydium_i2c_ts - Simplify error return and other changes

Simplify error return if the code returns anyway. Other relevant changes:
Replace devm_add_action() with devm_add_action_or_reset()

This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches

- Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'if (e) return e; return 0;' with 'return e;'

---
 drivers/input/touchscreen/raydium_i2c_ts.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/input/touchscreen/raydium_i2c_ts.c +1 -5
index 2658afa016c9..84507a882fa1 100644
@@ -741,11 +741,7 @@ static int raydium_i2c_do_update_firmware(struct raydium_data *ts,
 
        fw_checksum = raydium_calc_chksum(fw->data, fw->size);
 
-       error = raydium_i2c_write_checksum(client, fw->size, fw_checksum);
-       if (error)
-               return error;
-
-       return 0;
+       return raydium_i2c_write_checksum(client, fw->size, fw_checksum);
 }
 
 static int raydium_i2c_fw_update(struct raydium_data *ts) @@ -831,12 +827,12 @@ static irqreturn_t raydium_i2c_irq(int irq, void *_dev)
        u16 calc_crc;

        if (ts->boot_mode != RAYDIUM_TS_MAIN)

- goto out;
+ return IRQ_HANDLED;

        error = raydium_i2c_read_message(ts->client, ts->data_bank_addr,
                                         ts->report_data, ts->pkg_size);
        if (error)

- goto out;
+ return IRQ_HANDLED;

        fw_crc = get_unaligned_le16(&ts->report_data[ts->report_size]);
        calc_crc = raydium_calc_chksum(ts->report_data, ts->report_size); @@ -844,12 +840,11 @@ static irqreturn_t raydium_i2c_irq(int irq, void *_dev)
                dev_warn(&ts->client->dev,
                         "%s: invalid packet crc %#04x vs %#04x\n",
                         __func__, calc_crc, fw_crc);
-               goto out;
+               return IRQ_HANDLED;
        }

        raydium_mt_event(ts);

-out:

        return IRQ_HANDLED;

}

@@ -1130,10 +1125,9 @@ static int raydium_i2c_probe(struct i2c_client *client,

                return error;
        }

- error = devm_add_action(&client->dev,
- raydium_i2c_remove_sysfs_group, ts);
+ error = devm_add_action_or_reset(&client->dev,

+                                        raydium_i2c_remove_sysfs_group, ts);
        if (error) {
-               raydium_i2c_remove_sysfs_group(ts);
                dev_err(&client->dev,
                        "Failed to add sysfs cleanup action: %d\n", error);
                return error;

--
2.7.4

CONFIDENTIALITY AND PROPRIETARY REMINDER:
This message and any attachment may contain confidential information. All rights including intellectual property rights arising out of this correspondence shall belong to Raydium Semiconductor Corp. Any unauthorized disclosure, forwarding, using, modifying, spreading, publishing or copying this email and the content is illegal and strictly prohibited. If you are not the intended recipient, please notify the sender by replying to this message and delete all copies of it from your system. Thank you for cooperation.