Re: [PATCH v9 2/5] regulator: hi6421v600-regulator: fix platform drvdata

From: Mauro Carvalho Chehab
Date: Tue Jun 29 2021 - 06:23:42 EST


Em Sat, 26 Jun 2021 11:41:50 +0800
Axel Lin <axel.lin@xxxxxxxxxx> escreveu:

> > @@ -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 = &regulator_info[i];
> >
> > config.dev = pdev->dev.parent;
> > - config.driver_data = info;
> > + config.driver_data = sreg;
>
> This won't work and that was what my patch fixed.
> e.g. When you call
> struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
> sreg->eco_mode_mask and sreg->eco_uA will always be 0.

Yeah, probably something got lost during the several rebases.
Anyway, I'll send in a few a new patch series addressing this issue.

Thanks,
Mauro