[PATCH] lm75.c write values below 0°C

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

 



Hi Christian,

On Tue, 24 Jul 2007 11:35:37 +0200, Christian Hohnstaedt wrote:
> writing values < 0?C to TLow and THigh of the LM75 is not 
> supported by the driver, since it strtoul()s instead
> of strtol()ing.
> 
> Trivial fix attached.

Good catch, however your fix is not correct:

> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index a40166f..4fa3220 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -95,7 +95,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
>  	struct i2c_client *client = to_i2c_client(dev);
>  	struct lm75_data *data = i2c_get_clientdata(client);
>  	int nr = attr->index;
> -	unsigned long temp = simple_strtoul(buf, NULL, 10);
> +	int temp = simple_strtol(buf, NULL, 10);
>  
>  	mutex_lock(&data->update_lock);
>  	data->temp[nr] = LM75_TEMP_TO_REG(temp);

temp should be a long rather than an int. Otherwise the input value
might wrap before LM75_TEMP_TO_REG has a chance to clamp it.

Your patch also lacks a Signed-off-by line (see
Documentation/SubmittingPatches, section 12.)

Care to resend an updated patch?

Thanks,
-- 
Jean Delvare




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

  Powered by Linux