All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] First cut of a adt7470 driver
Date: Fri, 13 Jul 2007 12:08:53 +0000	[thread overview]
Message-ID: <46976B55.8010803@hhs.nl> (raw)
In-Reply-To: <20070706211144.GI3435@tree.beaverton.ibm.com>

Hi All,

While actually updating the driver I realized I didn't respond to all points 
raised (I think), so here is my reply to the other points.

>> +static struct f71882fg_data *f71882fg_update_device(struct device * dev)
>> +{
>> +	struct f71882fg_data *data = dev_get_drvdata(dev);
>> +	int nr, reg, reg2;
>> +
>> +	mutex_lock(&data->update_lock);
>> +	
>> +	/* Update once every 60 seconds */
>> +	if ( time_after(jiffies, data->last_updated + 60 * HZ ) ||
>> +			!data->valid) {
> 
> You test last_updated here but update last_limits below.  Is that
> really what you intended?  last_limits isn't used anywhere in
> the driver.
> 

Good catch, will fix.

>> +static ssize_t store_in_max(struct device *dev, struct device_attribute
>> +	*devattr, const char *buf, size_t count)
>> +{
>> +	struct f71882fg_data *data = dev_get_drvdata(dev);
>> +	int val = simple_strtoul(buf, NULL, 10) / 8;
>> +	
>> +	if (val > 255)
>> +		val = 255;
> 
> This check won't catch the case where I feed your sysfs file "-4096"
> and the value inside f71882fg_data won't match what gets written to the
> port.  Granted, the maxim "If you write garbage to the control systems
> you deserve what you get" might apply here too.
> 

Notice that I use simple_strtoul, so val will never be < 0, if you write -4096 
strtoul will not recognize the - and return 0.

I know it looks strange to store the return value in an int then, but in some 
of the other store methods I need val to be signed, and for consistency I've 
thus stored it into an int everywhere.


Regards,

Hans


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2007-07-13 12:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-06 21:11 [lm-sensors] [PATCH] First cut of a adt7470 driver Darrick J. Wong
2007-07-07  8:21 ` Hans de Goede
2007-07-07  8:23 ` Hans de Goede
2007-07-08 16:53 ` Jean Delvare
2007-07-10 18:59 ` Darrick J. Wong
2007-07-10 23:33 ` Darrick J. Wong
2007-07-11  5:23 ` Hans de Goede
2007-07-11 12:47 ` Hans de Goede
2007-07-13 12:08 ` Hans de Goede [this message]
2007-07-14 14:23 ` Vadim Zeitlin
2007-07-14 20:05 ` Jean Delvare
2007-07-14 20:17 ` Hans de Goede
2007-07-16 20:18 ` Darrick J. Wong
2007-07-16 22:19 ` Philip Pokorny
2007-07-19 16:47 ` Jean Delvare
2007-07-19 16:57 ` Jean Delvare
2007-07-19 17:11 ` Hans de Goede
2007-07-21 20:07 ` Jean Delvare

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=46976B55.8010803@hhs.nl \
    --to=j.w.r.degoede@hhs.nl \
    --cc=lm-sensors@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.