lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yo8oWvd3ChpOyOJ7@t480s.localdomain>
Date:   Thu, 26 May 2022 09:12:26 +0200
From:   Slawomir Stepien <sst@...zta.fm>
To:     Guenter Roeck <linux@...ck-us.net>
Cc:     linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jean Delvare <jdelvare@...e.com>
Subject: Re: [PATCH 13/40] hwmon: (lm90) Support multiple temperature
 resolutions

On maj 25, 2022 06:57, Guenter Roeck wrote:
> (...)
> @@ -1477,36 +1332,36 @@ static int lm90_temp_write(struct device *dev, u32 attr, int channel, long val)
>  
>  	switch (attr) {
>  	case hwmon_temp_min:
> -		if (channel == 0)
> -			err = lm90_set_temp8(data,
> -					      lm90_temp_min_index[channel],
> -					      val);
> -		else
> -			err = lm90_set_temp11(data,
> -					      lm90_temp_min_index[channel],
> -					      val);
> +		err = lm90_set_temp(data, lm90_temp_min_index[channel],
> +				    channel, val);
>  		break;
>  	case hwmon_temp_max:
> -		if (channel == 0)
> -			err = lm90_set_temp8(data,
> -					     lm90_temp_max_index[channel],
> -					     val);
> -		else
> -			err = lm90_set_temp11(data,
> -					      lm90_temp_max_index[channel],
> -					      val);
> +		err = lm90_set_temp(data, lm90_temp_max_index[channel],
> +				    channel, val);
>  		break;
>  	case hwmon_temp_crit:
> -		err = lm90_set_temp8(data, lm90_temp_crit_index[channel], val);
> +		err = lm90_set_temp(data, lm90_temp_crit_index[channel],
> +				    channel, val);
>  		break;
>  	case hwmon_temp_crit_hyst:
>  		err = lm90_set_temphyst(data, val);
>  		break;
>  	case hwmon_temp_emergency:
> -		err = lm90_set_temp8(data, lm90_temp_emerg_index[channel], val);
> +		err = lm90_set_temp(data, lm90_temp_emerg_index[channel],
> +				    channel, val);
>  		break;
>  	case hwmon_temp_offset:
> -		err = lm90_set_temp11(data, REMOTE_OFFSET, val);
> +		val = lm90_temp_to_reg(0, val,
> +				       lm90_temp_get_resolution(data, REMOTE_OFFSET));
> +		data->temp[REMOTE_OFFSET] = val;

I do not understand why you do this val assignment here, before doing real i2c write. That write
might fail and then we have "incorrect" value in data->temp.

> +		err = i2c_smbus_write_byte_data(data->client,
> +						LM90_REG_REMOTE_OFFSH,
> +						val >> 8);
> +		if (err)
> +			break;
> +		err = i2c_smbus_write_byte_data(data->client,
> +						LM90_REG_REMOTE_OFFSL,
> +						val & 0xff);
>  		break;
>  	default:
>  		err = -EOPNOTSUPP;
> @@ -2035,6 +1890,7 @@ static int lm90_probe(struct i2c_client *client)
>  	 * ALERT# output
>  	 */
>  	data->alert_alarms = lm90_params[data->kind].alert_alarms;
> +	data->resolution = lm90_params[data->kind].resolution ? : 11;
>  
>  	/* Set chip capabilities */
>  	data->flags = lm90_params[data->kind].flags;

-- 
Slawomir Stepien

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