From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Lakshay Piplani <lakshay.piplani@nxp.com>
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, marcelo.schmitt1@gmail.com,
gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk,
peterz@infradead.org, jstephan@baylibre.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, vikash.bansal@nxp.com,
priyanka.jain@nxp.com, shashank.rebbapragada@nxp.com,
Frank.Li@nxp.com, carlos.song@nxp.com, xiaoning.wang@nxp.com,
haibo.chen@nxp.com
Subject: Re: [PATCH 2/2] iio: temperature: Add driver for NXP P3T175x temperature sensor.
Date: Thu, 24 Jul 2025 14:59:25 +0300 [thread overview]
Message-ID: <aIIgHV38kKsPVCUN@smile.fi.intel.com> (raw)
In-Reply-To: <20250724083951.2273717-2-lakshay.piplani@nxp.com>
On Thu, Jul 24, 2025 at 02:09:51PM +0530, Lakshay Piplani wrote:
> Add support for the NXP P3T175x (P3T1755/P3T1750)
> family of temperature sensor devices. These devices
> communicates via both I2C or I3C interfaces.
...
> drivers/iio/temperature/p3t/Kconfig | 89 ++++
> drivers/iio/temperature/p3t/Makefile | 5 +
> drivers/iio/temperature/p3t/p3t1755.h | 60 +++
> drivers/iio/temperature/p3t/p3t1755_core.c | 513 +++++++++++++++++++++
> drivers/iio/temperature/p3t/p3t1755_i2c.c | 142 ++++++
> drivers/iio/temperature/p3t/p3t1755_i3c.c | 147 ++++++
Please, split glue drivers in a separate patches. At bare minimum it will help
reviewing the core part.
...
> +// Conversion rate table: maps bits to sampling frequency
> +static const struct {
> + u8 bits;
> + int freq_hz;
Can frequency be negative?
> +} p3t1755_samp_freqs[] = {
> + { 0x00, 36 }, // 27.5 ms
> + { 0x01, 18 }, // 55 ms (default)
> + { 0x02, 9 }, // 110 ms
> + { 0x03, 4 }, // 220 ms
If you need ms, make the field to be ms and not Hz.
Otherwise drop unneeded comments. Conversion from Hz to s is straightforward
for the 101 in school for physics.
> +};
...
> +int p3t1755_fault_queue_to_bits(int val)
> +{
> + int i;
Why signed?
> + for (i = 0; i < ARRAY_SIZE(p3t1755_fault_queue_values); i++)
> + if (p3t1755_fault_queue_values[i] == val)
> + return i;
> + return -EINVAL;
> +}
...
> +int p3t1755_get_temp_and_limits(struct p3t1755_data *data,
> + int *temp_mc, int *thigh_mc, int *tlow_mc)
> +{
> + u8 buf[2];
Not a proper bitwise endianess-aware type?
> + int ret;
> +
> + ret = regmap_bulk_read(data->regmap, P3T1755_REG_TEMP, buf, 2);
> + if (ret) {
> + dev_dbg(data->dev, "Failed to read TEMP register: %d\n", ret);
> + return ret;
> + }
> + *temp_mc = (((buf[0] << 8) | buf[1]) >> 4) * P3T1755_RESOLUTION_10UC / 1000;
Use constant from units.h or from time.h.
> + dev_dbg(data->dev, "TEMP raw: 0x%02x%02x, temp_mc: %d\n",
> + buf[0], buf[1], *temp_mc);
Printing raw with proper 126-bit type will be easier.
> + ret = regmap_bulk_read(data->regmap, P3T1755_REG_HIGH_LIM, buf, 2);
sizeof()
> + if (ret) {
> + dev_dbg(data->dev, "Failed to read HIGH_LIM register: %d\n", ret);
> + return ret;
> + }
> + *thigh_mc = (((buf[0] << 8) | buf[1]) >> 4) * P3T1755_RESOLUTION_10UC / 1000;
> + dev_dbg(data->dev, "HIGH_LIM raw: 0x%02x%02x, thigh_mc: %d\n",
> + buf[0], buf[1], *thigh_mc);
> +
> + ret = regmap_bulk_read(data->regmap, P3T1755_REG_LOW_LIM, buf, 2);
> + if (ret) {
> + dev_dbg(data->dev, "Failed to read LOW_LIM register: %d\n", ret);
> + return ret;
> + }
> + *tlow_mc = (((buf[0] << 8) | buf[1]) >> 4) * P3T1755_RESOLUTION_10UC / 1000;
> + dev_dbg(data->dev, "LOW_LIM raw: 0x%02x%02x, tlow_mc: %d\n",
> + buf[0], buf[1], *tlow_mc);
> +
> + dev_dbg(data->dev, "Successfully read all temperature values\n");
> + return 0;
> +}
...
> +#include <linux/kernel.h>
No way this header should be in a new code.
> +#include <linux/module.h>
> +#include <linux/i2c.h>
> +#include <linux/slab.h>
> +#include <linux/regmap.h>
> +#include <linux/of.h>
Neither this.
Hint: use device property API (or fwnode in the cases where no struct device is
available).
> +#include <linux/iio/iio.h>
> +#include <linux/iio/events.h>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-07-24 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 8:39 [PATCH 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
2025-07-24 8:39 ` [PATCH 2/2] iio: temperature: Add driver for NXP P3T175x temperature sensor Lakshay Piplani
2025-07-24 8:57 ` Krzysztof Kozlowski
2025-07-24 11:59 ` Andy Shevchenko [this message]
2025-07-24 12:29 ` Jonathan Cameron
2025-07-24 14:29 ` Frank Li
2025-07-24 9:02 ` [PATCH 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Krzysztof Kozlowski
2025-07-24 21:39 ` kernel test robot
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=aIIgHV38kKsPVCUN@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=Frank.Li@nxp.com \
--cc=andy@kernel.org \
--cc=carlos.song@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=haibo.chen@nxp.com \
--cc=jic23@kernel.org \
--cc=jstephan@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lakshay.piplani@nxp.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=nuno.sa@analog.com \
--cc=peterz@infradead.org \
--cc=priyanka.jain@nxp.com \
--cc=robh@kernel.org \
--cc=shashank.rebbapragada@nxp.com \
--cc=vikash.bansal@nxp.com \
--cc=viro@zeniv.linux.org.uk \
--cc=xiaoning.wang@nxp.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 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.