Re: [PATCH v6 2/4] iio: light: add support for veml6031x00 ALS series
From: Javier Carrasco
Date: Fri Aug 14 2026 - 05:24:08 EST
On Fri Aug 14, 2026 at 11:07 AM CEST, Andy Shevchenko wrote:
> On Fri, Aug 14, 2026 at 10:58:10AM +0200, Javier Carrasco wrote:
>> On Fri Aug 14, 2026 at 9:49 AM CEST, Andy Shevchenko wrote:
>> > On Thu, Aug 13, 2026 at 11:46:32AM +0200, Javier Carrasco wrote:
>> >> Hello Andy, thank you again for your thorough review.
>> >> On Thu Aug 13, 2026 at 8:59 AM CEST, Andy Shevchenko wrote:
>> >> > On Wed, Aug 12, 2026 at 10:27:41PM +0200, Javier Carrasco wrote:
>
> ...
>
>> >> >> + data->regmap = devm_regmap_init_i2c(i2c, &veml6031x00_regmap_config);
>> >> >> + if (IS_ERR(data->regmap))
>> >> >> + return dev_err_probe(dev, PTR_ERR(data->regmap),
>> >> >> + "Failed to set regmap\n");
>> >> >
>> >> > Is debugfs access already enabled for regmap after this call? Perhaps you want
>> >> > mutex to be initialised before that?
>> >>
>> >> Could you please explain what you are trying to avoid? Even if the
>> >> debugfs is already enabled for regmap at this point, what is the
>> >> possible race condition?
>> >
>> > That's my question to you. If you think there is none, then we are all good.
>> > Basically the Q is if that mutex (that is initialised later in the probe) is
>> > required for the device IO which might be possible immediately when regmap
>> > is registered.
>> >
>> >> The IIO device is still not registered at this
>> >> point, and the registers are set to their right values in _hw_init()
>> >> after the mutexes were initialized. Moving the mutex initialization a
>> >> couple of lines towards the top is not an issue, but I would like to
>> >> understand the reasoning behind.
>> >
>> > User may read (and depending on the driver case writing) the register map.
>> > Would it be a problem?
>>
>> That is not a problem, as no assumptions about the original values are
>> made.
>
> It's not about the values, it's about the *access* HW during that time when
> there is no mutex available yet.
>
There is no issue with that either. The mutex serializes the access to
multiple registers that store the scale to provide a consistent value
that can't be manipulated by other accesses (e.g. debugfs). That does
not have any meaning as long as the IIO device has been registered,
which of course happens after the mutex initialization.
Best regards,
Javier