public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Urs Fleisch <urs.fleisch@gmail.com>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	LM Sensors <lm-sensors@lm-sensors.org>,
	Jean Delvare <khali@linux-fr.org>
Subject: Re: [PATCH V3] hwmon: driver for Sensirion SHT21 humidity and temperature sensor
Date: Mon, 3 Jan 2011 07:12:42 -0800	[thread overview]
Message-ID: <20110103151242.GC25600@ericsson.com> (raw)
In-Reply-To: <20110103150134.e4858844.urs.fleisch@gmail.com>

On Mon, Jan 03, 2011 at 09:01:34AM -0500, Urs Fleisch wrote:
> Hi Jonathan,
> 
> > Is there actualy a use case that means these can't both be set
> > by platform data?  Also, if these are acceptable, should they have
> > some means of indicating which combination of values are available?
> 
> I can imagine a use case where an embedded device wants to operate in a
> low-power mode while still monitoring humidity and/or temperature. Measurement
> time and thus power consumption of the SHT21 are significantly smaller when
> using a low resolution. Or you can use a low resolution while waiting for a
> significant change in humidity and/or temperature and then switch to a higher
> resolution to actually report the measurement values.
> 
> > Rely on platform data to get this right rather than an adhoc test that
> > might well pass on some random devices.
> 
> I removed that probing stuff. As read and write addresses for the user
> register are different, it would probably not pass on another device, but it
> could disturb another device.
> 
> > Sorry to say I missed some error handling issues the first time around.
> > Please always provide userspace with the most detailed and correct error
> > possible. Normally this is the one comming up from the bus subsystem.
> 
> All error codes should now be passed up to userspace.
> 
> Thanks again,
> Urs
> 
> Signed-off-by: Urs Fleisch <urs.fleisch@sensirion.com>

All the above shows up in the commit log if the patch is applied. Just adds
additional work for the maintainers.

> ---
[ ...] 
> +
> +/**
> + * sht21_show_temperature() - show temperature measurement value in sysfs
> + * @dev: device
> + * @attr: device attribute
> + * @buf: sysfs buffer (PAGE_SIZE) where measurement values are written to
> + *
> + * Will be called on read access to temp1_input sysfs attribute.
> + * Returns number of bytes written into buffer, negative errno on error.
> + */
> +static ssize_t sht21_show_temperature(struct device *dev,
> +       struct device_attribute *attr,
> +       char *buf)
> +{
> +       struct i2c_client *client = to_i2c_client(dev);
> +       int result = sht21_update_measurements(client);
> +       if (result >= 0) {
> +               struct sht21 *sht21 = i2c_get_clientdata(client);
> +
> +               return sprintf(buf, "%d\n", sht21->temperature);
> +       }
> +       return result;

Highly unusual way of detecting and returning errors. Common would be

	if (result < 0)
		return result;
	/* other code */

ie keep the code flow intact. Makes the code much easier to read.

Guenter

  reply	other threads:[~2011-01-03 15:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-29 12:45 [PATCH] hwmon: driver for Sensirion SHT21 humidity and temperature sensor Urs Fleisch
2010-12-31 15:02 ` Jonathan Cameron
2011-01-03  7:14   ` Urs Fleisch
2011-01-03 11:06     ` Jonathan Cameron
2011-01-03 14:01       ` [PATCH V3] " Urs Fleisch
2011-01-03 15:12         ` Guenter Roeck [this message]
2011-01-03 14:53       ` [PATCH] " Guenter Roeck
2011-01-03 18:09       ` Guenter Roeck
2011-01-04 12:13         ` Jonathan Cameron
2011-01-04 15:28           ` Guenter Roeck
2011-01-04 19:00             ` Urs Fleisch
2011-01-04 19:42               ` Guenter Roeck
2011-01-06  7:43                 ` [PATCH V4] " Urs Fleisch
2011-01-06 10:58                   ` Jonathan Cameron
2011-01-06 15:21                     ` Guenter Roeck
2011-01-06 15:56                   ` Guenter Roeck
2011-01-07  7:15                     ` [PATCH V5] " Urs Fleisch
2011-01-07 11:55                       ` Guenter Roeck

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=20110103151242.GC25600@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --cc=jic23@cam.ac.uk \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=urs.fleisch@gmail.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