[RFC PATCH 2.6.12-rc3] dynamic driver sysfs callbacks and RFC on bmcsensor rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/4/05, Grant Coady <grant_lkml at dodo.com.au> wrote:
> I have queries, is there a reason why sysfs doesn't return multiple
> values?  So instead of asking for a filename with encoded array index,
> one gets a list of values?  One line per value, it works, easy to use
> as 'flat' datafiles.  And it removes index from filename.  the many
> to many (eg. temp channel -> fan speed control channel) can be resolved
> same as database normalisation.

As I understand it this was a deliberate decision to ease the problems
experienced with 2.4 proc entries where userspace programs would have
to parse the contents to extract specific information, and every time
the format of the contents (e.g. number/order of columns) changed all
these userspace apps would be broken. It was decided presenting the
specific information per file was a much simpler and more sensible
interface. I tend to agree.

> 
> Secondly is there a design document I've missed for this?  What does
> dynamic sysfs look like to user?  sub-directory per device/block or
> in the same directory level namespace?  I damaged the patches somewhere,
> one didn't apply so couldn't 'see' it yet.

This patch just changes the way device attributes are created, it does
not change the external sysfs interface at all.

At the moment every driver in the kernel (as far as I can see) defines
a set of static device attribute structs which are used by the driver
when calling the sysfs_create_file function. Greg was referring to
creating non-static attributes or creating device attributes at
runtime (as bmcsensors does) as dynamic.

Due to the nature of the sysfs device callbacks, each device attribute
in general requires a separate sysfs show/store callback function.
This has led to the kludge of a large number of macro defined
callbacks that are virtually identical. This leads to two problems,
first we can only define a limited and pre-determined number of sysfs
callbacks and hence device_attributes (in the case of bmcsensors it
can have an unlimited number of sensors), secondly a whole load of
redundant code is generated by the macros and is a large waste of
space. By adding a void * attribute member to the device_attribute
structure and passing these to callback functions we allow drivers to
greatly reduce the number of callback functions and also allow for a
potentially unlimited number of sysfs entries to be created. I refer
to these callbacks as dynamic because they change their function
depending on what is passed to them.

Yani



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux