mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Andreas Klinger <ak@it-klinger.de>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Angel Iglesias <ang.iglesiasg@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] iio: pressure: Honeywell mpr pressure sensor
Date: Sat, 1 Apr 2023 11:29:00 -0700	[thread overview]
Message-ID: <5c142a1b-c413-66b2-86d9-b8c95ed46241@metafoo.de> (raw)
In-Reply-To: <ZCf085W4XL2PtQf6@arbad>

Hi,

Looks pretty good. Jonathan already covered most of it, a few additional 
comments.

On 4/1/23 02:10, Andreas Klinger wrote:
> [...]
> +struct mpr_data {
> +	struct device		*dev;
> +	void			*client;

Any reason not to use `struct i2c_client` for the type?

> +	struct mutex		lock;
> +	s32			pmin;
> +	s32			pmax;
> +	struct gpio_desc	*gpiod_reset;
> +	int			irq;
> +	struct completion	completion;
> +	s64			channel[2] __aligned(8);
> +};
> +
> [...]
> +static int mpr_read_pressure(struct mpr_data *data, s64 *press)
> +{
> +	int ret, i;
> +	u8 wdata[] = {0xAA, 0x00, 0x00};
> +	s32 status;
> +	int nloops = 10;
> +	char buf[5];
The tx buffer is `u8`, the rx buffer is `char`. This should be consistent.
> +	s64 press_cnt;
> +	s64 outputmin = 1677722;
> +	s64 outputmax = 15099494;
> +
> +	reinit_completion(&data->completion);
> +
> +	ret = i2c_master_send(data->client, wdata, sizeof(wdata));

The i2c family of transfer functions returns the number of bytes 
transferred, this can be less than what you expect if you get an early 
NACK. Its always good to check that all the data was transferred. E.g.

if (ret >= 0 && ret != sizeof(wdata))

    ret = -EIO;

Same for the receive later on.

[...]

  parent reply	other threads:[~2023-04-01 18:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01  9:10 Andreas Klinger
2023-04-01 12:05 ` kernel test robot
2023-04-01 17:57 ` Jonathan Cameron
2023-04-06 19:43   ` Andreas Klinger
2023-04-08 11:29     ` Jonathan Cameron
2023-04-01 18:29 ` Lars-Peter Clausen [this message]
2023-04-02  3:02 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-04-01  9:09 [PATCH 1/3] dt-bindings: iio: pressure: Support Honeywell mpr sensors Andreas Klinger
2023-04-01  9:42 ` Krzysztof Kozlowski
2023-04-01 15:27   ` Jonathan Cameron
2023-04-06 20:15     ` Andreas Klinger
2023-04-07  6:45       ` Krzysztof Kozlowski
2023-04-14  7:27   ` Andreas Klinger
2023-04-14  7:52     ` Krzysztof Kozlowski
2023-04-01 15:22 ` 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=5c142a1b-c413-66b2-86d9-b8c95ed46241@metafoo.de \
    --to=lars@metafoo.de \
    --cc=ak@it-klinger.de \
    --cc=ang.iglesiasg@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®