linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 01/27] Input: Simplify with dev_err_probe()
@ 2020-08-27 18:58 Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 01/27] Input: gpio_keys_polled - " Krzysztof Kozlowski
                   ` (27 more replies)
  0 siblings, 28 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Hi,

Changes since v2:
1. Add review tags,
2. Fixes after review (see individual patches).
3. Two new patches - 26 and 27.


Best regards,
Krzysztof



Krzysztof Kozlowski (27):
  Input: gpio_keys_polled - Simplify with dev_err_probe()
  Input: gpio-vibra - Simplify with dev_err_probe()
  Input: pwm-beeper - Simplify with dev_err_probe()
  Input: pwm-vibra - Simplify with dev_err_probe()
  Input: rotary_encoder - Simplify with dev_err_probe()
  Input: elan_i2c - Simplify with dev_err_probe()
  Input: bu21013_ts - Simplify with dev_err_probe()
  Input: bu21029_ts - Simplify with dev_err_probe()
  Input: chipone_icn8318 - Simplify with dev_err_probe()
  Input: cy8ctma140 - Simplify with dev_err_probe()
  Input: edf-ft5x06 - Simplify with dev_err_probe()
  Input: ektf2127 - Simplify with dev_err_probe()
  Input: elants_i2c - Simplify with dev_err_probe()
  Input: goodix - Simplify with dev_err_probe()
  Input: melfas_mip4 - Simplify with dev_err_probe()
  Input: pixcir_i2c_ts - Simplify with dev_err_probe()
  Input: raydium_i2c_ts - Simplify with dev_err_probe()
  Input: resistive-adc-touch - Simplify with dev_err_probe()
  Input: silead - Simplify with dev_err_probe()
  Input: sis_i2c - Simplify with dev_err_probe()
  Input: surface3_spi - Simplify with dev_err_probe()
  Input: sx8643 - Simplify with dev_err_probe()
  Input: bcm-keypad - Simplify with dev_err_probe()
  gpio: Add devm_fwnode_gpiod_get_optional() helpers
  Input: gpio_keys - Simplify with dev_err_probe()
  Input: bu21013_ts - Use local 'client->dev' variable in probe()
  Input: bu21029_ts - Use local 'client->dev' variable in probe()

 drivers/gpio/gpiolib-devres.c                 | 71 ++++++++++++++++++
 drivers/input/keyboard/bcm-keypad.c           | 14 ++--
 drivers/input/keyboard/gpio_keys.c            | 25 +++----
 drivers/input/keyboard/gpio_keys_polled.c     |  8 +--
 drivers/input/misc/gpio-vibra.c               | 20 ++----
 drivers/input/misc/pwm-beeper.c               | 19 ++---
 drivers/input/misc/pwm-vibra.c                | 20 ++----
 drivers/input/misc/rotary_encoder.c           |  8 +--
 drivers/input/mouse/elan_i2c_core.c           |  9 +--
 drivers/input/touchscreen/bu21013_ts.c        | 72 ++++++++-----------
 drivers/input/touchscreen/bu21029_ts.c        | 53 ++++++--------
 drivers/input/touchscreen/chipone_icn8318.c   |  8 +--
 drivers/input/touchscreen/cy8ctma140.c        |  8 +--
 drivers/input/touchscreen/edt-ft5x06.c        | 10 +--
 drivers/input/touchscreen/ektf2127.c          |  8 +--
 drivers/input/touchscreen/elants_i2c.c        | 22 ++----
 drivers/input/touchscreen/goodix.c            | 40 +++--------
 drivers/input/touchscreen/melfas_mip4.c       |  9 +--
 drivers/input/touchscreen/pixcir_i2c_ts.c     | 38 ++++------
 drivers/input/touchscreen/raydium_i2c_ts.c    | 30 +++-----
 .../input/touchscreen/resistive-adc-touch.c   |  8 +--
 drivers/input/touchscreen/silead.c            |  8 +--
 drivers/input/touchscreen/sis_i2c.c           | 20 ++----
 drivers/input/touchscreen/surface3_spi.c      | 13 +---
 drivers/input/touchscreen/sx8654.c            | 10 +--
 include/linux/gpio/consumer.h                 | 30 ++++++++
 26 files changed, 253 insertions(+), 328 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 01/27] Input: gpio_keys_polled - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 02/27] Input: gpio-vibra " Krzysztof Kozlowski
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/keyboard/gpio_keys_polled.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index c3937d2fc744..ba00ecfbd343 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -299,13 +299,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 							     NULL, GPIOD_IN,
 							     button->desc);
 			if (IS_ERR(bdata->gpiod)) {
-				error = PTR_ERR(bdata->gpiod);
-				if (error != -EPROBE_DEFER)
-					dev_err(dev,
-						"failed to get gpio: %d\n",
-						error);
 				fwnode_handle_put(child);
-				return error;
+				return dev_err_probe(dev, PTR_ERR(bdata->gpiod),
+						     "failed to get gpio\n");
 			}
 		} else if (gpio_is_valid(button->gpio)) {
 			/*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 02/27] Input: gpio-vibra - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 01/27] Input: gpio_keys_polled - " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 19:36   ` Andy Shevchenko
  2020-08-27 18:58 ` [PATCH v3 03/27] Input: pwm-beeper " Krzysztof Kozlowski
                   ` (25 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>

---

Changes since v1:
1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy.
---
 drivers/input/misc/gpio-vibra.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/input/misc/gpio-vibra.c b/drivers/input/misc/gpio-vibra.c
index f79f75595dd7..13c69f173620 100644
--- a/drivers/input/misc/gpio-vibra.c
+++ b/drivers/input/misc/gpio-vibra.c
@@ -113,22 +113,14 @@ static int gpio_vibrator_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
-	err = PTR_ERR_OR_ZERO(vibrator->vcc);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request regulator: %d\n",
-				err);
-		return err;
-	}
+	if (IS_ERR(vibrator->vcc))
+		return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc),
+				     "Failed to request regulator\n");
 
 	vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
-	err = PTR_ERR_OR_ZERO(vibrator->gpio);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request main gpio: %d\n",
-				err);
-		return err;
-	}
+	if (IS_ERR(vibrator->gpio))
+		return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->gpio),
+				     "Failed to request main gpio\n");
 
 	INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 03/27] Input: pwm-beeper - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 01/27] Input: gpio_keys_polled - " Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 02/27] Input: gpio-vibra " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 04/27] Input: pwm-vibra " Krzysztof Kozlowski
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/misc/pwm-beeper.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index d6b12477748a..8c0085e8c552 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -132,13 +132,8 @@ static int pwm_beeper_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	beeper->pwm = devm_pwm_get(dev, NULL);
-	if (IS_ERR(beeper->pwm)) {
-		error = PTR_ERR(beeper->pwm);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to request PWM device: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(beeper->pwm))
+		return dev_err_probe(dev, PTR_ERR(beeper->pwm), "Failed to request PWM device\n");
 
 	/* Sync up PWM state and ensure it is off. */
 	pwm_init_state(beeper->pwm, &state);
@@ -151,13 +146,9 @@ static int pwm_beeper_probe(struct platform_device *pdev)
 	}
 
 	beeper->amplifier = devm_regulator_get(dev, "amp");
-	if (IS_ERR(beeper->amplifier)) {
-		error = PTR_ERR(beeper->amplifier);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get 'amp' regulator: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(beeper->amplifier))
+		return dev_err_probe(dev, PTR_ERR(beeper->amplifier),
+				     "Failed to get 'amp' regulator\n");
 
 	INIT_WORK(&beeper->work, pwm_beeper_work);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 04/27] Input: pwm-vibra - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 03/27] Input: pwm-beeper " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 19:39   ` Andy Shevchenko
  2020-08-27 18:58 ` [PATCH v3 05/27] Input: rotary_encoder " Krzysztof Kozlowski
                   ` (23 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>

---

Changes since v1:
1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy.
---
 drivers/input/misc/pwm-vibra.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c
index 81e777a04b88..45c4f6a02177 100644
--- a/drivers/input/misc/pwm-vibra.c
+++ b/drivers/input/misc/pwm-vibra.c
@@ -134,22 +134,14 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
-	err = PTR_ERR_OR_ZERO(vibrator->vcc);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request regulator: %d",
-				err);
-		return err;
-	}
+	if (IS_ERR(vibrator->vcc))
+		return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc),
+				     "Failed to request regulator\n");
 
 	vibrator->pwm = devm_pwm_get(&pdev->dev, "enable");
-	err = PTR_ERR_OR_ZERO(vibrator->pwm);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request main pwm: %d",
-				err);
-		return err;
-	}
+	if (IS_ERR(vibrator->pwm))
+		return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->pwm),
+				     "Failed to request main pwm\n");
 
 	INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 05/27] Input: rotary_encoder - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 04/27] Input: pwm-vibra " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 06/27] Input: elan_i2c " Krzysztof Kozlowski
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/misc/rotary_encoder.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 6d613f2a017c..ea56c9f4975a 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -236,12 +236,8 @@ static int rotary_encoder_probe(struct platform_device *pdev)
 		device_property_read_bool(dev, "rotary-encoder,relative-axis");
 
 	encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN);
