hwmon: Add a driver for the ADT7475 thermal sensor (resend)

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

 



On 14/09/08 19:50 +0200, Hans de Goede wrote:
> >   CC [M]  drivers/hwmon/adt7475.o
> > drivers/hwmon/adt7475.c: In function ?adt7475_update_device?:
> > drivers/hwmon/adt7475.c:1043: warning: array subscript is above array bounds
> > 
> 
> <snip>
> 
> > Apparently struct adt7475_data should be changed from
> > 	s16 temp[6][3];
> > to
> > 	s16 temp[7][3];
> > 
> 
> Looking closer at the code: you are completely right
> 
> Also while looking closer:
> 
> This snippet in adt7475_update_device() :
> 
>          data->temp[HYSTERSIS][0] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS);
>          data->temp[HYSTERSIS][1] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS);
>          data->temp[HYSTERSIS][2] = (u16) adt7475_read(REG_REMOTE2_HYSTERSIS);
> 
> Should be rewritten to:
>          data->temp[HYSTERSIS][0] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS);
>          data->temp[HYSTERSIS][1] = data->temp[HYSTERSIS][0];
>          data->temp[HYSTERSIS][2] = (u16) adt7475_read(REG_REMOTE2_HYSTERSIS);
> 
> To avoid 1 (slow) unnecessary i2c transaction.

With much egg on my face, here is an updated patch.  Compiles clean
with gcc 4.2.3.  Updated the index and removed the redundant smbus read.

Jordan

-- 
Jordan Crouse
Systems Software Development Engineer 
Advanced Micro Devices, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: adt7475.patch
Type: text/x-diff
Size: 40320 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20080915/d4ef0e4b/attachment.bin 


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

  Powered by Linux