devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: jdelvare@suse.com, robh+dt@kernel.org,
	linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] hwmon: (adt7475) Use enum chips when loading attenuator settings
Date: Sun, 1 May 2022 21:37:00 -0700	[thread overview]
Message-ID: <20220502043700.GA1719447@roeck-us.net> (raw)
In-Reply-To: <20220323034056.260455-4-chris.packham@alliedtelesis.co.nz>

On Wed, Mar 23, 2022 at 04:40:56PM +1300, Chris Packham wrote:
> Make use of enum chips and use a switch statement in load_attenuators()
> so that the compiler can tell us if we've failed to cater for a
> supported chip.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>

Applied to hwmon-next.

Thanks,
Guenter

> ---
> 
> Notes:
>     Changes in v3:
>     - Reword commit message
>     - Use switch instead of if/else
>     Changes in v2:
>     - New
> 
>  drivers/hwmon/adt7475.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
> index 6de501de41b2..ac480e6e4818 100644
> --- a/drivers/hwmon/adt7475.c
> +++ b/drivers/hwmon/adt7475.c
> @@ -1569,12 +1569,12 @@ static int set_property_bit(const struct i2c_client *client, char *property,
>  	return ret;
>  }
>  
> -static int load_attenuators(const struct i2c_client *client, int chip,
> +static int load_attenuators(const struct i2c_client *client, enum chips chip,
>  			    struct adt7475_data *data)
>  {
> -	int ret;
> -
> -	if (chip == adt7476 || chip == adt7490) {
> +	switch (chip) {
> +	case adt7476:
> +	case adt7490:
>  		set_property_bit(client, "adi,bypass-attenuator-in0",
>  				 &data->config4, 4);
>  		set_property_bit(client, "adi,bypass-attenuator-in1",
> @@ -1584,18 +1584,15 @@ static int load_attenuators(const struct i2c_client *client, int chip,
>  		set_property_bit(client, "adi,bypass-attenuator-in4",
>  				 &data->config4, 7);
>  
> -		ret = i2c_smbus_write_byte_data(client, REG_CONFIG4,
> -						data->config4);
> -		if (ret < 0)
> -			return ret;
> -	} else if (chip == adt7473 || chip == adt7475) {
> +		return i2c_smbus_write_byte_data(client, REG_CONFIG4,
> +						 data->config4);
> +	case adt7473:
> +	case adt7475:
>  		set_property_bit(client, "adi,bypass-attenuator-in1",
>  				 &data->config2, 5);
>  
> -		ret = i2c_smbus_write_byte_data(client, REG_CONFIG2,
> -						data->config2);
> -		if (ret < 0)
> -			return ret;
> +		return i2c_smbus_write_byte_data(client, REG_CONFIG2,
> +						 data->config2);
>  	}
>  
>  	return 0;

      parent reply	other threads:[~2022-05-02  4:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23  3:40 [PATCH v3 0/3] hwmon: (adt7475) pin configuration Chris Packham
2022-03-23  3:40 ` [PATCH v3 1/3] dt-bindings: hwmon: Document adt7475 pin-function properties Chris Packham
2022-04-24 16:52   ` Guenter Roeck
2022-05-02  4:35   ` Guenter Roeck
2022-03-23  3:40 ` [PATCH v3 2/3] hwmon: (adt7475) Add support for pin configuration Chris Packham
2022-04-24 16:53   ` Guenter Roeck
2022-05-02  4:36   ` Guenter Roeck
2022-03-23  3:40 ` [PATCH v3 3/3] hwmon: (adt7475) Use enum chips when loading attenuator settings Chris Packham
2022-04-24 16:54   ` Guenter Roeck
2022-05-02  4:37   ` Guenter Roeck [this message]

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=20220502043700.GA1719447@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).