Linux Hardware Monitor development
 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 v2 3/3] hwmon: (adt7475) Use enum chips when loading attenuator settings
Date: Fri, 18 Mar 2022 07:32:23 -0700	[thread overview]
Message-ID: <20220318143223.GA673001@roeck-us.net> (raw)
In-Reply-To: <20220317223051.1227110-4-chris.packham@alliedtelesis.co.nz>

On Fri, Mar 18, 2022 at 11:30:50AM +1300, Chris Packham wrote:
> Simplify load_attenuators() by making use of enum chips instead of int.
> 

That isn't the only thing the patch is doing.

> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> 
> Notes:
>     Changes in v2:
>     - New
> 
>  drivers/hwmon/adt7475.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
> index 6de501de41b2..ebe4a85eb62e 100644
> --- a/drivers/hwmon/adt7475.c
> +++ b/drivers/hwmon/adt7475.c
> @@ -1569,7 +1569,7 @@ 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;
> @@ -1588,7 +1588,7 @@ static int load_attenuators(const struct i2c_client *client, int chip,
>  						data->config4);
>  		if (ret < 0)
>  			return ret;
> -	} else if (chip == adt7473 || chip == adt7475) {
> +	} else {

This is the real change. Well, in theory. It doesn't really make a difference,
it is just (currently) unnecessary but clarifies that the following code only
applies to the two chips. It may be better to replace the if/else with a switch
statement to clarify this. Dropping the conditional would not require to change
the parameter type. That only really adds value if you also use a switch
statement (without dummy default).

Thanks,
Guenter

>  		set_property_bit(client, "adi,bypass-attenuator-in1",
>  				 &data->config2, 5);
>  

  reply	other threads:[~2022-03-18 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 22:30 [PATCH v2 0/3] hwmon: (adt7475) pin configuration Chris Packham
2022-03-17 22:30 ` [PATCH v2 1/3] dt-bindings: hwmon: Document adt7475 pin-function properties Chris Packham
2022-03-17 22:30 ` [PATCH v2 2/3] hwmon: (adt7475) Add support for pin configuration Chris Packham
2022-03-17 22:30 ` [PATCH v2 3/3] hwmon: (adt7475) Use enum chips when loading attenuator settings Chris Packham
2022-03-18 14:32   ` Guenter Roeck [this message]
2022-03-21  0:27     ` Chris Packham

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=20220318143223.GA673001@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