Skip to content

SYSFS: Sysfs attribute improvements

Andi Kleen lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest12 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12SYSFS: Pass attribute in sysdev_class attributes show/storearch/mips/txx9/generic/7segled.c arch/s390/kernel/smp.c arch/s390/kernel/time.c +7 more+89 -301 reply
2/12SYSFS: Convert node driver class attributes to be data drivendrivers/base/node.c+18 -470 replies
3/12SYSDEV: Convert cpu driver sysdev class attributesdrivers/base/cpu.c+22 -170 replies
4/12SYSFS: Add sysfs_add/remove_files utility functionsfs/sysfs/file.c include/linux/sysfs.h+34 -03 replies
5/12SYSFS: Add attribute array to sysdev classesdrivers/base/sys.c include/linux/sysdev.h+10 -13 replies
6/12SYSDEV: Convert node driverdrivers/base/cpu.c+17 -400 replies
7/12SYSDEV: Use sysdev_class attribute arrays in node driverdrivers/base/node.c+16 -150 replies
8/12SYSFS: Add sysdev_create/remove_filesinclude/linux/sysdev.h+13 -00 replies
9/12SYSFS: Fix type of sysdev class attribute in memory driverdrivers/base/memory.c+4 -30 replies
10/12SYSDEV: Add attribute argument to class_attribute show/storedrivers/base/class.c drivers/base/cpu.c drivers/base/firmware_class.c +18 more+87 -320 replies
11/12SYSFS: Add class_attr_string for simple read-only stringdrivers/base/class.c include/linux/device.h+27 -00 replies
12/12SYSFS: Convert some drivers to CLASS_ATTR_STRINGdrivers/gpu/drm/drm_sysfs.c drivers/infiniband/core/ucm.c drivers/infiniband/core/user_mad.c +3 more+26 -560 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH] [0/12] SYSFS: Sysfs attribute improvements

sysdev_class attributes and class attributes do not pass their own attribute to the low level store/show functions. This means that itiss not possible to use shared functions for common data, but each data item had to have its own function. Typically this lead to ugly and big custom macro cascades in drivers, generating the store/show functions for each attribute. This leads to large code and is ugly.

When the attributes are passed to the callbacks -- like they are for plain attributes and sysdev attributes -- it's possible to "derive" own attribute objects that carry some data, use that data and then call into shared store/show code.

This patchkit fixes up these callback interfaces to allow to do this. This involves two tree sweeps for sysdev_class_attributes and class_attributes, changing them all to accept the new attribute argument.

I tried to convert all users, but was only able to compile test on x86.

All users were converted in a single patch to avoid unbisectable sections. I didn't put all the individual driver maintainers in cc, they probably wouldn't need to care.

Also I added some utility functions to easier deal with arrays of attributes. A lot of users define multiple attributes and had to open code array handling for this. Add new sysfs interfaces to handle the arrays directly. sysdev classes now can just directly carry their own attributes, similar to normal classes.

Then the CPU and the NODE driver in drivers/base serve as a poster child for the new facilities and shrink their code dramatically by using the new facilities.

In addition I added a new string attribute type derived from class attributes. This allows various drivers who use class attributes to export static version strings to just use a single macro, no custom callbacks.

I didn't convert all drivers over to the new facilities, this can be done gradually.

-Andi