Re: [PATCH v2 3/4] hwmon: (lm92) Drop function macros

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

 



Hi Guenter,

On Sun, 20 Apr 2014 20:43:51 -0700, Guenter Roeck wrote:
> Function macros obfuscate code and increase code size, so drop them.
> 
> Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> ---
> v2: Drop comma after t_num_regs
>     Declare register array as const and with explicit size
> 
>  drivers/hwmon/lm92.c |  165 +++++++++++++++++++++++++-------------------------
>  1 file changed, 82 insertions(+), 83 deletions(-)
> (...)
> +static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
> +			   const char *buf, size_t count)
>  {
> -	struct lm92_data *data = lm92_update_device(dev);
> -	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_crit)
> -		       - TEMP_FROM_REG(data->temp1_hyst));
> +	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
> +	struct i2c_client *client = to_i2c_client(dev);
> +	struct lm92_data *data = i2c_get_clientdata(client);
> +	int nr = attr->index;
> +	long val;
> +	int err = kstrtol(buf, 10, &val);

I would separate variable declaration from actual code here, that would
be easier to read and would be consistent with the code in
set_temp_hyst().

> +	if (err)
> +		return err;
> +
> +	mutex_lock(&data->update_lock);
> +	data->temp[nr] = TEMP_TO_REG(val);
> +	i2c_smbus_write_word_swapped(client, regs[nr], data->temp[nr]);
> +	mutex_unlock(&data->update_lock);
> +	return count;
>  }

Other than this it looks good to me, although I can't test. Do you
happen to have a register dump from an LM92, MAX6635 or any compatible
chip?

Reviewed-by: Jean Delvare <jdelvare@xxxxxxx>

-- 
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors




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

  Powered by Linux