From: Philip Pokorny <ppokorny@penguincomputing.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Subject: Re: [PATCH] More i2c driver changes for 2.5.70
Date: Wed, 11 Jun 2003 19:40:09 -0700 [thread overview]
Message-ID: <3EE7E809.1000005@penguincomputing.com> (raw)
In-Reply-To: 10553638062379@kroah.com
I think there is a race condition here in the "set" functions.
I had added a down()/up() semaphore pair to the write clauses of the
functions in the pre-sysfs driver to prevent the xx_update_client() call
from modifying the cached values at the same time that the set_xxx()
function was trying to change them.
So for example:
> static ssize_t set_temp_max(struct device *dev, const char *buf,
> size_t count, int nr)
> {
> struct i2c_client *client = to_i2c_client(dev);
> struct lm85_data *data = i2c_get_clientdata(client);
>
> int val = simple_strtol(buf, NULL, 10);
> + down(&data->update_lock);
> data->temp_max[nr] = TEMP_TO_REG(val);
> lm85_write_value(client, LM85_REG_TEMP_MAX(nr),
> data->temp_max[nr]);
> + up(&data->update_lock);
> return count;
> }
Isn't that still needed?
:v)
Greg KH wrote:
> ChangeSet 1.1419.1.3, 2003/06/11 11:42:47-07:00, margitsw@t-online.de
>
> [PATCH] I2C: add LM85 driver
>
> Nothing extra in sysfs (yet) but I have left the way open in the driver
> to do this.
> Provides vid, vrm, fan_input(1-4), fan_min(1-4), pwm(1-3),
> pwm_enable(1-3), in_input(0-4), in_min(0-4), in_max(0-4),
> temp_input(1-3), temp_min(1-3), temp_max(1-3), alarms.
>
>
> drivers/i2c/chips/Kconfig | 19
> drivers/i2c/chips/Makefile | 1
> drivers/i2c/chips/lm85.c | 1223 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 1241 insertions(+), 2 deletions(-)
>
> +static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + struct lm85_data *data = i2c_get_clientdata(client);
> +
> + lm85_update_client(client);
> + return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]) );
> +}
> +static ssize_t set_temp_max(struct device *dev, const char *buf,
> + size_t count, int nr)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + struct lm85_data *data = i2c_get_clientdata(client);
> +
> + int val = simple_strtol(buf, NULL, 10);
> + data->temp_max[nr] = TEMP_TO_REG(val);
> + lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
> + return count;
> +}
--
Philip Pokorny, Director of Engineering
Tel: 415-358-2635 Fax: 415-358-2646 Toll Free: 888-PENGUIN
PENGUIN COMPUTING, INC.
www.penguincomputing.com
next prev parent reply other threads:[~2003-06-12 2:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-11 20:35 [BK PATCH] More i2c driver changes for 2.5.70 Greg KH
2003-06-11 20:36 ` [PATCH] " Greg KH
2003-06-11 20:36 ` Greg KH
2003-06-11 20:36 ` Greg KH
2003-06-11 20:36 ` Greg KH
2003-06-11 20:36 ` Greg KH
2003-06-11 20:36 ` Greg KH
2003-06-12 2:40 ` Philip Pokorny [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-06-12 9:16 Margit Schubert-While
2003-06-12 10:22 Margit Schubert-While
2003-06-16 18:42 ` Greg KH
2003-06-18 12:18 ` Margit Schubert-While
2003-06-18 14:22 ` Greg KH
2003-06-18 15:53 ` Margit Schubert-While
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EE7E809.1000005@penguincomputing.com \
--to=ppokorny@penguincomputing.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@Stimpy.netroedge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox