From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Subject: [PATCH 2/3] hwmon: (adm9240) Store i2c device instead of client in local data
Date: Wed, 10 Mar 2021 23:33:01 -0800 [thread overview]
Message-ID: <20210311073302.221954-2-linux@roeck-us.net> (raw)
In-Reply-To: <20210311073302.221954-1-linux@roeck-us.net>
We only use the pointer to i2c_client to access &client->dev.
Store the device pointer directly instead of retrieving it
from i2c_client.
Cc: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/adm9240.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 3bbdd662c9e4..7404082c7a3f 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -123,7 +123,7 @@ static inline unsigned int AOUT_FROM_REG(u8 reg)
/* per client data */
struct adm9240_data {
- struct i2c_client *client;
+ struct device *dev;
struct regmap *regmap;
struct mutex update_lock;
char valid;
@@ -160,7 +160,7 @@ static int adm9240_write_fan_div(struct adm9240_data *data, int nr,
err = regmap_write(data->regmap, ADM9240_REG_VID_FAN_DIV, reg);
if (err < 0)
return err;
- dev_dbg(&data->client->dev,
+ dev_dbg(data->dev,
"fan%d clock divider changed from %u to %u\n",
nr + 1, 1 << old, 1 << fan_div);
@@ -507,7 +507,6 @@ static ssize_t fan_min_store(struct device *dev,
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct adm9240_data *data = dev_get_drvdata(dev);
- struct i2c_client *client = data->client;
int nr = attr->index;
u8 new_div;
unsigned long val;
@@ -523,14 +522,14 @@ static ssize_t fan_min_store(struct device *dev,
data->fan_min[nr] = 255;
new_div = data->fan_div[nr];
- dev_dbg(&client->dev, "fan%u low limit set disabled\n",
+ dev_dbg(data->dev, "fan%u low limit set disabled\n",
nr + 1);
} else if (val < 1350000 / (8 * 254)) {
new_div = 3;
data->fan_min[nr] = 254;
- dev_dbg(&client->dev, "fan%u low limit set minimum %u\n",
+ dev_dbg(data->dev, "fan%u low limit set minimum %u\n",
nr + 1, FAN_FROM_REG(254, 1 << new_div));
} else {
@@ -546,7 +545,7 @@ static ssize_t fan_min_store(struct device *dev,
data->fan_min[nr] = new_min;
- dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n",
+ dev_dbg(data->dev, "fan%u low limit set fan speed %u\n",
nr + 1, FAN_FROM_REG(new_min, 1 << new_div));
}
@@ -663,7 +662,7 @@ static ssize_t alarm_store(struct device *dev, struct device_attribute *attr,
mutex_unlock(&data->update_lock);
if (err < 0)
return err;
- dev_dbg(&data->client->dev, "chassis intrusion latch cleared\n");
+ dev_dbg(data->dev, "chassis intrusion latch cleared\n");
return count;
}
@@ -755,7 +754,7 @@ static int adm9240_detect(struct i2c_client *new_client,
return 0;
}
-static int adm9240_init_client(struct i2c_client *client, struct adm9240_data *data)
+static int adm9240_init_client(struct adm9240_data *data)
{
u8 conf, mode;
int err;
@@ -770,13 +769,13 @@ static int adm9240_init_client(struct i2c_client *client, struct adm9240_data *d
data->vrm = vid_which_vrm(); /* need this to report vid as mV */
- dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10,
- data->vrm % 10);
+ dev_info(data->dev, "Using VRM: %d.%d\n", data->vrm / 10,
+ data->vrm % 10);
if (conf & 1) { /* measurement cycle running: report state */
- dev_info(&client->dev, "status: config 0x%02x mode %u\n",
- conf, mode);
+ dev_info(data->dev, "status: config 0x%02x mode %u\n",
+ conf, mode);
} else { /* cold start: open limits before starting chip */
int i;
@@ -809,7 +808,7 @@ static int adm9240_init_client(struct i2c_client *client, struct adm9240_data *d
if (err < 0)
return err;
- dev_info(&client->dev,
+ dev_info(data->dev,
"cold start: config was 0x%02x mode %u\n", conf, mode);
}
@@ -834,13 +833,13 @@ static int adm9240_probe(struct i2c_client *new_client)
if (!data)
return -ENOMEM;
- data->client = new_client;
+ data->dev = dev;
mutex_init(&data->update_lock);
data->regmap = devm_regmap_init_i2c(new_client, &adm9240_regmap_config);
if (IS_ERR(data->regmap))
return PTR_ERR(data->regmap);
- err = adm9240_init_client(new_client, data);
+ err = adm9240_init_client(data);
if (err < 0)
return err;
--
2.17.1
next prev parent reply other threads:[~2021-03-11 7:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 7:33 [PATCH 1/3] hwmon: (adm9240) Drop log messages from detect function Guenter Roeck
2021-03-11 7:33 ` Guenter Roeck [this message]
2021-03-11 21:10 ` [PATCH 2/3] hwmon: (adm9240) Store i2c device instead of client in local data Chris Packham
2021-03-11 7:33 ` [PATCH 3/3] hwmon: (adm9240) Convert to devm_hwmon_device_register_with_info API Guenter Roeck
2021-03-11 21:10 ` Chris Packham
2021-05-12 21:54 ` Chris Packham
2021-05-12 22:09 ` Guenter Roeck
2021-05-12 22:35 ` Guenter Roeck
2021-05-12 22:41 ` Chris Packham
2021-05-12 22:51 ` Guenter Roeck
2021-05-12 22:58 ` Chris Packham
2021-03-11 21:09 ` [PATCH 1/3] hwmon: (adm9240) Drop log messages from detect function 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=20210311073302.221954-2-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Chris.Packham@alliedtelesis.co.nz \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@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;
as well as URLs for NNTP newsgroup(s).