mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Lakshay Piplani <lakshay.piplani@nxp.com>,
	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
Cc: 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 10:57:58 +0200	[thread overview]
Message-ID: <e8b6a6bf-fe4a-4ff3-addf-142212368903@kernel.org> (raw)
In-Reply-To: <20250724083951.2273717-2-lakshay.piplani@nxp.com>

On 24/07/2025 10:39, Lakshay Piplani wrote:
> +
> +static void p3t1755_ibi_handler(struct i3c_device *dev,
> +				const struct i3c_ibi_payload *payload)
> +{
> +	struct iio_dev *indio_dev = dev_get_drvdata(&dev->dev);
> +
> +	dev_dbg(&dev->dev, "IBI received, handling threshold event\n");

Drop

> +
> +	// Handle threshold event via helper
> +	p3t1755_push_thresh_event(indio_dev);
> +}
> +
> +/*
> + * Both P3T1755 and P3T1750 share the same I3C
> + * PID (0x011B:0x152A), making runtime differentiation
> + * impossible, so a common "p3t175x" name in sysfs
> + * and IIO for I3C based instances.
> + */
> +static const struct i3c_device_id p3t1755_i3c_ids[] = {
> +	I3C_DEVICE(0x011B, 0x152A, (void *)&p3t175x_channels_info),
> +	{ /* sentinel */ },
> +};
> +
> +MODULE_DEVICE_TABLE(i3c, p3t1755_i3c_ids);
> +
> +static int p3t1755_i3c_probe(struct i3c_device *i3cdev)
> +{
> +	const struct regmap_config p3t1755_i3c_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	};
> +
> +	const struct i3c_device_id *id = i3c_device_match_id(i3cdev, p3t1755_i3c_ids);
> +	const struct p3t17xx_info *chip = &p3t175x_channels_info;
> +	struct device_node *np = i3cdev->dev.of_node;
> +	bool alert_active_high = false;
> +	struct i3c_ibi_setup ibi_setup;
> +	struct regmap *regmap;
> +	bool tm_mode = false;
> +	int fq_bits = -1;
> +	int ret;
> +
> +	regmap = devm_regmap_init_i3c(i3cdev, &p3t1755_i3c_regmap_config);
> +	if (IS_ERR(regmap)) {
> +		dev_err_probe(&i3cdev->dev, PTR_ERR(regmap),
> +			      "Failed to register I3C regmap %ld\n", PTR_ERR(regmap));
> +		return PTR_ERR(regmap);

Syntax is return dev_err_probe

> +	}
> +
> +	/* Parse optional device tree property for alert polarity */
> +	alert_active_high = of_property_read_bool(np, "nxp,alert-active-high");
> +
> +	/* Parse optional device tree property for thermostat mode */
> +	tm_mode = of_property_read_bool(np, "nxp,interrupt-mode");
> +
> +	/* Optional fault queue length */
> +	if (np) {
> +		u32 fq;
> +
> +		if (!of_property_read_u32(np, "nxp,fault-queue", &fq)) {
> +			fq_bits = p3t1755_fault_queue_to_bits(fq);
> +			if (fq_bits < 0) {
> +				dev_err_probe(&i3cdev->dev, fq_bits,
> +					      "invalid nxp,fault-queue %u (1/2/4/6)\n", fq);

Syntax is return dev_err_probe

> +				return fq_bits;
> +			}
> +		}
> +	}
> +
> +	dev_info(&i3cdev->dev, "Using TM mode: %s\n", tm_mode ? "Interrupt" : "Comparator");
> +	dev_info(&i3cdev->dev, "Alert polarity: %s\n",
> +		 alert_active_high ? "Active-High" : "Active-Low");

Drivers should be silent on success. See coding style as well.

> +
> +	if (id && id->data)
> +		chip = (const struct p3t17xx_info *)id->data;
> +
> +	ret = p3t1755_probe(&i3cdev->dev, chip, regmap, tm_mode, alert_active_high, fq_bits);
> +	if (ret) {
> +		dev_err_probe(&i3cdev->dev, ret, "p3t175x probe failed: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!tm_mode) {
> +		dev_warn(&i3cdev->dev, "IBI not supported in comparator mode, skipping IBI registration\n");
> +		return 0;
> +	}
> +
> +	ibi_setup.handler = p3t1755_ibi_handler;
> +	ibi_setup.num_slots = 4;
> +	ibi_setup.max_payload_len = 0;
> +
> +	ret = i3c_device_request_ibi(i3cdev, &ibi_setup);
> +	if (ret) {
> +		dev_err_probe(&i3cdev->dev, ret, "Failed to request IBI: %d\n", ret);

Syntax is return dev_err_probe

> +		return ret;
> +	}
> +
> +	ret = i3c_device_enable_ibi(i3cdev);
> +	if (ret) {
> +		dev_err_probe(&i3cdev->dev, ret, "Failed to enable IBI: %d\n", ret);

Syntax is return dev_err_probe

> +		i3c_device_free_ibi(i3cdev);
> +		return ret;
> +	}
> +
> +	dev_info(&i3cdev->dev, "IBI successfully registered\n");

Drivers should be silent on success. See coding style as well.

Same comments for all your other drivers here.


Best regards,
Krzysztof

  reply	other threads:[~2025-07-24  8:58 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 [this message]
2025-07-24 11:59   ` Andy Shevchenko
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=e8b6a6bf-fe4a-4ff3-addf-142212368903@kernel.org \
    --to=krzk@kernel.org \
    --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 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®