Re: Generic battery interface

Greg KH
2006-07-27T23:01:09Z

> > sysfs is great for demos from a shell prompt,
> > but isn't such a great programming interface, either
> > from inside the kernel or from user-space.

I would tend to dispute this point :)

> Anyone volunteers write battery layer? If so, I'd go with /dev/XXX,
> otherwise I'd go with /sys/XXX, because it is simpler to code, and I
> believe it is also good enough...

Please go with /sys/battery/batteryN/XXXX, not an ioctl filled /dev/
interface that can not easily be scripted.

That way it is extensable (if the specific battery type just doesn't
provide a specific functionality, that sysfs file will not be present),
it allows for polling if needed, and would unify all the different types
of batteries.

Look at the kind of documentation the hwmon and i2c people have
created[1] for how to specify sysfs interfaces for different types of
sensor devices. It should not be that hard to create the same for
something as "simple" as a battery :)

thanks,

greg k-h

[1] Documentation/hwmon/sysfs-interface