[PATCH v3 6/6] iio: light: vcnl4000: use variables for I2C client and device instances

Erikas Bitovtas
2026-03-14T16:06:46Z

After moving data->client and client->dev into variables of their own,
replace all instances of data->client and client->dev being used in
vcnl4200_init and vcnl4000_probe by the said variables to reduce
clutter.

Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index c8bb1826b916..9b7cd3f0c8fb 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -362,14 +362,14 @@ static int vcnl4200_init(struct vcnl4000_data *data)
int ret, id;
u16 regval;

- ret = i2c_smbus_read_word_data(data->client, VCNL4200_DEV_ID);
+ ret = i2c_smbus_read_word_data(client, VCNL4200_DEV_ID);
if (ret < 0)
return ret;

id = ret & 0xff;

if (id != VCNL4200_PROD_ID) {
- ret = i2c_smbus_read_word_data(data->client, VCNL4040_DEV_ID);
+ ret = i2c_smbus_read_word_data(client, VCNL4040_DEV_ID);
if (ret < 0)
return ret;

@@ -379,7 +379,7 @@ static int vcnl4200_init(struct vcnl4000_data *data)
return -ENODEV;
}

- dev_dbg(&data->client->dev, "device id 0x%x", id);
+ dev_dbg(dev, "device id 0x%x", id);

data->rev = (ret >> 8) & 0xf;
data->ps_int = 0;
@@ -413,23 +413,23 @@ static int vcnl4200_init(struct vcnl4000_data *data)
return ret;

/* Use 16 bits proximity sensor readings */
- ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1);
+ ret = i2c_smbus_read_word_data(client, VCNL4200_PS_CONF1);
if (ret < 0)
return ret;

regval = ret | VCNL4040_PS_CONF2_PS_HD;
- ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1,
+ ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF1,
regval);
if (ret < 0)
return ret;

/* Align proximity sensor sample rate to 16 bits data width */
- ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF3);
+ ret = i2c_smbus_read_word_data(client, VCNL4200_PS_CONF3);
if (ret < 0)
return ret;

regval = ret | VCNL4040_CONF3_PS_SAMPLE_16BITS;
- ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF3,
+ ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF3,
regval);
if (ret < 0)
return ret;
@@ -1998,7 +1998,7 @@ static int vcnl4000_probe(struct i2c_client *client)
struct device *dev = &client->dev;
int ret;

- indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;

@@ -2022,10 +2022,10 @@ static int vcnl4000_probe(struct i2c_client *client)
if (ret < 0)
return ret;

- dev_dbg(&client->dev, "%s Ambient light/proximity sensor, Rev: %02x\n",
+ dev_dbg(dev, "%s Ambient light/proximity sensor, Rev: %02x\n",
data->chip_spec->prod, data->rev);

- if (device_property_read_u32(&client->dev, "proximity-near-level",
+ if (device_property_read_u32(dev, "proximity-near-level",
&data->near_level))
data->near_level = 0;

@@ -2037,7 +2037,7 @@ static int vcnl4000_probe(struct i2c_client *client)

if (data->chip_spec->trig_buffer_func &&
data->chip_spec->buffer_setup_ops) {
- ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev,
+ ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
NULL,
data->chip_spec->trig_buffer_func,
data->chip_spec->buffer_setup_ops);
@@ -2046,8 +2046,8 @@ static int vcnl4000_probe(struct i2c_client *client)
}

if (client->irq && data->chip_spec->irq_thread) {
- ret = devm_request_threaded_irq(&client->dev, client->irq,
- NULL, data->chip_spec->irq_thread,
+ ret = devm_request_threaded_irq(dev, client->irq, NULL,
+ data->chip_spec->irq_thread,
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT,
"vcnl4000_irq",
@@ -2060,7 +2060,7 @@ static int vcnl4000_probe(struct i2c_client *client)
return ret;
}

- ret = pm_runtime_set_active(&client->dev);
+ ret = pm_runtime_set_active(dev);
if (ret < 0)
goto fail_poweroff;

@@ -2068,9 +2068,9 @@ static int vcnl4000_probe(struct i2c_client *client)
if (ret < 0)
goto fail_poweroff;

- pm_runtime_enable(&client->dev);
- pm_runtime_set_autosuspend_delay(&client->dev, VCNL4000_SLEEP_DELAY_MS);
- pm_runtime_use_autosuspend(&client->dev);
+ pm_runtime_enable(dev);
+ pm_runtime_set_autosuspend_delay(dev, VCNL4000_SLEEP_DELAY_MS);
+ pm_runtime_use_autosuspend(dev);

return 0;
fail_poweroff:

--
2.53.0