All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] Question on platform drivers
@ 2006-02-19 22:03 Juerg Haefliger
  2006-02-19 22:12 ` Jean Delvare
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Juerg Haefliger @ 2006-02-19 22:03 UTC (permalink / raw)
  To: lm-sensors

Hi all,

I rewrote the vt1211 driver to implement it as a platform driver but
now sensors doesn't see it anymore. The chip is registered at
/sys/devices/platform/vt1211.24576 but sensors (2.10.0) reports:
Can't access procfs/sysfs file
Unable to find i2c bus information;
For 2.6 kernels, make sure you have mounted sysfs and libsensors
was compiled with sysfs support!
For older kernels, make sure you have done 'modprobe i2c-proc'!

SYSFS support is compiled into libsensors and kernel version is 2.6.16-rc3-mm1.

Thanks
...juerg


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
@ 2006-02-19 22:12 ` Jean Delvare
  2006-02-22  5:17 ` Juerg Haefliger
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2006-02-19 22:12 UTC (permalink / raw)
  To: lm-sensors


Hi Juerg,

> I rewrote the vt1211 driver to implement it as a platform driver but
> now sensors doesn't see it anymore. The chip is registered at
> /sys/devices/platform/vt1211.24576 but sensors (2.10.0) reports:
> Can't access procfs/sysfs file
> Unable to find i2c bus information;
> For 2.6 kernels, make sure you have mounted sysfs and libsensors
> was compiled with sysfs support!
> For older kernels, make sure you have done 'modprobe i2c-proc'!
>
> SYSFS support is compiled into libsensors and kernel version is
> 2.6.16-rc3-mm1.

Did you register your driver with the hwmon class? libsensors scans
/sys/class/hwmon for hardware monitoring chips. If you device doesn't
show up there, it won't be found.

--
Jean Delvare


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
  2006-02-19 22:12 ` Jean Delvare
@ 2006-02-22  5:17 ` Juerg Haefliger
  2006-02-22  8:37 ` Jean Delvare
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Juerg Haefliger @ 2006-02-22  5:17 UTC (permalink / raw)
  To: lm-sensors

Hi Jean,

Yes I did register the device with the hwmon class. It shows up under
/sys/class/hwmon/hwmon0/device

...juerg


> Hi Juerg,
>
>> I rewrote the vt1211 driver to implement it as a platform driver but
>> now sensors doesn't see it anymore. The chip is registered at
>> /sys/devices/platform/vt1211.24576 but sensors (2.10.0) reports:
>> Can't access procfs/sysfs file
>> Unable to find i2c bus information;
>> For 2.6 kernels, make sure you have mounted sysfs and libsensors
>> was compiled with sysfs support!
>> For older kernels, make sure you have done 'modprobe i2c-proc'!
>>
>> SYSFS support is compiled into libsensors and kernel version is
>> 2.6.16-rc3-mm1.
>
> Did you register your driver with the hwmon class? libsensors scans
> /sys/class/hwmon for hardware monitoring chips. If you device doesn't
> show up there, it won't be found.
>
> --
> Jean Delvare


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
  2006-02-19 22:12 ` Jean Delvare
  2006-02-22  5:17 ` Juerg Haefliger
@ 2006-02-22  8:37 ` Jean Delvare
  2006-02-23  2:02 ` Juerg Haefliger
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2006-02-22  8:37 UTC (permalink / raw)
  To: lm-sensors


Hi Juerg,

On 2006-02-22, Juerg Haefliger wrote:
> Yes I did register the device with the hwmon class. It shows up under
> /sys/class/hwmon/hwmon0/device

Did you create a "name" device attribute? libsensors needs it to find
out the chip name. i2c drivers don't need to explicitely create it
because the i2c subsystem does it for them, but there is no such
mechanism for platform drivers (yet).

You can take a look at my f71805f driver to see how this is done. It's
really simple.

If it still doesn't work after that, you could strace sensors and see
where it is failing.

--
Jean Delvare


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
                   ` (2 preceding siblings ...)
  2006-02-22  8:37 ` Jean Delvare
@ 2006-02-23  2:02 ` Juerg Haefliger
  2006-02-24  4:31 ` Mark M. Hoffman
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Juerg Haefliger @ 2006-02-23  2:02 UTC (permalink / raw)
  To: lm-sensors

