Skip to contentSkip to conversation

A question about masks in sysfs

DISCUSSION Joshua Scott 2 participants 2 messages Aug 14, 2016 – Aug 16, 2016 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

Hi,

I am wanting to add write support to the alarms mask sysfs entry for the adt7470 driver.

Before going forward with this, I had a question about consistency in this area.

In the other drivers I see that expose masks, it looks like they do this as decimal numbers (adm1026.c, w83627hf.c, w83781d.c).

The adt7470 driver already exposes the alarm mask, but instead of decimal it uses hex.

What would be the correct way of adding write support to this? Should it be converted to decimal to be consistent with other drivers, or should it remain in hex to prevent breaking any userspace code that may be relying on the current behaviour?

Thanks,
Joshua Scott

maintainer
#1 lore raw
Quoted 11 lines · Joshua Scott

Hi,

I am wanting to add write support to the alarms mask sysfs entry for the adt7470 driver.

Before going forward with this, I had a question about consistency in this area.

In the other drivers I see that expose masks, it looks like they do this as decimal numbers (adm1026.c, w83627hf.c, w83781d.c).

Quoted 8 lines

The adt7470 driver already exposes the alarm mask, but instead of decimal it uses hex.

What would be the correct way of adding write support to this? Should it be converted to decimal to be consistent with other drivers, or should it remain in hex to prevent breaking any userspace code that may be relying on the current behaviour?

For all of those, the attribute is non-standard (not part of the ABI), which is bad to start with. But either case, using hex without 0x annotation is _really_ bad, so you really picked the worst of the drivers to change. I'd suggest to leave the show part alone for backward compliance (shudder), and to use kstrtoul() with a base of 0 for write. This will accept an integer unless 0x is provided, which is what it should be.

Guenter