Re: [PATCH v9 2/5] regulator: hi6421v600-regulator: fix platform drvdata
From: Axel Lin <hidden>
Date: 2021-06-26 03:42:31
Also in:
lkml
quoted hunk ↗ jump to hunk
@@ -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;
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. Regards, Axel