All of lore.kernel.org
 help / color / mirror / Atom feed
From: IKEGAMI Tokunori <ikegami@allied-telesis.co.jp>
To: Guenter Roeck <linux@roeck-us.net>, Jean Delvare <jdelvare@suse.com>
Cc: PACKHAM Chris <chris.packham@alliedtelesis.co.nz>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Subject: RE: [PATCH 4/5] hwmon: adt7475: Change to use adt7475_write macro
Date: Thu, 12 Jul 2018 02:56:55 +0000	[thread overview]
Message-ID: <OSAPR01MB3170C2F14D75DC381B14994DDC590@OSAPR01MB3170.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <fe368940-6b82-7da2-4827-8193f75f5072@roeck-us.net>

Hi Guenter-san,

I think to change the patch to repeat for the error case by a adt7475_write function as same with adt7475_read.

Regards,
Ikegami

> -----Original Message-----
> From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter
> Roeck
> Sent: Thursday, July 12, 2018 10:53 AM
> To: IKEGAMI Tokunori; Jean Delvare
> Cc: PACKHAM Chris; linux-hwmon@vger.kernel.org
> Subject: Re: [PATCH 4/5] hwmon: adt7475: Change to use adt7475_write
> macro
> 
> On 07/11/2018 06:04 PM, Tokunori Ikegami wrote:
> > As same with adt7475_read it is better to use adt7475_write macro.
> > So change to use it instead of i2c_smbus_write_byte_data.
> >
> You don't explain why this would be "better", and I disagree that it is.
> On the contrary, it just hides the API function. I don't see why this
> would be better, and even more I don't want to encourage others
> flooding us with patches to introduce similar code in other drivers
> because they think that it is "better".
> 
> Guenter
> 
> > Signed-off-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
> > Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > Cc: linux-hwmon@vger.kernel.org
> > ---
> >   drivers/hwmon/adt7475.c | 30 +++++++++++++++++-------------
> >   1 file changed, 17 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
> > index bad250729e99..31a12ac405ef 100644
> > --- a/drivers/hwmon/adt7475.c
> > +++ b/drivers/hwmon/adt7475.c
> > @@ -133,6 +133,10 @@
> >
> >   #define adt7475_read(reg) i2c_smbus_read_byte_data(client, (reg))
> >
> > +/* Macro to write the registers */
> >  > +#define adt7475_write(reg, val) i2c_smbus_write_byte_data(client,
> (reg), (val))
> > +
> >   /* Macros to easily index the registers */
> >
> >   #define TACH_REG(idx) (REG_TACH_BASE + ((idx) * 2))
> > @@ -322,11 +326,11 @@ static int adt7475_write_word(struct i2c_client
> *client, int reg, u16 val)
> >   {
> >   	int ret;
> >
> > -	ret = i2c_smbus_write_byte_data(client, reg + 1, val >> 8);
> > +	ret = adt7475_write(reg + 1, val >> 8);
> >   	if (ret < 0)
> >   		return ret;
> >
> > -	ret = i2c_smbus_write_byte_data(client, reg, val & 0xFF);
> > +	ret = adt7475_write(reg, val & 0xFF);
> >   	if (ret < 0)
> >   		return ret;
> >
> > @@ -381,7 +385,7 @@ static ssize_t set_voltage(struct device *dev,
> struct device_attribute *attr,
> >   			reg = REG_VTT_MAX;
> >   	}
> >
> > -	i2c_smbus_write_byte_data(client, reg,
> > +	adt7475_write(reg,
> >
> data->voltage[sattr->nr][sattr->index] >> 2);
> >   	mutex_unlock(&data->lock);
> >
> > @@ -534,7 +538,7 @@ static ssize_t set_temp(struct device *dev, struct
> device_attribute *attr,
> >   		break;
> >   	}
> >
> > -	i2c_smbus_write_byte_data(client, reg, out);
> > +	adt7475_write(reg, out);
> >
> >   	mutex_unlock(&data->lock);
> >   	return count;
> > @@ -615,7 +619,7 @@ static ssize_t set_temp_st(struct device *dev,
> struct device_attribute *attr,
> >   	data->enh_acoustics[idx] &= ~(0xf << shift);
> >   	data->enh_acoustics[idx] |= (val << shift);
> >
> > -	i2c_smbus_write_byte_data(client, reg,
> data->enh_acoustics[idx]);
> > +	adt7475_write(reg, data->enh_acoustics[idx]);
> >
> >   	mutex_unlock(&data->lock);
> >
> > @@ -683,7 +687,7 @@ static ssize_t set_point2(struct device *dev,
> struct device_attribute *attr,
> >   	data->range[sattr->index] &= ~0xF0;
> >   	data->range[sattr->index] |= val << 4;
> >
> > -	i2c_smbus_write_byte_data(client,
> TEMP_TRANGE_REG(sattr->index),
> > +	adt7475_write(TEMP_TRANGE_REG(sattr->index),
> >   				  data->range[sattr->index]);
> >
> >   	mutex_unlock(&data->lock);
> > @@ -798,7 +802,7 @@ static ssize_t set_pwm(struct device *dev, struct
> device_attribute *attr,
> >   	}
> >
> >   	data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF);
> > -	i2c_smbus_write_byte_data(client, reg,
> > +	adt7475_write(reg,
> >
> data->pwm[sattr->nr][sattr->index]);
> >   	mutex_unlock(&data->lock);
> >
> > @@ -835,7 +839,7 @@ static ssize_t set_stall_disable(struct device
> *dev,
> >   	if (val)
> >   		data->enh_acoustics[0] |= mask;
> >
> > -	i2c_smbus_write_byte_data(client, REG_ENHANCE_ACOUSTICS1,
> > +	adt7475_write(REG_ENHANCE_ACOUSTICS1,
> >   				  data->enh_acoustics[0]);
> >
> >   	mutex_unlock(&data->lock);
> > @@ -894,7 +898,7 @@ static int hw_set_pwm(struct i2c_client *client,
> int index,
> >   	data->pwm[CONTROL][index] &= ~0xE0;
> >   	data->pwm[CONTROL][index] |= (val & 7) << 5;
> >
> > -	i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
> > +	adt7475_write(PWM_CONFIG_REG(index),
> >   				  data->pwm[CONTROL][index]);
> >
> >   	return 0;
> > @@ -983,7 +987,7 @@ static ssize_t set_pwmfreq(struct device *dev,
> struct device_attribute *attr,
> >   	data->range[sattr->index] &= ~0xf;
> >   	data->range[sattr->index] |= out;
> >
> > -	i2c_smbus_write_byte_data(client,
> TEMP_TRANGE_REG(sattr->index),
> > +	adt7475_write(TEMP_TRANGE_REG(sattr->index),
> >   				  data->range[sattr->index]);
> >
> >   	mutex_unlock(&data->lock);
> > @@ -1017,7 +1021,7 @@ static ssize_t
> pwm_use_point2_pwm_at_crit_store(struct device *dev,
> >   		data->config4 |= CONFIG4_MAXDUTY;
> >   	else
> >   		data->config4 &= ~CONFIG4_MAXDUTY;
> > -	i2c_smbus_write_byte_data(client, REG_CONFIG4,
> data->config4);
> > +	adt7475_write(REG_CONFIG4, data->config4);
> >   	mutex_unlock(&data->lock);
> >
> >   	return count;
> > @@ -1642,10 +1646,10 @@ static void adt7475_read_pwm(struct i2c_client
> *client, int index)
> >   		data->pwm[CONTROL][index] &= ~0xE0;
> >   		data->pwm[CONTROL][index] |= (7 << 5);
> >
> > -		i2c_smbus_write_byte_data(client,
> PWM_CONFIG_REG(index),
> > +		adt7475_write(PWM_CONFIG_REG(index),
> >   					  data->pwm[INPUT][index]);
> >
> > -		i2c_smbus_write_byte_data(client,
> PWM_CONFIG_REG(index),
> > +		adt7475_write(PWM_CONFIG_REG(index),
> >   					  data->pwm[CONTROL][index]);
> >
> >   		data->pwmctl[index] = 1;
> >


  reply	other threads:[~2018-07-12  2:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12  1:04 [PATCH 0/5] hwmon: adt7475: Add error handling for update function Tokunori Ikegami
2018-07-12  1:04 ` [PATCH 1/5] hwmon: adt7475: Split device update function to measure and limits Tokunori Ikegami
2018-07-12  2:00   ` Guenter Roeck
2018-07-12  3:01     ` IKEGAMI Tokunori
2018-07-12  1:04 ` [PATCH 2/5] hwmon: adt7475: Change read and write functions to return error Tokunori Ikegami
2018-07-12  1:04 ` [PATCH 3/5] hwmon: adt7475: Change to use adt7475_read macro Tokunori Ikegami
2018-07-12  1:50   ` Guenter Roeck
2018-07-12  2:52     ` IKEGAMI Tokunori
2018-07-12  3:41       ` Guenter Roeck
2018-07-12  4:01         ` IKEGAMI Tokunori
2018-07-12  4:23           ` Guenter Roeck
2018-07-12  6:22             ` IKEGAMI Tokunori
2018-07-12 13:47             ` IKEGAMI Tokunori
2018-07-12 14:05               ` Guenter Roeck
2018-07-12 14:33                 ` IKEGAMI Tokunori
2018-07-12  1:04 ` [PATCH 4/5] hwmon: adt7475: Change to use adt7475_write macro Tokunori Ikegami
2018-07-12  1:52   ` Guenter Roeck
2018-07-12  2:56     ` IKEGAMI Tokunori [this message]
2018-07-12  1:04 ` [PATCH 5/5] hwmon: adt7475: Change update functions to add error handling Tokunori Ikegami

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OSAPR01MB3170C2F14D75DC381B14994DDC590@OSAPR01MB3170.jpnprd01.prod.outlook.com \
    --to=ikegami@allied-telesis.co.jp \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.