* linux 2.6 port of smsc47m1
@ 2005-05-19 6:24 Gabriele Gorla
2005-05-19 6:24 ` Jean Delvare
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Gabriele Gorla @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
[Please reply to the list, not to me directly]
> I ported the smsc47m1 driver to kernel 2.6
> you can find the file at:
> http://penguintown.net/~gorlik/smsc47m1.c
Nice :)
> I don't know what is the procedure to get it into the
> lm_sensors and/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/w83627hf.c@1.6?nav=cset@1.1371.600.23
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.
--
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
2005-05-19 6:24 ` Jean Delvare
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Quoting myself:
> 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.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Mark Studebaker
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Quoting myself (again):
> 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.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
` (4 preceding siblings ...)
2005-05-19 6:24 ` Gabriele Gorla
@ 2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:25 ` Linux " Jean Delvare
7 siblings, 0 replies; 9+ messages in thread
From: Mark Studebaker @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
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
Jean Delvare wrote:
> Quoting myself:
>
>
>>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.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
` (3 preceding siblings ...)
2005-05-19 6:24 ` Mark Studebaker
@ 2005-05-19 6:24 ` Gabriele Gorla
2005-05-19 6:24 ` Mark Studebaker
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Gabriele Gorla @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
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
--- Mark Studebaker <mds4@verizon.net> wrote:
> 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
>
> Jean Delvare wrote:
> > Quoting myself:
> >
> >
> >>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.
> >
>
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
` (2 preceding siblings ...)
2005-05-19 6:24 ` Jean Delvare
@ 2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:24 ` Gabriele Gorla
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Mark Studebaker @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
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
Gabriele Gorla wrote:
> 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
> --- Mark Studebaker <mds4@verizon.net> wrote:
>
>>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
>>
>>Jean Delvare wrote:
>>
>>>Quoting myself:
>>>
>>>
>>>
>>>>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.
>>>
>>
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
` (5 preceding siblings ...)
2005-05-19 6:24 ` Mark Studebaker
@ 2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:25 ` Linux " Jean Delvare
7 siblings, 0 replies; 9+ messages in thread
From: Mark Studebaker @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
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
Gabriele Gorla wrote:
> 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,
> GG
>
> --- Mark Studebaker <mds4@verizon.net> wrote:
>
>>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
>>
>>Gabriele Gorla wrote:
>>
>>>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
>>>--- Mark Studebaker <mds4@verizon.net> wrote:
>>>
>>>
>>>>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
>>>>
>>>>Jean Delvare wrote:
>>>>
>>>>
>>>>>Quoting myself:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>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.
>>>>>
>>>>
>>>
>>>
>>>
>>>
>>>__________________________________
>>>Do you Yahoo!?
>>>Win a $20,000 Career Makeover at Yahoo! HotJobs
>>>
>>
>>http://hotjobs.sweepstakes.yahoo.com/careermakeover
>>
>>>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Linux 2.6 port of smsc47m1
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
` (6 preceding siblings ...)
2005-05-19 6:24 ` Mark Studebaker
@ 2005-05-19 6:25 ` Jean Delvare
7 siblings, 0 replies; 9+ messages in thread
From: Jean Delvare @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
Hi 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.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-05-19 6:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19 6:24 linux 2.6 port of smsc47m1 Gabriele Gorla
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:24 ` Gabriele Gorla
2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:24 ` Mark Studebaker
2005-05-19 6:25 ` Linux " Jean Delvare
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.