Hi Jean,

Thanks for the hint. You're right, I didn't have the "name" attribute
implemented but after fixing this, it still doesn't work. See the
strace output below, it looks like sensors is going after i2c-adapter
which of course is not there. Am I missing something here?

Thanks
...juerg


[snip]

lstat64("/sys/devices/platform/vt1211.24576/in0_max",
{st_mode=S_IFREG|0644, st_size@96, ...}) = 0
stat64("/sys/devices/platform/vt1211.24576/in0_max",
{st_mode=S_IFREG|0644, st_size@96, ...}) = 0
open("/sys/devices/platform/vt1211.24576/in0_max", O_RDONLY) = 5
read(5, "2630\n", 4096)                 = 5
close(5)                                = 0
lstat64("/sys/devices/platform/vt1211.24576/in0_min",
{st_mode=S_IFREG|0644, st_size@96, ...}) = 0
stat64("/sys/devices/platform/vt1211.24576/in0_min",
{st_mode=S_IFREG|0644, st_size@96, ...}) = 0
open("/sys/devices/platform/vt1211.24576/in0_min", O_RDONLY) = 5
read(5, "0\n", 4096)                    = 2
close(5)                                = 0
lstat64("/sys/devices/platform/vt1211.24576/in0_input",
{st_mode=S_IFREG|0444, st_size@96, ...}) = 0
stat64("/sys/devices/platform/vt1211.24576/in0_input",
{st_mode=S_IFREG|0444, st_size@96, ...}) = 0
open("/sys/devices/platform/vt1211.24576/in0_input", O_RDONLY) = 5
read(5, "1972\n", 4096)                 = 5
close(5)                                = 0
lstat64("/sys/devices/platform/vt1211.24576/hwmon:hwmon0",
{st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
lstat64("/sys/devices/platform/vt1211.24576/power",
{st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat64("/sys/devices/platform/vt1211.24576/uevent",
{st_mode=S_IFREG|0200, st_size@96, ...}) = 0
stat64("/sys/devices/platform/vt1211.24576/uevent",
{st_mode=S_IFREG|0200, st_size@96, ...}) = 0
getdents64(4, /* 0 entries */, 4096)    = 0
close(4)                                = 0
open("/sys/devices/platform/vt1211.24576/name", O_RDONLY) = 4
read(4, "vt1211\n", 4096)               = 7
close(4)                                = 0
open("/proc/mounts", O_RDONLY)          = 4
fstat64(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fbb000
read(4, "rootfs / rootfs rw 0 0\n/dev/root"..., 1024) = 300
close(4)                                = 0
munmap(0xb7fbb000, 4096)                = 0
lstat64("/sys/class/i2c-adapter", 0xbf923fcc) = -1 ENOENT (No such
file or directory)
write(2, "Can\'t access procfs/sysfs file\n", 31Can't access procfs/sysfs file
) = 31
write(2, "Unable to find i2c bus informati"..., 198Unable to find i2c
bus information;
For 2.6 kernels, make sure you have mounted sysfs and libsensors
was compiled with sysfs support!
For older kernels, make sure you have done 'modprobe i2c-proc'!
) = 198
exit_group(1)                           = ?
-bash-3.00#



On 2/22/06, Jean Delvare <khali at linux-fr.org> wrote:
>
> Hi Juerg,
>
> On 2006-02-22, Juerg Haefliger wrote:
> > Yes I did register the device with the hwmon class. It shows up under
> > /sys/class/hwmon/hwmon0/device
>
> Did you create a "name" device attribute? libsensors needs it to find
> out the chip name. i2c drivers don't need to explicitely create it
> because the i2c subsystem does it for them, but there is no such
> mechanism for platform drivers (yet).
>
> You can take a look at my f71805f driver to see how this is done. It's
> really simple.
>
> If it still doesn't work after that, you could strace sensors and see
> where it is failing.
>
> --
> Jean Delvare
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
                   ` (3 preceding siblings ...)
  2006-02-23  2:02 ` Juerg Haefliger
@ 2006-02-24  4:31 ` Mark M. Hoffman
  2006-02-24  8:21 ` Jean Delvare
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Mark M. Hoffman @ 2006-02-24  4:31 UTC (permalink / raw)
  To: lm-sensors

Hello Juerg:

* Juerg Haefliger <juergh at gmail.com> [2006-02-22 18:02:27 -0800]:
> Thanks for the hint. You're right, I didn't have the "name" attribute
> implemented but after fixing this, it still doesn't work. See the
> strace output below, it looks like sensors is going after i2c-adapter
> which of course is not there. Am I missing something here?

Hmmm... I guess it's a libsensors bug - try this patch.

Jean: comments?

Index: lib/sysfs.c
=================================RCS file: /home/cvs/lm_sensors2/lib/sysfs.c,v
retrieving revision 1.4
diff -u -r1.4 sysfs.c
--- lib/sysfs.c	9 Jan 2006 19:55:18 -0000	1.4
+++ lib/sysfs.c	24 Feb 2006 05:23:58 -0000
@@ -171,7 +171,7 @@
 	int ret = 0;
 
 	if (!(cls = sysfs_open_class("i2c-adapter"))) {
-		ret = -SENSORS_ERR_PROC;
+		/* not an error - sensors completely without I2C is possible */
 		goto exit0;
 	}
 
Regards,

-- 
Mark M. Hoffman
mhoffman at lightlink.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
                   ` (4 preceding siblings ...)
  2006-02-24  4:31 ` Mark M. Hoffman
@ 2006-02-24  8:21 ` Jean Delvare
  2006-02-24 22:01 ` Jean Delvare
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2006-02-24  8:21 UTC (permalink / raw)
  To: lm-sensors


Hi Mark, Juerg,

On 2006-02-24, Mark M. Hoffman wrote:
> > Thanks for the hint. You're right, I didn't have the "name" attribute
> > implemented but after fixing this, it still doesn't work. See the
> > strace output below, it looks like sensors is going after i2c-adapter
> > which of course is not there. Am I missing something here?
>
> Hmmm... I guess it's a libsensors bug - try this patch.
>
> Jean: comments?
>
> Index: lib/sysfs.c
> =================================> RCS file: /home/cvs/lm_sensors2/lib/sysfs.c,v
> retrieving revision 1.4
> diff -u -r1.4 sysfs.c
> --- lib/sysfs.c	9 Jan 2006 19:55:18 -0000	1.4
> +++ lib/sysfs.c	24 Feb 2006 05:23:58 -0000
> @@ -171,7 +171,7 @@
>  	int ret = 0;
> 
>  	if (!(cls = sysfs_open_class("i2c-adapter"))) {
> -		ret = -SENSORS_ERR_PROC;
> +		/* not an error - sensors completely without I2C is
> +                  possible */
>  		goto exit0;
>  	}

Seems so. I could reproduce the bug yesterday evening by removing all i2c
stuff from my kernel. I had never tried that before, because even on the
system where I can use a totally i2c-free hardware monitoring driver
(f71805f), I have other devices which use i2c (my DC10+ grabber).

I did not send a patch yesterday as I first wanted to make sure it would
work properly, and I was short of time for the additional tests. We need
to make sure that nowhere in the libsensors code we assumed that at
least one i2c adapter had been found. I'll look into it this evening.

Thanks Juerg for spotting and reporting the bug, hopefully we can fix it
shortly now.

--
Jean


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
                   ` (5 preceding siblings ...)
  2006-02-24  8:21 ` Jean Delvare
@ 2006-02-24 22:01 ` Jean Delvare
  2006-02-25 15:27 ` Mark M. Hoffman
  2006-02-25 19:27 ` Juerg Haefliger
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2006-02-24 22:01 UTC (permalink / raw)
  To: lm-sensors

Hi Mark, Juerg,

On 2006-02-24, Mark M. Hoffman wrote:
> > Hmmm... I guess it's a libsensors bug - try this patch.
> >
> > Jean: comments?
> >
> > Index: lib/sysfs.c
> > =================================> > RCS file: /home/cvs/lm_sensors2/lib/sysfs.c,v
> > retrieving revision 1.4
> > diff -u -r1.4 sysfs.c
> > --- lib/sysfs.c	9 Jan 2006 19:55:18 -0000	1.4
> > +++ lib/sysfs.c	24 Feb 2006 05:23:58 -0000
> > @@ -171,7 +171,7 @@
> >  	int ret = 0;
> > 
> >  	if (!(cls = sysfs_open_class("i2c-adapter"))) {
> > -		ret = -SENSORS_ERR_PROC;
> > +		/* not an error - sensors completely without I2C is
> > +                  possible */
> >  		goto exit0;
> >  	}
> 
> Seems so. I could reproduce the bug yesterday evening by removing all i2c
> stuff from my kernel. I had never tried that before, because even on the
> system where I can use a totally i2c-free hardware monitoring driver
> (f71805f), I have other devices which use i2c (my DC10+ grabber).
> 
> I did not send a patch yesterday as I first wanted to make sure it would
> work properly, and I was short of time for the additional tests. We need
> to make sure that nowhere in the libsensors code we assumed that at
> least one i2c adapter had been found. I'll look into it this evening.

Further investigations reveal that the patch above isn't sufficient. It
covers the case where no i2c driver at all is loaded, but fails again
is i2c-core is loaded but no bus driver is. It is also a bit too loose
with error checking in my opinion.

Here is the patch I have come up with. Juerg, please give it a try and
report. It works fine for me at least.

Index: lib/sysfs.c
=================================RCS file: /home/cvs/lm_sensors2/lib/sysfs.c,v
retrieving revision 1.4
diff -u -r1.4 sysfs.c
--- lib/sysfs.c	9 Jan 2006 19:55:18 -0000	1.4
+++ lib/sysfs.c	24 Feb 2006 22:49:09 -0000
@@ -22,6 +22,7 @@
 
 #include <string.h>
 #include <limits.h>
+#include <errno.h>
 #include <sysfs/libsysfs.h>
 #include "data.h"
 #include "error.h"
@@ -171,12 +172,14 @@
 	int ret = 0;
 
 	if (!(cls = sysfs_open_class("i2c-adapter"))) {
-		ret = -SENSORS_ERR_PROC;
+		if (errno && errno != ENOENT)
+			ret = -SENSORS_ERR_PROC;
 		goto exit0;
 	}
 
 	if (!(clsdevs = sysfs_get_class_devices(cls))) {
-		ret = -SENSORS_ERR_PROC;
+		if (errno)
+			ret = -SENSORS_ERR_PROC;
 		goto exit1;
 	}
 

Thanks,
-- 
Jean Delvare


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
                   ` (6 preceding siblings ...)
  2006-02-24 22:01 ` Jean Delvare
@ 2006-02-25 15:27 ` Mark M. Hoffman
  2006-02-25 19:27 ` Juerg Haefliger
  8 siblings, 0 replies; 10+ messages in thread
From: Mark M. Hoffman @ 2006-02-25 15:27 UTC (permalink / raw)
  To: lm-sensors

Hi:

[ I wrote a quick hack of a patch ]

* Jean Delvare <khali at linux-fr.org> [2006-02-24 23:01:25 +0100]:
> Further investigations reveal that the patch above isn't sufficient. It
> covers the case where no i2c driver at all is loaded, but fails again
> is i2c-core is loaded but no bus driver is. It is also a bit too loose
> with error checking in my opinion.
> 
> Here is the patch I have come up with. Juerg, please give it a try and
> report. It works fine for me at least.

Yep, that looks a lot better.

Regards,

-- 
Mark M. Hoffman
mhoffman at lightlink.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Question on platform drivers
  2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
                   ` (7 preceding siblings ...)
  2006-02-25 15:27 ` Mark M. Hoffman
@ 2006-02-25 19:27 ` Juerg Haefliger
  8 siblings, 0 replies; 10+ messages in thread
From: Juerg Haefliger @ 2006-02-25 19:27 UTC (permalink / raw)
  To: lm-sensors

Hi Jean,

Yes, your patch below works for me. Thanks!

...juerg

-bash-3.00# sensors
vt1211-isa-6000
Adapter: ISA adapter
ERROR: Can't get alarm data!
+3.3V:     +3.31 V  (min =  +3.03 V, max =  +3.17 V)
+2.5V:     +2.42 V  (min =  +2.17 V, max =  +2.27 V)
VCore:     +1.39 V  (min =  +1.36 V, max =  +1.44 V)
+5V:       +4.66 V  (min =  +4.73 V, max =  +5.23 V)
+12V:     +12.07 V  (min = +10.77 V, max = +13.14 V)
+3.3V(i):  +3.27 V  (min =  +3.13 V, max =  +3.46 V)
fan1:        0 RPM  (min = 3006 RPM, div = 2)
fan2:     3877 RPM  (min = 3006 RPM, div = 2)
Int Temp:  +48.0?C  (high =  +204?C, hyst =    +0?C)
CPU Temp:  +98.0?C  (high =   +65?C, hyst =   +60?C)
vid:      +1.250 V  (VRM Version 8.5)


> Hi Mark, Juerg,
>
> On 2006-02-24, Mark M. Hoffman wrote:
>> > Hmmm... I guess it's a libsensors bug - try this patch.
>> >
>> > Jean: comments?
>> >
>> > Index: lib/sysfs.c
>> > =================================>> > RCS file: /home/cvs/lm_sensors2/lib/sysfs.c,v
>> > retrieving revision 1.4
>> > diff -u -r1.4 sysfs.c
>> > --- lib/sysfs.c	9 Jan 2006 19:55:18 -0000	1.4
>> > +++ lib/sysfs.c	24 Feb 2006 05:23:58 -0000
>> > @@ -171,7 +171,7 @@
>> >  	int ret = 0;
>> >
>> >  	if (!(cls = sysfs_open_class("i2c-adapter"))) {
>> > -		ret = -SENSORS_ERR_PROC;
>> > +		/* not an error - sensors completely without I2C is
>> > +                  possible */
>> >  		goto exit0;
>> >  	}
>>
>> Seems so. I could reproduce the bug yesterday evening by removing all
>> i2c
>> stuff from my kernel. I had never tried that before, because even on the
>> system where I can use a totally i2c-free hardware monitoring driver
>> (f71805f), I have other devices which use i2c (my DC10+ grabber).
>>
>> I did not send a patch yesterday as I first wanted to make sure it would
>> work properly, and I was short of time for the additional tests. We need
>> to make sure that nowhere in the libsensors code we assumed that at
>> least one i2c adapter had been found. I'll look into it this evening.
>
> Further investigations reveal that the patch above isn't sufficient. It
> covers the case where no i2c driver at all is loaded, but fails again
> is i2c-core is loaded but no bus driver is. It is also a bit too loose
> with error checking in my opinion.
>
> Here is the patch I have come up with. Juerg, please give it a try and
> report. It works fine for me at least.
>
> Index: lib/sysfs.c
> =================================> RCS file: /home/cvs/lm_sensors2/lib/sysfs.c,v
> retrieving revision 1.4
> diff -u -r1.4 sysfs.c
> --- lib/sysfs.c	9 Jan 2006 19:55:18 -0000	1.4
> +++ lib/sysfs.c	24 Feb 2006 22:49:09 -0000
> @@ -22,6 +22,7 @@
>
>  #include <string.h>
>  #include <limits.h>
> +#include <errno.h>
>  #include <sysfs/libsysfs.h>
>  #include "data.h"
>  #include "error.h"
> @@ -171,12 +172,14 @@
>  	int ret = 0;
>
>  	if (!(cls = sysfs_open_class("i2c-adapter"))) {
> -		ret = -SENSORS_ERR_PROC;
> +		if (errno && errno != ENOENT)
> +			ret = -SENSORS_ERR_PROC;
>  		goto exit0;
>  	}
>
>  	if (!(clsdevs = sysfs_get_class_devices(cls))) {
> -		ret = -SENSORS_ERR_PROC;
> +		if (errno)
> +			ret = -SENSORS_ERR_PROC;
>  		goto exit1;
>  	}
>
>
> Thanks,
> --
> Jean Delvare
>
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-02-25 19:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-19 22:03 [lm-sensors] Question on platform drivers Juerg Haefliger
2006-02-19 22:12 ` Jean Delvare
2006-02-22  5:17 ` Juerg Haefliger
2006-02-22  8:37 ` Jean Delvare
2006-02-23  2:02 ` Juerg Haefliger
2006-02-24  4:31 ` Mark M. Hoffman
2006-02-24  8:21 ` Jean Delvare
2006-02-24 22:01 ` Jean Delvare
2006-02-25 15:27 ` Mark M. Hoffman
2006-02-25 19:27 ` Juerg Haefliger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.