[lm-sensors] superio lock coordinator

David Hubbard david.c.hubbard at gmail.com
Fri Nov 14 11:20:42 CET 2008

Hi Jim, Hans,

> Hi David,
> heres my git-log -p  for your patch, and several others layering on
> trivial fixes.
> Maybe its useful  ( maybe it saves you a tiny bit of time )
> Or maybe not.
> have fun
> -jimc

At last, I think I've made it to a point where I can ask for your help.

Attached is a patch that works (sort of!) on my w83627ehf. (.txt is so
the content-type is right.)

I *think* this is what is happening:

Before, w83627ehf would call platform_device_alloc when it probed the
superio registers. That's a primitive approach (discussed in

Well, I've pulled the two steps apart. In superio.c, it looks at
superio registers, finds the superio ID, and then creates a
platform_device with a driver name that pulls in w83627ehf. There's a
device table in superio.c, so Jim can add pc87360 and it should
automatically get modprobed also. (I'd be happy to port drivers, but
it could take a while.)

The driver core sees the platform device, autoloads w83627ehf.ko and
calls the probe() function in it. This part works. :-)

[ 6383.126757] superio: Found w83627ehf (0x8863) at 0x2e
[ 6383.126842] w83627ehf: found a w83627ehg at 0x290
[ 6383.127443] superio: no superio found at 0x4e

So something I'm not too sure about, but I think I did it right, is
platform_device_put(pdev); /* now the device can exist on its own */

In theory, superio.c doesn't store the pdev pointer at all. It
releases its hold on it and leaves the rest to the driver core. But
when I remove the superio module:

[ 6475.442046] Trying to free nonexistent resource <0290-0291>
[ 6506.698974] superio: region request 0x2e-0x2f failed
[ 6506.698996] superio: no superio found at 0x4e

So Jim, Hans, can you take a look at how I'm doing platform device
code and make suggestions?

Jim, I'm fine with your suggestion, if (err) instead of if (err != 0).
I chose superio_in2b instead of superio_inw, because it is possible to
do a hardware 16-bit read with inw() which could have a different
result. After fumbling around a little, I added #ifdef/#define to
superio.h and then defined the functions superio_enter / superio_exit
etc. with "static inline". That should work OK for now.

Things TODO:
- Add mutexes (the whole point in the first place)
- Don't print out which superio ports had nothing, as long as at least
one port has something

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: w83627ehf-use-superio-v02.patch.txt
URL: <http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20081114/4acbf12c/attachment.txt>

More information about the lm-sensors mailing list