-	if (IS_ERR(encoder->gpios)) {
-		err = PTR_ERR(encoder->gpios);
-		if (err != -EPROBE_DEFER)
-			dev_err(dev, "unable to get gpios: %d\n", err);
-		return err;
-	}
+	if (IS_ERR(encoder->gpios))
+		return dev_err_probe(dev, PTR_ERR(encoder->gpios), "unable to get gpios\n");
 	if (encoder->gpios->ndescs < 2) {
 		dev_err(dev, "not enough gpios found\n");
 		return -EINVAL;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 06/27] Input: elan_i2c - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 05/27] Input: rotary_encoder " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 07/27] Input: bu21013_ts " Krzysztof Kozlowski
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/mouse/elan_i2c_core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index c599e21a8478..d703b0d5a3bd 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1229,13 +1229,8 @@ static int elan_probe(struct i2c_client *client,
 	mutex_init(&data->sysfs_mutex);
 
 	data->vcc = devm_regulator_get(dev, "vcc");
-	if (IS_ERR(data->vcc)) {
-		error = PTR_ERR(data->vcc);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get 'vcc' regulator: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(data->vcc))
+		return dev_err_probe(dev, PTR_ERR(data->vcc), "Failed to get 'vcc' regulator\n");
 
 	error = regulator_enable(data->vcc);
 	if (error) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 07/27] Input: bu21013_ts - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 06/27] Input: elan_i2c " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 19:39   ` Andy Shevchenko
  2020-08-28 14:29   ` Linus Walleij
  2020-08-27 18:58 ` [PATCH v3 08/27] Input: bu21029_ts " Krzysztof Kozlowski
                   ` (20 subsequent siblings)
  27 siblings, 2 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>

---

Changes since v1:
1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy.
---
 drivers/input/touchscreen/bu21013_ts.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 2f1f0d7607f8..86bd38243d6c 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -496,12 +496,10 @@ static int bu21013_probe(struct i2c_client *client,
 
 	/* Named "CS" on the chip, DT binding is "reset" */
 	ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
-	error = PTR_ERR_OR_ZERO(ts->cs_gpiod);
-	if (error) {
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev, "failed to get CS GPIO\n");
-		return error;
-	}
+	if (IS_ERR(ts->cs_gpiod))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->cs_gpiod),
+				     "failed to get CS GPIO\n");
+
 	gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
 
 	error = devm_add_action_or_reset(&client->dev,
@@ -516,11 +514,8 @@ static int bu21013_probe(struct i2c_client *client,
 	ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
 						"touch", GPIOD_IN);
 	error = PTR_ERR_OR_ZERO(ts->int_gpiod);
-	if (error) {
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev, "failed to get INT GPIO\n");
-		return error;
-	}
+	if (error)
+		return dev_err_probe(&client->dev, error, "failed to get INT GPIO\n");
 
 	if (ts->int_gpiod)
 		gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 08/27] Input: bu21029_ts - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (6 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 07/27] Input: bu21013_ts " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 09/27] Input: chipone_icn8318 " Krzysztof Kozlowski
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/bu21029_ts.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/input/touchscreen/bu21029_ts.c b/drivers/input/touchscreen/bu21029_ts.c
index 49a8d4bbca3a..96c178b606dc 100644
--- a/drivers/input/touchscreen/bu21029_ts.c
+++ b/drivers/input/touchscreen/bu21029_ts.c
@@ -360,23 +360,15 @@ static int bu21029_probe(struct i2c_client *client,
 	}
 
 	bu21029->vdd = devm_regulator_get(&client->dev, "vdd");
-	if (IS_ERR(bu21029->vdd)) {
-		error = PTR_ERR(bu21029->vdd);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"failed to acquire 'vdd' supply: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(bu21029->vdd))
+		return dev_err_probe(&client->dev, PTR_ERR(bu21029->vdd),
+				     "failed to acquire 'vdd' supply\n");
 
 	bu21029->reset_gpios = devm_gpiod_get_optional(&client->dev,
 						       "reset", GPIOD_OUT_HIGH);
-	if (IS_ERR(bu21029->reset_gpios)) {
-		error = PTR_ERR(bu21029->reset_gpios);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"failed to acquire 'reset' gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(bu21029->reset_gpios))
+		return dev_err_probe(&client->dev, PTR_ERR(bu21029->reset_gpios),
+				     "failed to acquire 'reset' gpio\n");
 
 	in_dev = devm_input_allocate_device(&client->dev);
 	if (!in_dev) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 09/27] Input: chipone_icn8318 - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (7 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 08/27] Input: bu21029_ts " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 10/27] Input: cy8ctma140 " Krzysztof Kozlowski
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/chipone_icn8318.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/chipone_icn8318.c b/drivers/input/touchscreen/chipone_icn8318.c
index d91d2fd78649..5bee007184c4 100644
--- a/drivers/input/touchscreen/chipone_icn8318.c
+++ b/drivers/input/touchscreen/chipone_icn8318.c
@@ -194,12 +194,8 @@ static int icn8318_probe(struct i2c_client *client,
 		return -ENOMEM;
 
 	data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW);
-	if (IS_ERR(data->wake_gpio)) {
-		error = PTR_ERR(data->wake_gpio);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Error getting wake gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(data->wake_gpio))
+		return dev_err_probe(dev, PTR_ERR(data->wake_gpio), "Error getting wake gpio\n");
 
 	input = devm_input_allocate_device(dev);
 	if (!input)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 10/27] Input: cy8ctma140 - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (8 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 09/27] Input: chipone_icn8318 " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 11/27] Input: edf-ft5x06 " Krzysztof Kozlowski
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/cy8ctma140.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/cy8ctma140.c b/drivers/input/touchscreen/cy8ctma140.c
index a9be29139cbf..23da5bb00ead 100644
--- a/drivers/input/touchscreen/cy8ctma140.c
+++ b/drivers/input/touchscreen/cy8ctma140.c
@@ -259,12 +259,8 @@ static int cy8ctma140_probe(struct i2c_client *client,
 	ts->regulators[1].supply = "vdd";
 	error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->regulators),
 				      ts->regulators);
-	if (error) {
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get regulators %d\n",
-				error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(dev, error, "Failed to get regulators\n");
 
 	error = cy8ctma140_power_up(ts);
 	if (error)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 11/27] Input: edf-ft5x06 - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (9 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 10/27] Input: cy8ctma140 " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 12/27] Input: ektf2127 " Krzysztof Kozlowski
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 6ff81d48da86..d4827ac963b0 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -1098,13 +1098,9 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	tsdata->max_support_points = chip_data->max_support_points;
 
 	tsdata->vcc = devm_regulator_get(&client->dev, "vcc");
-	if (IS_ERR(tsdata->vcc)) {
-		error = PTR_ERR(tsdata->vcc);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"failed to request regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(tsdata->vcc))
+		return dev_err_probe(&client->dev, PTR_ERR(tsdata->vcc),
+				     "failed to request regulator\n");
 
 	error = regulator_enable(tsdata->vcc);
 	if (error < 0) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 12/27] Input: ektf2127 - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (10 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 11/27] Input: edf-ft5x06 " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 13/27] Input: elants_i2c " Krzysztof Kozlowski
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/ektf2127.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/ektf2127.c b/drivers/input/touchscreen/ektf2127.c
index eadd389cf81f..cd41483cfae5 100644
--- a/drivers/input/touchscreen/ektf2127.c
+++ b/drivers/input/touchscreen/ektf2127.c
@@ -237,12 +237,8 @@ static int ektf2127_probe(struct i2c_client *client,
 
 	/* This requests the gpio *and* turns on the touchscreen controller */
 	ts->power_gpios = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH);
-	if (IS_ERR(ts->power_gpios)) {
-		error = PTR_ERR(ts->power_gpios);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Error getting power gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->power_gpios))
+		return dev_err_probe(dev, PTR_ERR(ts->power_gpios), "Error getting power gpio\n");
 
 	input = devm_input_allocate_device(dev);
 	if (!input)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 13/27] Input: elants_i2c - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (11 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 12/27] Input: ektf2127 " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 14/27] Input: goodix " Krzysztof Kozlowski
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/elants_i2c.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index b0bd5bb079be..ad299eb333f1 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1245,24 +1245,14 @@ static int elants_i2c_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, ts);
 
 	ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
-	if (IS_ERR(ts->vcc33)) {
-		error = PTR_ERR(ts->vcc33);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get 'vcc33' regulator: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(ts->vcc33))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->vcc33),
+				     "Failed to get 'vcc33' regulator\n");
 
 	ts->vccio = devm_regulator_get(&client->dev, "vccio");
-	if (IS_ERR(ts->vccio)) {
-		error = PTR_ERR(ts->vccio);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get 'vccio' regulator: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(ts->vccio))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->vccio),
+				     "Failed to get 'vccio' regulator\n");
 
 	ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ts->reset_gpio)) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 14/27] Input: goodix - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (12 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 13/27] Input: elants_i2c " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 15/27] Input: melfas_mip4 " Krzysztof Kozlowski
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/goodix.c | 40 ++++++++----------------------
 1 file changed, 11 insertions(+), 29 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 02c75ea385e0..48c4c3d297fe 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -864,7 +864,6 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
  */
 static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 {
-	int error;
 	struct device *dev;
 	struct gpio_desc *gpiod;
 	bool added_acpi_mappings = false;
@@ -874,33 +873,20 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	dev = &ts->client->dev;
 
 	ts->avdd28 = devm_regulator_get(dev, "AVDD28");
-	if (IS_ERR(ts->avdd28)) {
-		error = PTR_ERR(ts->avdd28);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev,
-				"Failed to get AVDD28 regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->avdd28))
+		return dev_err_probe(dev, PTR_ERR(ts->avdd28), "Failed to get AVDD28 regulator\n");
 
 	ts->vddio = devm_regulator_get(dev, "VDDIO");
-	if (IS_ERR(ts->vddio)) {
-		error = PTR_ERR(ts->vddio);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev,
-				"Failed to get VDDIO regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->vddio))
+		return dev_err_probe(dev, PTR_ERR(ts->vddio), "Failed to get VDDIO regulator\n");
 
 retry_get_irq_gpio:
 	/* Get the interrupt GPIO pin number */
 	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN);
-	if (IS_ERR(gpiod)) {
-		error = PTR_ERR(gpiod);
-		if (error != -EPROBE_DEFER)
-			dev_dbg(dev, "Failed to get %s GPIO: %d\n",
-				GOODIX_GPIO_INT_NAME, error);
-		return error;
-	}
+	if (IS_ERR(gpiod))
+		return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n",
+				     GOODIX_GPIO_INT_NAME);
+
 	if (!gpiod && has_acpi_companion(dev) && !added_acpi_mappings) {
 		added_acpi_mappings = true;
 		if (goodix_add_acpi_gpio_mappings(ts) == 0)
@@ -911,13 +897,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 
 	/* Get the reset line GPIO pin number */
 	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, GPIOD_IN);
-	if (IS_ERR(gpiod)) {
-		error = PTR_ERR(gpiod);
-		if (error != -EPROBE_DEFER)
-			dev_dbg(dev, "Failed to get %s GPIO: %d\n",
-				GOODIX_GPIO_RST_NAME, error);
-		return error;
-	}
+	if (IS_ERR(gpiod))
+		return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n",
+				     GOODIX_GPIO_RST_NAME);
 
 	ts->gpiod_rst = gpiod;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 15/27] Input: melfas_mip4 - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (13 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 14/27] Input: goodix " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 16/27] Input: pixcir_i2c_ts " Krzysztof Kozlowski
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/melfas_mip4.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index f67efdd040b2..d43a8643adcd 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -1451,13 +1451,8 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
 	ts->gpio_ce = devm_gpiod_get_optional(&client->dev,
 					      "ce", GPIOD_OUT_LOW);
-	if (IS_ERR(ts->gpio_ce)) {
-		error = PTR_ERR(ts->gpio_ce);
-		if (error != EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->gpio_ce))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->gpio_ce), "Failed to get gpio\n");
 
 	error = mip4_power_on(ts);
 	if (error)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 16/27] Input: pixcir_i2c_ts - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (14 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 15/27] Input: melfas_mip4 " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 17/27] Input: raydium_i2c_ts " Krzysztof Kozlowski
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 38 +++++++----------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 9aa098577350..fb37567e2d7e 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -515,41 +515,27 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	input_set_drvdata(input, tsdata);
 
 	tsdata->gpio_attb = devm_gpiod_get(dev, "attb", GPIOD_IN);
-	if (IS_ERR(tsdata->gpio_attb)) {
-		error = PTR_ERR(tsdata->gpio_attb);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to request ATTB gpio: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(tsdata->gpio_attb))
+		return dev_err_probe(dev, PTR_ERR(tsdata->gpio_attb),
+				     "Failed to request ATTB gpio\n");
 
 	tsdata->gpio_reset = devm_gpiod_get_optional(dev, "reset",
 						     GPIOD_OUT_LOW);
-	if (IS_ERR(tsdata->gpio_reset)) {
-		error = PTR_ERR(tsdata->gpio_reset);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to request RESET gpio: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(tsdata->gpio_reset))
+		return dev_err_probe(dev, PTR_ERR(tsdata->gpio_reset),
+				     "Failed to request RESET gpio\n");
 
 	tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
 						    GPIOD_OUT_HIGH);
-	if (IS_ERR(tsdata->gpio_wake)) {
-		error = PTR_ERR(tsdata->gpio_wake);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get wake gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(tsdata->gpio_wake))
+		return dev_err_probe(dev, PTR_ERR(tsdata->gpio_wake),
+				     "Failed to get wake gpio\n");
 
 	tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
 						      GPIOD_OUT_HIGH);
-	if (IS_ERR(tsdata->gpio_enable)) {
-		error = PTR_ERR(tsdata->gpio_enable);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get enable gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(tsdata->gpio_enable))
+		return dev_err_probe(dev, PTR_ERR(tsdata->gpio_enable),
+				     "Failed to get enable gpio\n");
 
 	if (tsdata->gpio_enable)
 		msleep(100);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 17/27] Input: raydium_i2c_ts - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (15 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 16/27] Input: pixcir_i2c_ts " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 18/27] Input: resistive-adc-touch " Krzysztof Kozlowski
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/raydium_i2c_ts.c | 30 +++++++---------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index fe245439adee..4017775f6466 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -1015,32 +1015,20 @@ static int raydium_i2c_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, ts);
 
 	ts->avdd = devm_regulator_get(&client->dev, "avdd");
-	if (IS_ERR(ts->avdd)) {
-		error = PTR_ERR(ts->avdd);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get 'avdd' regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->avdd))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->avdd),
+				     "Failed to get 'avdd' regulator\n");
 
 	ts->vccio = devm_regulator_get(&client->dev, "vccio");
-	if (IS_ERR(ts->vccio)) {
-		error = PTR_ERR(ts->vccio);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get 'vccio' regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->vccio))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->vccio),
+				     "Failed to get 'vccio' regulator\n");
 
 	ts->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
 						 GPIOD_OUT_LOW);
-	if (IS_ERR(ts->reset_gpio)) {
-		error = PTR_ERR(ts->reset_gpio);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"failed to get reset gpio: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->reset_gpio))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->reset_gpio),
+				     "Failed to get reset gpio\n");
 
 	error = raydium_i2c_power_on(ts);
 	if (error)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 18/27] Input: resistive-adc-touch - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (16 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 17/27] Input: raydium_i2c_ts " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 19/27] Input: silead " Krzysztof Kozlowski
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/resistive-adc-touch.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/resistive-adc-touch.c b/drivers/input/touchscreen/resistive-adc-touch.c
index cfc8bb4553f7..46b5a6caef84 100644
--- a/drivers/input/touchscreen/resistive-adc-touch.c
+++ b/drivers/input/touchscreen/resistive-adc-touch.c
@@ -108,12 +108,8 @@ static int grts_probe(struct platform_device *pdev)
 
 	/* get the channels from IIO device */
 	st->iio_chans = devm_iio_channel_get_all(dev);
-	if (IS_ERR(st->iio_chans)) {
-		error = PTR_ERR(st->iio_chans);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "can't get iio channels.\n");
-		return error;
-	}
+	if (IS_ERR(st->iio_chans))
+		return dev_err_probe(dev, PTR_ERR(st->iio_chans), "can't get iio channels\n");
 
 	chan = &st->iio_chans[0];
 	st->pressure = false;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 19/27] Input: silead - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (17 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 18/27] Input: resistive-adc-touch " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 20/27] Input: sis_i2c " Krzysztof Kozlowski
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/silead.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index 8fa2f3b7cfd8..754debb4b2c4 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -512,11 +512,9 @@ static int silead_ts_probe(struct i2c_client *client,
 
 	/* Power GPIO pin */
 	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
-	if (IS_ERR(data->gpio_power)) {
-		if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER)
-			dev_err(dev, "Shutdown GPIO request failed\n");
-		return PTR_ERR(data->gpio_power);
-	}
+	if (IS_ERR(data->gpio_power))
+		return dev_err_probe(dev, PTR_ERR(data->gpio_power),
+				     "Shutdown GPIO request failed\n");
 
 	error = silead_ts_setup(client);
 	if (error)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 20/27] Input: sis_i2c - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (18 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 19/27] Input: silead " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 21/27] Input: surface3_spi " Krzysztof Kozlowski
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/sis_i2c.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/input/touchscreen/sis_i2c.c b/drivers/input/touchscreen/sis_i2c.c
index 6274555f1673..348a2ba9b7c9 100644
--- a/drivers/input/touchscreen/sis_i2c.c
+++ b/drivers/input/touchscreen/sis_i2c.c
@@ -311,23 +311,15 @@ static int sis_ts_probe(struct i2c_client *client,
 
 	ts->attn_gpio = devm_gpiod_get_optional(&client->dev,
 						"attn", GPIOD_IN);
-	if (IS_ERR(ts->attn_gpio)) {
-		error = PTR_ERR(ts->attn_gpio);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get attention GPIO: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->attn_gpio))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->attn_gpio),
+				     "Failed to get attention GPIO\n");
 
 	ts->reset_gpio = devm_gpiod_get_optional(&client->dev,
 						 "reset", GPIOD_OUT_LOW);
-	if (IS_ERR(ts->reset_gpio)) {
-		error = PTR_ERR(ts->reset_gpio);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev,
-				"Failed to get reset GPIO: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->reset_gpio))
+		return dev_err_probe(&client->dev, PTR_ERR(ts->reset_gpio),
+				     "Failed to get reset GPIO\n");
 
 	sis_ts_reset(ts);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 21/27] Input: surface3_spi - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (19 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 20/27] Input: sis_i2c " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 22/27] Input: sx8643 " Krzysztof Kozlowski
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/surface3_spi.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/input/touchscreen/surface3_spi.c b/drivers/input/touchscreen/surface3_spi.c
index ce4828b1415a..25bb77ddf2ef 100644
--- a/drivers/input/touchscreen/surface3_spi.c
+++ b/drivers/input/touchscreen/surface3_spi.c
@@ -223,7 +223,6 @@ static void surface3_spi_power(struct surface3_ts_data *data, bool on)
  */
 static int surface3_spi_get_gpio_config(struct surface3_ts_data *data)
 {
-	int error;
 	struct device *dev;
 	struct gpio_desc *gpiod;
 	int i;
@@ -233,15 +232,9 @@ static int surface3_spi_get_gpio_config(struct surface3_ts_data *data)
 	/* Get the reset lines GPIO pin number */
 	for (i = 0; i < 2; i++) {
 		gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_OUT_LOW);
-		if (IS_ERR(gpiod)) {
-			error = PTR_ERR(gpiod);
-			if (error != -EPROBE_DEFER)
-				dev_err(dev,
-					"Failed to get power GPIO %d: %d\n",
-					i,
-					error);
-			return error;
-		}
+		if (IS_ERR(gpiod))
+			return dev_err_probe(dev, PTR_ERR(gpiod),
+					     "Failed to get power GPIO %d\n", i);
 
 		data->gpiod_rst[i] = gpiod;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 22/27] Input: sx8643 - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (20 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 21/27] Input: surface3_spi " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 23/27] Input: bcm-keypad " Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/sx8654.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
index de85e57b2486..d2ed9be64c3a 100644
--- a/drivers/input/touchscreen/sx8654.c
+++ b/drivers/input/touchscreen/sx8654.c
@@ -323,13 +323,9 @@ static int sx8654_probe(struct i2c_client *client,
 
 	sx8654->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset",
 						     GPIOD_OUT_HIGH);
-	if (IS_ERR(sx8654->gpio_reset)) {
-		error = PTR_ERR(sx8654->gpio_reset);
-		if (error != -EPROBE_DEFER)
-			dev_err(&client->dev, "unable to get reset-gpio: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(sx8654->gpio_reset))
+		return dev_err_probe(&client->dev, PTR_ERR(sx8654->gpio_reset),
+				     "unable to get reset-gpio\n");
 	dev_dbg(&client->dev, "got GPIO reset pin\n");
 
 	sx8654->data = device_get_match_data(&client->dev);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 23/27] Input: bcm-keypad - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (21 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 22/27] Input: sx8643 " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe() and devm_clk_get_optional().  Less code and the error
value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

---

Changes since v1:
1. Use also devm_clk_get_optional()
---
 drivers/input/keyboard/bcm-keypad.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c
index 2b771c3a5578..23e11b4efd13 100644
--- a/drivers/input/keyboard/bcm-keypad.c
+++ b/drivers/input/keyboard/bcm-keypad.c
@@ -376,17 +376,11 @@ static int bcm_kp_probe(struct platform_device *pdev)
 		return PTR_ERR(kp->base);
 
 	/* Enable clock */
-	kp->clk = devm_clk_get(&pdev->dev, "peri_clk");
+	kp->clk = devm_clk_get_optional(&pdev->dev, "peri_clk");
 	if (IS_ERR(kp->clk)) {
-		error = PTR_ERR(kp->clk);
-		if (error != -ENOENT) {
-			if (error != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Failed to get clock\n");
-			return error;
-		}
-		dev_dbg(&pdev->dev,
-			"No clock specified. Assuming it's enabled\n");
-		kp->clk = NULL;
+		return dev_err_probe(&pdev->dev, error, "Failed to get clock\n");
+	} else if (!kp->clk) {
+		dev_dbg(&pdev->dev, "No clock specified. Assuming it's enabled\n");
 	} else {
 		unsigned int desired_rate;
 		long actual_rate;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (22 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 23/27] Input: bcm-keypad " Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-28 14:31   ` Linus Walleij
  2020-08-27 18:58 ` [PATCH v3 25/27] Input: gpio_keys - Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Add devm_fwnode_gpiod_get_optional() and
devm_fwnode_gpiod_get_index_optional() helpers, similar to regular
devm_gpiod optional versions.  Drivers getting GPIOs from a firmware
node might use it to remove some boilerplate code.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

---

Changes since v2:
1. Return NULL

Changes since v1:
1. New patch
---
 drivers/gpio/gpiolib-devres.c | 71 +++++++++++++++++++++++++++++++++++
 include/linux/gpio/consumer.h | 30 +++++++++++++++
 2 files changed, 101 insertions(+)

diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c
index 7dbce4c4ebdf..f8476f6a65cc 100644
--- a/drivers/gpio/gpiolib-devres.c
+++ b/drivers/gpio/gpiolib-devres.c
@@ -184,6 +184,37 @@ struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_gpiod_get_from_of_node);
 
+/**
+ * devm_fwnode_gpiod_get_optional - Resource-managed fwnode_gpiod_get_index()
+ *                                  for optional GPIO
+ * @dev:	GPIO consumer
+ * @fwnode:	firmware node containing GPIO reference
+ * @con_id:	function within the GPIO consumer
+ * @flags:	GPIO initialization flags
+ * @label:	label to attach to the requested GPIO
+ *
+ * GPIO descriptors returned from this function are automatically disposed on
+ * driver detach.
+ *
+ * This is equivalent to devm_fwnode_gpiod_get_index(), except that when no
+ * GPIO with the specified index was assigned to the requested function it will
+ * return NULL.  This is convenient for drivers that need to handle optional
+ * GPIOs.
+ *
+ * On successful request the GPIO pin is configured in accordance with
+ * provided @flags.
+ */
+struct gpio_desc *devm_fwnode_gpiod_get_optional(struct device *dev,
+						 struct fwnode_handle *fwnode,
+						 const char *con_id,
+						 enum gpiod_flags flags,
+						 const char *label)
+{
+	return devm_fwnode_gpiod_get_index_optional(dev, fwnode, con_id, 0,
+						    flags, label);
+}
+EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_optional);
+
 /**
  * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node
  * @dev:	GPIO consumer
@@ -226,6 +257,46 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_index);
 
+/**
+ * devm_fwnode_gpiod_get_index_optional - Resource-managed fwnode_gpiod_get_index()
+ *                                        for optional GPIO
+ * @dev:	GPIO consumer
+ * @fwnode:	firmware node containing GPIO reference
+ * @con_id:	function within the GPIO consumer
+ * @index:	index of the GPIO to obtain in the consumer
+ * @flags:	GPIO initialization flags
+ * @label:	label to attach to the requested GPIO
+ *
+ * GPIO descriptors returned from this function are automatically disposed on
+ * driver detach.
+ *
+ * This is equivalent to devm_fwnode_gpiod_get_index(), except that when no
+ * GPIO with the specified index was assigned to the requested function it will
+ * return NULL.  This is convenient for drivers that need to handle optional
+ * GPIOs.
+ *
+ * On successful request the GPIO pin is configured in accordance with
+ * provided @flags.
+ */
+struct gpio_desc *devm_fwnode_gpiod_get_index_optional(struct device *dev,
+						       struct fwnode_handle *fwnode,
+						       const char *con_id, int index,
+						       enum gpiod_flags flags,
+						       const char *label)
+{
+	struct gpio_desc *desc;
+
+	desc = devm_fwnode_gpiod_get_index(dev, fwnode, con_id, index, flags,
+					   label);
+	if (IS_ERR(desc)) {
+		if (PTR_ERR(desc) == -ENOENT)
+			return NULL;
+	}
+
+	return desc;
+}
+EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_index_optional);
+
 /**
  * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()
  * @dev: GPIO consumer
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 901aab89d025..7854d80b1e9a 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -183,11 +183,21 @@ struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
 					 enum gpiod_flags flags,
 					 const char *label);
+struct gpio_desc *devm_fwnode_gpiod_get_optional(struct device *dev,
+						 struct fwnode_handle *fwnode,
+						 const char *con_id,
+						 enum gpiod_flags flags,
+						 const char *label);
 struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 					      struct fwnode_handle *child,
 					      const char *con_id, int index,
 					      enum gpiod_flags flags,
 					      const char *label);
+struct gpio_desc *devm_fwnode_gpiod_get_index_optional(struct device *dev,
+						       struct fwnode_handle *fwnode,
+						       const char *con_id, int index,
+						       enum gpiod_flags flags,
+						       const char *label);
 
 #else /* CONFIG_GPIOLIB */
 
@@ -562,6 +572,16 @@ struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 	return ERR_PTR(-ENOSYS);
 }
 
+static inline
+struct gpio_desc *devm_fwnode_gpiod_get_optional(struct device *dev,
+						 struct fwnode_handle *fwnode,
+						 const char *con_id,
+						 enum gpiod_flags flags,
+						 const char *label)
+{
+	return NULL;
+}
+
 static inline
 struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 					      struct fwnode_handle *fwnode,
@@ -572,6 +592,16 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 	return ERR_PTR(-ENOSYS);
 }
 
+static inline
+struct gpio_desc *devm_fwnode_gpiod_get_index_optional(struct device *dev,
+						       struct fwnode_handle *fwnode,
+						       const char *con_id, int index,
+						       enum gpiod_flags flags,
+						       const char *label)
+{
+	return NULL;
+}
+
 #endif /* CONFIG_GPIOLIB */
 
 static inline
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 25/27] Input: gpio_keys - Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (23 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 18:58 ` [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe() and devm_fwnode_gpiod_get_optional().   Less code and
the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

---

Changes since v2:
1. Preserve comment,
2. Include <device.h> to fix warning on clang (reported by kbuild),
3. Fix use of uninitialized "error" variable.

Changes since v1:
1. Use devm_fwnode_gpiod_get_optional
---
 drivers/input/keyboard/gpio_keys.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index f2d4e4daa818..160d94b1c2c0 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -18,6 +18,7 @@
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
 #include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
@@ -494,23 +495,13 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 	spin_lock_init(&bdata->lock);
 
 	if (child) {
-		bdata->gpiod = devm_fwnode_gpiod_get(dev, child,
-						     NULL, GPIOD_IN, desc);
-		if (IS_ERR(bdata->gpiod)) {
-			error = PTR_ERR(bdata->gpiod);
-			if (error == -ENOENT) {
-				/*
-				 * GPIO is optional, we may be dealing with
-				 * purely interrupt-driven setup.
-				 */
-				bdata->gpiod = NULL;
-			} else {
-				if (error != -EPROBE_DEFER)
-					dev_err(dev, "failed to get gpio: %d\n",
-						error);
-				return error;
-			}
-		}
+		/*
+		 * GPIO is optional, we may be dealing with purely
+		 * interrupt-driven setup.
+		 */
+		bdata->gpiod = devm_fwnode_gpiod_get_optional(dev, child, NULL, GPIOD_IN, desc);
+		if (IS_ERR(bdata->gpiod))
+			return dev_err_probe(dev, PTR_ERR(bdata->gpiod), "failed to get gpio\n");
 	} else if (gpio_is_valid(button->gpio)) {
 		/*
 		 * Legacy GPIO number, so request the GPIO here and
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (24 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 25/27] Input: gpio_keys - Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 19:43   ` Andy Shevchenko
                     ` (2 more replies)
  2020-08-27 18:58 ` [PATCH v3 27/27] Input: bu21029_ts " Krzysztof Kozlowski
  2020-10-02 16:23 ` [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
  27 siblings, 3 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

'dev' is shorter and simpler than '&client->dev' and in few cases it
allows to skip line wrapping. Probe function uses '&client->dev' a lot,
so this improves readability slightly.

Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Changes since v2:
1. New patch
---
 drivers/input/touchscreen/bu21013_ts.c | 61 ++++++++++++--------------
 1 file changed, 28 insertions(+), 33 deletions(-)

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 86bd38243d6c..f09204091ba5 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -411,31 +411,32 @@ static int bu21013_probe(struct i2c_client *client,
 	struct input_dev *in_dev;
 	struct input_absinfo *info;
 	u32 max_x = 0, max_y = 0;
+	struct device *dev = &client->dev;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter,
 				     I2C_FUNC_SMBUS_BYTE_DATA)) {
-		dev_err(&client->dev, "i2c smbus byte data not supported\n");
+		dev_err(dev, "i2c smbus byte data not supported\n");
 		return -EIO;
 	}
 
 	if (!client->irq) {
-		dev_err(&client->dev, "No IRQ set up\n");
+		dev_err(dev, "No IRQ set up\n");
 		return -EINVAL;
 	}
 
-	ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
+	ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
 	if (!ts)
 		return -ENOMEM;
 
 	ts->client = client;
 
-	ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x");
-	ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y");
+	ts->x_flip = device_property_read_bool(dev, "rohm,flip-x");
+	ts->y_flip = device_property_read_bool(dev, "rohm,flip-y");
 
-	in_dev = devm_input_allocate_device(&client->dev);
+	in_dev = devm_input_allocate_device(dev);
 	if (!in_dev) {
-		dev_err(&client->dev, "device memory alloc failed\n");
+		dev_err(dev, "device memory alloc failed\n");
 		return -ENOMEM;
 	}
 	ts->in_dev = in_dev;
@@ -445,8 +446,8 @@ static int bu21013_probe(struct i2c_client *client,
 	in_dev->name = DRIVER_TP;
 	in_dev->id.bustype = BUS_I2C;
 
-	device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x);
-	device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y);
+	device_property_read_u32(dev, "rohm,touch-max-x", &max_x);
+	device_property_read_u32(dev, "rohm,touch-max-y", &max_y);
 
 	input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0);
 	input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
@@ -455,14 +456,14 @@ static int bu21013_probe(struct i2c_client *client,
 
 	/* Adjust for the legacy "flip" properties, if present */
 	if (!ts->props.invert_x &&
-	    device_property_read_bool(&client->dev, "rohm,flip-x")) {
+	    device_property_read_bool(dev, "rohm,flip-x")) {
 		info = &in_dev->absinfo[ABS_MT_POSITION_X];
 		info->maximum -= info->minimum;
 		info->minimum = 0;
 	}
 
 	if (!ts->props.invert_y &&
-	    device_property_read_bool(&client->dev, "rohm,flip-y")) {
+	    device_property_read_bool(dev, "rohm,flip-y")) {
 		info = &in_dev->absinfo[ABS_MT_POSITION_Y];
 		info->maximum -= info->minimum;
 		info->minimum = 0;
@@ -472,50 +473,46 @@ static int bu21013_probe(struct i2c_client *client,
 				    INPUT_MT_DIRECT | INPUT_MT_TRACK |
 					INPUT_MT_DROP_UNUSED);
 	if (error) {
-		dev_err(&client->dev, "failed to initialize MT slots");
+		dev_err(dev, "failed to initialize MT slots");
 		return error;
 	}
 
-	ts->regulator = devm_regulator_get(&client->dev, "avdd");
+	ts->regulator = devm_regulator_get(dev, "avdd");
 	if (IS_ERR(ts->regulator)) {
-		dev_err(&client->dev, "regulator_get failed\n");
+		dev_err(dev, "regulator_get failed\n");
 		return PTR_ERR(ts->regulator);
 	}
 
 	error = regulator_enable(ts->regulator);
 	if (error) {
-		dev_err(&client->dev, "regulator enable failed\n");
+		dev_err(dev, "regulator enable failed\n");
 		return error;
 	}
 
-	error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts);
+	error = devm_add_action_or_reset(dev, bu21013_power_off, ts);
 	if (error) {
-		dev_err(&client->dev, "failed to install power off handler\n");
+		dev_err(dev, "failed to install power off handler\n");
 		return error;
 	}
 
 	/* Named "CS" on the chip, DT binding is "reset" */
-	ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
+	ts->cs_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(ts->cs_gpiod))
-		return dev_err_probe(&client->dev, PTR_ERR(ts->cs_gpiod),
-				     "failed to get CS GPIO\n");
+		return dev_err_probe(dev, PTR_ERR(ts->cs_gpiod), "failed to get CS GPIO\n");
 
 	gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
 
-	error = devm_add_action_or_reset(&client->dev,
-					 bu21013_disable_chip, ts);
+	error = devm_add_action_or_reset(dev, bu21013_disable_chip, ts);
 	if (error) {
-		dev_err(&client->dev,
-			"failed to install chip disable handler\n");
+		dev_err(dev, "failed to install chip disable handler\n");
 		return error;
 	}
 
 	/* Named "INT" on the chip, DT binding is "touch" */
-	ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
-						"touch", GPIOD_IN);
+	ts->int_gpiod = devm_gpiod_get_optional(dev, "touch", GPIOD_IN);
 	error = PTR_ERR_OR_ZERO(ts->int_gpiod);
 	if (error)
