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] hwmon/w83781d: Add individual alarm and
Date: Sun, 07 Oct 2007 19:11:20 +0000	[thread overview]
Message-ID: <47092F58.5020808@hhs.nl> (raw)
In-Reply-To: <20071007205740.0c52f8cf@hyperion.delvare>

Jean Delvare wrote:
> The upcoming libsensors 3 needs these individual alarm and beep files.
> For the W83781D, this is quirky because this chip has a single alarm
> bit for both temp2 and temp3.
> 

Here is a quick review:

<snip>

> +static ssize_t
> +store_beep(struct device *dev, struct device_attribute *attr,
> +		const char *buf, size_t count)
> +{
> +	struct w83781d_data *data = w83781d_update_device(dev);
> +	int bitnr = to_sensor_dev_attr(attr)->index;
> +	unsigned long bit;
> +	u8 reg;
> +

You've just thought me not to call foo_update_device() in store functions, 
since I agree with your assessment that calling foo_update_device() in store 
functions is bad, please fix this.

> +	bit = simple_strtoul(buf, NULL, 10);
> +	if (bit & ~1)
> +		return -EINVAL;
 > +	bit <<= bitnr;
 > +
 > +	mutex_lock(&data->update_lock);
 > +	data->beep_mask &= ~(1 << bitnr);
 > +	data->beep_mask |= bit;

Hmm, we need a clearer convention for writes to sysfs attr which are a boolean. 
In both of my abituguru drivers and in the fschmd driver I use:
	unsigned long bool = bit = simple_strtoul(buf, NULL, 10);

And then
	if (bool)
		...
	else
		...

Your code above does things different. So I think we need a convention for this 
(and add the conention to the sysfs-interface doc). I prefer my way, if only 
for not having to change it everywhere. I would like to suggest the following 
for your code:

 > +	bit = simple_strtoul(buf, NULL, 10);
 > +
 > +	mutex_lock(&data->update_lock);
 > +	if (bit)
 > +		data->beep_mask |= 1 << bitnr;
 > +	else
 > +		data->beep_mask &= ~(1 << bitnr);

I must say I also find this more readable / cleaner.

<rest snipped, is ok>

Regards

Hans

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

  reply	other threads:[~2007-10-07 19:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-07 18:57 [lm-sensors] [PATCH] hwmon/w83781d: Add individual alarm and beep Jean Delvare
2007-10-07 19:11 ` Hans de Goede [this message]
2007-10-08  8:49 ` [lm-sensors] [PATCH] hwmon/w83781d: Add individual alarm and Jean Delvare
2007-10-08 16:29 ` [lm-sensors] [PATCH] hwmon/w83781d: Add individual alarm and beep Jean Delvare
2007-10-08 18:02 ` [lm-sensors] [PATCH] hwmon/w83781d: Add individual alarm and Hans de Goede
2007-10-09  0:59 ` Mark M. Hoffman

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=47092F58.5020808@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.