[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250416-for-upstream-spd5118-spd-write-prot-detect-v1-1-8b3bcafe9dad@canonical.com>
Date: Wed, 16 Apr 2025 14:46:26 +0800
From: "Yo-Jung (Leo) Lin" <leo.lin@...onical.com>
To: Jean Delvare <jdelvare@...e.com>, Guenter Roeck <linux@...ck-us.net>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
"Yo-Jung Lin (Leo)" <leo.lin@...onical.com>
Subject: [PATCH 1/2] hwmon: (spd5118) pass spd5118_data to hwmon callbacks
Currently only the regcache is passed to the hwmon device. Pass the
whole spd5118_data for better flexibility.
Signed-off-by: Yo-Jung (Leo) Lin <leo.lin@...onical.com>
---
drivers/hwmon/spd5118.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index 358152868d96..3cb2eb2e0227 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -174,7 +174,8 @@ static int spd5118_read_enable(struct regmap *regmap, long *val)
static int spd5118_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
- struct regmap *regmap = dev_get_drvdata(dev);
+ struct spd5118_data *data = dev_get_drvdata(dev);
+ struct regmap *regmap = data->regmap;
if (type != hwmon_temp)
return -EOPNOTSUPP;
@@ -256,7 +257,8 @@ static int spd5118_temp_write(struct regmap *regmap, u32 attr, long val)
static int spd5118_write(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long val)
{
- struct regmap *regmap = dev_get_drvdata(dev);
+ struct spd5118_data *data = dev_get_drvdata(dev);
+ struct regmap *regmap = data->regmap;
switch (type) {
case hwmon_temp:
@@ -269,6 +271,8 @@ static int spd5118_write(struct device *dev, enum hwmon_sensor_types type,
static umode_t spd5118_is_visible(const void *_data, enum hwmon_sensor_types type,
u32 attr, int channel)
{
+ struct spd5118_data *data = (struct spd5118_data *)_data;
+
if (type != hwmon_temp)
return 0;
@@ -611,7 +615,7 @@ static int spd5118_probe(struct i2c_client *client)
}
hwmon_dev = devm_hwmon_device_register_with_info(dev, "spd5118",
- regmap, &spd5118_chip_info,
+ data, &spd5118_chip_info,
NULL);
if (IS_ERR(hwmon_dev))
return PTR_ERR(hwmon_dev);
--
2.43.0
Powered by blists - more mailing lists