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

Erikas Bitovtas
2026-03-16T10:50:52Z

On 3/16/26 12:39 PM, Andy Shevchenko wrote:
> 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);
>

device_property_read_u32() throws an error if a property is missing.
Would data->near_level be left without an assigned default value in that
case?