-		return dev_err_probe(&client->dev, error, "failed to get INT GPIO\n");
+		return dev_err_probe(dev, error, "failed to get INT GPIO\n");
 
 	if (ts->int_gpiod)
 		gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
@@ -523,22 +520,20 @@ static int bu21013_probe(struct i2c_client *client,
 	/* configure the touch panel controller */
 	error = bu21013_init_chip(ts);
 	if (error) {
-		dev_err(&client->dev, "error in bu21013 config\n");
+		dev_err(dev, "error in bu21013 config\n");
 		return error;
 	}
 
-	error = devm_request_threaded_irq(&client->dev, client->irq,
-					  NULL, bu21013_gpio_irq,
+	error = devm_request_threaded_irq(dev, client->irq, NULL, bu21013_gpio_irq,
 					  IRQF_ONESHOT, DRIVER_TP, ts);
 	if (error) {
-		dev_err(&client->dev, "request irq %d failed\n",
-			client->irq);
+		dev_err(dev, "request irq %d failed\n", client->irq);
 		return error;
 	}
 
 	error = input_register_device(in_dev);
 	if (error) {
-		dev_err(&client->dev, "failed to register input device\n");
+		dev_err(dev, "failed to register input device\n");
 		return error;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v3 27/27] Input: bu21029_ts - Use local 'client->dev' variable in probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (25 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
@ 2020-08-27 18:58 ` Krzysztof Kozlowski
  2020-08-27 19:44   ` Andy Shevchenko
  2020-10-02 16:23 ` [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
  27 siblings, 1 reply; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 18:58 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

'dev' is shorter and simpler than '&client->dev' and in few cases it
allows to skip line wrapping. Probe function uses '&client->dev' a lot,
so this improves readability slightly.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Changes since v2:
1. New patch
---
 drivers/input/touchscreen/bu21029_ts.c | 37 +++++++++++---------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/input/touchscreen/bu21029_ts.c b/drivers/input/touchscreen/bu21029_ts.c
index 96c178b606dc..78e256254764 100644
--- a/drivers/input/touchscreen/bu21029_ts.c
+++ b/drivers/input/touchscreen/bu21029_ts.c
@@ -334,6 +334,7 @@ static void bu21029_stop_chip(struct input_dev *dev)
 static int bu21029_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
+	struct device *dev = &client->dev;
 	struct bu21029_ts_data *bu21029;
 	struct input_dev *in_dev;
 	int error;
@@ -342,37 +343,33 @@ static int bu21029_probe(struct i2c_client *client,
 				     I2C_FUNC_SMBUS_WRITE_BYTE |
 				     I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
 				     I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
-		dev_err(&client->dev,
-			"i2c functionality support is not sufficient\n");
+		dev_err(dev, "i2c functionality support is not sufficient\n");
 		return -EIO;
 	}
 
-	bu21029 = devm_kzalloc(&client->dev, sizeof(*bu21029), GFP_KERNEL);
+	bu21029 = devm_kzalloc(dev, sizeof(*bu21029), GFP_KERNEL);
 	if (!bu21029)
 		return -ENOMEM;
 
-	error = device_property_read_u32(&client->dev, "rohm,x-plate-ohms",
-					 &bu21029->x_plate_ohms);
+	error = device_property_read_u32(dev, "rohm,x-plate-ohms", &bu21029->x_plate_ohms);
 	if (error) {
-		dev_err(&client->dev,
-			"invalid 'x-plate-ohms' supplied: %d\n", error);
+		dev_err(dev, "invalid 'x-plate-ohms' supplied: %d\n", error);
 		return error;
 	}
 
-	bu21029->vdd = devm_regulator_get(&client->dev, "vdd");
+	bu21029->vdd = devm_regulator_get(dev, "vdd");
 	if (IS_ERR(bu21029->vdd))
-		return dev_err_probe(&client->dev, PTR_ERR(bu21029->vdd),
+		return dev_err_probe(dev, PTR_ERR(bu21029->vdd),
 				     "failed to acquire 'vdd' supply\n");
 
-	bu21029->reset_gpios = devm_gpiod_get_optional(&client->dev,
-						       "reset", GPIOD_OUT_HIGH);
+	bu21029->reset_gpios = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(bu21029->reset_gpios))
-		return dev_err_probe(&client->dev, PTR_ERR(bu21029->reset_gpios),
+		return dev_err_probe(dev, PTR_ERR(bu21029->reset_gpios),
 				     "failed to acquire 'reset' gpio\n");
 
-	in_dev = devm_input_allocate_device(&client->dev);
+	in_dev = devm_input_allocate_device(dev);
 	if (!in_dev) {
-		dev_err(&client->dev, "unable to allocate input device\n");
+		dev_err(dev, "unable to allocate input device\n");
 		return -ENOMEM;
 	}
 
@@ -394,19 +391,17 @@ static int bu21029_probe(struct i2c_client *client,
 	input_set_drvdata(in_dev, bu21029);
 
 	irq_set_status_flags(client->irq, IRQ_NOAUTOEN);
-	error = devm_request_threaded_irq(&client->dev, client->irq,
-					  NULL, bu21029_touch_soft_irq,
-					  IRQF_ONESHOT, DRIVER_NAME, bu21029);
+	error = devm_request_threaded_irq(dev, client->irq, NULL,
+					  bu21029_touch_soft_irq, IRQF_ONESHOT,
+					  DRIVER_NAME, bu21029);
 	if (error) {
-		dev_err(&client->dev,
-			"unable to request touch irq: %d\n", error);
+		dev_err(dev, "unable to request touch irq: %d\n", error);
 		return error;
 	}
 
 	error = input_register_device(in_dev);
 	if (error) {
-		dev_err(&client->dev,
-			"unable to register input device: %d\n", error);
+		dev_err(dev, "unable to register input device: %d\n", error);
 		return error;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 02/27] Input: gpio-vibra - Simplify with dev_err_probe()
  2020-08-27 18:58 ` [PATCH v3 02/27] Input: gpio-vibra " Krzysztof Kozlowski
@ 2020-08-27 19:36   ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2020-08-27 19:36 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, linux-input,
	Platform Driver, clang-built-linux

On Thu, Aug 27, 2020 at 9:58 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

>
> ---
>
> Changes since v1:
> 1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy.
> ---
>  drivers/input/misc/gpio-vibra.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/input/misc/gpio-vibra.c b/drivers/input/misc/gpio-vibra.c
> index f79f75595dd7..13c69f173620 100644
> --- a/drivers/input/misc/gpio-vibra.c
> +++ b/drivers/input/misc/gpio-vibra.c
> @@ -113,22 +113,14 @@ static int gpio_vibrator_probe(struct platform_device *pdev)
>                 return -ENOMEM;
>
>         vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
> -       err = PTR_ERR_OR_ZERO(vibrator->vcc);
> -       if (err) {
> -               if (err != -EPROBE_DEFER)
> -                       dev_err(&pdev->dev, "Failed to request regulator: %d\n",
> -                               err);
> -               return err;
> -       }
> +       if (IS_ERR(vibrator->vcc))
> +               return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc),
> +                                    "Failed to request regulator\n");
>
>         vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
> -       err = PTR_ERR_OR_ZERO(vibrator->gpio);
> -       if (err) {
> -               if (err != -EPROBE_DEFER)
> -                       dev_err(&pdev->dev, "Failed to request main gpio: %d\n",
> -                               err);
> -               return err;
> -       }
> +       if (IS_ERR(vibrator->gpio))
> +               return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->gpio),
> +                                    "Failed to request main gpio\n");
>
>         INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work);
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 04/27] Input: pwm-vibra - Simplify with dev_err_probe()
  2020-08-27 18:58 ` [PATCH v3 04/27] Input: pwm-vibra " Krzysztof Kozlowski
@ 2020-08-27 19:39   ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2020-08-27 19:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, linux-input,
	Platform Driver, clang-built-linux

On Thu, Aug 27, 2020 at 9:58 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and also it prints the error value.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>
> ---
>
> Changes since v1:
> 1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy.
> ---
>  drivers/input/misc/pwm-vibra.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c
> index 81e777a04b88..45c4f6a02177 100644
> --- a/drivers/input/misc/pwm-vibra.c
> +++ b/drivers/input/misc/pwm-vibra.c
> @@ -134,22 +134,14 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
>                 return -ENOMEM;
>
>         vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
> -       err = PTR_ERR_OR_ZERO(vibrator->vcc);
> -       if (err) {
> -               if (err != -EPROBE_DEFER)
> -                       dev_err(&pdev->dev, "Failed to request regulator: %d",
> -                               err);
> -               return err;
> -       }
> +       if (IS_ERR(vibrator->vcc))
> +               return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc),
> +                                    "Failed to request regulator\n");
>
>         vibrator->pwm = devm_pwm_get(&pdev->dev, "enable");
> -       err = PTR_ERR_OR_ZERO(vibrator->pwm);
> -       if (err) {
> -               if (err != -EPROBE_DEFER)
> -                       dev_err(&pdev->dev, "Failed to request main pwm: %d",
> -                               err);
> -               return err;
> -       }
> +       if (IS_ERR(vibrator->pwm))
> +               return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->pwm),
> +                                    "Failed to request main pwm\n");
>
>         INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work);
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 07/27] Input: bu21013_ts - Simplify with dev_err_probe()
  2020-08-27 18:58 ` [PATCH v3 07/27] Input: bu21013_ts " Krzysztof Kozlowski
