diff options
author | Antoniu Miclaus <antoniu.miclaus@analog.com> | 2023-10-31 12:56:46 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2023-12-11 17:20:28 +0300 |
commit | 34c76a51205a32f2665cc2ef1247b4408187d4f0 (patch) | |
tree | 8ee16da71fdbb845ab853a835fee9a873b6085f4 | |
parent | 89fec128d5d10d3e09553975d19d8b1f29b429d4 (diff) | |
download | linux-34c76a51205a32f2665cc2ef1247b4408187d4f0.tar.xz |
hwmon: (ltc2991) remove device reference from state
Remove device reference from struct ltc2991_state since it is used only
inside the init function.
Pass the struct device as parameter to the init function instead.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20231031095647.48376-1-antoniu.miclaus@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/ltc2991.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/hwmon/ltc2991.c b/drivers/hwmon/ltc2991.c index fc53fdcb2b6c..80a6e391f266 100644 --- a/drivers/hwmon/ltc2991.c +++ b/drivers/hwmon/ltc2991.c @@ -54,7 +54,6 @@ #define LTC2991_VCC_CH_NR 0 struct ltc2991_state { - struct device *dev; struct regmap *regmap; u32 r_sense_uohm[LTC2991_MAX_CHANNEL]; bool temp_en[LTC2991_MAX_CHANNEL]; @@ -283,19 +282,19 @@ static const struct regmap_config ltc2991_regmap_config = { .max_register = 0x1D, }; -static int ltc2991_init(struct ltc2991_state *st) +static int ltc2991_init(struct ltc2991_state *st, struct device *dev) { struct fwnode_handle *child; int ret; u32 val, addr; u8 v5_v8_reg_data = 0, v1_v4_reg_data = 0; - ret = devm_regulator_get_enable(st->dev, "vcc"); + ret = devm_regulator_get_enable(dev, "vcc"); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "failed to enable regulator\n"); - device_for_each_child_node(st->dev, child) { + device_for_each_child_node(dev, child) { ret = fwnode_property_read_u32(child, "reg", &addr); if (ret < 0) { fwnode_handle_put(child); @@ -312,7 +311,7 @@ static int ltc2991_init(struct ltc2991_state *st) &val); if (!ret) { if (!val) - return dev_err_probe(st->dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "shunt resistor value cannot be zero\n"); st->r_sense_uohm[addr] = val; @@ -361,18 +360,18 @@ static int ltc2991_init(struct ltc2991_state *st) ret = regmap_write(st->regmap, LTC2991_V5_V8_CTRL, v5_v8_reg_data); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "Error: Failed to set V5-V8 CTRL reg.\n"); ret = regmap_write(st->regmap, LTC2991_V1_V4_CTRL, v1_v4_reg_data); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "Error: Failed to set V1-V4 CTRL reg.\n"); ret = regmap_write(st->regmap, LTC2991_PWM_TH_LSB_T_INT, LTC2991_REPEAT_ACQ_EN); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "Error: Failed to set continuous mode.\n"); /* Enable all channels and trigger conversions */ @@ -392,12 +391,11 @@ static int ltc2991_i2c_probe(struct i2c_client *client) if (!st) return -ENOMEM; - st->dev = &client->dev; st->regmap = devm_regmap_init_i2c(client, <c2991_regmap_config); if (IS_ERR(st->regmap)) return PTR_ERR(st->regmap); - ret = ltc2991_init(st); + ret = ltc2991_init(st, &client->dev); if (ret) return ret; |