From: Guenter Roeck <linux@roeck-us.net>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] hwmon: (adm9240) Use loops to avoid duplicated code
Date: Thu, 24 Sep 2020 07:47:08 -0700 [thread overview]
Message-ID: <20200924144708.GA191738@roeck-us.net> (raw)
In-Reply-To: <20200924085102.15219-2-chris.packham@alliedtelesis.co.nz>
Hi Chris,
On Thu, Sep 24, 2020 at 08:51:00PM +1200, Chris Packham wrote:
> Use loops for reading temp_max and initialising FAN_MIN/TEMP_MAX rather
> than duplicating code.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Series applied (and module tested).
Thanks a lot for the clean submission.
Guenter
> ---
> drivers/hwmon/adm9240.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
> index 496d47490e10..f95dde1b9c7f 100644
> --- a/drivers/hwmon/adm9240.c
> +++ b/drivers/hwmon/adm9240.c
> @@ -223,10 +223,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
> data->fan_min[i] = i2c_smbus_read_byte_data(client,
> ADM9240_REG_FAN_MIN(i));
> }
> - data->temp_max[0] = i2c_smbus_read_byte_data(client,
> - ADM9240_REG_TEMP_MAX(0));
> - data->temp_max[1] = i2c_smbus_read_byte_data(client,
> - ADM9240_REG_TEMP_MAX(1));
> + for (i = 0; i < 2; i++) {
> + data->temp_max[i] = i2c_smbus_read_byte_data(client,
> + ADM9240_REG_TEMP_MAX(i));
> + }
>
> /* read fan divs and 5-bit VID */
> i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
> @@ -687,14 +687,14 @@ static void adm9240_init_client(struct i2c_client *client)
> i2c_smbus_write_byte_data(client,
> ADM9240_REG_IN_MAX(i), 255);
> }
> - i2c_smbus_write_byte_data(client,
> - ADM9240_REG_FAN_MIN(0), 255);
> - i2c_smbus_write_byte_data(client,
> - ADM9240_REG_FAN_MIN(1), 255);
> - i2c_smbus_write_byte_data(client,
> - ADM9240_REG_TEMP_MAX(0), 127);
> - i2c_smbus_write_byte_data(client,
> - ADM9240_REG_TEMP_MAX(1), 127);
> + for (i = 0; i < 2; i++) {
> + i2c_smbus_write_byte_data(client,
> + ADM9240_REG_FAN_MIN(i), 255);
> + }
> + for (i = 0; i < 2; i++) {
> + i2c_smbus_write_byte_data(client,
> + ADM9240_REG_TEMP_MAX(i), 127);
> + }
>
> /* start measurement cycle */
> i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1);
next prev parent reply other threads:[~2020-09-24 14:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 8:50 [PATCH 0/3] hwmon: (adm9240) driver updates Chris Packham
2020-09-24 8:51 ` [PATCH 1/3] hwmon: (adm9240) Use loops to avoid duplicated code Chris Packham
2020-09-24 14:47 ` Guenter Roeck [this message]
2020-09-24 8:51 ` [PATCH 2/3] hwmon: (adm9240) Create functions for updating measure and config Chris Packham
2020-09-24 8:51 ` [PATCH 3/3] hwmon: (adm9240) Convert to regmap 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=20200924144708.GA191738@roeck-us.net \
--to=linux@roeck-us.net \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®