Skip to content

Commit 7a5c24d

Browse files
Wolfram Sanggroeck
authored andcommitted
hwmon: (lm75) Remove superfluous 'client' member from private struct
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 2b64c6f commit 7a5c24d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/hwmon/lm75.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
105105
#define LM75_REG_MAX 0x03
106106
#define PCT2075_REG_IDLE 0x04
107107

108-
/* Each client has this additional data */
109108
struct lm75_data {
110-
struct i2c_client *client;
111109
struct regmap *regmap;
112110
u16 orig_conf;
113111
u8 resolution; /* In bits, 9 to 16 */
@@ -572,8 +570,8 @@ static bool lm75_is_volatile_reg(struct device *dev, unsigned int reg)
572570

573571
static int lm75_i2c_reg_read(void *context, unsigned int reg, unsigned int *val)
574572
{
575-
struct lm75_data *data = context;
576-
struct i2c_client *client = data->client;
573+
struct i2c_client *client = context;
574+
struct lm75_data *data = i2c_get_clientdata(client);
577575
int ret;
578576

579577
if (reg == LM75_REG_CONF) {
@@ -592,8 +590,8 @@ static int lm75_i2c_reg_read(void *context, unsigned int reg, unsigned int *val)
592590

593591
static int lm75_i2c_reg_write(void *context, unsigned int reg, unsigned int val)
594592
{
595-
struct lm75_data *data = context;
596-
struct i2c_client *client = data->client;
593+
struct i2c_client *client = context;
594+
struct lm75_data *data = i2c_get_clientdata(client);
597595

598596
if (reg == PCT2075_REG_IDLE ||
599597
(reg == LM75_REG_CONF && !data->params->config_reg_16bits))
@@ -645,14 +643,13 @@ static int lm75_probe(struct i2c_client *client)
645643
/* needed by custom regmap callbacks */
646644
dev_set_drvdata(dev, data);
647645

648-
data->client = client;
649646
data->kind = (uintptr_t)i2c_get_match_data(client);
650647

651648
err = devm_regulator_get_enable(dev, "vs");
652649
if (err)
653650
return err;
654651

655-
data->regmap = devm_regmap_init(dev, &lm75_i2c_regmap_bus, data,
652+
data->regmap = devm_regmap_init(dev, &lm75_i2c_regmap_bus, client,
656653
&lm75_regmap_config);
657654
if (IS_ERR(data->regmap))
658655
return PTR_ERR(data->regmap);

0 commit comments

Comments
 (0)