Skip to content

Commit 9bc146a

Browse files
AxelLinbroonie
authored andcommitted
regulator: hi6421v600: Fix setting wrong driver_data
Current code set "config.driver_data = sreg" but sreg only init the mutex, the othere fields are just zero. Fix it by pass *info to config.driver_data so each regulator can get corresponding data by rdev_get_drvdata(). Separate enable_mutex from struct hi6421_spmi_reg_info since only need one mutex for the driver. Fixes: d2dfd50 ("staging: hikey9xx: hi6421v600-regulator: move LDO config from DT") Signed-off-by: Axel Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d1c02a7 commit 9bc146a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

drivers/regulator/hi6421v600-regulator.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
#include <linux/regulator/driver.h>
1717
#include <linux/spmi.h>
1818

19+
struct hi6421_spmi_reg_priv {
20+
/* Serialize regulator enable logic */
21+
struct mutex enable_mutex;
22+
};
23+
1924
struct hi6421_spmi_reg_info {
2025
struct regulator_desc desc;
2126
u8 eco_mode_mask;
2227
u32 eco_uA;
23-
24-
/* Serialize regulator enable logic */
25-
struct mutex enable_mutex;
2628
};
2729

2830
static const unsigned int ldo3_voltages[] = {
@@ -96,11 +98,12 @@ static const unsigned int ldo34_voltages[] = {
9698

9799
static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
98100
{
99-
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
101+
struct hi6421_spmi_reg_priv *priv;
100102
int ret;
101103

104+
priv = dev_get_drvdata(rdev->dev.parent);
102105
/* cannot enable more than one regulator at one time */
103-
mutex_lock(&sreg->enable_mutex);
106+
mutex_lock(&priv->enable_mutex);
104107

105108
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
106109
rdev->desc->enable_mask,
@@ -109,7 +112,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
109112
/* Avoid powering up multiple devices at the same time */
110113
usleep_range(rdev->desc->off_on_delay, rdev->desc->off_on_delay + 60);
111114

112-
mutex_unlock(&sreg->enable_mutex);
115+
mutex_unlock(&priv->enable_mutex);
113116

114117
return ret;
115118
}
@@ -228,7 +231,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
228231
{
229232
struct device *pmic_dev = pdev->dev.parent;
230233
struct regulator_config config = { };
231-
struct hi6421_spmi_reg_info *sreg;
234+
struct hi6421_spmi_reg_priv *priv;
232235
struct hi6421_spmi_reg_info *info;
233236
struct device *dev = &pdev->dev;
234237
struct hi6421_spmi_pmic *pmic;
@@ -244,17 +247,18 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
244247
if (WARN_ON(!pmic))
245248
return -ENODEV;
246249

247-
sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
248-
if (!sreg)
250+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
251+
if (!priv)
249252
return -ENOMEM;
250253

251-
mutex_init(&sreg->enable_mutex);
254+
mutex_init(&priv->enable_mutex);
255+
platform_set_drvdata(pdev, priv);
252256

253257
for (i = 0; i < ARRAY_SIZE(regulator_info); i++) {
254258
info = &regulator_info[i];
255259

256260
config.dev = pdev->dev.parent;
257-
config.driver_data = sreg;
261+
config.driver_data = info;
258262
config.regmap = pmic->regmap;
259263

260264
rdev = devm_regulator_register(dev, &info->desc, &config);

0 commit comments

Comments
 (0)