Skip to contentSkip to conversation

lm_sensors2/kernel/chips lm75.c

DISCUSSION Jean Delvare 2 participants 3 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines

Modified Files:

	lm75.c 

Log Message:
(mds) only initialize CMP/INT bit, and only if necessary

I am not happy with that change.

For one thing, if the chip was in shutdown mode, you leave it there. This means that the temperature will never be updated, making the driver useless.

For another, changing the CMP/INT bit is NOT a good idea. It's fine to change the mode when it only affects alarm bits. However in this case what it affects is the OS output, and you don't know what is wired to that output. If the chip was programmed to INT mode, which is not the default, there must be a reason, and that reason must be that whatever is wired to the OS output expects interrupts and not comparator mode. By arbitrarily changing the mode (and with no reason at that) you probably screw the hardware overtemperature control mechanism.

The second point is no worse than what we had before (which obviously means that most hardware designs don't use the interrupt mode, or we would have had bad feedback), but the first one is a regression.

Thanks,

Signature · 1 line
Jean Delvare
#1 lore raw
Quoted 2 lines

good points
thanks for reviewing

Thanks. Care to prepare a similar patch for Linux 2.6?

As a side note, your (u8) casts seem unnecessary to me.

Quoted 2 lines

I forgot the LM75 doesn't have an alarm bit, so there's no use changing the CMP/INT bit.

That's absolutely right.

Quoted 4 lines

This is similar to what we do in other drivers, but for those chips, the CMP/INT mode setting affects the output pin AND the alarm bits, with no harm done as far as I know.

I don't quite agree. There are in fact three different cases:
1* Mode affects output pin(s) only.
2* Mode affects flags only.
3* Mode affects flags and output pin(s) at the same time.

In case 1, changing the mode is pointless.

In case 2, we obviously can pick comparator mode so that flags behave the standard way.

In case 3, I think we should *not* change the mode. If the chip is brought to us in interrupt mode, we might decide not to display any alarm (because they wouldn't be what user-space expects), but changing the mode will have the side effect of altering the output, and this is wrong, because we just don't know what is connected to it.

I think that most chips with a CMP/INT flag fall under case 3.

The fact that other drivers do change the flag in case 3 doesn't mean it's the right thing to do. Most drivers used to reset the chip on load, which has since proven to be incorrect.

Thanks,

Signature · 1 line
Jean Delvare
#2 lore raw
In reply to Jean Delvare

good points
thanks for reviewing

Quoted 6 lines · Jean Delvare
Quoted 4 lines

Modified Files:

	lm75.c 

Log Message:
(mds) only initialize CMP/INT bit, and only if necessary

Quoted 6 lines

I am not happy with that change.

For one thing, if the chip was in shutdown mode, you leave it there. This means that the temperature will never be updated, making the driver useless.

I missed the shutdown bit.

Quoted 9 lines

For another, changing the CMP/INT bit is NOT a good idea. It's fine to change the mode when it only affects alarm bits. However in this case what it affects is the OS output, and you don't know what is wired to that output. If the chip was programmed to INT mode, which is not the default, there must be a reason, and that reason must be that whatever is wired to the OS output expects interrupts and not comparator mode. By arbitrarily changing the mode (and with no reason at that) you probably screw the hardware overtemperature control mechanism.

I forgot the LM75 doesn't have an alarm bit, so there's no use changing the CMP/INT bit.

This is similar to what we do in other drivers,
but for those chips, the CMP/INT mode setting affects the output pin AND the alarm bits, with no harm done as far as I know.
But in this case, it's pointless, since there's no alarm bit.

mds