sysfs and power management

From: Onkalo Samu
Date: Wed Oct 27 2010 - 06:59:54 EST


Hi

I have recently sent couple of sensor drivers to kernel.
Interface is purely sysfs based. The hard part is to get
power management to work reasonable way.

With /dev/* interface power management is quite easy to do since
driver gets clear open and release calls. With sysfs, there is only
read / write methods available.
My solution has been separate sysfs entry which controls operating
state. However, there are some problems with that.
In case of boolean type enable / disable control, there must be
only one userspace component which decides sensor state.
In case of counting type of control, there is a change that
sensor is permanently left on if the userspace component crashes.
This would lead to unbalanced enable / disable count.

If the sensor functionality is based on interrupts (like threshold
interrupt), it may take long time before there is any activity.
In this kind of case timeout from the previous sysfs access doesn't make
much sense.
I started to wonder if it makes sense to enhance sysfs so that it
optionally prodives open / close call backs. Internally sysfs has some
bookkeeping about the refcount but this is not visible to the driver.
Of course majority of the sysfs users doesn't need that at all
and for them this is just overhead.

Is it out of the question to provide call back to driver when
some sysfs entry is opened (first time) and when refcnt goes back
to 0?

Regards,
Samu


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/