From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755328AbbJ1CrP (ORCPT ); Tue, 27 Oct 2015 22:47:15 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:40988 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754305AbbJ1CrO (ORCPT ); Tue, 27 Oct 2015 22:47:14 -0400 Date: Tue, 27 Oct 2015 19:47:11 -0700 From: Guenter Roeck To: Marc Titinger Cc: jdelvare@suse.com, lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, bcousson@baylibre.com, ptitiano@baylibre.com Subject: Re: [PATCH v2 1/2] hwmon: ina2xx: convert driver to using regmap Message-ID: <20151028024711.GA30927@roeck-us.net> References: <20151027011229.GC31838@roeck-us.net> <1445939468-21755-1-git-send-email-mtitinger@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445939468-21755-1-git-send-email-mtitinger@baylibre.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > > 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. Thanks, Guenter