Re: [PATCH] thermal: core: Send a sysfs notification on trip points

From: Daniel Lezcano
Date: Mon Apr 06 2020 - 05:45:17 EST


On 06/04/2020 09:45, Vincent Whitchurch wrote:
> On Fri, Apr 03, 2020 at 05:26:39PM +0200, Daniel Lezcano wrote:
>> On 03/04/2020 16:40, Vincent Whitchurch wrote:
>>> Normally sysfs_notify() is used to notify userspace that the
>>> value of the sysfs file has changed, but in this case it's
>>> being used on a sysfs file whose value never changes. I don't
>>> know if there are other drivers that do something similar.
>>
>> I think so:
>>
>> eg.
>>
>> drivers/hwmon/adt7x10.c: sysfs_notify(&dev->kobj, NULL,
>> "temp1_max_alarm"); drivers/hwmon/adt7x10.c:
>> sysfs_notify(&dev->kobj, NULL, "temp1_min_alarm");
>> drivers/hwmon/adt7x10.c: sysfs_notify(&dev->kobj, NULL,
>> "temp1_crit_alarm");
>>
>> drivers/hwmon/abx500.c: sysfs_notify(&data->pdev->dev.kobj, NULL,
>> alarm_node); drivers/hwmon/abx500.c:
>> sysfs_notify(&data->pdev->dev.kobj, NULL, alarm_node);
>>
>> drivers/hwmon/stts751.c: sysfs_notify(&priv->dev->kobj, NULL,
>> "temp1_max_alarm"); drivers/hwmon/stts751.c:
>> sysfs_notify(&priv->dev->kobj, NULL, "temp1_min_alarm");
>>
>> There are also some other places I believe they are doing the
>> same like:
>>
>> drivers/md/md.c: sysfs_notify(&mddev->kobj, NULL,
>> "sync_completed"); drivers/md/md.c: sysfs_notify(&mddev->kobj,
>> NULL, "degraded");
>
> AFAICS all these drivers (including the hwmon ones) use
> sysfs_notify() to notify that the value of the sysfs file has
> changed, unlike your proposed patch.

Sorry, I don't have the same understanding:

drivers/hwmon/adt7x10.c:

- receives an interrupt because one of the programmed temperature is
reached
- reads the status to know which one and sends a sysfs notification

drivers/hwmon/stts751.c:

- receives an I2C alert message, checks if it is a temperature alert
and then sends a sysfs notification

drivers/hwmon/abx500:

- This one is probably sending a notification on a change

The documentation also is giving the semantic for sysfs_notify for
certain sysfs nodes:

Documentation/misc-devices/apds990x.txt: sysfs_notify
called when threshold interrupt occurs
Documentation/misc-devices/bh1770glc.txt: sysfs_notify
called when threshold interrupt occurs

AFAICT, it is a matter of documenting the notification for
trip_point_*_temp.


--
<http://www.linaro.org/> Linaro.org â Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog