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: d2dfd50a0b
("staging: hikey9xx: hi6421v600-regulator: move LDO config from DT")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20210622043329.392072-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
d1c02a7451
Коммит
9bc146acc3
|
@ -16,13 +16,15 @@
|
||||||
#include <linux/regulator/driver.h>
|
#include <linux/regulator/driver.h>
|
||||||
#include <linux/spmi.h>
|
#include <linux/spmi.h>
|
||||||
|
|
||||||
|
struct hi6421_spmi_reg_priv {
|
||||||
|
/* Serialize regulator enable logic */
|
||||||
|
struct mutex enable_mutex;
|
||||||
|
};
|
||||||
|
|
||||||
struct hi6421_spmi_reg_info {
|
struct hi6421_spmi_reg_info {
|
||||||
struct regulator_desc desc;
|
struct regulator_desc desc;
|
||||||
u8 eco_mode_mask;
|
u8 eco_mode_mask;
|
||||||
u32 eco_uA;
|
u32 eco_uA;
|
||||||
|
|
||||||
/* Serialize regulator enable logic */
|
|
||||||
struct mutex enable_mutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned int ldo3_voltages[] = {
|
static const unsigned int ldo3_voltages[] = {
|
||||||
|
@ -96,11 +98,12 @@ static const unsigned int ldo34_voltages[] = {
|
||||||
|
|
||||||
static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
|
static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
|
struct hi6421_spmi_reg_priv *priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
priv = dev_get_drvdata(rdev->dev.parent);
|
||||||
/* cannot enable more than one regulator at one time */
|
/* cannot enable more than one regulator at one time */
|
||||||
mutex_lock(&sreg->enable_mutex);
|
mutex_lock(&priv->enable_mutex);
|
||||||
|
|
||||||
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||||
rdev->desc->enable_mask,
|
rdev->desc->enable_mask,
|
||||||
|
@ -109,7 +112,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
|
||||||
/* Avoid powering up multiple devices at the same time */
|
/* Avoid powering up multiple devices at the same time */
|
||||||
usleep_range(rdev->desc->off_on_delay, rdev->desc->off_on_delay + 60);
|
usleep_range(rdev->desc->off_on_delay, rdev->desc->off_on_delay + 60);
|
||||||
|
|
||||||
mutex_unlock(&sreg->enable_mutex);
|
mutex_unlock(&priv->enable_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +231,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *pmic_dev = pdev->dev.parent;
|
struct device *pmic_dev = pdev->dev.parent;
|
||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
struct hi6421_spmi_reg_info *sreg;
|
struct hi6421_spmi_reg_priv *priv;
|
||||||
struct hi6421_spmi_reg_info *info;
|
struct hi6421_spmi_reg_info *info;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct hi6421_spmi_pmic *pmic;
|
struct hi6421_spmi_pmic *pmic;
|
||||||
|
@ -244,17 +247,18 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
|
||||||
if (WARN_ON(!pmic))
|
if (WARN_ON(!pmic))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
|
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||||
if (!sreg)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mutex_init(&sreg->enable_mutex);
|
mutex_init(&priv->enable_mutex);
|
||||||
|
platform_set_drvdata(pdev, priv);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(regulator_info); i++) {
|
for (i = 0; i < ARRAY_SIZE(regulator_info); i++) {
|
||||||
info = ®ulator_info[i];
|
info = ®ulator_info[i];
|
||||||
|
|
||||||
config.dev = pdev->dev.parent;
|
config.dev = pdev->dev.parent;
|
||||||
config.driver_data = sreg;
|
config.driver_data = info;
|
||||||
config.regmap = pmic->regmap;
|
config.regmap = pmic->regmap;
|
||||||
|
|
||||||
rdev = devm_regulator_register(dev, &info->desc, &config);
|
rdev = devm_regulator_register(dev, &info->desc, &config);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче