linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: Add tmp006 IR temperature sensor
Date: Sun, 04 Aug 2013 15:49:09 +0200	[thread overview]
Message-ID: <51FE5BD5.3060700@metafoo.de> (raw)
In-Reply-To: <1375136888-19978-1-git-send-email-pmeerw@pmeerw.net>

On 07/30/2013 12:28 AM, Peter Meerwald wrote:
[...]
> +static int tmp006_read_raw(struct iio_dev *indio_dev,
> +			    struct iio_chan_spec const *channel, int *val,
> +			    int *val2, long mask)
> +{
> +	struct tmp006_data *data = iio_priv(indio_dev);
> +	s32 ret;
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW:
> +		if (channel->type == IIO_VOLTAGE) {
> +			ret = tmp006_read_measurement(data, TMP006_VOBJECT);
> +			if (ret < 0)
> +				return ret;
> +			*val = (s16) ret;
> +		} else if (channel->type == IIO_TEMP) {
> +			ret = tmp006_read_measurement(data, TMP006_TAMBIENT);
> +			if (ret < 0)
> +				return ret;
> +			*val = (s16) ret >> 2;
> +		} else
> +			break;

Needs braces around the last else branch.

> +		return IIO_VAL_INT;
> +	case IIO_CHAN_INFO_SCALE:
> +		if (channel->type == IIO_VOLTAGE) {
> +			*val = 0;
> +			*val2 = 156250;
> +		} else if (channel->type == IIO_TEMP) {
> +			*val = 31;
> +			*val2 = 250000;
> +		} else
> +			break;

Same here.

> +		return IIO_VAL_INT_PLUS_MICRO;
> +	default:
> +		break;
> +	}
> +
> +	return -EINVAL;
> +}
> +

[...]
> +
> +static int tmp006_probe(struct i2c_client *client,
> +			 const struct i2c_device_id *id)
> +{
> +	struct iio_dev *indio_dev;
> +	struct tmp006_data *data;
> +	int ret;
> +
> +	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
> +		return -ENODEV;
> +
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	data = iio_priv(indio_dev);
> +	i2c_set_clientdata(client, indio_dev);
> +	data->client = client;
> +
> +	indio_dev->dev.parent = &client->dev;
> +	indio_dev->name = dev_name(&client->dev);
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +	indio_dev->info = &tmp006_info;
> +
> +	indio_dev->channels = tmp006_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(tmp006_channels);
> +
> +	if (!tmp006_check_identification(data)) {
> +		dev_err(&client->dev, "no TMP006 sensor\n");
> +		return -ENODEV;
> +	}
> +
> +	dev_info(&client->dev, "TMP006 IR thermophile sensor\n");

That's just noise.

> +
> +	ret = i2c_smbus_read_word_swapped(data->client, TMP006_CONFIG);
> +	if (ret < 0)
> +		return ret;
> +	data->config = ret;
> +
> +	ret = iio_device_register(indio_dev);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
return 0;
> +}
[...]


      parent reply	other threads:[~2013-08-04 13:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 22:28 [PATCH] iio: Add tmp006 IR temperature sensor Peter Meerwald
2013-08-04 10:39 ` Jonathan Cameron
2013-08-04 13:22   ` Guenter Roeck
2013-08-05 11:10   ` Grygorii Strashko
2013-08-04 13:49 ` Lars-Peter Clausen [this message]

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=51FE5BD5.3060700@metafoo.de \
    --to=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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;
as well as URLs for NNTP newsgroup(s).