From: Ethan Tidmore <ethantidmore06@gmail.com>
To: jic23@kernel.org, andy@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH v4 6/9] iio: light: gp2ap020a00f: Use temporary variable for struct device
Date: Tue, 17 Feb 2026 22:37:25 -0600 [thread overview]
Message-ID: <20260218043728.609659-7-ethantidmore06@gmail.com> (raw)
In-Reply-To: <20260218043728.609659-1-ethantidmore06@gmail.com>
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Use temporary variable for struct device to make code neater.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
v4:
- Integrate Andy Shevchenko's cleanups.
drivers/iio/light/gp2ap020a00f.c | 34 +++++++++++++++-----------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
index f9ff8bbbe5ec..54b5d1993035 100644
--- a/drivers/iio/light/gp2ap020a00f.c
+++ b/drivers/iio/light/gp2ap020a00f.c
@@ -1192,6 +1192,7 @@ static int gp2ap020a00f_read_event_config(struct iio_dev *indio_dev,
static int gp2ap020a00f_read_channel(struct gp2ap020a00f_data *data,
struct iio_chan_spec const *chan, int *val)
{
+ struct device *dev = &data->client->dev;
enum gp2ap020a00f_cmd cmd;
int err;
@@ -1211,27 +1212,23 @@ static int gp2ap020a00f_read_channel(struct gp2ap020a00f_data *data,
err = gp2ap020a00f_exec_cmd(data, cmd);
if (err < 0) {
- dev_err(&data->client->dev,
- "gp2ap020a00f_exec_cmd failed\n");
- goto error_ret;
+ dev_err(dev, "gp2ap020a00f_exec_cmd failed\n");
+ return err;
}
err = gp2ap020a00f_read_output(data, chan->address, val);
if (err < 0)
- dev_err(&data->client->dev,
- "gp2ap020a00f_read_output failed\n");
+ dev_err(dev, "gp2ap020a00f_read_output failed\n");
err = gp2ap020a00f_set_operation_mode(data,
GP2AP020A00F_OPMODE_SHUTDOWN);
if (err < 0)
- dev_err(&data->client->dev,
- "Failed to shut down the device.\n");
+ dev_err(dev, "Failed to shut down the device.\n");
if (cmd == GP2AP020A00F_CMD_READ_RAW_CLEAR ||
cmd == GP2AP020A00F_CMD_READ_RAW_IR)
gp2ap020a00f_output_to_lux(data, val);
-error_ret:
return err;
}
@@ -1421,18 +1418,19 @@ static const struct iio_buffer_setup_ops gp2ap020a00f_buffer_setup_ops = {
static int gp2ap020a00f_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
+ struct device *dev = &client->dev;
struct gp2ap020a00f_data *data;
struct iio_dev *indio_dev;
struct regmap *regmap;
int err;
- indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
data = iio_priv(indio_dev);
- data->vled_reg = devm_regulator_get(&client->dev, "vled");
+ data->vled_reg = devm_regulator_get(dev, "vled");
if (IS_ERR(data->vled_reg))
return PTR_ERR(data->vled_reg);
@@ -1442,7 +1440,7 @@ static int gp2ap020a00f_probe(struct i2c_client *client)
regmap = devm_regmap_init_i2c(client, &gp2ap020a00f_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Regmap initialization failed.\n");
+ dev_err(dev, "Regmap initialization failed.\n");
err = PTR_ERR(regmap);
goto error_regulator_disable;
}
@@ -1453,7 +1451,7 @@ static int gp2ap020a00f_probe(struct i2c_client *client)
ARRAY_SIZE(gp2ap020a00f_reg_init_tab));
if (err < 0) {
- dev_err(&client->dev, "Device initialization failed.\n");
+ dev_err(dev, "Device initialization failed.\n");
goto error_regulator_disable;
}
@@ -1478,11 +1476,10 @@ static int gp2ap020a00f_probe(struct i2c_client *client)
goto error_regulator_disable;
/* Allocate trigger */
- data->trig = devm_iio_trigger_alloc(&client->dev, "%s-trigger",
- indio_dev->name);
+ data->trig = devm_iio_trigger_alloc(dev, "%s-trigger", indio_dev->name);
if (data->trig == NULL) {
err = -ENOMEM;
- dev_err(&indio_dev->dev, "Failed to allocate iio trigger.\n");
+ dev_err(dev, "Failed to allocate iio trigger.\n");
goto error_uninit_buffer;
}
@@ -1494,7 +1491,7 @@ static int gp2ap020a00f_probe(struct i2c_client *client)
"gp2ap020a00f_als_event",
indio_dev);
if (err < 0) {
- dev_err(&client->dev, "Irq request failed.\n");
+ dev_err(dev, "Irq request failed.\n");
goto error_uninit_buffer;
}
@@ -1502,7 +1499,7 @@ static int gp2ap020a00f_probe(struct i2c_client *client)
err = iio_trigger_register(data->trig);
if (err < 0) {
- dev_err(&client->dev, "Failed to register iio trigger.\n");
+ dev_err(dev, "Failed to register iio trigger.\n");
goto error_free_irq;
}
@@ -1528,12 +1525,13 @@ static void gp2ap020a00f_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct gp2ap020a00f_data *data = iio_priv(indio_dev);
+ struct device *dev = &client->dev;
int err;
err = gp2ap020a00f_set_operation_mode(data,
GP2AP020A00F_OPMODE_SHUTDOWN);
if (err < 0)
- dev_err(&indio_dev->dev, "Failed to power off the device.\n");
+ dev_err(dev, "Failed to power off the device.\n");
iio_device_unregister(indio_dev);
iio_trigger_unregister(data->trig);
--
2.53.0
next prev parent reply other threads:[~2026-02-18 4:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 4:37 [PATCH v4 0/9] iio: light: gp2ap020a00f: General cleanup and Ethan Tidmore
2026-02-18 4:37 ` [PATCH v4 1/9] iio: light: gp2ap020a00f: simplify locking with guard() Ethan Tidmore
2026-02-18 7:08 ` Andy Shevchenko
2026-02-20 2:38 ` Ethan Tidmore
2026-02-20 7:43 ` Andy Shevchenko
2026-02-18 4:37 ` [PATCH v4 2/9] iio: light: gp2ap020a00f: correct return type to int Ethan Tidmore
2026-02-18 4:37 ` [PATCH v4 3/9] iio: light: gp2ap020a00f: Use correct types for 16-bit LE data Ethan Tidmore
2026-02-18 4:37 ` [PATCH v4 4/9] iio: light: gp2ap020a00f: Replace custom implementation of min() Ethan Tidmore
2026-02-18 4:37 ` [PATCH v4 5/9] iio: light: gp2ap020a00f: Return directly from the switch cases Ethan Tidmore
2026-02-19 19:32 ` Ethan Tidmore
2026-02-19 20:00 ` Andy Shevchenko
2026-02-18 4:37 ` Ethan Tidmore [this message]
2026-02-18 4:37 ` [PATCH v4 7/9] iio: light: gp2ap020a00f: Explicitly use string literal for driver name Ethan Tidmore
2026-02-18 4:37 ` [PATCH v4 8/9] iio: light: gp2ap020a00f: Remove trailing comma in termination entry Ethan Tidmore
2026-02-18 4:37 ` [PATCH v4 9/9] iio: light: gp2ap020a00f: Join some lines of code to be a single line Ethan Tidmore
2026-02-18 7:10 ` [PATCH v4 0/9] iio: light: gp2ap020a00f: General cleanup and Andy Shevchenko
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=20260218043728.609659-7-ethantidmore06@gmail.com \
--to=ethantidmore06@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox