Skip to contentSkip to conversation

regulator: stpmic1: Remove regul_id and *regmap from struct stpmic1_regulator

PATCH Superseded Axel Lin 2 participants 2 messages Feb 9, 2019 – Feb 11, 2019 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: stpmic1: Remove regul_id and *regmap from struct stpmic1_regulator

At the context with *rdev available, there is no problem to get regulator id and *regmap, so no need to store them in struct stpmic1_regulator.

---
 drivers/regulator/stpmic1_regulator.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/regulator/stpmic1_regulator.c +2 -8
index 963e67fa9ca6..dd5c8fb1ff86 100644
@@ -30,20 +30,16 @@ struct stpmic1_regulator_cfg {
 
 /**
  * stpmic1 regulator data: this structure is used as driver data
- * @regul_id: regulator id
  * @reg_node: DT node of regulator (unused on non-DT platforms)
  * @cfg: stpmic specific regulator description
  * @mask_reset: mask_reset bit value
  * @irq_curlim: current limit interrupt number
- * @regmap: point to parent regmap structure
  */
 struct stpmic1_regulator {
-	unsigned int regul_id;
 	struct device_node *reg_node;
 	const struct stpmic1_regulator_cfg *cfg;
 	u8 mask_reset;
 	int irq_curlim;
-	struct regmap *regmap;
 };
 
 static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode);
@@ -477,7 +473,7 @@ static int stpmic1_set_icc(struct regulator_dev *rdev)
 	struct stpmic1_regulator *regul = rdev_get_drvdata(rdev);
 
 	/* enable switch off in case of over current */
-	return regmap_update_bits(regul->regmap, regul->cfg->icc_reg,
+	return regmap_update_bits(rdev->regmap, regul->cfg->icc_reg,
 				  regul->cfg->icc_mask, regul->cfg->icc_mask);
 }
 
@@ -505,7 +501,7 @@ static int stpmic1_regulator_init(struct platform_device *pdev,
 
 	/* set mask reset */
 	if (regul->mask_reset && regul->cfg->mask_reset_reg != 0) {
-		ret = regmap_update_bits(regul->regmap,
+		ret = regmap_update_bits(rdev->regmap,
 					 regul->cfg->mask_reset_reg,
 					 regul->cfg->mask_reset_mask,
 					 regul->cfg->mask_reset_mask);
@@ -584,10 +580,8 @@ regulator_dev *stpmic1_regulator_register(struct platform_device *pdev, int id,
 	config.regmap = pmic_dev->regmap;
 	config.driver_data = regul;
 
-	regul->regul_id = id;
 	regul->reg_node = config.of_node;
 	regul->cfg = &stpmic1_regulator_cfgs[id];
-	regul->regmap = pmic_dev->regmap;
 
 	rdev = devm_regulator_register(&pdev->dev, &regul->cfg->desc, &config);
 	if (IS_ERR(rdev)) {
Signature · 1 line
2.17.1
#1 lore raw

Hello Axel,

Quoted 34 lines · Axel Lin

At the context with *rdev available, there is no problem to get regulator id and *regmap, so no need to store them in struct stpmic1_regulator.

---
  drivers/regulator/stpmic1_regulator.c | 10 ++--------
  1 file changed, 2 insertions(+), 8 deletions(-)
drivers/regulator/stpmic1_regulator.c +0 -4
index 963e67fa9ca6..dd5c8fb1ff86 100644
@@ -30,20 +30,16 @@ struct stpmic1_regulator_cfg {
 
  /**
   * stpmic1 regulator data: this structure is used as driver data
- * @regul_id: regulator id
   * @reg_node: DT node of regulator (unused on non-DT platforms)
   * @cfg: stpmic specific regulator description
   * @mask_reset: mask_reset bit value
   * @irq_curlim: current limit interrupt number
- * @regmap: point to parent regmap structure
   */
  struct stpmic1_regulator {
-	unsigned int regul_id;
  	struct device_node *reg_node;
  	const struct stpmic1_regulator_cfg *cfg;
  	u8 mask_reset;
  	int irq_curlim;
-	struct regmap *regmap;
  };
 
  static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode);

drivers/regulator/stpmic1_regulator.c static int stpmic1_set_icc(struct regulator_dev *rdev) · line 477

Quoted 6 lines
drivers/regulator/stpmic1_regulator.c +1 -1
@@ -477,7 +473,7 @@ static int stpmic1_set_icc(struct regulator_dev *rdev)
  	struct stpmic1_regulator *regul = rdev_get_drvdata(rdev);
 
  	/* enable switch off in case of over current */
-	return regmap_update_bits(regul->regmap, regul->cfg->icc_reg,
+	return regmap_update_bits(rdev->regmap, regul->cfg->icc_reg,
  				  regul->cfg->icc_mask, regul->cfg->icc_mask);

Maybe this is not compatible with a recommandation from include/linux/regulator/driver.h:438:
* This should *not* be used directly by anything except the regulator
* core and notification injection (which should take the mutex and do
* no other direct access).

drivers/regulator/stpmic1_regulator.c static int stpmic1_set_icc(struct regulator_dev *rdev) · line 479

Quoted 2 lines
drivers/regulator/stpmic1_regulator.c +0 -0
  }
 

...

thank you,
pascal