Re: [PATCH v2] iio: adc: pac1921: add ACPI support to pac1921
From: Jonathan Cameron
Date: Sun Oct 06 2024 - 07:41:31 EST
On Wed, 2 Oct 2024 15:54:45 +0300
<victor.duicu@xxxxxxxxxxxxx> wrote:
> From: Victor Duicu <victor.duicu@xxxxxxxxxxxxx>
>
> This patch implements ACPI support to Microchip pac1921.
> The driver can read shunt resistor value and device label
> from ACPI table.
>
> Differences related to previous versions:
> v2:
> - remove name variable from priv. Driver reads label attribute with
> sysfs.
> - define pac1921_shunt_is_valid function.
> - move default assignments in pac1921_probe to original position.
> - roll back coding style changes.
> - add documentation for DSM(the linked document was used as reference).
> - remove acpi_match_device in pac1921_match_acpi_device.
> - remove unnecessary null assignment and comment.
> - change name of function pac1921_match_of_device to
> pac1921_parse_of_fw.
>
> v1:
> - initial version for review.
>
> Signed-off-by: Victor Duicu <victor.duicu@xxxxxxxxxxxxx>
One additional thing from me.
> +
> +static int pac1921_parse_of_fw(struct i2c_client *client, struct pac1921_priv *priv,
> + struct iio_dev *indio_dev)
> +{
> + int ret;
> + struct device *dev = &client->dev;
> +
> + ret = device_property_read_u32(dev, "shunt-resistor-micro-ohms",
> + &priv->rshunt_uohm);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Cannot read shunt resistor property\n");
> +
> + if (!pac1921_shunt_is_valid(priv->rshunt_uohm))
> + return dev_err_probe(dev, -EINVAL, "Invalid shunt resistor: %u\n",
> + priv->rshunt_uohm);
> +
> + pac1921_calc_current_scales(priv);
> +
> + if (device_property_present(dev, "label")) {
> + ret = device_property_read_string(dev, "label",
> + (const char **)&indio_dev->label);
That cast looks odd and the equivalent core code doesn't have it which makes
me wonder why you need it here?
Anyhow as the other review pointed out the iio core code should handle this anyway.
> + if (ret)
> + return dev_err_probe(&client->dev, ret,
> + "Invalid rail-name value\n");
> + } else {
> + indio_dev->label = "pac1921";
> + }
> +
> + return 0;
> +}