diff mbox series

[RFC,3/5] hwmon: (lm75) Remove superfluous 'client' member from private struct

Message ID 20241219225522.3490-10-wsa+renesas@sang-engineering.com (mailing list archive)
State New
Delegated to: Geert Uytterhoeven
Headers show
Series hwmon: (lm75) add I3C support | expand

Commit Message

Wolfram Sang Dec. 19, 2024, 10:55 p.m. UTC
The regmap-only conversion allows us to store the client-pointer as the
'context' parameter for regmap. This not only makes the private struct
smaller, but also allows proper separation of I2C and I3C in the future.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/hwmon/lm75.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Guenter Roeck Dec. 20, 2024, 2:57 p.m. UTC | #1
On Thu, Dec 19, 2024 at 11:55:25PM +0100, Wolfram Sang wrote:
> The regmap-only conversion allows us to store the client-pointer as the
> 'context' parameter for regmap. This not only makes the private struct
> smaller, but also allows proper separation of I2C and I3C in the future.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 4d0fd1c93c63..0f034110daed 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -105,9 +105,7 @@  static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
 #define LM75_REG_MAX		0x03
 #define PCT2075_REG_IDLE	0x04
 
-/* Each client has this additional data */
 struct lm75_data {
-	struct i2c_client		*client;
 	struct regmap			*regmap;
 	u16				orig_conf;
 	u8				resolution;	/* In bits, 9 to 16 */
@@ -572,8 +570,8 @@  static bool lm75_is_volatile_reg(struct device *dev, unsigned int reg)
 
 static int lm75_i2c_reg_read(void *context, unsigned int reg, unsigned int *val)
 {
-	struct lm75_data *data = context;
-	struct i2c_client *client = data->client;
+	struct i2c_client *client = context;
+	struct lm75_data *data = i2c_get_clientdata(client);
 	int ret;
 
 	if (reg == LM75_REG_CONF) {
@@ -592,8 +590,8 @@  static int lm75_i2c_reg_read(void *context, unsigned int reg, unsigned int *val)
 
 static int lm75_i2c_reg_write(void *context, unsigned int reg, unsigned int val)
 {
-	struct lm75_data *data = context;
-	struct i2c_client *client = data->client;
+	struct i2c_client *client = context;
+	struct lm75_data *data = i2c_get_clientdata(client);
 
 	if (reg == PCT2075_REG_IDLE ||
 	    (reg == LM75_REG_CONF && !data->params->config_reg_16bits))
@@ -645,14 +643,13 @@  static int lm75_probe(struct i2c_client *client)
 	/* needed by custom regmap callbacks */
 	dev_set_drvdata(dev, data);
 
-	data->client = client;
 	data->kind = (uintptr_t)i2c_get_match_data(client);
 
 	err = devm_regulator_get_enable(dev, "vs");
 	if (err)
 		return err;
 
-	data->regmap = devm_regmap_init(dev, &lm75_i2c_regmap_bus, data,
+	data->regmap = devm_regmap_init(dev, &lm75_i2c_regmap_bus, client,
 					&lm75_regmap_config);
 	if (IS_ERR(data->regmap))
 		return PTR_ERR(data->regmap);