iio: light: vcnl4000: use variables for I2C client and device instances

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.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Erikas Bitovtas 2026-03-20 18:45:41 +02:00 committed by Jonathan Cameron
parent b10aecd9d5
commit c4380f9075

View File

@ -361,14 +361,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;
@ -378,7 +378,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;
@ -412,24 +412,22 @@ 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,
regval);
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,
regval);
ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF3, regval);
if (ret < 0)
return ret;
@ -1992,7 +1990,7 @@ static int vcnl4000_probe(struct i2c_client *client)
struct iio_dev *indio_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;
@ -2014,7 +2012,7 @@ static int vcnl4000_probe(struct i2c_client *client)
if (ret)
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",
@ -2029,8 +2027,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,
NULL,
ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
data->chip_spec->trig_buffer_func,
data->chip_spec->buffer_setup_ops);
if (ret < 0)
@ -2038,8 +2035,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",
@ -2052,7 +2049,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;
@ -2060,9 +2057,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: