Re: sysfs and power management

From: Greg KH
Date: Sun Oct 31 2010 - 10:32:24 EST


On Sun, Oct 31, 2010 at 01:57:55PM +0200, Onkalo Samu wrote:
> On Sat, 2010-10-30 at 16:00 +0200, ext Henrique de Moraes Holschuh
> wrote:
> > On Fri, 29 Oct 2010, Greg KH wrote:
> > > back to sleep. That's probably the best way to do this, as userspace
> > > isn't going to open the sysfs file and not close it instantly anyway
> > > after it has read the data (seeking on a sysfs file isn't really
> > > recommended, even if it sometimes seems to work.)
> >
> > Well, it is documented that seek(start of file) on sysfs works, and it
> > is ABI already (some userspace uses it on poll/select-capable
> > attributes). So, maybe seek(somewhere that is not the start of the
> > file) doesn't work -- and it should return an error in that case if it
> > doesn't already... but it is a lot more deterministic than "sometimes"
> > ;-)
> >
> > So yes, userspace will open() and not close() a sysfs attribute immediately
> > afterwards. It is not only shell crap that interfaces to the kernel over
> > sysfs :-)
> >
>
> What I would like to do is:
>
> Control sensors operating mode and regulators based on the userspace
> activity. If no-one is interested about the sensor, it can be turned
> totally off including its operating power via regulator framework.
>
> So far the only accepted interface for the small sensor seems to be
> sysfs. I tried use misc device but it was not accepted.

Look at the drivers/staging/iio/ subsystem. It is working on a
framework that you can use through a character device (I think) to
properly manage your drivers in this manner.

Try working with those developers as I think it is what you are looking
for here.

thanks,

greg k-h
--
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/