From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Thomas Bonnefille <thomas.bonnefille@bootlin.com>
Cc: "Puranjay Mohan" <puranjay@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: temperature: tmp117: add support for HIGH and LOW alerts
Date: Tue, 06 Oct 2026 16:09:16 +0200 [thread overview]
Message-ID: <87se2ihqer.fsf@bootlin.com> (raw)
In-Reply-To: <20261005-add-tmp117-notif-v1-2-c6cef6fad64c@bootlin.com> (Thomas Bonnefille's message of "Mon, 05 Oct 2026 16:44:20 +0200")
Hi Thomas,
The code overall looks fine but I have a couple of style improvement
proposals.
> +
> + /*
> + * The threshold is passed in millidegrees Celsius as
> + * value = val + val2 / 1000000 (val2 holds the fractional part, with
> + * the sign taken from val). Convert it back with the same LSB ratio:
> + * raw = value / (TMP117_LIMIT_LSB_NUM / TMP117_LIMIT_LSB_DEN).
> + */
> + tmp = (val < 0) ? (s64)val * 1000000 - val2
> + : (s64)val * 1000000 + val2;
^
Usually operators stay at the end of the previous line
> + tmp = DIV_ROUND_CLOSEST(tmp * TMP117_LIMIT_LSB_DEN,
> + (s64)TMP117_LIMIT_LSB_NUM * 1000000);
> + tmp = clamp_t(s64, tmp, S16_MIN, S16_MAX);
> +
> + return i2c_smbus_write_word_swapped(data->client,
> + reg, tmp);
Overall the wrapping looks too aggressive in several places
> +}
...
> static int tmp117_probe(struct i2c_client *client)
> @@ -208,6 +343,16 @@ static int tmp117_probe(struct i2c_client *client)
> indio_dev->num_channels = match_data->num_channels;
> indio_dev->name = match_data->name;
>
> + if (client->irq) {
Since you're adding the binding for it, I'm surprised the irq already
exists?
> + ret = devm_request_threaded_irq(&client->dev, client->irq,
> + NULL, tmp117_interrupt_handler,
> + IRQF_ONESHOT, match_data->name,
> + indio_dev);
> + if (ret) {
> + dev_err_probe(&client->dev, ret, "irq request error\n");
> + return ret;
Isn't dev_err_probe() return ret already? so return `dev_err_probe()`?
> + }
> + }
>
> return devm_iio_device_register(&client->dev, indio_dev);
> }
Thanks,
Miquèl
prev parent reply other threads:[~2026-10-06 14:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 14:44 [PATCH 0/2] Add interrupt support on TMP117 Thomas Bonnefille
2026-10-05 14:44 ` [PATCH 1/2] dt-bindings: iio: ti,tmp117: describe interrupts for TMP117 Thomas Bonnefille
2026-10-05 14:44 ` [PATCH 2/2] iio: temperature: tmp117: add support for HIGH and LOW alerts Thomas Bonnefille
2026-10-06 4:47 ` kernel test robot
2026-10-06 6:02 ` kernel test robot
2026-10-06 14:09 ` Miquel Raynal [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=87se2ihqer.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=puranjay@kernel.org \
--cc=robh@kernel.org \
--cc=thomas.bonnefille@bootlin.com \
--cc=thomas.petazzoni@bootlin.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
all inboxes | Powered by JetHome®