···137137Consumer drivers can request a change in their supply regulator operating mode138138by calling :-139139140140-int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);140140+int regulator_set_load(struct regulator *regulator, int load_uA);141141142142This will cause the core to recalculate the total load on the regulator (based143143on all its consumers) and change operating mode (if necessary and permitted)
+3-3
drivers/gpu/drm/msm/edp/edp_ctrl.c
···332332 goto vdda_set_fail;333333 }334334335335- ret = regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_ON_LOAD);335335+ ret = regulator_set_load(ctrl->vdda_vreg, VDDA_UA_ON_LOAD);336336 if (ret < 0) {337337 pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__);338338 goto vdda_set_fail;···356356lvl_enable_fail:357357 regulator_disable(ctrl->vdda_vreg);358358vdda_enable_fail:359359- regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);359359+ regulator_set_load(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);360360vdda_set_fail:361361 return ret;362362}···365365{366366 regulator_disable(ctrl->lvl_vreg);367367 regulator_disable(ctrl->vdda_vreg);368368- regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);368368+ regulator_set_load(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);369369}370370371371static int edp_gpio_config(struct edp_ctrl *ctrl)
+2-2
drivers/phy/phy-qcom-ufs.c
···346346 goto out;347347 }348348 uA_load = on ? vreg->max_uA : 0;349349- ret = regulator_set_optimum_mode(reg, uA_load);349349+ ret = regulator_set_load(reg, uA_load);350350 if (ret >= 0) {351351 /*352352- * regulator_set_optimum_mode() returns new regulator352352+ * regulator_set_load() returns new regulator353353 * mode upon success.354354 */355355 ret = 0;
+4-4
drivers/regulator/core.c
···30613061EXPORT_SYMBOL_GPL(regulator_get_mode);3062306230633063/**30643064- * regulator_set_optimum_mode - set regulator optimum operating mode30643064+ * regulator_set_load - set regulator load30653065 * @regulator: regulator source30663066 * @uA_load: load current30673067 *···30843084 * DRMS will sum the total requested load on the regulator and change30853085 * to the most efficient operating mode if platform constraints allow.30863086 *30873087- * Returns the new regulator mode or error.30873087+ * On error a negative errno is returned.30883088 */30893089-int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)30893089+int regulator_set_load(struct regulator *regulator, int uA_load)30903090{30913091 struct regulator_dev *rdev = regulator->rdev;30923092 int ret;···3098309830993099 return ret;31003100}31013101-EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);31013101+EXPORT_SYMBOL_GPL(regulator_set_load);3102310231033103/**31043104 * regulator_allow_bypass - allow the regulator to go into bypass mode
+85
drivers/regulator/devres.c
···413413 devm_regulator_unregister_supply_alias(dev, id[i]);414414}415415EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias);416416+417417+struct regulator_notifier_match {418418+ struct regulator *regulator;419419+ struct notifier_block *nb;420420+};421421+422422+static int devm_regulator_match_notifier(struct device *dev, void *res,423423+ void *data)424424+{425425+ struct regulator_notifier_match *match = res;426426+ struct regulator_notifier_match *target = data;427427+428428+ return match->regulator == target->regulator && match->nb == target->nb;429429+}430430+431431+static void devm_regulator_destroy_notifier(struct device *dev, void *res)432432+{433433+ struct regulator_notifier_match *match = res;434434+435435+ regulator_unregister_notifier(match->regulator, match->nb);436436+}437437+438438+/**439439+ * devm_regulator_register_notifier - Resource managed440440+ * regulator_register_notifier441441+ *442442+ * @regulator: regulator source443443+ * @nb: notifier block444444+ *445445+ * The notifier will be registers under the consumer device and be446446+ * automatically be unregistered when the source device is unbound.447447+ */448448+int devm_regulator_register_notifier(struct regulator *regulator,449449+ struct notifier_block *nb)450450+{451451+ struct regulator_notifier_match *match;452452+ int ret;453453+454454+ match = devres_alloc(devm_regulator_destroy_notifier,455455+ sizeof(struct regulator_notifier_match),456456+ GFP_KERNEL);457457+ if (!match)458458+ return -ENOMEM;459459+460460+ match->regulator = regulator;461461+ match->nb = nb;462462+463463+ ret = regulator_register_notifier(regulator, nb);464464+ if (ret < 0) {465465+ devres_free(match);466466+ return ret;467467+ }468468+469469+ devres_add(regulator->dev, match);470470+471471+ return 0;472472+}473473+EXPORT_SYMBOL_GPL(devm_regulator_register_notifier);474474+475475+/**476476+ * devm_regulator_unregister_notifier - Resource managed477477+ * regulator_unregister_notifier()478478+ *479479+ * @regulator: regulator source480480+ * @nb: notifier block481481+ *482482+ * Unregister a notifier registered with devm_regulator_register_notifier().483483+ * Normally this function will not need to be called and the resource484484+ * management code will ensure that the resource is freed.485485+ */486486+void devm_regulator_unregister_notifier(struct regulator *regulator,487487+ struct notifier_block *nb)488488+{489489+ struct regulator_notifier_match match;490490+ int rc;491491+492492+ match.regulator = regulator;493493+ match.nb = nb;494494+495495+ rc = devres_release(regulator->dev, devm_regulator_destroy_notifier,496496+ devm_regulator_match_notifier, &match);497497+ if (rc != 0)498498+ WARN_ON(rc);499499+}500500+EXPORT_SYMBOL_GPL(devm_regulator_unregister_notifier);
···5656{5757 struct stw481x *stw481x = dev_get_platdata(&pdev->dev);5858 struct regulator_config config = { };5959+ struct regulator_dev *rdev;5960 int ret;60616162 /* First disable the external VMMC if it's active */···7675 pdev->dev.of_node,7776 &vmmc_regulator);78777979- stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev,8080- &vmmc_regulator, &config);8181- if (IS_ERR(stw481x->vmmc_regulator)) {7878+ rdev = devm_regulator_register(&pdev->dev, &vmmc_regulator, &config);7979+ if (IS_ERR(rdev)) {8280 dev_err(&pdev->dev,8381 "error initializing STw481x VMMC regulator\n");8484- return PTR_ERR(stw481x->vmmc_regulator);8282+ return PTR_ERR(rdev);8583 }86848785 dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n");
+7-20
drivers/scsi/ufs/ufshcd.c
···42254225static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,42264226 int ua)42274227{42284228- int ret = 0;42294229- struct regulator *reg = vreg->reg;42304230- const char *name = vreg->name;42284228+ int ret;4231422942324232- BUG_ON(!vreg);42304230+ if (!vreg)42314231+ return 0;4233423242344234- ret = regulator_set_optimum_mode(reg, ua);42354235- if (ret >= 0) {42364236- /*42374237- * regulator_set_optimum_mode() returns new regulator42384238- * mode upon success.42394239- */42404240- ret = 0;42414241- } else {42424242- dev_err(dev, "%s: %s set optimum mode(ua=%d) failed, err=%d\n",42434243- __func__, name, ua, ret);42334233+ ret = regulator_set_load(vreg->reg, ua);42344234+ if (ret < 0) {42354235+ dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",42364236+ __func__, vreg->name, ua, ret);42444237 }4245423842464239 return ret;···42424249static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,42434250 struct ufs_vreg *vreg)42444251{42454245- if (!vreg)42464246- return 0;42474247-42484252 return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);42494253}4250425442514255static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,42524256 struct ufs_vreg *vreg)42534257{42544254- if (!vreg)42554255- return 0;42564256-42574258 return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);42584259}42594260
+2-2
drivers/usb/phy/phy-ab8500-usb.c
···277277 dev_err(ab->dev, "Failed to set the Vintcore to 1.3V, ret=%d\n",278278 ret);279279280280- ret = regulator_set_optimum_mode(ab->v_ulpi, 28000);280280+ ret = regulator_set_load(ab->v_ulpi, 28000);281281 if (ret < 0)282282 dev_err(ab->dev, "Failed to set optimum mode (ret=%d)\n",283283 ret);···317317 ab->saved_v_ulpi, ret);318318 }319319320320- ret = regulator_set_optimum_mode(ab->v_ulpi, 0);320320+ ret = regulator_set_load(ab->v_ulpi, 0);321321 if (ret < 0)322322 dev_err(ab->dev, "Failed to set optimum mode (ret=%d)\n",323323 ret);
+5-10
drivers/usb/phy/phy-msm-usb.c
···142142 int ret = 0;143143144144 if (on) {145145- ret = regulator_set_optimum_mode(motg->v1p8,146146- USB_PHY_1P8_HPM_LOAD);145145+ ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_HPM_LOAD);147146 if (ret < 0) {148147 pr_err("Could not set HPM for v1p8\n");149148 return ret;150149 }151151- ret = regulator_set_optimum_mode(motg->v3p3,152152- USB_PHY_3P3_HPM_LOAD);150150+ ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_HPM_LOAD);153151 if (ret < 0) {154152 pr_err("Could not set HPM for v3p3\n");155155- regulator_set_optimum_mode(motg->v1p8,156156- USB_PHY_1P8_LPM_LOAD);153153+ regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD);157154 return ret;158155 }159156 } else {160160- ret = regulator_set_optimum_mode(motg->v1p8,161161- USB_PHY_1P8_LPM_LOAD);157157+ ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD);162158 if (ret < 0)163159 pr_err("Could not set LPM for v1p8\n");164164- ret = regulator_set_optimum_mode(motg->v3p3,165165- USB_PHY_3P3_LPM_LOAD);160160+ ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_LPM_LOAD);166161 if (ret < 0)167162 pr_err("Could not set LPM for v3p3\n");168163 }
+1
include/linux/mfd/palmas.h
···117117 int ldo_begin;118118 int ldo_end;119119 int max_reg;120120+ bool has_regen3;120121 struct palmas_regs_info *palmas_regs_info;121122 struct of_regulator_match *palmas_matches;122123 struct palmas_sleep_requestor_info *sleep_req_info;
-4
include/linux/mfd/stw481x.h
···41414242/**4343 * struct stw481x - state holder for the Stw481x drivers4444- * @mutex: mutex to serialize I2C accesses4544 * @i2c_client: corresponding I2C client4646- * @regulator: regulator device for regulator children4745 * @map: regmap handle to access device registers4846 */4947struct stw481x {5050- struct mutex lock;5148 struct i2c_client *client;5252- struct regulator_dev *vmmc_regulator;5349 struct regmap *map;5450};5551
+18-3
include/linux/regulator/consumer.h
···238238239239int regulator_set_mode(struct regulator *regulator, unsigned int mode);240240unsigned int regulator_get_mode(struct regulator *regulator);241241-int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);241241+int regulator_set_load(struct regulator *regulator, int load_uA);242242243243int regulator_allow_bypass(struct regulator *regulator, bool allow);244244···252252/* regulator notifier block */253253int regulator_register_notifier(struct regulator *regulator,254254 struct notifier_block *nb);255255+int devm_regulator_register_notifier(struct regulator *regulator,256256+ struct notifier_block *nb);255257int regulator_unregister_notifier(struct regulator *regulator,256258 struct notifier_block *nb);259259+void devm_regulator_unregister_notifier(struct regulator *regulator,260260+ struct notifier_block *nb);257261258262/* driver data - core doesn't touch */259263void *regulator_get_drvdata(struct regulator *regulator);···483479 return REGULATOR_MODE_NORMAL;484480}485481486486-static inline int regulator_set_optimum_mode(struct regulator *regulator,487487- int load_uA)482482+static inline int regulator_set_load(struct regulator *regulator, int load_uA)488483{489484 return REGULATOR_MODE_NORMAL;490485}···518515 return 0;519516}520517518518+static inline int devm_regulator_register_notifier(struct regulator *regulator,519519+ struct notifier_block *nb)520520+{521521+ return 0;522522+}523523+521524static inline int regulator_unregister_notifier(struct regulator *regulator,522525 struct notifier_block *nb)526526+{527527+ return 0;528528+}529529+530530+static inline int devm_regulator_unregister_notifier(struct regulator *regulator,531531+ struct notifier_block *nb)523532{524533 return 0;525534}