[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5630942F.1020705@baylibre.com>
Date: Wed, 28 Oct 2015 10:23:59 +0100
From: Marc Titinger <mtitinger@...libre.com>
To: Guenter Roeck <linux@...ck-us.net>
Cc: jdelvare@...e.com, lm-sensors@...sensors.org,
linux-kernel@...r.kernel.org, mturquette@...libre.com,
bcousson@...libre.com, ptitiano@...libre.com
Subject: Re: [PATCH v2 1/2] hwmon: ina2xx: convert driver to using regmap
On 28/10/2015 03:47, Guenter Roeck wrote:
> On Tue, Oct 27, 2015 at 10:51:07AM +0100, Marc Titinger wrote:
>> Any sysfs "show" read access from the client app will result in reading
>> all registers (8 with ina226). Depending on the host this can limit the
>> best achievable read rate.
>>
>> This changeset allows for individual register accesses through regmap.
>>
>> Tested with BeagleBone Black (Baylibre-ACME) and ina226.
>>
>> Signed-off-by: Marc Titinger <mtitinger@...libre.com>
>> ---
>>
>> v2:
>> - rename 'rv' to 'regval' for clarity
>> - fix missed smbus_xxx api change to regmap
>> - rename ina2xx_do_update to ina2xx_read_reg
>> - fix indentation
>>
>> drivers/hwmon/ina2xx.c | 211 +++++++++++++++++++------------------------------
>> 1 file changed, 82 insertions(+), 129 deletions(-)
>>
>> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
>> index 4d28150..5e7ada8 100644
>> --- a/drivers/hwmon/ina2xx.c
>> +++ b/drivers/hwmon/ina2xx.c
>
> [ ... ]
>>
>> - mutex_lock(&data->update_lock);
>> data->rshunt = val;
>> status = ina2xx_calibrate(data);
>> - mutex_unlock(&data->update_lock);
>
> I think this can result in a race conditon if multiple processes
> try to update the shunt resistor value at the same time in a
> multi-core system. There is no guarantee that the value programmed
> into the chip matches the value that is written into 'rshunt'.
> So I think we still need the mutex, unless you have a better
> idea how to avoid the race.
>
Right, I had that same afterthought when removing the mutex at that
position. Fix incoming!
M.
> Thanks,
> Guenter
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists