linux 2.6 port of smsc47m1
Hello,
I ported the smsc47m1 driver to kernel 2.6
you can find the file at:
http://penguintown.net/~gorlik/smsc47m1.c
I don't know what is the procedure to get it into the lm_sensors and/or kernel distribution.
thanks,
GG
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
[Please reply to the list, not to me directly]
Quoted 3 lines
I ported the smsc47m1 driver to kernel 2.6
you can find the file at:
http://penguintown.net/~gorlik/smsc47m1.c
Nice :)
Quoted 2 lines
I don't know what is the procedure to get it into the
lm_sensorsand/or kernel distribution.
The file has to go into the main 2.6 kernel tree, after taking the several steps:
1* Propose the patch on this mailing-list for reviewing and comments. Do
the requested changes (or explain why you won't) until we agree that the file is clean (code and style altogether).
2* Send a proper patch against the latest stable kernel or -mm kernel (whichever has the more up-to-date i2c subsystem) to Greg KH (greg at kroah dot com), CC the mailing list. The patch must include the new driver (of course) as well as updates to the Makefile and Kconfig files.
3* Greg applies the patch to his tree (and thanks you).
4* At some later time, Andrew Morton includes Greg's updates to the i2c subsystem into his -mm series.
5* Once enough testing has been done, Greg send the patch to Linus for inclusion into the main tree.
We're at step 1 at the moment ;)
Now, here are my comments about your code.
1* The memory allocation scheme changed recently in both the CVS chip drivers and the Linux 2.6 kernel's ones. Your file still uses the old one, this needs to be changed. An example of what you need to do is here:
http://linux.bkbits.net:8080/linux-2.5/diffs/drivers/i2c/chips/[email protected][email protected]
2* In smsc47m1_find(), you added a printk:
printk("smsc47m1.o: found SMSC47M1xx with DevID=0x%02X\n",val);
I think it should be:
printk(KERN_INFO "smsc47m1.o: found SMSC47M1xx with DevID=0x%02X\n",
val);
printks without KERN_* constants are not welcome if I remember correctly.
3* Please respect the coding style. Your style is definitely better than
most of what I usually have to review, but still... Please do not leave white spaces before closing parenthesis. OTOH, please leave a white space after comas.
4* There are a few lines you commented out (two of them if I counted right). Just remove them. And don't use C++-style comments please.
5* You have an extra tabulation before "new_client->flags = 0;" in smsc47m1_detect().
6* In smsc47m1_detect(), you use check_region(). This is deprecated. See how things are fone in the w83627hf.c driver (basically you just try to request the region, and bail out with an error if it fails).
That's about all for this first check. I have yet to take a look at the sysfs callback functions. Please update your file and provide a full patch against linux-2.6.6-rcX.
BTW, Have you been fixing things that you think should be backported to the CVS (2.4) driver?
Thanks.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoting myself:
Quoted 2 lines
That's about all for this first check. I have yet to take a look at the sysfs callback functions.
OK, I just did this. Your code is correct in the sense that it does the same as what the 2.4/CVS driver does. However, I have noticed a number of strangenesses, and think this is the right time to discuss them.
First, there is no lock on read/write. There is a lock for the update function, but that's about all. It's obviously not sufficent. Usually, drivers have a second lock for read and write operations.
Second, I'm really confused by the operations made on the PWM registers. When reading the code, it looks like bit 7 is for enabling PWM and bits 6-0 hold the duty cycle value. Except that only bits 5-0 can be set, and the conversions macros are odd. When looking at the datasheet OTOH, I read that PWM enable is bit 0, inverted (1 actually disables PWM), and value is in bits 6-1. Bit 7 is a clock modifier, we don't care. Conversions would be as simple as multiplying / dividing by 4 (with some rounding if you want).
Mark, am I missing something here or is PWM handling in the smsc47m1 driver plain broken? I'd be surprised that nobody reported so far if it is, but sometimes we get surprised.
Another point that could be improved in the 2.6 driver is the fan divisor setting. Instead of defaulting to 2 on invalid sets, you should refuse them and return -EINVAL. This couldn't be done in the 2.4 driver, but it can be in 2.6, so let's do it. A number of drivers already do (fscher.c was the first IIRC).
Thanks.
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Quoted 3 lines · myself
First, there is no lock on read/write. There is a lock for the update function, but that's about all. It's obviously not sufficent. Usually, drivers have a second lock for read and write operations.
OK, I've added this to the 2.4 driver. Please test if you can.
Please add locking to your 2.6 driver as well. It should be really easy, just like:
struct smsc47m1_data *data = i2c_get_clientdata(client); down(&data->lock);
<read or write>up(&data->lock);
in both smsc47m1_read_value and smsc47m1_write_value.
Thanks.
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Hello,
wow! it has been a long time that I didn't get such good code review, thanks guys!
I agree... the PWM code seemed a bit strange to me but I assumed it to be working in the original driver, so I didn't really pay too much attention to it. (perhaps I should have?)
I'll work on the changes sometimes this week and resubmit the file.
thanks,
GG
Quoted 56 lines · --- Mark Studebaker
Gabriele, I reviewed the code and the datasheet and I agree with Jean that the
code looks totally broken. On the other hand you would think I tested the
driver when I wrote it. Would you please test the PWM operation in the current driver, including the PWM enable?
Running our pwmconfig script would be a good test. thanks
mdsQuoted 4 lines · Jean Delvare
Quoting myself:
Quoted 1 line
That's about all for this first check. I have yet
to take a look at
Quoted 4 lines
Quoted 1 line
the sysfs callback functions.
OK, I just did this. Your code is correct in the
sense that it does the
Quoted 1 line
same as what the 2.4/CVS driver does. However, I
have noticed a number
Quoted 1 line
of strangenesses, and think this is the right time
to discuss them.
Quoted 2 lines
First, there is no lock on read/write. There is a
lock for the update
Quoted 1 line
function, but that's about all. It's obviously not
sufficent. Usually,
Quoted 1 line
drivers have a second lock for read and write
operations.
Quoted 2 lines
Second, I'm really confused by the operations made
on the PWM registers.
Quoted 1 line
When reading the code, it looks like bit 7 is for
enabling PWM and bits
Quoted 1 line
6-0 hold the duty cycle value. Except that only
bits 5-0 can be set,
Quoted 1 line
and the conversions macros are odd. When looking
at the datasheet OTOH,
Quoted 1 line
I read that PWM enable is bit 0, inverted (1
actually disables PWM),
Quoted 1 line
and value is in bits 6-1. Bit 7 is a clock
modifier, we don't care.
Quoted 1 line
Conversions would be as simple as multiplying /
dividing by 4 (with
Quoted 3 lines
some rounding if you want).
Mark, am I missing something here or is PWM
handling in the smsc47m1
Quoted 1 line
driver plain broken? I'd be surprised that nobody
reported so far if it
Quoted 2 lines
is, but sometimes we get surprised.
Quoted 13 lines
Quoted 1 line
Another point that could be improved in the 2.6
driver is the fan
Quoted 1 line
divisor setting. Instead of defaulting to 2 on
invalid sets, you should
Quoted 1 line
refuse them and return
-EINVAL. This couldn't bedone in the 2.4
Quoted 1 line
driver, but it can be in 2.6, so let's do it. A
number of drivers
Quoted 4 lines
already do (
fscher.cwas the first IIRC).Thanks.
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
Gabriele, I reviewed the code and the datasheet and I agree with Jean that the code looks totally broken. On the other hand you would think I tested the driver when I wrote it. Would you please test the PWM operation in the current driver, including the PWM enable?
Running our pwmconfig script would be a good test.
thanks
mds
Quoted 36 lines · Jean Delvare
Quoting myself:
Quoted 2 lines
That's about all for this first check. I have yet to take a look at the sysfs callback functions.
OK, I just did this. Your code is correct in the sense that it does the same as what the 2.4/CVS driver does. However, I have noticed a number of strangenesses, and think this is the right time to discuss them.
First, there is no lock on read/write. There is a lock for the update function, but that's about all. It's obviously not sufficent. Usually, drivers have a second lock for read and write operations.
Second, I'm really confused by the operations made on the PWM registers. When reading the code, it looks like bit 7 is for enabling PWM and bits 6-0 hold the duty cycle value. Except that only bits 5-0 can be set, and the conversions macros are odd. When looking at the datasheet OTOH, I read that PWM enable is bit 0, inverted (1 actually disables PWM), and value is in bits 6-1. Bit 7 is a clock modifier, we don't care. Conversions would be as simple as multiplying / dividing by 4 (with some rounding if you want).
Mark, am I missing something here or is PWM handling in the smsc47m1 driver plain broken? I'd be surprised that nobody reported so far if it is, but sometimes we get surprised.
Another point that could be improved in the 2.6 driver is the fan divisor setting. Instead of defaulting to 2 on invalid sets, you should refuse them and return
-EINVAL. This couldn't be done in the 2.4 driver, but it can be in 2.6, so let's do it. A number of drivers already do (fscher.cwas the first IIRC).Thanks.
before you send us another patch, would you please test the driver either with the 2.4 version or the 2.6 version, to see if it works? thanks
Quoted 136 lines · Gabriele Gorla
Hello,
wow! it has been a long time that I didn't get such good code review, thanks guys!I agree... the PWM code seemed a bit strange to me but I assumed it to be working in the original driver, so I didn't really pay too much attention to it. (perhaps I should have?)
I'll work on the changes sometimes this week and resubmit the file.
thanks,
GGQuoted 96 lines · --- Mark Studebaker
Gabriele, I reviewed the code and the datasheet and I agree with Jean that the
code looks totally broken. On the other hand you would think I tested the
driver when I wrote it. Would you please test the PWM operation in the current driver, including the PWM enable?
Running our pwmconfig script would be a good test. thanks
mdsQuoted 5 lines · Jean Delvare
Quoting myself:
Quoted 1 line
That's about all for this first check. I have yet
to take a look at
Quoted 4 lines
Quoted 1 line
the sysfs callback functions.
OK, I just did this. Your code is correct in the
sense that it does the
Quoted 1 line
same as what the 2.4/CVS driver does. However, I
have noticed a number
Quoted 1 line
of strangenesses, and think this is the right time
to discuss them.
Quoted 1 line
First, there is no lock on read/write. There is a
lock for the update
Quoted 1 line
function, but that's about all. It's obviously not
sufficent. Usually,
Quoted 1 line
drivers have a second lock for read and write
operations.
Quoted 1 line
Second, I'm really confused by the operations made
on the PWM registers.
Quoted 1 line
When reading the code, it looks like bit 7 is for
enabling PWM and bits
Quoted 1 line
6-0 hold the duty cycle value. Except that only
bits 5-0 can be set,
Quoted 1 line
and the conversions macros are odd. When looking
at the datasheet OTOH,
Quoted 1 line
I read that PWM enable is bit 0, inverted (1
actually disables PWM),
Quoted 1 line
and value is in bits 6-1. Bit 7 is a clock
modifier, we don't care.
Quoted 1 line
Conversions would be as simple as multiplying /
dividing by 4 (with
Quoted 3 lines
some rounding if you want).
Mark, am I missing something here or is PWM
handling in the smsc47m1
Quoted 1 line
driver plain broken? I'd be surprised that nobody
reported so far if it
Quoted 3 lines
is, but sometimes we get surprised.
Another point that could be improved in the 2.6
driver is the fan
Quoted 1 line
divisor setting. Instead of defaulting to 2 on
invalid sets, you should
Quoted 13 lines
Quoted 1 line
refuse them and return
-EINVAL. This couldn't bedone in the 2.4
Quoted 1 line
driver, but it can be in 2.6, so let's do it. A
number of drivers
Quoted 4 lines
already do (
fscher.cwas the first IIRC).Thanks.
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
I've checked in lots of fixes for the driver into CVS.
It should work better now.
Would you please test it (either on 2.4, or merge the changes into your 2.6 port) thanks
mds
Quoted 215 lines · Gabriele Gorla
sure.
I did not know the existence of the testing script but I did test it with a 2.6 kernel on my intel i815 motherboard. One fan reads back something reasonable one reads back 0 and the 2 pwm do not seem to do anything (the registers read back correctly). I assumed that some features do not work on my mb because they are not connected. I do not have access to the mb schematics to check.thanks,
GGQuoted 183 lines · --- Mark Studebaker
before you send us another patch, would you please test the driver either
with the 2.4 version or the 2.6 version, to see if it works?
thanksQuoted 2 lines · Gabriele Gorla
Hello,
wow! it has been a long time that I didn't getsuch
Quoted 3 lines
good code review, thanks guys!
I agree... the PWM code seemed a bit strange to me
but
Quoted 1 line
I assumed it to be working in the original driver,
so
Quoted 1 line
I didn't really pay too much attention to it.
(perhaps
Quoted 11 lines
I should have?)
I'll work on the changes sometimes this week and
resubmit the file.thanks,
GGQuoted 1 line · --- Mark Studebaker
Gabriele, I reviewed the code and the datasheet
and
Quoted 13 lines
Quoted 13 lines
I agree with Jean that the
code looks totally broken. On the other hand you would think I tested the
driver when I wrote it. Would you please test the PWM operation in the current driver, including the PWM enable?
Running our pwmconfig script would be a good test. thanks
mdsJean Delvare wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoting myself:
Quoted 1 line
That's about all for this first check. I have
yet
Quoted 11 lines
Quoted 11 lines
to take a look at
Quoted 4 lines
Quoted 1 line
the sysfs callback functions.
OK, I just did this. Your code is correct in the
sense that it does the
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
same as what the 2.4/CVS driver does. However, I
have noticed a number
Quoted 1 line
of strangenesses, and think this is the right
time
Quoted 9 lines
Quoted 9 lines
to discuss them.
Quoted 1 line
First, there is no lock on read/write. There is a
lock for the update
Quoted 1 line
function, but that's about all. It's obviously
not
Quoted 9 lines
Quoted 9 lines
sufficent. Usually,
Quoted 1 line
drivers have a second lock for read and write
operations.
Quoted 1 line
Second, I'm really confused by the operations
made
Quoted 76 lines
Quoted 72 lines
on the PWM registers.
Quoted 1 line
When reading the code, it looks like bit 7 is for
enabling PWM and bits
Quoted 1 line
6-0 hold the duty cycle value. Except that only
bits 5-0 can be set,
Quoted 1 line
and the conversions macros are odd. When looking
at the datasheet OTOH,
Quoted 1 line
I read that PWM enable is bit 0, inverted (1
actually disables PWM),
Quoted 1 line
and value is in bits 6-1. Bit 7 is a clock
modifier, we don't care.
Quoted 1 line
Conversions would be as simple as multiplying /
dividing by 4 (with
Quoted 3 lines
some rounding if you want).
Mark, am I missing something here or is PWM
handling in the smsc47m1
Quoted 1 line
driver plain broken? I'd be surprised that nobody
reported so far if it
Quoted 3 lines
is, but sometimes we get surprised.
Another point that could be improved in the 2.6
driver is the fan
Quoted 1 line
divisor setting. Instead of defaulting to 2 on
invalid sets, you should
Quoted 1 line
refuse them and return
-EINVAL. This couldn't bedone in the 2.4
Quoted 1 line
driver, but it can be in 2.6, so let's do it. A
number of drivers
Quoted 4 lines
already do (
fscher.cwas the first IIRC).Thanks.
Quoted 8 lines
Quoted 4 lines
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobshttp://hotjobs.sweepstakes.yahoo.com/careermakeover
Quoted 1 line
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
Linux 2.6 port of smsc47m1
In reply to Gabriele GorlaHi Gabriele,
Some times ago you came to us with a Linux 2.6 port of the smsc47m1 driver. It was in rather good shape as far as I remember, except for a few things that were not correct in the original driver. These problems have been fixed since, and we would much appreciate if you could integrate the changes into your code and provide a complete patch against linux-2.6.7. We have had several requests from users interested in this port, so it would be great if we could get it integrated soon now.
Thanks.
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/