diff mbox series

[1/5] Input: zinitix - Helper dev variable in probe()

Message ID 20220410120059.2583849-1-linus.walleij@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/5] Input: zinitix - Helper dev variable in probe() | expand

Commit Message

Linus Walleij April 10, 2022, noon UTC
Create a helper variable struct device *dev in probe() to
make the code more compact and easier to read.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/input/touchscreen/zinitix.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Linus Walleij May 24, 2022, 12:08 p.m. UTC | #1
On Sun, Apr 10, 2022 at 2:03 PM Linus Walleij <linus.walleij@linaro.org> wrote:

> Create a helper variable struct device *dev in probe() to
> make the code more compact and easier to read.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Anything needed with this patch set?

I'd be fine if we just merge the cleanups (patches 1-3) as a base
to begin with.

Sorry for pushing, I know there may be much to do.

Yours,
Linus Walleij
Dmitry Torokhov May 27, 2022, 5:36 a.m. UTC | #2
Hi Linus,

On Sun, Apr 10, 2022 at 02:00:55PM +0200, Linus Walleij wrote:
> Create a helper variable struct device *dev in probe() to
> make the code more compact and easier to read.

Actually I wonder if this is a good idea: when just seeing "dev" I often
have hard time to remember what device we are dealing with, whereas
"client->dev" gives a very string hint that we are dealing with I2C
peripheral physical device.

Did you observe object code savings from the conversion by chance?

Thanks.
Linus Walleij May 27, 2022, 1:30 p.m. UTC | #3
On Fri, May 27, 2022 at 7:36 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Sun, Apr 10, 2022 at 02:00:55PM +0200, Linus Walleij wrote:

> > Create a helper variable struct device *dev in probe() to
> > make the code more compact and easier to read.
>
> Actually I wonder if this is a good idea: when just seeing "dev" I often
> have hard time to remember what device we are dealing with, whereas
> "client->dev" gives a very string hint that we are dealing with I2C
> peripheral physical device.

Hm yeah that has a point I suppose.

> Did you observe object code savings from the conversion by chance?

No it is just cognitively easier for me (less characters on the screen)
but that is admittedly a bit of personal preference.

I'll drop this patch, because the subsystem maintainer's taste is
more important than mine.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index 8bd03278ad9a..cd13075ae3ab 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -503,15 +503,16 @@  static int zinitix_init_input_dev(struct bt541_ts_data *bt541)
 static int zinitix_ts_probe(struct i2c_client *client)
 {
 	struct bt541_ts_data *bt541;
+	struct device *dev = &client->dev;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		dev_err(&client->dev,
+		dev_err(dev,
 			"Failed to assert adapter's support for plain I2C.\n");
 		return -ENXIO;
 	}
 
-	bt541 = devm_kzalloc(&client->dev, sizeof(*bt541), GFP_KERNEL);
+	bt541 = devm_kzalloc(dev, sizeof(*bt541), GFP_KERNEL);
 	if (!bt541)
 		return -ENOMEM;
 
@@ -520,28 +521,28 @@  static int zinitix_ts_probe(struct i2c_client *client)
 
 	error = zinitix_init_regulators(bt541);
 	if (error) {
-		dev_err(&client->dev,
+		dev_err(dev,
 			"Failed to initialize regulators: %d\n", error);
 		return error;
 	}
 
-	error = devm_request_threaded_irq(&client->dev, client->irq,
+	error = devm_request_threaded_irq(dev, client->irq,
 					  NULL, zinitix_ts_irq_handler,
 					  IRQF_ONESHOT | IRQF_NO_AUTOEN,
 					  client->name, bt541);
 	if (error) {
-		dev_err(&client->dev, "Failed to request IRQ: %d\n", error);
+		dev_err(dev, "Failed to request IRQ: %d\n", error);
 		return error;
 	}
 
 	error = zinitix_init_input_dev(bt541);
 	if (error) {
-		dev_err(&client->dev,
+		dev_err(dev,
 			"Failed to initialize input device: %d\n", error);
 		return error;
 	}
 
-	error = device_property_read_u32(&client->dev, "zinitix,mode",
+	error = device_property_read_u32(dev, "zinitix,mode",
 					 &bt541->zinitix_mode);
 	if (error < 0) {
 		/* fall back to mode 2 */
@@ -553,7 +554,7 @@  static int zinitix_ts_probe(struct i2c_client *client)
 		 * If there are devices that don't support mode 2, support
 		 * for other modes (0, 1) will be needed.
 		 */
-		dev_err(&client->dev,
+		dev_err(dev,
 			"Malformed zinitix,mode property, must be 2 (supplied: %d)\n",
 			bt541->zinitix_mode);
 		return -EINVAL;