New chip driver development plan to Lm_sensors

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

 



Hi Jean

This is chunhao.
I meet another troublesome question when I develop the W83792D
driver, which need your help:

I have finished some of the functions in w83792d.c, and can produce
some device files in directory /proc/sys/dev/sensors/w83792d-i2c-0-2f/
for example in0.

But each time(except within the interval "HZ + HZ/2") I read the in0 file
by "cat" command, I find that the delay is comparatively large, which is
about 1-2 seconds. That's to say it takes me about 1-2 seconds to show me
the content of "in0", which also leads to the delay of the program "sensors".

I have debugged about it, find that the function "w83792d_update_client"
is the reason of the delay. Because in the course of the delay, this
function is executing and reading the registers' value one by one.

I also tested another Winbond chip W83627THF with the driver w83627hf.c
find that this phenomena does NOT exist on W83627THF. That's to say all
the device files of W83627THF can be read very quickly almost without any
delay, just like regular text file.

So my questions are:
(1) Does this phenomena appears in other I2C chip drivers? such as
w83781d.c. Because W83627THF use ISA bus instead of I2C.

(2) Does it have something to do with the register numbers be read in
the function " w83792d_update_client()"?
Because w83792d_update_client read much more registers than w83627hf.

(3) Or does it have something to do with the "w83792d_data->last_updated"
in the last mail? but there is also "w83627hf_data->last_updated" in
w83627hf.c, and the interval is same: HZ + HZ/2

(4) I also have tried to split the codes of w83792d_update_client()
into indivial function, for example: I move the following codes from
 w83792d_update_client() into the function w83792d_in(), and comment
 out the " w83792d_update_client()" in w83792d_in(), but it seems
 useless, because the delay becomes more larger.:-(

  ************ codes be moved  ******************
  data->in[0] = w83792d_read_value(client, W83792D_REG_IN0);
  data->in[1] = w83792d_read_value(client, W83792D_REG_IN1);
  data->in[2] = w83792d_read_value(client, W83792D_REG_IN2);
  data->in[3] = w83792d_read_value(client, W83792D_REG_IN3);
  data->in[4] = w83792d_read_value(client, W83792D_REG_IN4);
  data->in[5] = w83792d_read_value(client, W83792D_REG_IN5);
  data->in[6] = w83792d_read_value(client, W83792D_REG_IN6);
  data->in[7] = w83792d_read_value(client, W83792D_REG_IN7);
  data->in[8] = w83792d_read_value(client, W83792D_REG_IN8);


Thanks
Best Regards
chunhao

-----Original Message-----
From: Jean Delvare [mailto:khali at linux-fr.org] 
Sent: 2004??11??24?? 17:29
To: PI14 HUANG0; sensors at Stimpy.netroedge.com
Cc: PI10 LHHsu; PI14 DZSHEN
Subject: RE: New chip driver development plan to Lm_sensors


Hi Chunhao,

> I'm writing a new driver for w83792D, which is w83792d.c,using
> w83781d.c as my reference, deleting the codes related with ISA except
> two places, because 792D will only be on I2C.

Sounds good :)

> But I have two questions about w83792d driver now.
> (1) Can I delete the following codes?
> static unsigned int normal_isa[] = { 0x0290, SENSORS_ISA_END };
> static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
> I guess the above two sentences are useless, but I'm not very
> sure about it's function, can you tell me whether I can delete
> them or not?

No you can't. The i2c-core needs them. Simply remove the address and
leave:

static unsigned int normal_isa[] = { SENSORS_ISA_END };
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };

This will let the core know that it should not attempt to use your driver
for the ISA bus. This is what's done in other i2c-only drivers (such as
lm90.c for example).

> (2) When you are free, can you give me some general explanation
> of the member "last_updated" of struct w83792d_data?
>
> What I need to do is just keep all the codes related with
> "w83792d_data->last_updated" in w83781d.c
> Is that right?

Yes, keep it. This is something common to (almost) all drivers.

The idea is to remember when the chip registers where last read, and
force a little delay (typically between 0.5 and 2 seconds depending on
the chip) before the driver is allowed to read them all again. This
leaves some time for the chip to sample the voltages, temperatures etc.
Not all chips do need it, but some chips stop sampling when there is
traffic on the I2C interface so we have to do that. Also, since regular
users can request data from the driver, it is a good safety that this
won't generate I2C traffic each time. If we were really reading the
registers each time, then any user could overflow the I2C bus and
possibly cause trouble to the system (such as alarm conditions not
triggering as needed).

So last_updated stores the last time the registers were updated. It is
set at the end of the update function. At the beginning of the update
function we compare with the current time and if less than the defined
delay (usually expressed as x * HZ where HZ means 1 second) has passed
since the last update, then we do not read the registers and use the
previously read values instead.

Jean



===========================================================================================The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original author of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such person, please kindly reply the sender indicating accordingly and delete all copies of it from your computer and network server immediately. We thank you for your cooperation. It is advisable that any unauthorized use of confidential information of Winbond is strictly prohibited; and any information in this email that does not relate to the official business of Winbond shall be deemed as neither given nor endorsed by Winbond.===========================================================================================If your computer is unable to decode Chinese font, please ignore the following message. They essentially repea!
 t the  English statement above.???H???????t?????q?l???]???????K?????T, ?????v???o?H?H???w?????H?H???\????. ?????z???D?Q???w?????H?H???]???????]?b???g???v?????????U???????H??, ???z?i?????o?H?H?????Y?N?H???q?q???P???????A???????H????. ?????z???X?@, ?????????P??. ?S??????, ???????g???v?????????????q?l?????K???T???????O?Q?Y???T????. ?H???P?????q?l???~?L???????e,???o?????????q?l?????????N??.



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

  Powered by Linux