@ 2020-08-27 19:39   ` Andy Shevchenko
  2020-08-28 14:29   ` Linus Walleij
  1 sibling, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2020-08-27 19:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, linux-input,
	Platform Driver, clang-built-linux

On Thu, Aug 27, 2020 at 9:59 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and also it prints the error value.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>
> ---
>
> Changes since v1:
> 1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy.
> ---
>  drivers/input/touchscreen/bu21013_ts.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 2f1f0d7607f8..86bd38243d6c 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -496,12 +496,10 @@ static int bu21013_probe(struct i2c_client *client,
>
>         /* Named "CS" on the chip, DT binding is "reset" */
>         ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
> -       error = PTR_ERR_OR_ZERO(ts->cs_gpiod);
> -       if (error) {
> -               if (error != -EPROBE_DEFER)
> -                       dev_err(&client->dev, "failed to get CS GPIO\n");
> -               return error;
> -       }
> +       if (IS_ERR(ts->cs_gpiod))
> +               return dev_err_probe(&client->dev, PTR_ERR(ts->cs_gpiod),
> +                                    "failed to get CS GPIO\n");
> +
>         gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
>
>         error = devm_add_action_or_reset(&client->dev,
> @@ -516,11 +514,8 @@ static int bu21013_probe(struct i2c_client *client,
>         ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
>                                                 "touch", GPIOD_IN);
>         error = PTR_ERR_OR_ZERO(ts->int_gpiod);
> -       if (error) {
> -               if (error != -EPROBE_DEFER)
> -                       dev_err(&client->dev, "failed to get INT GPIO\n");
> -               return error;
> -       }
> +       if (error)
> +               return dev_err_probe(&client->dev, error, "failed to get INT GPIO\n");
>
>         if (ts->int_gpiod)
>                 gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe()
  2020-08-27 18:58 ` [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
@ 2020-08-27 19:43   ` Andy Shevchenko
  2020-08-27 19:47   ` [PATCH v3.1] " Krzysztof Kozlowski
  2020-08-28 14:32   ` [PATCH v3 26/27] " Linus Walleij
  2 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2020-08-27 19:43 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, linux-input,
	Platform Driver, clang-built-linux

On Thu, Aug 27, 2020 at 10:00 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> 'dev' is shorter and simpler than '&client->dev' and in few cases it
> allows to skip line wrapping. Probe function uses '&client->dev' a lot,
> so this improves readability slightly.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Andy Shevchenko <andy.shevchenko@gmail.com>

Suggested-by: (I suppose)

> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
>
> ---
>
> Changes since v2:
> 1. New patch
> ---
>  drivers/input/touchscreen/bu21013_ts.c | 61 ++++++++++++--------------
>  1 file changed, 28 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 86bd38243d6c..f09204091ba5 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -411,31 +411,32 @@ static int bu21013_probe(struct i2c_client *client,
>         struct input_dev *in_dev;
>         struct input_absinfo *info;
>         u32 max_x = 0, max_y = 0;
> +       struct device *dev = &client->dev;
>         int error;
>
>         if (!i2c_check_functionality(client->adapter,
>                                      I2C_FUNC_SMBUS_BYTE_DATA)) {
> -               dev_err(&client->dev, "i2c smbus byte data not supported\n");
> +               dev_err(dev, "i2c smbus byte data not supported\n");
>                 return -EIO;
>         }
>
>         if (!client->irq) {
> -               dev_err(&client->dev, "No IRQ set up\n");
> +               dev_err(dev, "No IRQ set up\n");
>                 return -EINVAL;
>         }
>
> -       ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
> +       ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
>         if (!ts)
>                 return -ENOMEM;
>
>         ts->client = client;
>
> -       ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x");
> -       ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y");
> +       ts->x_flip = device_property_read_bool(dev, "rohm,flip-x");
> +       ts->y_flip = device_property_read_bool(dev, "rohm,flip-y");
>
> -       in_dev = devm_input_allocate_device(&client->dev);
> +       in_dev = devm_input_allocate_device(dev);
>         if (!in_dev) {
> -               dev_err(&client->dev, "device memory alloc failed\n");
> +               dev_err(dev, "device memory alloc failed\n");
>                 return -ENOMEM;
>         }
>         ts->in_dev = in_dev;
> @@ -445,8 +446,8 @@ static int bu21013_probe(struct i2c_client *client,
>         in_dev->name = DRIVER_TP;
>         in_dev->id.bustype = BUS_I2C;
>
> -       device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x);
> -       device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y);
> +       device_property_read_u32(dev, "rohm,touch-max-x", &max_x);
> +       device_property_read_u32(dev, "rohm,touch-max-y", &max_y);
>
>         input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0);
>         input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
> @@ -455,14 +456,14 @@ static int bu21013_probe(struct i2c_client *client,
>
>         /* Adjust for the legacy "flip" properties, if present */
>         if (!ts->props.invert_x &&
> -           device_property_read_bool(&client->dev, "rohm,flip-x")) {
> +           device_property_read_bool(dev, "rohm,flip-x")) {
>                 info = &in_dev->absinfo[ABS_MT_POSITION_X];
>                 info->maximum -= info->minimum;
>                 info->minimum = 0;
>         }
>
>         if (!ts->props.invert_y &&
> -           device_property_read_bool(&client->dev, "rohm,flip-y")) {
> +           device_property_read_bool(dev, "rohm,flip-y")) {
>                 info = &in_dev->absinfo[ABS_MT_POSITION_Y];
>                 info->maximum -= info->minimum;
>                 info->minimum = 0;
> @@ -472,50 +473,46 @@ static int bu21013_probe(struct i2c_client *client,
>                                     INPUT_MT_DIRECT | INPUT_MT_TRACK |
>                                         INPUT_MT_DROP_UNUSED);
>         if (error) {
> -               dev_err(&client->dev, "failed to initialize MT slots");
> +               dev_err(dev, "failed to initialize MT slots");
>                 return error;
>         }
>
> -       ts->regulator = devm_regulator_get(&client->dev, "avdd");
> +       ts->regulator = devm_regulator_get(dev, "avdd");
>         if (IS_ERR(ts->regulator)) {
> -               dev_err(&client->dev, "regulator_get failed\n");
> +               dev_err(dev, "regulator_get failed\n");
>                 return PTR_ERR(ts->regulator);
>         }
>
>         error = regulator_enable(ts->regulator);
>         if (error) {
> -               dev_err(&client->dev, "regulator enable failed\n");
> +               dev_err(dev, "regulator enable failed\n");
>                 return error;
>         }
>
> -       error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts);
> +       error = devm_add_action_or_reset(dev, bu21013_power_off, ts);
>         if (error) {
> -               dev_err(&client->dev, "failed to install power off handler\n");
> +               dev_err(dev, "failed to install power off handler\n");
>                 return error;
>         }
>
>         /* Named "CS" on the chip, DT binding is "reset" */
> -       ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
> +       ts->cs_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
>         if (IS_ERR(ts->cs_gpiod))
> -               return dev_err_probe(&client->dev, PTR_ERR(ts->cs_gpiod),
> -                                    "failed to get CS GPIO\n");
> +               return dev_err_probe(dev, PTR_ERR(ts->cs_gpiod), "failed to get CS GPIO\n");
>
>         gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
>
> -       error = devm_add_action_or_reset(&client->dev,
> -                                        bu21013_disable_chip, ts);
> +       error = devm_add_action_or_reset(dev, bu21013_disable_chip, ts);
>         if (error) {
> -               dev_err(&client->dev,
> -                       "failed to install chip disable handler\n");
> +               dev_err(dev, "failed to install chip disable handler\n");
>                 return error;
>         }
>
>         /* Named "INT" on the chip, DT binding is "touch" */
> -       ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
> -                                               "touch", GPIOD_IN);
> +       ts->int_gpiod = devm_gpiod_get_optional(dev, "touch", GPIOD_IN);
>         error = PTR_ERR_OR_ZERO(ts->int_gpiod);
>         if (error)
> -               return dev_err_probe(&client->dev, error, "failed to get INT GPIO\n");
> +               return dev_err_probe(dev, error, "failed to get INT GPIO\n");
>
>         if (ts->int_gpiod)
>                 gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
> @@ -523,22 +520,20 @@ static int bu21013_probe(struct i2c_client *client,
>         /* configure the touch panel controller */
>         error = bu21013_init_chip(ts);
>         if (error) {
> -               dev_err(&client->dev, "error in bu21013 config\n");
> +               dev_err(dev, "error in bu21013 config\n");
>                 return error;
>         }
>
> -       error = devm_request_threaded_irq(&client->dev, client->irq,
> -                                         NULL, bu21013_gpio_irq,
> +       error = devm_request_threaded_irq(dev, client->irq, NULL, bu21013_gpio_irq,
>                                           IRQF_ONESHOT, DRIVER_TP, ts);
>         if (error) {
> -               dev_err(&client->dev, "request irq %d failed\n",
> -                       client->irq);
> +               dev_err(dev, "request irq %d failed\n", client->irq);
>                 return error;
>         }
>
>         error = input_register_device(in_dev);
>         if (error) {
> -               dev_err(&client->dev, "failed to register input device\n");
> +               dev_err(dev, "failed to register input device\n");
>                 return error;
>         }
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 27/27] Input: bu21029_ts - Use local 'client->dev' variable in probe()
  2020-08-27 18:58 ` [PATCH v3 27/27] Input: bu21029_ts " Krzysztof Kozlowski
@ 2020-08-27 19:44   ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2020-08-27 19:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, linux-input,
	Platform Driver, clang-built-linux

On Thu, Aug 27, 2020 at 10:00 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> 'dev' is shorter and simpler than '&client->dev' and in few cases it
> allows to skip line wrapping. Probe function uses '&client->dev' a lot,
> so this improves readability slightly.
>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
>
> ---
>
> Changes since v2:
> 1. New patch
> ---
>  drivers/input/touchscreen/bu21029_ts.c | 37 +++++++++++---------------
>  1 file changed, 16 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/input/touchscreen/bu21029_ts.c b/drivers/input/touchscreen/bu21029_ts.c
> index 96c178b606dc..78e256254764 100644
> --- a/drivers/input/touchscreen/bu21029_ts.c
> +++ b/drivers/input/touchscreen/bu21029_ts.c
> @@ -334,6 +334,7 @@ static void bu21029_stop_chip(struct input_dev *dev)
>  static int bu21029_probe(struct i2c_client *client,
>                          const struct i2c_device_id *id)
>  {
> +       struct device *dev = &client->dev;
>         struct bu21029_ts_data *bu21029;
>         struct input_dev *in_dev;
>         int error;
> @@ -342,37 +343,33 @@ static int bu21029_probe(struct i2c_client *client,
>                                      I2C_FUNC_SMBUS_WRITE_BYTE |
>                                      I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
>                                      I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
> -               dev_err(&client->dev,
> -                       "i2c functionality support is not sufficient\n");
> +               dev_err(dev, "i2c functionality support is not sufficient\n");
>                 return -EIO;
>         }
>
> -       bu21029 = devm_kzalloc(&client->dev, sizeof(*bu21029), GFP_KERNEL);
> +       bu21029 = devm_kzalloc(dev, sizeof(*bu21029), GFP_KERNEL);
>         if (!bu21029)
>                 return -ENOMEM;
>
> -       error = device_property_read_u32(&client->dev, "rohm,x-plate-ohms",
> -                                        &bu21029->x_plate_ohms);
> +       error = device_property_read_u32(dev, "rohm,x-plate-ohms", &bu21029->x_plate_ohms);
>         if (error) {
> -               dev_err(&client->dev,
> -                       "invalid 'x-plate-ohms' supplied: %d\n", error);
> +               dev_err(dev, "invalid 'x-plate-ohms' supplied: %d\n", error);
>                 return error;
>         }
>
> -       bu21029->vdd = devm_regulator_get(&client->dev, "vdd");
> +       bu21029->vdd = devm_regulator_get(dev, "vdd");
>         if (IS_ERR(bu21029->vdd))
> -               return dev_err_probe(&client->dev, PTR_ERR(bu21029->vdd),
> +               return dev_err_probe(dev, PTR_ERR(bu21029->vdd),
>                                      "failed to acquire 'vdd' supply\n");
>
> -       bu21029->reset_gpios = devm_gpiod_get_optional(&client->dev,
> -                                                      "reset", GPIOD_OUT_HIGH);
> +       bu21029->reset_gpios = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
>         if (IS_ERR(bu21029->reset_gpios))
> -               return dev_err_probe(&client->dev, PTR_ERR(bu21029->reset_gpios),
> +               return dev_err_probe(dev, PTR_ERR(bu21029->reset_gpios),
>                                      "failed to acquire 'reset' gpio\n");
>
> -       in_dev = devm_input_allocate_device(&client->dev);
> +       in_dev = devm_input_allocate_device(dev);
>         if (!in_dev) {
> -               dev_err(&client->dev, "unable to allocate input device\n");
> +               dev_err(dev, "unable to allocate input device\n");
>                 return -ENOMEM;
>         }
>
> @@ -394,19 +391,17 @@ static int bu21029_probe(struct i2c_client *client,
>         input_set_drvdata(in_dev, bu21029);
>
>         irq_set_status_flags(client->irq, IRQ_NOAUTOEN);
> -       error = devm_request_threaded_irq(&client->dev, client->irq,
> -                                         NULL, bu21029_touch_soft_irq,
> -                                         IRQF_ONESHOT, DRIVER_NAME, bu21029);
> +       error = devm_request_threaded_irq(dev, client->irq, NULL,
> +                                         bu21029_touch_soft_irq, IRQF_ONESHOT,
> +                                         DRIVER_NAME, bu21029);
>         if (error) {
> -               dev_err(&client->dev,
> -                       "unable to request touch irq: %d\n", error);
> +               dev_err(dev, "unable to request touch irq: %d\n", error);
>                 return error;
>         }
>
>         error = input_register_device(in_dev);
>         if (error) {
> -               dev_err(&client->dev,
> -                       "unable to register input device: %d\n", error);
> +               dev_err(dev, "unable to register input device: %d\n", error);
>                 return error;
>         }
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3.1] Input: bu21013_ts - Use local 'client->dev' variable in probe()
  2020-08-27 18:58 ` [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
  2020-08-27 19:43   ` Andy Shevchenko
@ 2020-08-27 19:47   ` Krzysztof Kozlowski
  2020-08-28 14:32   ` [PATCH v3 26/27] " Linus Walleij
  2 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-27 19:47 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	Andy Shevchenko, linux-gpio, linux-kernel, linux-input,
	platform-driver-x86, clang-built-linux
  Cc: Krzysztof Kozlowski

'dev' is shorter and simpler than '&client->dev' and in few cases it
allows to skip line wrapping. Probe function uses '&client->dev' a lot,
so this improves readability slightly.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

---

Changes since v3:
1. Correct suggested-by tag,
2. Add Reviewed-by tag.

Changes since v2:
1. New patch
---
 drivers/input/touchscreen/bu21013_ts.c | 61 ++++++++++++--------------
 1 file changed, 28 insertions(+), 33 deletions(-)

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 86bd38243d6c..f09204091ba5 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -411,31 +411,32 @@ static int bu21013_probe(struct i2c_client *client,
 	struct input_dev *in_dev;
 	struct input_absinfo *info;
 	u32 max_x = 0, max_y = 0;
+	struct device *dev = &client->dev;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter,
 				     I2C_FUNC_SMBUS_BYTE_DATA)) {
-		dev_err(&client->dev, "i2c smbus byte data not supported\n");
+		dev_err(dev, "i2c smbus byte data not supported\n");
 		return -EIO;
 	}
 
 	if (!client->irq) {
-		dev_err(&client->dev, "No IRQ set up\n");
+		dev_err(dev, "No IRQ set up\n");
 		return -EINVAL;
 	}
 
-	ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
+	ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
 	if (!ts)
 		return -ENOMEM;
 
 	ts->client = client;
 
-	ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x");
-	ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y");
+	ts->x_flip = device_property_read_bool(dev, "rohm,flip-x");
+	ts->y_flip = device_property_read_bool(dev, "rohm,flip-y");
 
-	in_dev = devm_input_allocate_device(&client->dev);
+	in_dev = devm_input_allocate_device(dev);
 	if (!in_dev) {
-		dev_err(&client->dev, "device memory alloc failed\n");
+		dev_err(dev, "device memory alloc failed\n");
 		return -ENOMEM;
 	}
 	ts->in_dev = in_dev;
@@ -445,8 +446,8 @@ static int bu21013_probe(struct i2c_client *client,
 	in_dev->name = DRIVER_TP;
 	in_dev->id.bustype = BUS_I2C;
 
-	device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x);
-	device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y);
+	device_property_read_u32(dev, "rohm,touch-max-x", &max_x);
+	device_property_read_u32(dev, "rohm,touch-max-y", &max_y);
 
 	input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0);
 	input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
@@ -455,14 +456,14 @@ static int bu21013_probe(struct i2c_client *client,
 
 	/* Adjust for the legacy "flip" properties, if present */
 	if (!ts->props.invert_x &&
-	    device_property_read_bool(&client->dev, "rohm,flip-x")) {
+	    device_property_read_bool(dev, "rohm,flip-x")) {
 		info = &in_dev->absinfo[ABS_MT_POSITION_X];
 		info->maximum -= info->minimum;
 		info->minimum = 0;
 	}
 
 	if (!ts->props.invert_y &&
-	    device_property_read_bool(&client->dev, "rohm,flip-y")) {
+	    device_property_read_bool(dev, "rohm,flip-y")) {
 		info = &in_dev->absinfo[ABS_MT_POSITION_Y];
 		info->maximum -= info->minimum;
 		info->minimum = 0;
@@ -472,50 +473,46 @@ static int bu21013_probe(struct i2c_client *client,
 				    INPUT_MT_DIRECT | INPUT_MT_TRACK |
 					INPUT_MT_DROP_UNUSED);
 	if (error) {
-		dev_err(&client->dev, "failed to initialize MT slots");
+		dev_err(dev, "failed to initialize MT slots");
 		return error;
 	}
 
-	ts->regulator = devm_regulator_get(&client->dev, "avdd");
+	ts->regulator = devm_regulator_get(dev, "avdd");
 	if (IS_ERR(ts->regulator)) {
-		dev_err(&client->dev, "regulator_get failed\n");
+		dev_err(dev, "regulator_get failed\n");
 		return PTR_ERR(ts->regulator);
 	}
 
 	error = regulator_enable(ts->regulator);
 	if (error) {
-		dev_err(&client->dev, "regulator enable failed\n");
+		dev_err(dev, "regulator enable failed\n");
 		return error;
 	}
 
-	error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts);
+	error = devm_add_action_or_reset(dev, bu21013_power_off, ts);
 	if (error) {
-		dev_err(&client->dev, "failed to install power off handler\n");
+		dev_err(dev, "failed to install power off handler\n");
 		return error;
 	}
 
 	/* Named "CS" on the chip, DT binding is "reset" */
-	ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
+	ts->cs_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(ts->cs_gpiod))
-		return dev_err_probe(&client->dev, PTR_ERR(ts->cs_gpiod),
-				     "failed to get CS GPIO\n");
+		return dev_err_probe(dev, PTR_ERR(ts->cs_gpiod), "failed to get CS GPIO\n");
 
 	gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
 
-	error = devm_add_action_or_reset(&client->dev,
-					 bu21013_disable_chip, ts);
+	error = devm_add_action_or_reset(dev, bu21013_disable_chip, ts);
 	if (error) {
-		dev_err(&client->dev,
-			"failed to install chip disable handler\n");
+		dev_err(dev, "failed to install chip disable handler\n");
 		return error;
 	}
 
 	/* Named "INT" on the chip, DT binding is "touch" */
-	ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
-						"touch", GPIOD_IN);
+	ts->int_gpiod = devm_gpiod_get_optional(dev, "touch", GPIOD_IN);
 	error = PTR_ERR_OR_ZERO(ts->int_gpiod);
 	if (error)
-		return dev_err_probe(&client->dev, error, "failed to get INT GPIO\n");
+		return dev_err_probe(dev, error, "failed to get INT GPIO\n");
 
 	if (ts->int_gpiod)
 		gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
@@ -523,22 +520,20 @@ static int bu21013_probe(struct i2c_client *client,
 	/* configure the touch panel controller */
 	error = bu21013_init_chip(ts);
 	if (error) {
-		dev_err(&client->dev, "error in bu21013 config\n");
+		dev_err(dev, "error in bu21013 config\n");
 		return error;
 	}
 
-	error = devm_request_threaded_irq(&client->dev, client->irq,
-					  NULL, bu21013_gpio_irq,
+	error = devm_request_threaded_irq(dev, client->irq, NULL, bu21013_gpio_irq,
 					  IRQF_ONESHOT, DRIVER_TP, ts);
 	if (error) {
-		dev_err(&client->dev, "request irq %d failed\n",
-			client->irq);
+		dev_err(dev, "request irq %d failed\n", client->irq);
 		return error;
 	}
 
 	error = input_register_device(in_dev);
 	if (error) {
-		dev_err(&client->dev, "failed to register input device\n");
+		dev_err(dev, "failed to register input device\n");
 		return error;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 07/27] Input: bu21013_ts - Simplify with dev_err_probe()
  2020-08-27 18:58 ` [PATCH v3 07/27] Input: bu21013_ts " Krzysztof Kozlowski
  2020-08-27 19:39   ` Andy Shevchenko
@ 2020-08-28 14:29   ` Linus Walleij
  1 sibling, 0 replies; 41+ messages in thread
From: Linus Walleij @ 2020-08-28 14:29 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Bartosz Golaszewski, Dmitry Torokhov, Hans de Goede,
	Bastien Nocera, Sangwon Jee, Eugen Hristev, Andy Shevchenko,
	open list:GPIO SUBSYSTEM, linux-kernel, Linux Input,
	platform-driver-x86, clang-built-linux

On Thu, Aug 27, 2020 at 8:59 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:

> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers
  2020-08-27 18:58 ` [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers Krzysztof Kozlowski
@ 2020-08-28 14:31   ` Linus Walleij
  2020-08-28 14:45     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 41+ messages in thread
From: Linus Walleij @ 2020-08-28 14:31 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Bartosz Golaszewski, Dmitry Torokhov, Hans de Goede,
	Bastien Nocera, Sangwon Jee, Eugen Hristev, Andy Shevchenko,
	open list:GPIO SUBSYSTEM, linux-kernel, Linux Input,
	platform-driver-x86, clang-built-linux

On Thu, Aug 27, 2020 at 9:00 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:

> Add devm_fwnode_gpiod_get_optional() and
> devm_fwnode_gpiod_get_index_optional() helpers, similar to regular
> devm_gpiod optional versions.  Drivers getting GPIOs from a firmware
> node might use it to remove some boilerplate code.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

OK then, I suppose this gets merged with the rest?

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe()
  2020-08-27 18:58 ` [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
  2020-08-27 19:43   ` Andy Shevchenko
  2020-08-27 19:47   ` [PATCH v3.1] " Krzysztof Kozlowski
@ 2020-08-28 14:32   ` Linus Walleij
  2 siblings, 0 replies; 41+ messages in thread
From: Linus Walleij @ 2020-08-28 14:32 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Bartosz Golaszewski, Dmitry Torokhov, Hans de Goede,
	Bastien Nocera, Sangwon Jee, Eugen Hristev, Andy Shevchenko,
	open list:GPIO SUBSYSTEM, linux-kernel, Linux Input,
	platform-driver-x86, clang-built-linux

On Thu, Aug 27, 2020 at 9:00 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:

> 'dev' is shorter and simpler than '&client->dev' and in few cases it
> allows to skip line wrapping. Probe function uses '&client->dev' a lot,
> so this improves readability slightly.
>
> Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers
  2020-08-28 14:31   ` Linus Walleij
@ 2020-08-28 14:45     ` Krzysztof Kozlowski
  2020-08-28 14:56       ` Andy Shevchenko
  0 siblings, 1 reply; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-28 14:45 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bartosz Golaszewski, Dmitry Torokhov, Hans de Goede,
	Bastien Nocera, Sangwon Jee, Eugen Hristev, Andy Shevchenko,
	open list:GPIO SUBSYSTEM, linux-kernel, Linux Input,
	platform-driver-x86, clang-built-linux

On Fri, 28 Aug 2020 at 16:31, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Aug 27, 2020 at 9:00 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> > Add devm_fwnode_gpiod_get_optional() and
> > devm_fwnode_gpiod_get_index_optional() helpers, similar to regular
> > devm_gpiod optional versions.  Drivers getting GPIOs from a firmware
> > node might use it to remove some boilerplate code.
> >
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> OK then, I suppose this gets merged with the rest?
>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

That's the easiest unless you expect some conflicts. Only one next
patch depends on this so worst case it could wait one cycle.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers
  2020-08-28 14:45     ` Krzysztof Kozlowski
@ 2020-08-28 14:56       ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2020-08-28 14:56 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Hans de Goede, Bastien Nocera, Sangwon Jee, Eugen Hristev,
	open list:GPIO SUBSYSTEM, linux-kernel, Linux Input,
	platform-driver-x86, clang-built-linux

On Fri, Aug 28, 2020 at 5:45 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> On Fri, 28 Aug 2020 at 16:31, Linus Walleij <linus.walleij@linaro.org> wrote:
> > On Thu, Aug 27, 2020 at 9:00 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > > Add devm_fwnode_gpiod_get_optional() and
> > > devm_fwnode_gpiod_get_index_optional() helpers, similar to regular
> > > devm_gpiod optional versions.  Drivers getting GPIOs from a firmware
> > > node might use it to remove some boilerplate code.
> > >
> > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> >
> > OK then, I suppose this gets merged with the rest?
> >
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> That's the easiest unless you expect some conflicts. Only one next
> patch depends on this so worst case it could wait one cycle.

I believe Dmitry and Linus are familiar with the concept of immutable
branches, so it won't be a problem to create one and share.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 01/27] Input: Simplify with dev_err_probe()
  2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (26 preceding siblings ...)
  2020-08-27 18:58 ` [PATCH v3 27/27] Input: bu21029_ts " Krzysztof Kozlowski
@ 2020-10-02 16:23 ` Krzysztof Kozlowski
  2021-09-16 19:40   ` Krzysztof Kozlowski
  27 siblings, 1 reply; 41+ messages in thread
From: Krzysztof Kozlowski @ 2020-10-02 16:23 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Bartosz Golaszewski, Hans de Goede,
	Bastien Nocera, Sangwon Jee, Eugen Hristev, Andy Shevchenko,
	linux-gpio, linux-kernel, linux-input, platform-driver-x86,
	clang-built-linux

On Thu, Aug 27, 2020 at 08:58:02PM +0200, Krzysztof Kozlowski wrote:
> Hi,
> 
> Changes since v2:
> 1. Add review tags,
> 2. Fixes after review (see individual patches).
> 3. Two new patches - 26 and 27.
> 
> 

Hi Dmitry,

Any comments here? Some of these nicely simplify the code or remove some
lines.

Best regards,
Krzysztof

> Best regards,
> Krzysztof
> 
> 
> 
> Krzysztof Kozlowski (27):
>   Input: gpio_keys_polled - Simplify with dev_err_probe()
>   Input: gpio-vibra - Simplify with dev_err_probe()
>   Input: pwm-beeper - Simplify with dev_err_probe()
>   Input: pwm-vibra - Simplify with dev_err_probe()
>   Input: rotary_encoder - Simplify with dev_err_probe()
>   Input: elan_i2c - Simplify with dev_err_probe()
>   Input: bu21013_ts - Simplify with dev_err_probe()
>   Input: bu21029_ts - Simplify with dev_err_probe()
>   Input: chipone_icn8318 - Simplify with dev_err_probe()
>   Input: cy8ctma140 - Simplify with dev_err_probe()
>   Input: edf-ft5x06 - Simplify with dev_err_probe()
>   Input: ektf2127 - Simplify with dev_err_probe()
>   Input: elants_i2c - Simplify with dev_err_probe()
>   Input: goodix - Simplify with dev_err_probe()
>   Input: melfas_mip4 - Simplify with dev_err_probe()
>   Input: pixcir_i2c_ts - Simplify with dev_err_probe()
>   Input: raydium_i2c_ts - Simplify with dev_err_probe()
>   Input: resistive-adc-touch - Simplify with dev_err_probe()
>   Input: silead - Simplify with dev_err_probe()
>   Input: sis_i2c - Simplify with dev_err_probe()
>   Input: surface3_spi - Simplify with dev_err_probe()
>   Input: sx8643 - Simplify with dev_err_probe()
>   Input: bcm-keypad - Simplify with dev_err_probe()
>   gpio: Add devm_fwnode_gpiod_get_optional() helpers
>   Input: gpio_keys - Simplify with dev_err_probe()
>   Input: bu21013_ts - Use local 'client->dev' variable in probe()
>   Input: bu21029_ts - Use local 'client->dev' variable in probe()
> 
>  drivers/gpio/gpiolib-devres.c                 | 71 ++++++++++++++++++
>  drivers/input/keyboard/bcm-keypad.c           | 14 ++--
>  drivers/input/keyboard/gpio_keys.c            | 25 +++----
>  drivers/input/keyboard/gpio_keys_polled.c     |  8 +--
>  drivers/input/misc/gpio-vibra.c               | 20 ++----
>  drivers/input/misc/pwm-beeper.c               | 19 ++---
>  drivers/input/misc/pwm-vibra.c                | 20 ++----
>  drivers/input/misc/rotary_encoder.c           |  8 +--
>  drivers/input/mouse/elan_i2c_core.c           |  9 +--
>  drivers/input/touchscreen/bu21013_ts.c        | 72 ++++++++-----------
>  drivers/input/touchscreen/bu21029_ts.c        | 53 ++++++--------
>  drivers/input/touchscreen/chipone_icn8318.c   |  8 +--
>  drivers/input/touchscreen/cy8ctma140.c        |  8 +--
>  drivers/input/touchscreen/edt-ft5x06.c        | 10 +--
>  drivers/input/touchscreen/ektf2127.c          |  8 +--
>  drivers/input/touchscreen/elants_i2c.c        | 22 ++----
>  drivers/input/touchscreen/goodix.c            | 40 +++--------
>  drivers/input/touchscreen/melfas_mip4.c       |  9 +--
>  drivers/input/touchscreen/pixcir_i2c_ts.c     | 38 ++++------
>  drivers/input/touchscreen/raydium_i2c_ts.c    | 30 +++-----
>  .../input/touchscreen/resistive-adc-touch.c   |  8 +--
>  drivers/input/touchscreen/silead.c            |  8 +--
>  drivers/input/touchscreen/sis_i2c.c           | 20 ++----
>  drivers/input/touchscreen/surface3_spi.c      | 13 +---
>  drivers/input/touchscreen/sx8654.c            | 10 +--
>  include/linux/gpio/consumer.h                 | 30 ++++++++
>  26 files changed, 253 insertions(+), 328 deletions(-)
> 
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 01/27] Input: Simplify with dev_err_probe()
  2020-10-02 16:23 ` [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2021-09-16 19:40   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 41+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-16 19:40 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Bartosz Golaszewski, Hans de Goede,
	Bastien Nocera, Sangwon Jee, Eugen Hristev, Andy Shevchenko,
	linux-gpio, linux-kernel, linux-input, platform-driver-x86,
	clang-built-linux

On Fri, 2 Oct 2020 at 18:23, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Thu, Aug 27, 2020 at 08:58:02PM +0200, Krzysztof Kozlowski wrote:
> > Hi,
> >
> > Changes since v2:
> > 1. Add review tags,
> > 2. Fixes after review (see individual patches).
> > 3. Two new patches - 26 and 27.
> >
> >
>
> Hi Dmitry,
>
> Any comments here? Some of these nicely simplify the code or remove some
> lines.

Hi Dmitry,

You never shared your thoughts about this simplification. Some of
these could be redundant with Rob's work:
https://lore.kernel.org/lkml/CAL_Jsq+ajm5aiAJfQdS2+2DO1ynBDHWha_7TsA4u-2qwd87y6g@mail.gmail.com/
but I am not sure if it was merged.

On the other hand there are here also few other changes like:
>   gpio: Add devm_fwnode_gpiod_get_optional() helpers
>   Input: gpio_keys - Simplify with dev_err_probe()
which does:
8 insertions(+), 17 deletions(-)

and these:
>   Input: bu21013_ts - Use local 'client->dev' variable in probe()
>   Input: bu21029_ts - Use local 'client->dev' variable in probe()

Any comments?

Best regards,
Krzysztof



> > Krzysztof Kozlowski (27):
> >   Input: gpio_keys_polled - Simplify with dev_err_probe()
> >   Input: gpio-vibra - Simplify with dev_err_probe()
> >   Input: pwm-beeper - Simplify with dev_err_probe()
> >   Input: pwm-vibra - Simplify with dev_err_probe()
> >   Input: rotary_encoder - Simplify with dev_err_probe()
> >   Input: elan_i2c - Simplify with dev_err_probe()
> >   Input: bu21013_ts - Simplify with dev_err_probe()
> >   Input: bu21029_ts - Simplify with dev_err_probe()
> >   Input: chipone_icn8318 - Simplify with dev_err_probe()
> >   Input: cy8ctma140 - Simplify with dev_err_probe()
> >   Input: edf-ft5x06 - Simplify with dev_err_probe()
> >   Input: ektf2127 - Simplify with dev_err_probe()
> >   Input: elants_i2c - Simplify with dev_err_probe()
> >   Input: goodix - Simplify with dev_err_probe()
> >   Input: melfas_mip4 - Simplify with dev_err_probe()
> >   Input: pixcir_i2c_ts - Simplify with dev_err_probe()
> >   Input: raydium_i2c_ts - Simplify with dev_err_probe()
> >   Input: resistive-adc-touch - Simplify with dev_err_probe()
> >   Input: silead - Simplify with dev_err_probe()
> >   Input: sis_i2c - Simplify with dev_err_probe()
> >   Input: surface3_spi - Simplify with dev_err_probe()
> >   Input: sx8643 - Simplify with dev_err_probe()
> >   Input: bcm-keypad - Simplify with dev_err_probe()
> >   gpio: Add devm_fwnode_gpiod_get_optional() helpers
> >   Input: gpio_keys - Simplify with dev_err_probe()
> >   Input: bu21013_ts - Use local 'client->dev' variable in probe()
> >   Input: bu21029_ts - Use local 'client->dev' variable in probe()
> >
> >  drivers/gpio/gpiolib-devres.c                 | 71 ++++++++++++++++++
> >  drivers/input/keyboard/bcm-keypad.c           | 14 ++--
> >  drivers/input/keyboard/gpio_keys.c            | 25 +++----
> >  drivers/input/keyboard/gpio_keys_polled.c     |  8 +--
> >  drivers/input/misc/gpio-vibra.c               | 20 ++----
> >  drivers/input/misc/pwm-beeper.c               | 19 ++---
> >  drivers/input/misc/pwm-vibra.c                | 20 ++----
> >  drivers/input/misc/rotary_encoder.c           |  8 +--
> >  drivers/input/mouse/elan_i2c_core.c           |  9 +--
> >  drivers/input/touchscreen/bu21013_ts.c        | 72 ++++++++-----------
> >  drivers/input/touchscreen/bu21029_ts.c        | 53 ++++++--------
> >  drivers/input/touchscreen/chipone_icn8318.c   |  8 +--
> >  drivers/input/touchscreen/cy8ctma140.c        |  8 +--
> >  drivers/input/touchscreen/edt-ft5x06.c        | 10 +--
> >  drivers/input/touchscreen/ektf2127.c          |  8 +--
> >  drivers/input/touchscreen/elants_i2c.c        | 22 ++----
> >  drivers/input/touchscreen/goodix.c            | 40 +++--------
> >  drivers/input/touchscreen/melfas_mip4.c       |  9 +--
> >  drivers/input/touchscreen/pixcir_i2c_ts.c     | 38 ++++------
> >  drivers/input/touchscreen/raydium_i2c_ts.c    | 30 +++-----
> >  .../input/touchscreen/resistive-adc-touch.c   |  8 +--
> >  drivers/input/touchscreen/silead.c            |  8 +--
> >  drivers/input/touchscreen/sis_i2c.c           | 20 ++----
> >  drivers/input/touchscreen/surface3_spi.c      | 13 +---
> >  drivers/input/touchscreen/sx8654.c            | 10 +--
> >  include/linux/gpio/consumer.h                 | 30 ++++++++
> >  26 files changed, 253 insertions(+), 328 deletions(-)
> >
> > --
> > 2.17.1
> >

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2021-09-16 19:41 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 18:58 [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 01/27] Input: gpio_keys_polled - " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 02/27] Input: gpio-vibra " Krzysztof Kozlowski
2020-08-27 19:36   ` Andy Shevchenko
2020-08-27 18:58 ` [PATCH v3 03/27] Input: pwm-beeper " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 04/27] Input: pwm-vibra " Krzysztof Kozlowski
2020-08-27 19:39   ` Andy Shevchenko
2020-08-27 18:58 ` [PATCH v3 05/27] Input: rotary_encoder " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 06/27] Input: elan_i2c " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 07/27] Input: bu21013_ts " Krzysztof Kozlowski
2020-08-27 19:39   ` Andy Shevchenko
2020-08-28 14:29   ` Linus Walleij
2020-08-27 18:58 ` [PATCH v3 08/27] Input: bu21029_ts " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 09/27] Input: chipone_icn8318 " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 10/27] Input: cy8ctma140 " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 11/27] Input: edf-ft5x06 " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 12/27] Input: ektf2127 " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 13/27] Input: elants_i2c " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 14/27] Input: goodix " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 15/27] Input: melfas_mip4 " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 16/27] Input: pixcir_i2c_ts " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 17/27] Input: raydium_i2c_ts " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 18/27] Input: resistive-adc-touch " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 19/27] Input: silead " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 20/27] Input: sis_i2c " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 21/27] Input: surface3_spi " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 22/27] Input: sx8643 " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 23/27] Input: bcm-keypad " Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 24/27] gpio: Add devm_fwnode_gpiod_get_optional() helpers Krzysztof Kozlowski
2020-08-28 14:31   ` Linus Walleij
2020-08-28 14:45     ` Krzysztof Kozlowski
2020-08-28 14:56       ` Andy Shevchenko
2020-08-27 18:58 ` [PATCH v3 25/27] Input: gpio_keys - Simplify with dev_err_probe() Krzysztof Kozlowski
2020-08-27 18:58 ` [PATCH v3 26/27] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
2020-08-27 19:43   ` Andy Shevchenko
2020-08-27 19:47   ` [PATCH v3.1] " Krzysztof Kozlowski
2020-08-28 14:32   ` [PATCH v3 26/27] " Linus Walleij
2020-08-27 18:58 ` [PATCH v3 27/27] Input: bu21029_ts " Krzysztof Kozlowski
2020-08-27 19:44   ` Andy Shevchenko
2020-10-02 16:23 ` [PATCH v3 01/27] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
2021-09-16 19:40   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).