[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ef0ff659a875b91b454df12b57888f2b473877fa.1624640087.git.mchehab+huawei@kernel.org>
Date: Fri, 25 Jun 2021 19:06:11 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linuxarm@...wei.com, mauro.chehab@...wei.com,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
"Lee Jones" <lee.jones@...aro.org>, Axel Lin <axel.lin@...ics.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, linux-kernel@...r.kernel.org,
linux-staging@...ts.linux.dev
Subject: [PATCH v9 2/5] regulator: hi6421v600-regulator: fix platform drvdata
platform drvdata can't be used inside the regulator driver,
as this is already used by the MFD and SPMI drivers.
So, change the logic to allocate it inside the
struct hi6421_spmi_pmic.
While here, drop the unused fields there.
Fixes: 50e629362e1f ("regulator: hi6421v600: Fix setting wrong driver_data")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
drivers/regulator/hi6421v600-regulator.c | 26 +++++++++------------
drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 2 +-
include/linux/mfd/hi6421-spmi-pmic.h | 9 +++----
3 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/drivers/regulator/hi6421v600-regulator.c b/drivers/regulator/hi6421v600-regulator.c
index 9b162c0555c3..49d83350435c 100644
--- a/drivers/regulator/hi6421v600-regulator.c
+++ b/drivers/regulator/hi6421v600-regulator.c
@@ -16,15 +16,13 @@
#include <linux/regulator/driver.h>
#include <linux/spmi.h>
-struct hi6421_spmi_reg_priv {
- /* Serialize regulator enable logic */
- struct mutex enable_mutex;
-};
-
struct hi6421_spmi_reg_info {
struct regulator_desc desc;
u8 eco_mode_mask;
u32 eco_uA;
+
+ /* Serialize regulator enable logic */
+ struct mutex *enable_mutex;
};
static const unsigned int ldo3_voltages[] = {
@@ -98,12 +96,11 @@ static const unsigned int ldo34_voltages[] = {
static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
{
- struct hi6421_spmi_reg_priv *priv;
+ struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
int ret;
- priv = dev_get_drvdata(rdev->dev.parent);
/* cannot enable more than one regulator at one time */
- mutex_lock(&priv->enable_mutex);
+ mutex_lock(sreg->enable_mutex);
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask,
@@ -112,7 +109,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
/* Avoid powering up multiple devices at the same time */
usleep_range(rdev->desc->off_on_delay, rdev->desc->off_on_delay + 60);
- mutex_unlock(&priv->enable_mutex);
+ mutex_unlock(sreg->enable_mutex);
return ret;
}
@@ -231,7 +228,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
{
struct device *pmic_dev = pdev->dev.parent;
struct regulator_config config = { };
- struct hi6421_spmi_reg_priv *priv;
+ struct hi6421_spmi_reg_info *sreg;
struct hi6421_spmi_reg_info *info;
struct device *dev = &pdev->dev;
struct hi6421_spmi_pmic *pmic;
@@ -247,18 +244,17 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
if (WARN_ON(!pmic))
return -ENODEV;
- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
+ sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
+ if (!sreg)
return -ENOMEM;
- mutex_init(&priv->enable_mutex);
- platform_set_drvdata(pdev, priv);
+ sreg->enable_mutex = &pmic->enable_mutex;
for (i = 0; i < ARRAY_SIZE(regulator_info); i++) {
info = ®ulator_info[i];
config.dev = pdev->dev.parent;
- config.driver_data = info;
+ config.driver_data = sreg;
config.regmap = pmic->regmap;
rdev = devm_regulator_register(dev, &info->desc, &config);
diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
index 0b5686655954..6864a19f3218 100644
--- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
+++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
@@ -40,7 +40,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
if (IS_ERR(ddata->regmap))
return PTR_ERR(ddata->regmap);
- ddata->dev = dev;
+ mutex_init(&ddata->enable_mutex);
dev_set_drvdata(&pdev->dev, ddata);
diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h
index e5b8dbf828b6..a72b2797a997 100644
--- a/include/linux/mfd/hi6421-spmi-pmic.h
+++ b/include/linux/mfd/hi6421-spmi-pmic.h
@@ -16,10 +16,11 @@
#include <linux/regmap.h>
struct hi6421_spmi_pmic {
- struct resource *res;
- struct device *dev;
- void __iomem *regs;
- struct regmap *regmap;
+ /* Serialize regulator enable logic */
+ struct mutex enable_mutex;
+
+ /* SPMI register regmap */
+ struct regmap *regmap;
};
#endif /* __HISI_PMIC_H */
--
2.31.1
Powered by blists - more mailing lists