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

Andy Shevchenko
2026-03-16T10:39:40Z

On Sat, Mar 14, 2026 at 06:06:35PM +0200, Erikas Bitovtas wrote:
> 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.

...

> - ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1,
> + ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF1,
> regval);

Now it's perfectly a single line.

ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF1, regval);

> 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);

Ditto.

> if (ret < 0)
> return ret;

> - 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;

The 'if' is redundant, I think you can drop it at some point, probably to avoid
churn in the follow up

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

Assuming data is allocated with kzalloc() or equivalent.

...

> - ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev,
> + ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
> NULL,

Now NULL can be moved to upper line.

> data->chip_spec->trig_buffer_func,
> data->chip_spec->buffer_setup_ops);

--
With Best Regards,
Andy Shevchenko