[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aHYUOs25SrUb4BtD@smile.fi.intel.com>
Date: Tue, 15 Jul 2025 11:41:30 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Sean Anderson <sean.anderson@...ux.dev>
Cc: Jonathan Cameron <jic23@...nel.org>, Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>, linux-iio@...r.kernel.org,
linux-hwmon@...r.kernel.org, Andy Shevchenko <andy@...nel.org>,
Nuno Sá <nuno.sa@...log.com>,
linux-kernel@...r.kernel.org, David Lechner <dlechner@...libre.com>
Subject: Re: [PATCH 6/7] hwmon: iio: Add min/max support
On Mon, Jul 14, 2025 at 09:20:22PM -0400, Sean Anderson wrote:
> Add support for minimum/maximum attributes. Like the _input attribute,
> we just need to call into the IIO API.
...
> +static ssize_t iio_hwmon_read_event(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
> + struct iio_hwmon_state *state = dev_get_drvdata(dev);
> + struct iio_channel *chan = &state->channels[sattr->index];
> + int ret, result, scale;
> +
> + scale = iio_hwmon_scale(chan);
> + if (scale < 0)
This part is definitely missed in the respective description.
> + return scale;
> +
> + ret = iio_read_event_processed_scale(chan, IIO_EV_TYPE_THRESH,
> + sattr->nr, IIO_EV_INFO_VALUE,
> + &result, scale);
> + if (ret < 0)
Why ' < 0' here?
> + return ret;
> +
> + return sprintf(buf, "%d\n", result);
Mustn't be sysfs_emit() ?
> +}
...
> + ret = iio_write_event_processed_scale(chan, IIO_EV_TYPE_THRESH,
> + sattr->nr, IIO_EV_INFO_VALUE,
> + val, scale);
> + if (ret < 0)
< 0 ?
> + return ret;
...
> +static int add_event_attr(struct device *dev, struct iio_hwmon_state *st,
> + int i, enum iio_event_direction dir,
> + const char *fmt, ...)
Same comments as per previous patch adding another attribute API.
...
> + va_start(ap, fmt);
> + a->dev_attr.attr.name = devm_kvasprintf(dev, GFP_KERNEL, fmt, ap);
> + va_end(ap);
Can't %pV be used?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists