lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05fbc6c9-0b6a-42bd-8940-242c80a79b7f@linux.dev>
Date: Tue, 15 Jul 2025 12:05:15 -0400
From: Sean Anderson <sean.anderson@...ux.dev>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
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 7/15/25 04:41, Andy Shevchenko wrote:
> 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.

OK

>> +		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?

This originally returned IIO_VAL_INT on success.

>> +		return ret;
>> +
>> +	return sprintf(buf, "%d\n", result);
> 
> Mustn't be sysfs_emit() ?

It doesn't matter in this case (as %d can never emit more
than 20ish characters), but that works too.

>> +}
> 
> ...
> 
>> +	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?

%pV is for when we have additional info to add. e.g. if we were doing

devm_kasprintf(dev, GFP_KERNEL, "my_extra_info_%d_%pV", i, &vaf);

but we aren't so there's no point adding a level of indirection.

--Sean

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