Using hwmon in-kernel

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

 



On Mon, 20 Oct 2008, Matthew Garrett wrote:
> Here's the patch I mentioned. Most of it is noise to update all the
> drivers, but the substantive portion is in the hunks modifying hwmon.c
> and hwmon.h. lm90.c has been updated to add the callbacks. This only
> scratches my own itch, so doesn't add voltage or fanspeed handling (or
> whatever) - adding those would be trivial if anyone needs them. Like I
> said, individual drivers can be updated piecemeal.

I wonder if there is a way to do this that makes more use of the existing
sysfs interface?

Maybe something like:

/* @dev:	device with attribute
  * @attr:	attribute name
  * @buf:	buffer where result is placed
  *
  * Return value is the length of the result or an error code, i.e.
  * the same as the attribute's show() method returns.
  */
int sysfs_show_attribute(struct device *dev, const char *attr, char *buf);

or maybe use a struct device_attribute * as an argument.

Then you could just call sysfs_show_attribute(hwmondev, "temp2_input", buf) or
whatever and get the value in the kernel.  It would would with all drivers
without adding a code to them.

Of course there is the conversion to and from acsii.  That's certainly ugly. 
It could be wrapped inside a function that just returns an int and deals with
finding a buffer and converting from ascii, but the conversion would still be
there.  Compared to rate sensor values change, it's not very expensive.




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

  Powered by Linux