Myson MTP008 driver ported to 2.6 kernel

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

 



On Wed, Oct 05, 2005 at 05:12:12PM +0200, Jean Delvare wrote:
> > #define SENS_FROM_REG(val)	((val) == 0 ? 0	: ((val) ^ 0x03))
> > #define SENS_TO_REG(val)	SENS_FROM_REG(val)
> 
> This looks like a trick. Don't use tricks. You're really not saving
> anything, but are increasing the chances that a bug sneaks in.

OK, these are two alternatives:

#define SENS_FROM_REG(val)	((val) == 0 ? 0	: (1 - (val - 1)) + 1)

#define SENS_FROM_REG(val)	((val) == 0 ? 0	: (val) == 1 ? 2 : 1)

Do you really find either of these more readable?  I don't.
This code is also clearly commented:

/* sysfs temperature sensor types       mtp008 sensor types
 * 0: Not defined                       0: Analog input (voltage)
 * 1: PII/Celeron Diode                 2: PII Diode
 * 2: 3904 transistor                   1: Thermistor

Regards,
	Andrew
-- 
mailto:xanni at xanadu.net                         Andrew Pam
http://www.xanadu.com.au/                       Chief Scientist, Xanadu
http://www.glasswings.com.au/                   Partner, Glass Wings
http://www.sericyb.com.au/                      Manager, Serious Cybernetics




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

  Powered by Linux