All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bastien Nocera" <hadess@hadess.net>,
	"Sangwon Jee" <jeesw@melfas.com>,
	"Eugen Hristev" <eugen.hristev@collabora.com>,
	"Mika Penttilä" <mpenttil@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org
Cc: Andi Shyti <andi.shyti@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [PATCH v4 23/24] Input: bu21013_ts - Use local 'client->dev' variable in probe()
Date: Sun, 25 Jun 2023 18:28:16 +0200	[thread overview]
Message-ID: <20230625162817.100397-24-krzysztof.kozlowski@linaro.org> (raw)
In-Reply-To: <20230625162817.100397-1-krzysztof.kozlowski@linaro.org>

'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 <krzysztof.kozlowski@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---

Changes since v3:
1. Correct suggested-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 f811677a59f7..652439a79e21 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -410,31 +410,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;
@@ -444,8 +445,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);
@@ -454,14 +455,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;
@@ -471,50 +472,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");
@@ -522,22 +519,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.34.1


  parent reply	other threads:[~2023-06-25 16:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25 16:27 [PATCH v4 00/24] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 01/24] Input: gpio_keys_polled - " Krzysztof Kozlowski
2023-06-26  7:13   ` Linus Walleij
2023-06-25 16:27 ` [PATCH v4 02/24] Input: gpio-vibra " Krzysztof Kozlowski
2023-06-26  7:14   ` Linus Walleij
2023-06-25 16:27 ` [PATCH v4 03/24] Input: pwm-vibra " Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 04/24] Input: rotary_encoder " Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 05/24] Input: elan_i2c " Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 06/24] Input: bu21013_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 07/24] Input: bu21029_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 08/24] Input: chipone_icn8318 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 09/24] Input: cy8ctma140 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 10/24] Input: edf-ft5x06 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 11/24] Input: ektf2127 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 12/24] Input: elants_i2c " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 13/24] Input: goodix " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 14/24] Input: melfas_mip4 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 15/24] Input: pixcir_i2c_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 16/24] Input: raydium_i2c_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 17/24] Input: resistive-adc-touch " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 18/24] Input: silead " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 19/24] Input: sis_i2c " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 20/24] Input: surface3_spi " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 21/24] Input: sx8643 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 22/24] Input: bcm-keypad " Krzysztof Kozlowski
2023-06-26 13:05   ` Dan Carpenter
2023-06-27  8:57     ` Krzysztof Kozlowski
2023-06-27 10:01       ` Dan Carpenter
2023-06-27 10:35         ` Krzysztof Kozlowski
2023-06-27 10:46           ` Dan Carpenter
2023-06-25 16:28 ` Krzysztof Kozlowski [this message]
2023-06-25 16:28 ` [PATCH v4 24/24] Input: bu21029_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
2023-07-07 23:58 ` [PATCH v4 00/24] Input: Simplify with dev_err_probe() Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230625162817.100397-24-krzysztof.kozlowski@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=andi.shyti@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eugen.hristev@collabora.com \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=jeesw@melfas.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpenttil@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.