All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waqar Hameed <waqar.hameed@axis.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@kernel.org>, <linux-iio@vger.kernel.org>,
	<kernel@axis.com>, <linux-kernel@vger.kernel.org>,
	<kernel@lists.axis.com>
Subject: Re: [PATCH 2/2] iio: Add driver for Murata IRS-D200
Date: Mon, 19 Jun 2023 13:21:51 +0200	[thread overview]
Message-ID: <pndsfan1mev.fsf@axis.com> (raw)
In-Reply-To: <682cf4f8-ba1b-d74a-c744-6aa484c1acd5@metafoo.de>

On Fri, Jun 16, 2023 at 18:37 -0700 Lars-Peter Clausen <lars@metafoo.de> wrote:

> On 6/16/23 08:10, Waqar Hameed wrote:
>> Murata IRS-D200 is a PIR sensor for human detection. It has support for
>> raw data measurements and detection event notification.
>>
>> Add a driver with support for triggered buffer and events. Map the
>> various settings to the `iio` framework, e.g. threshold values, sampling
>> frequency, filter frequencies etc.
>>
>> Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
>
> Looks very good, small minor comments.

Thanks!

[...]

>> index 000000000000..699801d60295
>> --- /dev/null
>> +++ b/drivers/iio/proximity/irsd200.c
>> @@ -0,0 +1,1051 @@
>> [...]
>> +/*
>> + * The upper 4 bits in register IRS_REG_COUNT value is the upper count value
>> + * (exceeding upper threshold value). The lower 4 is the lower count value
>> + * (exceeding lower threshold value).
>> + */
>> +#define IRS_UPPER_COUNT(count)	(count >> 4)
>> +#define IRS_LOWER_COUNT(count)	(count & GENMASK(3, 0))
>
> Usually we add parenthesis around macro arguments to avoid issues in case the
> argument is a non-singular expression.

Of course! Will use `FIELD_GET()` as Jonathan suggests.

>> [...]
>>
>> +static int irsd200_read_data(struct irsd200_data *data, s16 *val)
>> +{
>> +	unsigned int tmpval;
>> +	int ret;
>> +
>> +	ret = regmap_read(data->regmap, IRS_REG_DATA_HI, &tmpval);
>> +	if (ret < 0) {
>> +		dev_err(data->dev, "Could not read hi data (%d)\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	*val = (s16)(tmpval << 8);
>> +
>> +	ret = regmap_read(data->regmap, IRS_REG_DATA_LO, &tmpval);
>> +	if (ret < 0) {
>> +		dev_err(data->dev, "Could not read lo data (%d)\n", ret);
>> +		return ret;
>> +	}
> Is there a way to bulk read those registers in one go to avoid inconsistent data
> if they change while being read?

Yes, will use `regmap_bulk_read()`.

>> +	*val |= tmpval;
>> +
>> +	return 0;
>> +}
>> [...]
>> +static int irsd200_write_raw(struct iio_dev *indio_dev,
>> +			     struct iio_chan_spec const *chan, int val,
>> +			     int val2, long mask)
>> +{
>> +	struct irsd200_data *data = iio_priv(indio_dev);
>> +	int ret;
>> +
>> +	switch (mask) {
>> +	case IIO_CHAN_INFO_SAMP_FREQ:
>> +		ret = irsd200_write_data_rate(data, val);
>> +		return ret;
> Maybe just `return irsd200_write_data_rate(...)`

Of course! (Remnant from a refactorization... Sorry!)

>> +	default:
>> +		return -EINVAL;
>> +	}
>> +}
>> +
>>
>> [...]
>> +static int irsd200_probe(struct i2c_client *client)
>> +{
>> +	struct iio_trigger *trigger;
>> +	struct irsd200_data *data;
>> +	struct iio_dev *indio_dev;
>> +	struct regmap *regmap;
>> +	size_t i;
>> +	int ret;
>> +
>> +	regmap = devm_regmap_init_i2c(client, &irsd200_regmap_config);
>> +	if (IS_ERR(regmap)) {
>> +		dev_err(&client->dev, "Could not initialize regmap\n");
> dev_err_probe() is the more modern variant for error reporting in the probe
> function. Same for all the other dev_err() in this function.

Alright, I'll change to `dev_err_probe()`.

  reply	other threads:[~2023-06-19 15:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 15:10 [PATCH 0/2] Add driver for Murata IRS-D200 Waqar Hameed
2023-06-16 15:10 ` [PATCH 1/2] dt-bindings: iio: proximity: Add bindings " Waqar Hameed
2023-06-17  8:55   ` Krzysztof Kozlowski
2023-06-19 10:40     ` Waqar Hameed
2023-06-19 11:29       ` Krzysztof Kozlowski
2023-06-17 12:55   ` Jonathan Cameron
2023-06-19 10:41     ` Waqar Hameed
2023-07-02 10:34       ` Jonathan Cameron
2023-06-16 15:10 ` [PATCH 2/2] iio: Add driver " Waqar Hameed
2023-06-17  1:37   ` Lars-Peter Clausen
2023-06-19 11:21     ` Waqar Hameed [this message]
2023-06-17 13:35   ` Jonathan Cameron
2023-06-19 11:24     ` Waqar Hameed
2023-06-25 11:06       ` Jonathan Cameron
2023-06-30  8:54         ` Waqar Hameed
2023-07-02 10:42           ` Jonathan Cameron
2023-07-03  8:59             ` Waqar Hameed
2023-07-05  7:50               ` Jonathan Cameron
2023-07-12 15:33         ` Waqar Hameed
2023-07-15 16:51           ` Jonathan Cameron

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=pndsfan1mev.fsf@axis.com \
    --to=waqar.hameed@axis.com \
    --cc=jic23@kernel.org \
    --cc=kernel@axis.com \
    --cc=kernel@lists.axis.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@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.