Skip to content

Commit

Permalink
mfd: hi6421-spmi-pmic: Cleanup drvdata to only include regmap
Browse files Browse the repository at this point in the history
There are lots of fields in struct hi6421_spmi_pmic that aren't
used. As a matter of fact, only regmap is needed.

So, drop the struct as a whole, and set regmap as the drvdata.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Acked-by: Mark Brown <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Link: https://lore.kernel.org/r/1828cb783b1ebca0b98bf0b3077d8701adb228f7.1630586862.git.mchehab+huawei@kernel.org
  • Loading branch information
mchehab authored and Lee Jones committed Oct 5, 2021
1 parent 6880fa6 commit e68ce0f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 46 deletions.
16 changes: 5 additions & 11 deletions drivers/mfd/hi6421-spmi-pmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

#include <linux/mfd/core.h>
#include <linux/mfd/hi6421-spmi-pmic.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
Expand All @@ -30,19 +29,14 @@ static const struct regmap_config regmap_config = {
static int hi6421_spmi_pmic_probe(struct spmi_device *sdev)
{
struct device *dev = &sdev->dev;
struct regmap *regmap;
int ret;
struct hi6421_spmi_pmic *ddata;
ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;

ddata->regmap = devm_regmap_init_spmi_ext(sdev, &regmap_config);
if (IS_ERR(ddata->regmap))
return PTR_ERR(ddata->regmap);
regmap = devm_regmap_init_spmi_ext(sdev, &regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);

ddata->dev = dev;

dev_set_drvdata(&sdev->dev, ddata);
dev_set_drvdata(&sdev->dev, regmap);

ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE,
hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
Expand Down
9 changes: 4 additions & 5 deletions drivers/misc/hi6421v600-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/bitops.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/mfd/hi6421-spmi-pmic.h>
#include <linux/module.h>
#include <linux/of_gpio.h>
#include <linux/platform_device.h>
Expand Down Expand Up @@ -220,7 +219,7 @@ static int hi6421v600_irq_probe(struct platform_device *pdev)
struct platform_device *pmic_pdev;
struct device *dev = &pdev->dev;
struct hi6421v600_irq *priv;
struct hi6421_spmi_pmic *pmic;
struct regmap *regmap;
unsigned int virq;
int i, ret;

Expand All @@ -229,16 +228,16 @@ static int hi6421v600_irq_probe(struct platform_device *pdev)
* which should first set drvdata. If this doesn't happen, hit
* a warn on and return.
*/
pmic = dev_get_drvdata(pmic_dev);
if (WARN_ON(!pmic))
regmap = dev_get_drvdata(pmic_dev);
if (WARN_ON(!regmap))
return -ENODEV;

priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;

priv->dev = dev;
priv->regmap = pmic->regmap;
priv->regmap = regmap;

spin_lock_init(&priv->lock);

Expand Down
10 changes: 5 additions & 5 deletions drivers/regulator/hi6421v600-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// Guodong Xu <[email protected]>

#include <linux/delay.h>
#include <linux/mfd/hi6421-spmi-pmic.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
Expand Down Expand Up @@ -237,7 +237,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
struct hi6421_spmi_reg_priv *priv;
struct hi6421_spmi_reg_info *info;
struct device *dev = &pdev->dev;
struct hi6421_spmi_pmic *pmic;
struct regmap *regmap;
struct regulator_dev *rdev;
int i;

Expand All @@ -246,8 +246,8 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)
* which should first set drvdata. If this doesn't happen, hit
* a warn on and return.
*/
pmic = dev_get_drvdata(pmic_dev);
if (WARN_ON(!pmic))
regmap = dev_get_drvdata(pmic_dev);
if (WARN_ON(!regmap))
return -ENODEV;

priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
Expand All @@ -261,7 +261,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)

config.dev = pdev->dev.parent;
config.driver_data = priv;
config.regmap = pmic->regmap;
config.regmap = regmap;

rdev = devm_regulator_register(dev, &info->desc, &config);
if (IS_ERR(rdev)) {
Expand Down
25 changes: 0 additions & 25 deletions include/linux/mfd/hi6421-spmi-pmic.h

This file was deleted.

0 comments on commit e68ce0f

Please sign in to comment.