From 5a523605afa7d3b54b2e7041f8c9e6bc39872a7e Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 10 Sep 2013 15:45:05 +0530 Subject: regulator: core: provide fixed voltage in desc for single voltage rail If given rail has the single voltage (n_voltages = 1) then provide the rail voltage through regulator descriptor so that core can use this value for finding voltage. This will avoid the implementation of the callback for get_voltage() or list_voltage() callback on regulator driver. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/core.c | 5 ++++- include/linux/regulator/driver.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..abc899ed1ebf 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2489,6 +2489,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) ret = rdev->desc->ops->get_voltage(rdev); } else if (rdev->desc->ops->list_voltage) { ret = rdev->desc->ops->list_voltage(rdev, 0); + } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { + ret = rdev->desc->fixed_uV; } else { return -EINVAL; } @@ -3170,7 +3172,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev) /* some attributes need specific methods to be displayed */ if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || - (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0)) { + (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0) || + (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1))) { status = device_create_file(dev, &dev_attr_microvolts); if (status < 0) return status; diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 67e13aa5a478..9e8241a9f28f 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -207,6 +207,7 @@ enum regulator_type { * @min_uV: Voltage given by the lowest selector (if linear mapping) * @uV_step: Voltage increase with each selector (if linear mapping) * @linear_min_sel: Minimal selector for starting linear mapping + * @fixed_uV: Fixed voltage of rails. * @ramp_delay: Time to settle down after voltage change (unit: uV/us) * @volt_table: Voltage mapping table (if table based mapping) * @@ -239,6 +240,7 @@ struct regulator_desc { unsigned int min_uV; unsigned int uV_step; unsigned int linear_min_sel; + int fixed_uV; unsigned int ramp_delay; const struct regulator_linear_range *linear_ranges; -- cgit v1.2.3-55-g7522 From c368e5fc2a190923b786f2de3e79430ea3566a25 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 10 Sep 2013 15:45:06 +0530 Subject: regulator: fixed: get rid of {get|list}_voltage() Provide the rail supply voltage through descriptor to the core and remove the callbacks which implement the get_voltage and list_voltage. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/fixed.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 7610920014d7..de811f3b921b 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -34,7 +34,6 @@ struct fixed_voltage_data { struct regulator_desc desc; struct regulator_dev *dev; - int microvolts; }; @@ -108,30 +107,7 @@ of_get_fixed_voltage_config(struct device *dev) return config; } -static int fixed_voltage_get_voltage(struct regulator_dev *dev) -{ - struct fixed_voltage_data *data = rdev_get_drvdata(dev); - - if (data->microvolts) - return data->microvolts; - else - return -EINVAL; -} - -static int fixed_voltage_list_voltage(struct regulator_dev *dev, - unsigned selector) -{ - struct fixed_voltage_data *data = rdev_get_drvdata(dev); - - if (selector != 0) - return -EINVAL; - - return data->microvolts; -} - static struct regulator_ops fixed_voltage_ops = { - .get_voltage = fixed_voltage_get_voltage, - .list_voltage = fixed_voltage_list_voltage, }; static int reg_fixed_voltage_probe(struct platform_device *pdev) @@ -186,7 +162,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) if (config->microvolts) drvdata->desc.n_voltages = 1; - drvdata->microvolts = config->microvolts; + drvdata->desc.fixed_uV = config->microvolts; if (config->gpio >= 0) cfg.ena_gpio = config->gpio; @@ -222,7 +198,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) platform_set_drvdata(pdev, drvdata); dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, - drvdata->microvolts); + drvdata->desc.fixed_uV); return 0; -- cgit v1.2.3-55-g7522 From 0fdfd40aca7046eb0b770d64dfe526a03ed5d092 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 9 Sep 2013 13:49:27 +0200 Subject: regulator: da9063: Add missing initialization of da9063_reg_matches With gcc 4.1.2: drivers/regulator/da9063-regulator.c: In function ‘da9063_regulator_probe’: drivers/regulator/da9063-regulator.c:847: warning: ‘da9063_reg_matches’ is used uninitialized in this function If the parent device already has platform data, da9063_reg_matches will not be initialized. Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- drivers/regulator/da9063-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 1a7816390773..362261359ce8 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c @@ -717,7 +717,7 @@ static int da9063_regulator_probe(struct platform_device *pdev) { struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); struct da9063_pdata *da9063_pdata = dev_get_platdata(da9063->dev); - struct of_regulator_match *da9063_reg_matches; + struct of_regulator_match *da9063_reg_matches = NULL; struct da9063_regulators_pdata *regl_pdata; const struct da9063_dev_model *model; struct da9063_regulators *regulators; -- cgit v1.2.3-55-g7522 From 1aa20d27b4d23c18a20a9268e49e5d21a74789ff Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:42:46 +0100 Subject: regulator: wm831x-dcdc: Convert to devm_gpio_request_one() Saves code in the unwind path. Signed-off-by: Mark Brown --- drivers/regulator/wm831x-dcdc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 11861cb861df..8f627503ac41 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c @@ -387,8 +387,9 @@ static struct regulator_ops wm831x_buckv_ops = { * Set up DVS control. We just log errors since we can still run * (with reduced performance) if we fail. */ -static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, - struct wm831x_buckv_pdata *pdata) +static void wm831x_buckv_dvs_init(struct platform_device *pdev, + struct wm831x_dcdc *dcdc, + struct wm831x_buckv_pdata *pdata) { struct wm831x *wm831x = dcdc->wm831x; int ret; @@ -402,9 +403,9 @@ static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, */ dcdc->dvs_gpio_state = pdata->dvs_init_state; - ret = gpio_request_one(pdata->dvs_gpio, - dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, - "DCDC DVS"); + ret = devm_gpio_request_one(&pdev->dev, pdata->dvs_gpio, + dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, + "DCDC DVS"); if (ret < 0) { dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", dcdc->name, ret); @@ -513,7 +514,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev) dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK; if (pdata && pdata->dcdc[id]) - wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); + wm831x_buckv_dvs_init(pdev, dcdc, + pdata->dcdc[id]->driver_data); config.dev = pdev->dev.parent; if (pdata) @@ -557,8 +559,6 @@ err_uv: err_regulator: regulator_unregister(dcdc->regulator); err: - if (dcdc->dvs_gpio) - gpio_free(dcdc->dvs_gpio); return ret; } @@ -572,8 +572,6 @@ static int wm831x_buckv_remove(struct platform_device *pdev) free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), dcdc); regulator_unregister(dcdc->regulator); - if (dcdc->dvs_gpio) - gpio_free(dcdc->dvs_gpio); return 0; } -- cgit v1.2.3-55-g7522 From b0c4c0c68982156bfb94993305e69a03309395c3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:47:39 +0100 Subject: regulator: wm831x-dcdc: Convert to devm_request_threaded_irq() devm guarantees that resources are freed in the opposite order to that in which they are registered. Signed-off-by: Mark Brown --- drivers/regulator/wm831x-dcdc.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 8f627503ac41..aca2fcb190fd 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c @@ -532,8 +532,9 @@ static int wm831x_buckv_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, - IRQF_TRIGGER_RISING, dcdc->name, dcdc); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_dcdc_uv_irq, + IRQF_TRIGGER_RISING, dcdc->name, dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -541,21 +542,19 @@ static int wm831x_buckv_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq, - IRQF_TRIGGER_RISING, dcdc->name, dcdc); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_dcdc_oc_irq, + IRQF_TRIGGER_RISING, dcdc->name, dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", irq, ret); - goto err_uv; + goto err_regulator; } platform_set_drvdata(pdev, dcdc); return 0; -err_uv: - free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), - dcdc); err_regulator: regulator_unregister(dcdc->regulator); err: @@ -565,12 +564,7 @@ err: static int wm831x_buckv_remove(struct platform_device *pdev) { struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - struct wm831x *wm831x = dcdc->wm831x; - free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")), - dcdc); - free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), - dcdc); regulator_unregister(dcdc->regulator); return 0; @@ -688,8 +682,9 @@ static int wm831x_buckp_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, - IRQF_TRIGGER_RISING, dcdc->name, dcdc); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_dcdc_uv_irq, + IRQF_TRIGGER_RISING, dcdc->name, dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -710,8 +705,6 @@ static int wm831x_buckp_remove(struct platform_device *pdev) { struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), - dcdc); regulator_unregister(dcdc->regulator); return 0; @@ -820,9 +813,10 @@ static int wm831x_boostp_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, - IRQF_TRIGGER_RISING, dcdc->name, - dcdc); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_dcdc_uv_irq, + IRQF_TRIGGER_RISING, dcdc->name, + dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -843,8 +837,6 @@ static int wm831x_boostp_remove(struct platform_device *pdev) { struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), - dcdc); regulator_unregister(dcdc->regulator); return 0; -- cgit v1.2.3-55-g7522 From 63fb3149c8ba2b0194ba7e967f2dafc1c8c0da69 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:48:45 +0100 Subject: regulator: wm831x-isink: Use devm_request_threaded_irq() devm guarantees that resources are freed in the opposite order to that in which they are allocated. Signed-off-by: Mark Brown --- drivers/regulator/wm831x-isink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 4eb373de1fac..841cb52b2bb6 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c @@ -203,8 +203,10 @@ static int wm831x_isink_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); - ret = request_threaded_irq(irq, NULL, wm831x_isink_irq, - IRQF_TRIGGER_RISING, isink->name, isink); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_isink_irq, + IRQF_TRIGGER_RISING, isink->name, + isink); if (ret != 0) { dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", irq, ret); @@ -225,8 +227,6 @@ static int wm831x_isink_remove(struct platform_device *pdev) { struct wm831x_isink *isink = platform_get_drvdata(pdev); - free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); - regulator_unregister(isink->regulator); return 0; -- cgit v1.2.3-55-g7522 From 41c7a879d1d637c0c9731682a822b1c3162b0764 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:50:00 +0100 Subject: regulator: wm831x-ldo: Use devm_request_threaded_irq() devm guarantees that resources are freed in the oposite order to that in which they are allocated. Signed-off-by: Mark Brown --- drivers/regulator/wm831x-ldo.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 1432b26ef2e9..5570f3e59170 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c @@ -288,9 +288,10 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); - ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, - IRQF_TRIGGER_RISING, ldo->name, - ldo); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_ldo_uv_irq, + IRQF_TRIGGER_RISING, ldo->name, + ldo); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -311,8 +312,6 @@ static int wm831x_gp_ldo_remove(struct platform_device *pdev) { struct wm831x_ldo *ldo = platform_get_drvdata(pdev); - free_irq(wm831x_irq(ldo->wm831x, - platform_get_irq_byname(pdev, "UV")), ldo); regulator_unregister(ldo->regulator); return 0; @@ -514,8 +513,9 @@ static int wm831x_aldo_probe(struct platform_device *pdev) } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); - ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, - IRQF_TRIGGER_RISING, ldo->name, ldo); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + wm831x_ldo_uv_irq, + IRQF_TRIGGER_RISING, ldo->name, ldo); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -536,8 +536,6 @@ static int wm831x_aldo_remove(struct platform_device *pdev) { struct wm831x_ldo *ldo = platform_get_drvdata(pdev); - free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")), - ldo); regulator_unregister(ldo->regulator); return 0; -- cgit v1.2.3-55-g7522 From b33e46bcdc4e598d738ed12a5a7906be4e11d786 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:58:26 +0100 Subject: regulator: core: Provide managed regulator registration Many regulator drivers have a remove function that consists solely of calling regulator_unregister() so provide a devm_regulator_register() in order to allow this repeated code to be removed and help eliminate error handling code. Signed-off-by: Mark Brown --- Documentation/driver-model/devres.txt | 1 + drivers/regulator/core.c | 66 +++++++++++++++++++++++++++++++++++ include/linux/regulator/driver.h | 5 +++ 3 files changed, 72 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index fcb34a5697ea..3d9c2a766230 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -283,6 +283,7 @@ REGULATOR devm_regulator_get() devm_regulator_put() devm_regulator_bulk_get() + devm_regulator_register() CLOCK devm_clk_get() diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..5f995d281672 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3492,6 +3492,44 @@ clean: } EXPORT_SYMBOL_GPL(regulator_register); +static void devm_rdev_release(struct device *dev, void *res) +{ + regulator_unregister(*(struct regulator_dev **)res); +} + +/** + * devm_regulator_register - Resource managed regulator_register() + * @regulator_desc: regulator to register + * @config: runtime configuration for regulator + * + * Called by regulator drivers to register a regulator. Returns a + * valid pointer to struct regulator_dev on success or an ERR_PTR() on + * error. The regulator will automaticall be released when the device + * is unbound. + */ +struct regulator_dev *devm_regulator_register(struct device *dev, + const struct regulator_desc *regulator_desc, + const struct regulator_config *config) +{ + struct regulator_dev **ptr, *rdev; + + ptr = devres_alloc(devm_rdev_release, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + rdev = regulator_register(regulator_desc, config); + if (!IS_ERR(rdev)) { + *ptr = rdev; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return rdev; +} +EXPORT_SYMBOL_GPL(devm_regulator_register); + /** * regulator_unregister - unregister regulator * @rdev: regulator to unregister @@ -3521,6 +3559,34 @@ void regulator_unregister(struct regulator_dev *rdev) } EXPORT_SYMBOL_GPL(regulator_unregister); +static int devm_rdev_match(struct device *dev, void *res, void *data) +{ + struct regulator_dev **r = res; + if (!r || !*r) { + WARN_ON(!r || !*r); + return 0; + } + return *r == data; +} + +/** + * devm_regulator_unregister - Resource managed regulator_unregister() + * @regulator: regulator to free + * + * Unregister a regulator registered with devm_regulator_register(). + * Normally this function will not need to be called and the resource + * management code will ensure that the resource is freed. + */ +void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) +{ + int rc; + + rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev); + if (rc != 0) + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_regulator_unregister); + /** * regulator_suspend_prepare - prepare regulators for system wide suspend * @state: system suspend state diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 67e13aa5a478..8474c7f88745 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -334,7 +334,12 @@ struct regulator_dev { struct regulator_dev * regulator_register(const struct regulator_desc *regulator_desc, const struct regulator_config *config); +struct regulator_dev * +devm_regulator_register(struct device *dev, + const struct regulator_desc *regulator_desc, + const struct regulator_config *config); void regulator_unregister(struct regulator_dev *rdev); +void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev); int regulator_notifier_call_chain(struct regulator_dev *rdev, unsigned long event, void *data); -- cgit v1.2.3-55-g7522 From 14ffa8882bbd991497f2f87ce80382e5a1e6eb8f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:56:47 +0100 Subject: regulator: arizona-ldo1: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/arizona-ldo1.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 81d8681c3195..4f6c2055f6b2 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -226,7 +226,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev) else config.init_data = &ldo1->init_data; - ldo1->regulator = regulator_register(desc, &config); + ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); if (IS_ERR(ldo1->regulator)) { ret = PTR_ERR(ldo1->regulator); dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", @@ -239,18 +239,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) return 0; } -static int arizona_ldo1_remove(struct platform_device *pdev) -{ - struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); - - regulator_unregister(ldo1->regulator); - - return 0; -} - static struct platform_driver arizona_ldo1_driver = { .probe = arizona_ldo1_probe, - .remove = arizona_ldo1_remove, .driver = { .name = "arizona-ldo1", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From b6b7709cf95c6f5db074f2d725ddf29b0977589f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:57:00 +0100 Subject: regulator: arizona-micsupp: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/arizona-micsupp.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index e87536bf0bed..724706a97dc4 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c @@ -225,7 +225,9 @@ static int arizona_micsupp_probe(struct platform_device *pdev) regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, ARIZONA_CPMIC_BYPASS, 0); - micsupp->regulator = regulator_register(&arizona_micsupp, &config); + micsupp->regulator = devm_regulator_register(&pdev->dev, + &arizona_micsupp, + &config); if (IS_ERR(micsupp->regulator)) { ret = PTR_ERR(micsupp->regulator); dev_err(arizona->dev, "Failed to register mic supply: %d\n", @@ -238,18 +240,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) return 0; } -static int arizona_micsupp_remove(struct platform_device *pdev) -{ - struct arizona_micsupp *micsupp = platform_get_drvdata(pdev); - - regulator_unregister(micsupp->regulator); - - return 0; -} - static struct platform_driver arizona_micsupp_driver = { .probe = arizona_micsupp_probe, - .remove = arizona_micsupp_remove, .driver = { .name = "arizona-micsupp", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From b707a274455f8f80feab24b999dad9e649c98c9c Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:57:16 +0100 Subject: regulator: s2mps11: Convert to devm_regulator_register() Signed-off-by: Mark Brown Acked-by: Sangbeom Kim --- drivers/regulator/s2mps11.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 5eba2ff8c0e8..d7c241e1a173 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -453,27 +453,10 @@ common_reg: ret = PTR_ERR(s2mps11->rdev[i]); dev_err(&pdev->dev, "regulator init failed for %d\n", i); - s2mps11->rdev[i] = NULL; - goto err; + return ret; } } - return 0; -err: - for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) - regulator_unregister(s2mps11->rdev[i]); - - return ret; -} - -static int s2mps11_pmic_remove(struct platform_device *pdev) -{ - struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) - regulator_unregister(s2mps11->rdev[i]); - return 0; } @@ -489,7 +472,6 @@ static struct platform_driver s2mps11_pmic_driver = { .owner = THIS_MODULE, }, .probe = s2mps11_pmic_probe, - .remove = s2mps11_pmic_remove, .id_table = s2mps11_pmic_id, }; -- cgit v1.2.3-55-g7522 From f0db475dee8fdae611364829ceb7afcd6aa02166 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:57:34 +0100 Subject: regulator: s5m8767: Covert to devm_regulator_register() Signed-off-by: Mark Brown Acked-by: Sangbeom Kim --- drivers/regulator/s5m8767.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index c24448bc43cf..2297fdf9ba7e 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -910,33 +910,16 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.regmap = iodev->regmap; config.of_node = pdata->regulators[i].reg_node; - rdev[i] = regulator_register(®ulators[id], &config); + rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], + &config); if (IS_ERR(rdev[i])) { ret = PTR_ERR(rdev[i]); dev_err(s5m8767->dev, "regulator init failed for %d\n", id); - rdev[i] = NULL; - goto err; + return ret; } } - return 0; -err: - for (i = 0; i < s5m8767->num_regulators; i++) - regulator_unregister(rdev[i]); - - return ret; -} - -static int s5m8767_pmic_remove(struct platform_device *pdev) -{ - struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); - struct regulator_dev **rdev = s5m8767->rdev; - int i; - - for (i = 0; i < s5m8767->num_regulators; i++) - regulator_unregister(rdev[i]); - return 0; } @@ -952,7 +935,6 @@ static struct platform_driver s5m8767_pmic_driver = { .owner = THIS_MODULE, }, .probe = s5m8767_pmic_probe, - .remove = s5m8767_pmic_remove, .id_table = s5m8767_pmic_id, }; -- cgit v1.2.3-55-g7522 From d73b4cb7b3632ccd726746e9cb43002f1adf7956 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:58:40 +0100 Subject: regulator: wm831x-dcdc: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/wm831x-dcdc.c | 66 ++++++++--------------------------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index aca2fcb190fd..6823e6f2b88a 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c @@ -523,7 +523,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev) config.driver_data = dcdc; config.regmap = wm831x->regmap; - dcdc->regulator = regulator_register(&dcdc->desc, &config); + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, + &config); if (IS_ERR(dcdc->regulator)) { ret = PTR_ERR(dcdc->regulator); dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", @@ -538,7 +539,7 @@ static int wm831x_buckv_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); @@ -548,31 +549,19 @@ static int wm831x_buckv_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } platform_set_drvdata(pdev, dcdc); return 0; -err_regulator: - regulator_unregister(dcdc->regulator); err: return ret; } -static int wm831x_buckv_remove(struct platform_device *pdev) -{ - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - - regulator_unregister(dcdc->regulator); - - return 0; -} - static struct platform_driver wm831x_buckv_driver = { .probe = wm831x_buckv_probe, - .remove = wm831x_buckv_remove, .driver = { .name = "wm831x-buckv", .owner = THIS_MODULE, @@ -673,7 +662,8 @@ static int wm831x_buckp_probe(struct platform_device *pdev) config.driver_data = dcdc; config.regmap = wm831x->regmap; - dcdc->regulator = regulator_register(&dcdc->desc, &config); + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, + &config); if (IS_ERR(dcdc->regulator)) { ret = PTR_ERR(dcdc->regulator); dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", @@ -688,31 +678,19 @@ static int wm831x_buckp_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } platform_set_drvdata(pdev, dcdc); return 0; -err_regulator: - regulator_unregister(dcdc->regulator); err: return ret; } -static int wm831x_buckp_remove(struct platform_device *pdev) -{ - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - - regulator_unregister(dcdc->regulator); - - return 0; -} - static struct platform_driver wm831x_buckp_driver = { .probe = wm831x_buckp_probe, - .remove = wm831x_buckp_remove, .driver = { .name = "wm831x-buckp", .owner = THIS_MODULE, @@ -804,7 +782,8 @@ static int wm831x_boostp_probe(struct platform_device *pdev) config.driver_data = dcdc; config.regmap = wm831x->regmap; - dcdc->regulator = regulator_register(&dcdc->desc, &config); + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, + &config); if (IS_ERR(dcdc->regulator)) { ret = PTR_ERR(dcdc->regulator); dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", @@ -820,31 +799,19 @@ static int wm831x_boostp_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } platform_set_drvdata(pdev, dcdc); return 0; -err_regulator: - regulator_unregister(dcdc->regulator); err: return ret; } -static int wm831x_boostp_remove(struct platform_device *pdev) -{ - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - - regulator_unregister(dcdc->regulator); - - return 0; -} - static struct platform_driver wm831x_boostp_driver = { .probe = wm831x_boostp_probe, - .remove = wm831x_boostp_remove, .driver = { .name = "wm831x-boostp", .owner = THIS_MODULE, @@ -904,7 +871,8 @@ static int wm831x_epe_probe(struct platform_device *pdev) config.driver_data = dcdc; config.regmap = wm831x->regmap; - dcdc->regulator = regulator_register(&dcdc->desc, &config); + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, + &config); if (IS_ERR(dcdc->regulator)) { ret = PTR_ERR(dcdc->regulator); dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", @@ -920,18 +888,8 @@ err: return ret; } -static int wm831x_epe_remove(struct platform_device *pdev) -{ - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); - - regulator_unregister(dcdc->regulator); - - return 0; -} - static struct platform_driver wm831x_epe_driver = { .probe = wm831x_epe_probe, - .remove = wm831x_epe_remove, .driver = { .name = "wm831x-epe", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From af151ded1b4b22dbedd8cb1600fcaf72e3eaf31e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 11:59:57 +0100 Subject: regulator: wm831x-isink: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/wm831x-isink.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 841cb52b2bb6..0339b886df5d 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c @@ -194,7 +194,8 @@ static int wm831x_isink_probe(struct platform_device *pdev) config.init_data = pdata->isink[id]; config.driver_data = isink; - isink->regulator = regulator_register(&isink->desc, &config); + isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, + &config); if (IS_ERR(isink->regulator)) { ret = PTR_ERR(isink->regulator); dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", @@ -210,31 +211,19 @@ static int wm831x_isink_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } platform_set_drvdata(pdev, isink); return 0; -err_regulator: - regulator_unregister(isink->regulator); err: return ret; } -static int wm831x_isink_remove(struct platform_device *pdev) -{ - struct wm831x_isink *isink = platform_get_drvdata(pdev); - - regulator_unregister(isink->regulator); - - return 0; -} - static struct platform_driver wm831x_isink_driver = { .probe = wm831x_isink_probe, - .remove = wm831x_isink_remove, .driver = { .name = "wm831x-isink", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From fc7c60e390c9b99b28d078c27360cb6cd688cfd3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 12:00:17 +0100 Subject: regulator: wm831x-ldo: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/wm831x-ldo.c | 47 +++++++----------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 5570f3e59170..2be72fe36535 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c @@ -279,7 +279,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm831x->regmap; - ldo->regulator = regulator_register(&ldo->desc, &config); + ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, + &config); if (IS_ERR(ldo->regulator)) { ret = PTR_ERR(ldo->regulator); dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", @@ -295,31 +296,19 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } platform_set_drvdata(pdev, ldo); return 0; -err_regulator: - regulator_unregister(ldo->regulator); err: return ret; } -static int wm831x_gp_ldo_remove(struct platform_device *pdev) -{ - struct wm831x_ldo *ldo = platform_get_drvdata(pdev); - - regulator_unregister(ldo->regulator); - - return 0; -} - static struct platform_driver wm831x_gp_ldo_driver = { .probe = wm831x_gp_ldo_probe, - .remove = wm831x_gp_ldo_remove, .driver = { .name = "wm831x-ldo", .owner = THIS_MODULE, @@ -504,7 +493,8 @@ static int wm831x_aldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm831x->regmap; - ldo->regulator = regulator_register(&ldo->desc, &config); + ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, + &config); if (IS_ERR(ldo->regulator)) { ret = PTR_ERR(ldo->regulator); dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", @@ -519,31 +509,19 @@ static int wm831x_aldo_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); - goto err_regulator; + goto err; } platform_set_drvdata(pdev, ldo); return 0; -err_regulator: - regulator_unregister(ldo->regulator); err: return ret; } -static int wm831x_aldo_remove(struct platform_device *pdev) -{ - struct wm831x_ldo *ldo = platform_get_drvdata(pdev); - - regulator_unregister(ldo->regulator); - - return 0; -} - static struct platform_driver wm831x_aldo_driver = { .probe = wm831x_aldo_probe, - .remove = wm831x_aldo_remove, .driver = { .name = "wm831x-aldo", .owner = THIS_MODULE, @@ -661,7 +639,8 @@ static int wm831x_alive_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm831x->regmap; - ldo->regulator = regulator_register(&ldo->desc, &config); + ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, + &config); if (IS_ERR(ldo->regulator)) { ret = PTR_ERR(ldo->regulator); dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", @@ -677,18 +656,8 @@ err: return ret; } -static int wm831x_alive_ldo_remove(struct platform_device *pdev) -{ - struct wm831x_ldo *ldo = platform_get_drvdata(pdev); - - regulator_unregister(ldo->regulator); - - return 0; -} - static struct platform_driver wm831x_alive_ldo_driver = { .probe = wm831x_alive_ldo_probe, - .remove = wm831x_alive_ldo_remove, .driver = { .name = "wm831x-alive-ldo", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From e57e54693371fe1530f376c8a67c33d19bb2a0dc Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 12:00:37 +0100 Subject: regulator: wm8350: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/wm8350-regulator.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 835b5f0f344e..a438e937cfa0 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c @@ -1206,7 +1206,8 @@ static int wm8350_regulator_probe(struct platform_device *pdev) config.regmap = wm8350->regmap; /* register regulator */ - rdev = regulator_register(&wm8350_reg[pdev->id], &config); + rdev = devm_regulator_register(&pdev->dev, &wm8350_reg[pdev->id], + &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register %s\n", wm8350_reg[pdev->id].name); @@ -1217,7 +1218,6 @@ static int wm8350_regulator_probe(struct platform_device *pdev) ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, pmic_uv_handler, 0, "UV", rdev); if (ret < 0) { - regulator_unregister(rdev); dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", wm8350_reg[pdev->id].name); return ret; @@ -1233,8 +1233,6 @@ static int wm8350_regulator_remove(struct platform_device *pdev) wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); - regulator_unregister(rdev); - return 0; } -- cgit v1.2.3-55-g7522 From eb8b3c8360408b78ca99492f8c1fec080c75dd71 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 12:00:57 +0100 Subject: regulator: wm8400: Convert to devm_regulator_register() Signed-off-by: Mark Brown --- drivers/regulator/wm8400-regulator.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 58f51bec13f2..870b52f709bc 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c @@ -219,7 +219,8 @@ static int wm8400_regulator_probe(struct platform_device *pdev) config.driver_data = wm8400; config.regmap = wm8400->regmap; - rdev = regulator_register(®ulators[pdev->id], &config); + rdev = devm_regulator_register(&pdev->dev, ®ulators[pdev->id], + &config); if (IS_ERR(rdev)) return PTR_ERR(rdev); @@ -228,21 +229,11 @@ static int wm8400_regulator_probe(struct platform_device *pdev) return 0; } -static int wm8400_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - - return 0; -} - static struct platform_driver wm8400_regulator_driver = { .driver = { .name = "wm8400-regulator", }, .probe = wm8400_regulator_probe, - .remove = wm8400_regulator_remove, }; /** -- cgit v1.2.3-55-g7522 From 9e2bfbbdf203c954a306a5e402a84c24622c55b0 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 12:01:12 +0100 Subject: regulator: wm8994: Convert to devm_regulator_register Signed-off-by: Mark Brown --- drivers/regulator/wm8994-regulator.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 5ee2a208457c..71c5911f2e71 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -165,7 +165,9 @@ static int wm8994_ldo_probe(struct platform_device *pdev) ldo->init_data = *pdata->ldo[id].init_data; } - ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); + ldo->regulator = devm_regulator_register(&pdev->dev, + &wm8994_ldo_desc[id], + &config); if (IS_ERR(ldo->regulator)) { ret = PTR_ERR(ldo->regulator); dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", @@ -181,18 +183,8 @@ err: return ret; } -static int wm8994_ldo_remove(struct platform_device *pdev) -{ - struct wm8994_ldo *ldo = platform_get_drvdata(pdev); - - regulator_unregister(ldo->regulator); - - return 0; -} - static struct platform_driver wm8994_ldo_driver = { .probe = wm8994_ldo_probe, - .remove = wm8994_ldo_remove, .driver = { .name = "wm8994-ldo", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From bcb5fe44875b09756c5e81925de19f9ca5bb9117 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:17:36 +0800 Subject: regulator: 88pm8607: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/88pm8607.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 70230974468c..f704d83c93c4 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c @@ -391,7 +391,8 @@ static int pm8607_regulator_probe(struct platform_device *pdev) else config.regmap = chip->regmap_companion; - info->regulator = regulator_register(&info->desc, &config); + info->regulator = devm_regulator_register(&pdev->dev, &info->desc, + &config); if (IS_ERR(info->regulator)) { dev_err(&pdev->dev, "failed to register regulator %s\n", info->desc.name); @@ -402,14 +403,6 @@ static int pm8607_regulator_probe(struct platform_device *pdev) return 0; } -static int pm8607_regulator_remove(struct platform_device *pdev) -{ - struct pm8607_regulator_info *info = platform_get_drvdata(pdev); - - regulator_unregister(info->regulator); - return 0; -} - static struct platform_device_id pm8607_regulator_driver_ids[] = { { .name = "88pm860x-regulator", @@ -428,7 +421,6 @@ static struct platform_driver pm8607_regulator_driver = { .owner = THIS_MODULE, }, .probe = pm8607_regulator_probe, - .remove = pm8607_regulator_remove, .id_table = pm8607_regulator_driver_ids, }; -- cgit v1.2.3-55-g7522 From b1a613d505c53ad4f4af4cf228841a1784a50011 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:19:00 +0800 Subject: regulator: aat2870: Convert to devm_regulator_register Signed-off-by: Axel Lin Acked-by: Jinyoung Park Signed-off-by: Mark Brown --- drivers/regulator/aat2870-regulator.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 881159dfcb5e..f70a9bfa5ff2 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c @@ -176,7 +176,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev) config.driver_data = ri; config.init_data = dev_get_platdata(&pdev->dev); - rdev = regulator_register(&ri->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "Failed to register regulator %s\n", ri->desc.name); @@ -187,21 +187,12 @@ static int aat2870_regulator_probe(struct platform_device *pdev) return 0; } -static int aat2870_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - return 0; -} - static struct platform_driver aat2870_regulator_driver = { .driver = { .name = "aat2870-regulator", .owner = THIS_MODULE, }, .probe = aat2870_regulator_probe, - .remove = aat2870_regulator_remove, }; static int __init aat2870_regulator_init(void) -- cgit v1.2.3-55-g7522 From 9b2cdac712448ca182dabeffd36bd532c53f3935 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:20:25 +0800 Subject: regulator: ad5398: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/ad5398.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index b2b203cb6b2f..48016a050d5f 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c @@ -219,7 +219,6 @@ static int ad5398_probe(struct i2c_client *client, struct ad5398_chip_info *chip; const struct ad5398_current_data_format *df = (struct ad5398_current_data_format *)id->driver_data; - int ret; if (!init_data) return -EINVAL; @@ -240,33 +239,21 @@ static int ad5398_probe(struct i2c_client *client, chip->current_offset = df->current_offset; chip->current_mask = (chip->current_level - 1) << chip->current_offset; - chip->rdev = regulator_register(&ad5398_reg, &config); + chip->rdev = devm_regulator_register(&client->dev, &ad5398_reg, + &config); if (IS_ERR(chip->rdev)) { - ret = PTR_ERR(chip->rdev); dev_err(&client->dev, "failed to register %s %s\n", id->name, ad5398_reg.name); - goto err; + return PTR_ERR(chip->rdev); } i2c_set_clientdata(client, chip); dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); return 0; - -err: - return ret; -} - -static int ad5398_remove(struct i2c_client *client) -{ - struct ad5398_chip_info *chip = i2c_get_clientdata(client); - - regulator_unregister(chip->rdev); - return 0; } static struct i2c_driver ad5398_driver = { .probe = ad5398_probe, - .remove = ad5398_remove, .driver = { .name = "ad5398", }, -- cgit v1.2.3-55-g7522 From 27447c934a9e6ea7753f61211ef06327915ed0d2 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:22:00 +0800 Subject: regulator: as3711: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/as3711-regulator.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 8406cd745da2..fb27e6c8887c 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c @@ -273,33 +273,16 @@ static int as3711_regulator_probe(struct platform_device *pdev) config.regmap = as3711->regmap; config.of_node = of_node[id]; - rdev = regulator_register(&ri->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "Failed to register regulator %s\n", ri->desc.name); - ret = PTR_ERR(rdev); - goto eregreg; + return PTR_ERR(rdev); } reg->rdev = rdev; } platform_set_drvdata(pdev, regs); return 0; - -eregreg: - while (--id >= 0) - regulator_unregister(regs[id].rdev); - - return ret; -} - -static int as3711_regulator_remove(struct platform_device *pdev) -{ - struct as3711_regulator *regs = platform_get_drvdata(pdev); - int id; - - for (id = 0; id < AS3711_REGULATOR_NUM; ++id) - regulator_unregister(regs[id].rdev); - return 0; } static struct platform_driver as3711_regulator_driver = { @@ -308,7 +291,6 @@ static struct platform_driver as3711_regulator_driver = { .owner = THIS_MODULE, }, .probe = as3711_regulator_probe, - .remove = as3711_regulator_remove, }; static int __init as3711_regulator_init(void) -- cgit v1.2.3-55-g7522 From 4e8d79355da117b4be7ea6f870eabc7f18740f2c Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:23:14 +0800 Subject: regulator: da903x: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/da903x.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index f06854cf8cf5..c61d96e9d925 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c @@ -463,7 +463,7 @@ static int da903x_regulator_probe(struct platform_device *pdev) config.init_data = dev_get_platdata(&pdev->dev); config.driver_data = ri; - rdev = regulator_register(&ri->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register regulator %s\n", ri->desc.name); @@ -474,21 +474,12 @@ static int da903x_regulator_probe(struct platform_device *pdev) return 0; } -static int da903x_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - return 0; -} - static struct platform_driver da903x_regulator_driver = { .driver = { .name = "da903x-regulator", .owner = THIS_MODULE, }, .probe = da903x_regulator_probe, - .remove = da903x_regulator_remove, }; static int __init da903x_regulator_init(void) -- cgit v1.2.3-55-g7522 From ea49a5ebbbfa982c893d4d6cf68feeb829f58324 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:24:46 +0800 Subject: regulator: da9052: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/da9052-regulator.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 1e4d483f6163..c427e42472e8 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c @@ -389,8 +389,9 @@ static int da9052_regulator_probe(struct platform_device *pdev) #endif } - regulator->rdev = regulator_register(®ulator->info->reg_desc, - &config); + regulator->rdev = devm_regulator_register(&pdev->dev, + ®ulator->info->reg_desc, + &config); if (IS_ERR(regulator->rdev)) { dev_err(&pdev->dev, "failed to register regulator %s\n", regulator->info->reg_desc.name); @@ -402,17 +403,8 @@ static int da9052_regulator_probe(struct platform_device *pdev) return 0; } -static int da9052_regulator_remove(struct platform_device *pdev) -{ - struct da9052_regulator *regulator = platform_get_drvdata(pdev); - - regulator_unregister(regulator->rdev); - return 0; -} - static struct platform_driver da9052_regulator_driver = { .probe = da9052_regulator_probe, - .remove = da9052_regulator_remove, .driver = { .name = "da9052-regulator", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 0d3288063b4e45335ea011b89d0850a0fd76096c Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:26:10 +0800 Subject: regulator: da9055: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/da9055-regulator.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index 77b53e5a231c..7f340206d329 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c @@ -564,13 +564,13 @@ static int da9055_regulator_probe(struct platform_device *pdev) if (ret < 0) return ret; - regulator->rdev = regulator_register(®ulator->info->reg_desc, - &config); + regulator->rdev = devm_regulator_register(&pdev->dev, + ®ulator->info->reg_desc, + &config); if (IS_ERR(regulator->rdev)) { dev_err(&pdev->dev, "Failed to register regulator %s\n", regulator->info->reg_desc.name); - ret = PTR_ERR(regulator->rdev); - return ret; + return PTR_ERR(regulator->rdev); } /* Only LDO 5 and 6 has got the over current interrupt */ @@ -588,32 +588,18 @@ static int da9055_regulator_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to request Regulator IRQ %d: %d\n", irq, ret); - goto err_regulator; + return ret; } } } platform_set_drvdata(pdev, regulator); - return 0; - -err_regulator: - regulator_unregister(regulator->rdev); - return ret; -} - -static int da9055_regulator_remove(struct platform_device *pdev) -{ - struct da9055_regulator *regulator = platform_get_drvdata(pdev); - - regulator_unregister(regulator->rdev); - return 0; } static struct platform_driver da9055_regulator_driver = { .probe = da9055_regulator_probe, - .remove = da9055_regulator_remove, .driver = { .name = "da9055-regulator", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From b15f5f7603fe9963e2201874f6e6c6cc0410b4d1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 3 Sep 2013 14:27:56 +0800 Subject: regulator: fan53555: Convert to devm_regulator_register Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/fan53555.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 70b7220c587f..7ca3d9e3b0fe 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -218,9 +218,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, rdesc->vsel_mask = VSEL_NSEL_MASK; rdesc->owner = THIS_MODULE; - di->rdev = regulator_register(&di->desc, config); + di->rdev = devm_regulator_register(di->dev, &di->desc, config); return PTR_ERR_OR_ZERO(di->rdev); - } static struct regmap_config fan53555_regmap_config = { @@ -291,14 +290,6 @@ static int fan53555_regulator_probe(struct i2c_client *client, } -static int fan53555_regulator_remove(struct i2c_client *client) -{ - struct fan53555_device_info *di = i2c_get_clientdata(client); - - regulator_unregister(di->rdev); - return 0; -} - static const struct i2c_device_id fan53555_id[] = { {"fan53555", -1}, { }, @@ -309,7 +300,6 @@ static struct i2c_driver fan53555_regulator_driver = { .name = "fan53555-regulator", }, .probe = fan53555_regulator_probe, - .remove = fan53555_regulator_remove, .id_table = fan53555_id, }; -- cgit v1.2.3-55-g7522 From d55cd794d6ae9d0730c0b039c0a2d5d0e5ff12c4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:12:15 +0530 Subject: regulator: s2mps11: Use devm_regulator_register Commit e398b51a ("regulator: s2mps11: Convert to devm_regulator_register()") intended to do this conversion. However the actual conversion to devm_* got missed out. Fix this. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index d7c241e1a173..333677d68d0e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -448,7 +448,8 @@ common_reg: config.of_node = rdata[i].of_node; } - s2mps11->rdev[i] = regulator_register(®ulators[i], &config); + s2mps11->rdev[i] = devm_regulator_register(&pdev->dev, + ®ulators[i], &config); if (IS_ERR(s2mps11->rdev[i])) { ret = PTR_ERR(s2mps11->rdev[i]); dev_err(&pdev->dev, "regulator init failed for %d\n", -- cgit v1.2.3-55-g7522 From 44815b4a619065f510cffa2976722e78381d4fd2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:07:54 +0530 Subject: regulator: max77686: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index f563057e5690..de5b30ea823c 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -478,31 +478,16 @@ static int max77686_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].of_node; max77686->opmode[i] = regulators[i].enable_mask; - max77686->rdev[i] = regulator_register(®ulators[i], &config); + max77686->rdev[i] = devm_regulator_register(&pdev->dev, + ®ulators[i], &config); if (IS_ERR(max77686->rdev[i])) { - ret = PTR_ERR(max77686->rdev[i]); dev_err(&pdev->dev, "regulator init failed for %d\n", i); max77686->rdev[i] = NULL; - goto err; + return PTR_ERR(max77686->rdev[i]); } } - return 0; -err: - while (--i >= 0) - regulator_unregister(max77686->rdev[i]); - return ret; -} - -static int max77686_pmic_remove(struct platform_device *pdev) -{ - struct max77686_data *max77686 = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < MAX77686_REGULATORS; i++) - regulator_unregister(max77686->rdev[i]); - return 0; } @@ -518,7 +503,6 @@ static struct platform_driver max77686_pmic_driver = { .owner = THIS_MODULE, }, .probe = max77686_pmic_probe, - .remove = max77686_pmic_remove, .id_table = max77686_pmic_id, }; -- cgit v1.2.3-55-g7522 From 249cc1f21ee22d9cfead5ae552d91b9669d16c83 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:07:55 +0530 Subject: regulator: max1586: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max1586.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 3a599ee0a456..e242dd316d36 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c @@ -166,7 +166,7 @@ static int max1586_pmic_probe(struct i2c_client *client, struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); struct regulator_config config = { }; struct max1586_data *max1586; - int i, id, ret = -ENOMEM; + int i, id; max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), @@ -193,7 +193,7 @@ static int max1586_pmic_probe(struct i2c_client *client, continue; if (id < MAX1586_V3 || id > MAX1586_V6) { dev_err(&client->dev, "invalid regulator id %d\n", id); - goto err; + return -EINVAL; } if (id == MAX1586_V3) { @@ -207,33 +207,18 @@ static int max1586_pmic_probe(struct i2c_client *client, config.init_data = pdata->subdevs[i].platform_data; config.driver_data = max1586; - rdev[i] = regulator_register(&max1586_reg[id], &config); + rdev[i] = devm_regulator_register(&client->dev, + &max1586_reg[id], &config); if (IS_ERR(rdev[i])) { - ret = PTR_ERR(rdev[i]); dev_err(&client->dev, "failed to register %s\n", max1586_reg[id].name); - goto err; + return PTR_ERR(rdev[i]); } } i2c_set_clientdata(client, max1586); dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); return 0; - -err: - while (--i >= 0) - regulator_unregister(rdev[i]); - return ret; -} - -static int max1586_pmic_remove(struct i2c_client *client) -{ - struct max1586_data *max1586 = i2c_get_clientdata(client); - int i; - - for (i = 0; i <= MAX1586_V6; i++) - regulator_unregister(max1586->rdev[i]); - return 0; } static const struct i2c_device_id max1586_id[] = { @@ -244,7 +229,6 @@ MODULE_DEVICE_TABLE(i2c, max1586_id); static struct i2c_driver max1586_pmic_driver = { .probe = max1586_pmic_probe, - .remove = max1586_pmic_remove, .driver = { .name = "max1586", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 027a27545cc09dfc392d056437c5eb3f260d7e43 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:07:56 +0530 Subject: regulator: max77693: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max77693.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index ce4b96c15eba..2054ae1c496e 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c @@ -230,7 +230,7 @@ static int max77693_pmic_probe(struct platform_device *pdev) struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct max77693_pmic_dev *max77693_pmic; struct max77693_regulator_data *rdata = NULL; - int num_rdata, i, ret; + int num_rdata, i; struct regulator_config config; num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); @@ -266,35 +266,16 @@ static int max77693_pmic_probe(struct platform_device *pdev) config.init_data = rdata[i].initdata; config.of_node = rdata[i].of_node; - max77693_pmic->rdev[i] = regulator_register(®ulators[id], - &config); + max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev, + ®ulators[id], &config); if (IS_ERR(max77693_pmic->rdev[i])) { - ret = PTR_ERR(max77693_pmic->rdev[i]); dev_err(max77693_pmic->dev, "Failed to initialize regulator-%d\n", id); max77693_pmic->rdev[i] = NULL; - goto err; + return PTR_ERR(max77693_pmic->rdev[i]); } } - return 0; - err: - while (--i >= 0) - regulator_unregister(max77693_pmic->rdev[i]); - - return ret; -} - -static int max77693_pmic_remove(struct platform_device *pdev) -{ - struct max77693_pmic_dev *max77693_pmic = platform_get_drvdata(pdev); - struct regulator_dev **rdev = max77693_pmic->rdev; - int i; - - for (i = 0; i < max77693_pmic->num_regulators; i++) - if (rdev[i]) - regulator_unregister(rdev[i]); - return 0; } @@ -311,7 +292,6 @@ static struct platform_driver max77693_pmic_driver = { .owner = THIS_MODULE, }, .probe = max77693_pmic_probe, - .remove = max77693_pmic_remove, .id_table = max77693_pmic_id, }; -- cgit v1.2.3-55-g7522 From e453f92eec6d72db0d7fe6bab2e0a710dc6cd927 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:07:57 +0530 Subject: regulator: max8649: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max8649.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index 19c6f08eafd5..7f049c92ee52 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c @@ -234,7 +234,8 @@ static int max8649_regulator_probe(struct i2c_client *client, config.driver_data = info; config.regmap = info->regmap; - info->regulator = regulator_register(&dcdc_desc, &config); + info->regulator = devm_regulator_register(&client->dev, &dcdc_desc, + &config); if (IS_ERR(info->regulator)) { dev_err(info->dev, "failed to register regulator %s\n", dcdc_desc.name); @@ -244,16 +245,6 @@ static int max8649_regulator_probe(struct i2c_client *client, return 0; } -static int max8649_regulator_remove(struct i2c_client *client) -{ - struct max8649_regulator_info *info = i2c_get_clientdata(client); - - if (info) - regulator_unregister(info->regulator); - - return 0; -} - static const struct i2c_device_id max8649_id[] = { { "max8649", 0 }, { } @@ -262,7 +253,6 @@ MODULE_DEVICE_TABLE(i2c, max8649_id); static struct i2c_driver max8649_driver = { .probe = max8649_regulator_probe, - .remove = max8649_regulator_remove, .driver = { .name = "max8649", }, -- cgit v1.2.3-55-g7522 From dcfb6b56f18b5d9eff9b784d4e5b4a085f149de2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:07:58 +0530 Subject: regulator: max8660: Use devm_regulator_register devm_* simplifies the code. [Fixups from rebase onto v3.12 code -- broonie] Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max8660.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 144bcacd734d..8d94d3d7f97f 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c @@ -439,7 +439,7 @@ static int max8660_probe(struct i2c_client *client, for (i = 0; i < pdata->num_subdevs; i++) { if (!pdata->subdevs[i].platform_data) - goto err_out; + return ret; boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; @@ -465,7 +465,7 @@ static int max8660_probe(struct i2c_client *client, case MAX8660_V7: if (type == MAX8661) { dev_err(dev, "Regulator not on this chip!\n"); - goto err_out; + return -EINVAL; } if (boot_on) @@ -475,7 +475,7 @@ static int max8660_probe(struct i2c_client *client, default: dev_err(dev, "invalid regulator %s\n", pdata->subdevs[i].name); - goto err_out; + return ret; } } @@ -489,33 +489,18 @@ static int max8660_probe(struct i2c_client *client, config.of_node = of_node[i]; config.driver_data = max8660; - rdev[i] = regulator_register(&max8660_reg[id], &config); + rdev[i] = devm_regulator_register(&client->dev, + &max8660_reg[id], &config); if (IS_ERR(rdev[i])) { ret = PTR_ERR(rdev[i]); - dev_err(dev, "failed to register %s\n", + dev_err(&client->dev, "failed to register %s\n", max8660_reg[id].name); - goto err_unregister; + return PTR_ERR(rdev[i]); } } i2c_set_clientdata(client, max8660); return 0; - -err_unregister: - while (--i >= 0) - regulator_unregister(rdev[i]); -err_out: - return ret; -} - -static int max8660_remove(struct i2c_client *client) -{ - struct max8660 *max8660 = i2c_get_clientdata(client); - int i; - - for (i = 0; i < MAX8660_V_END; i++) - regulator_unregister(max8660->rdev[i]); - return 0; } static const struct i2c_device_id max8660_id[] = { @@ -527,7 +512,6 @@ MODULE_DEVICE_TABLE(i2c, max8660_id); static struct i2c_driver max8660_driver = { .probe = max8660_probe, - .remove = max8660_remove, .driver = { .name = "max8660", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 5ecdf140f21c50c08be34a83b44f28722813366c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:07:59 +0530 Subject: regulator: max8907-regulator: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max8907-regulator.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c index 4568c15fa78d..0c5fe6c6ac26 100644 --- a/drivers/regulator/max8907-regulator.c +++ b/drivers/regulator/max8907-regulator.c @@ -350,33 +350,17 @@ static int max8907_regulator_probe(struct platform_device *pdev) pmic->desc[i].ops = &max8907_out5v_hwctl_ops; } - pmic->rdev[i] = regulator_register(&pmic->desc[i], &config); + pmic->rdev[i] = devm_regulator_register(&pdev->dev, + &pmic->desc[i], &config); if (IS_ERR(pmic->rdev[i])) { dev_err(&pdev->dev, "failed to register %s regulator\n", pmic->desc[i].name); - ret = PTR_ERR(pmic->rdev[i]); - goto err_unregister_regulator; + return PTR_ERR(pmic->rdev[i]); } } return 0; - -err_unregister_regulator: - while (--i >= 0) - regulator_unregister(pmic->rdev[i]); - return ret; -} - -static int max8907_regulator_remove(struct platform_device *pdev) -{ - struct max8907_regulator *pmic = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < MAX8907_NUM_REGULATORS; i++) - regulator_unregister(pmic->rdev[i]); - - return 0; } static struct platform_driver max8907_regulator_driver = { @@ -385,7 +369,6 @@ static struct platform_driver max8907_regulator_driver = { .owner = THIS_MODULE, }, .probe = max8907_regulator_probe, - .remove = max8907_regulator_remove, }; static int __init max8907_regulator_init(void) -- cgit v1.2.3-55-g7522 From 8d581fd01c922f9df586074078d70027156cfff8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:08:00 +0530 Subject: regulator: max8973-regulator: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max8973-regulator.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 5b77ab7762e4..892aa1e5b96c 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -467,7 +467,7 @@ static int max8973_probe(struct i2c_client *client, config.regmap = max->regmap; /* Register the regulators */ - rdev = regulator_register(&max->desc, &config); + rdev = devm_regulator_register(&client->dev, &max->desc, &config); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); dev_err(max->dev, "regulator register failed, err %d\n", ret); @@ -478,14 +478,6 @@ static int max8973_probe(struct i2c_client *client, return 0; } -static int max8973_remove(struct i2c_client *client) -{ - struct max8973_chip *max = i2c_get_clientdata(client); - - regulator_unregister(max->rdev); - return 0; -} - static const struct i2c_device_id max8973_id[] = { {.name = "max8973",}, {}, @@ -499,7 +491,6 @@ static struct i2c_driver max8973_i2c_driver = { .owner = THIS_MODULE, }, .probe = max8973_probe, - .remove = max8973_remove, .id_table = max8973_id, }; -- cgit v1.2.3-55-g7522 From 4177f95b8433f809228ab485e3303ae4708c98ca Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:08:01 +0530 Subject: regulator: max8997: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max8997.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index df20069f0537..059e8ed7fa24 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c @@ -1081,7 +1081,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) pdata->buck1_voltage[i] + buck1245_voltage_map_desc.step); if (ret < 0) - goto err_out; + return ret; max8997->buck2_vol[i] = ret = max8997_get_voltage_proper_val( @@ -1090,7 +1090,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) pdata->buck2_voltage[i] + buck1245_voltage_map_desc.step); if (ret < 0) - goto err_out; + return ret; max8997->buck5_vol[i] = ret = max8997_get_voltage_proper_val( @@ -1099,7 +1099,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) pdata->buck5_voltage[i] + buck1245_voltage_map_desc.step); if (ret < 0) - goto err_out; + return ret; if (max_buck1 < max8997->buck1_vol[i]) max_buck1 = max8997->buck1_vol[i]; @@ -1143,24 +1143,23 @@ static int max8997_pmic_probe(struct platform_device *pdev) !gpio_is_valid(pdata->buck125_gpios[1]) || !gpio_is_valid(pdata->buck125_gpios[2])) { dev_err(&pdev->dev, "GPIO NOT VALID\n"); - ret = -EINVAL; - goto err_out; + return -EINVAL; } ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], "MAX8997 SET1"); if (ret) - goto err_out; + return ret; ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], "MAX8997 SET2"); if (ret) - goto err_out; + return ret; ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], "MAX8997 SET3"); if (ret) - goto err_out; + return ret; gpio_direction_output(pdata->buck125_gpios[0], (max8997->buck125_gpioindex >> 2) @@ -1205,33 +1204,17 @@ static int max8997_pmic_probe(struct platform_device *pdev) config.driver_data = max8997; config.of_node = pdata->regulators[i].reg_node; - rdev[i] = regulator_register(®ulators[id], &config); + rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], + &config); if (IS_ERR(rdev[i])) { - ret = PTR_ERR(rdev[i]); dev_err(max8997->dev, "regulator init failed for %d\n", id); rdev[i] = NULL; - goto err; + return PTR_ERR(rdev[i]); } } return 0; -err: - while (--i >= 0) - regulator_unregister(rdev[i]); -err_out: - return ret; -} - -static int max8997_pmic_remove(struct platform_device *pdev) -{ - struct max8997_data *max8997 = platform_get_drvdata(pdev); - struct regulator_dev **rdev = max8997->rdev; - int i; - - for (i = 0; i < max8997->num_regulators; i++) - regulator_unregister(rdev[i]); - return 0; } static const struct platform_device_id max8997_pmic_id[] = { @@ -1246,7 +1229,6 @@ static struct platform_driver max8997_pmic_driver = { .owner = THIS_MODULE, }, .probe = max8997_pmic_probe, - .remove = max8997_pmic_remove, .id_table = max8997_pmic_id, }; -- cgit v1.2.3-55-g7522 From 8d491bf42e01e8cc7597ee55cdeab20dbc75ec97 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 11:08:02 +0530 Subject: regulator: max8998: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max8998.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index a4c53b2d1aaf..ae3f0656feb0 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -790,16 +790,14 @@ static int max8998_pmic_probe(struct platform_device *pdev) dev_err(&pdev->dev, "MAX8998 SET1 GPIO defined as 0 !\n"); WARN_ON(!pdata->buck1_set1); - ret = -EIO; - goto err_out; + return -EIO; } /* Check if SET2 is not equal to 0 */ if (!pdata->buck1_set2) { dev_err(&pdev->dev, "MAX8998 SET2 GPIO defined as 0 !\n"); WARN_ON(!pdata->buck1_set2); - ret = -EIO; - goto err_out; + return -EIO; } gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); @@ -823,7 +821,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1 + v, i); if (ret) - goto err_out; + return ret; } } @@ -833,8 +831,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) dev_err(&pdev->dev, "MAX8998 SET3 GPIO defined as 0 !\n"); WARN_ON(!pdata->buck2_set3); - ret = -EIO; - goto err_out; + return -EIO; } gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); gpio_direction_output(pdata->buck2_set3, @@ -852,7 +849,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1 + v, i); if (ret) - goto err_out; + return ret; } } @@ -875,33 +872,18 @@ static int max8998_pmic_probe(struct platform_device *pdev) config.init_data = pdata->regulators[i].initdata; config.driver_data = max8998; - rdev[i] = regulator_register(®ulators[index], &config); + rdev[i] = devm_regulator_register(&pdev->dev, + ®ulators[index], &config); if (IS_ERR(rdev[i])) { ret = PTR_ERR(rdev[i]); dev_err(max8998->dev, "regulator %s init failed (%d)\n", regulators[index].name, ret); rdev[i] = NULL; - goto err; + return ret; } } - return 0; -err: - while (--i >= 0) - regulator_unregister(rdev[i]); -err_out: - return ret; -} - -static int max8998_pmic_remove(struct platform_device *pdev) -{ - struct max8998_data *max8998 = platform_get_drvdata(pdev); - struct regulator_dev **rdev = max8998->rdev; - int i; - - for (i = 0; i < max8998->num_regulators; i++) - regulator_unregister(rdev[i]); return 0; } @@ -918,7 +900,6 @@ static struct platform_driver max8998_pmic_driver = { .owner = THIS_MODULE, }, .probe = max8998_pmic_probe, - .remove = max8998_pmic_remove, .id_table = max8998_pmic_id, }; -- cgit v1.2.3-55-g7522 From be1221e893775d8447623475a01f877b902fc8b4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:00:57 +0530 Subject: regulator: anatop-regulator: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Acked-by: Marek Vasut Signed-off-by: Mark Brown --- drivers/regulator/anatop-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 0d4a8ccbb536..e42bfd17562a 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -200,7 +200,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) config.regmap = sreg->anatop; /* register regulator */ - rdev = regulator_register(rdesc, &config); + rdev = devm_regulator_register(dev, rdesc, &config); if (IS_ERR(rdev)) { dev_err(dev, "failed to register %s\n", rdesc->name); @@ -223,7 +223,6 @@ static int anatop_regulator_remove(struct platform_device *pdev) struct anatop_regulator *sreg = rdev_get_drvdata(rdev); const char *name = sreg->name; - regulator_unregister(rdev); kfree(name); return 0; -- cgit v1.2.3-55-g7522 From 0ab6e8ca54d22f986a488bbc493e01f1394a3b2b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:00:58 +0530 Subject: regulator: isl6271a-regulator: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Acked-by: Marek Vasut Signed-off-by: Mark Brown --- drivers/regulator/isl6271a-regulator.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index 88c1a3acf563..6e5da95fa025 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c @@ -112,7 +112,7 @@ static int isl6271a_probe(struct i2c_client *i2c, struct regulator_config config = { }; struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); struct isl_pmic *pmic; - int err, i; + int i; if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; @@ -133,32 +133,17 @@ static int isl6271a_probe(struct i2c_client *i2c, config.init_data = NULL; config.driver_data = pmic; - pmic->rdev[i] = regulator_register(&isl_rd[i], &config); + pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i], + &config); if (IS_ERR(pmic->rdev[i])) { dev_err(&i2c->dev, "failed to register %s\n", id->name); - err = PTR_ERR(pmic->rdev[i]); - goto error; + return PTR_ERR(pmic->rdev[i]); } } i2c_set_clientdata(i2c, pmic); return 0; - -error: - while (--i >= 0) - regulator_unregister(pmic->rdev[i]); - return err; -} - -static int isl6271a_remove(struct i2c_client *i2c) -{ - struct isl_pmic *pmic = i2c_get_clientdata(i2c); - int i; - - for (i = 0; i < 3; i++) - regulator_unregister(pmic->rdev[i]); - return 0; } static const struct i2c_device_id isl6271a_id[] = { @@ -174,7 +159,6 @@ static struct i2c_driver isl6271a_i2c_driver = { .owner = THIS_MODULE, }, .probe = isl6271a_probe, - .remove = isl6271a_remove, .id_table = isl6271a_id, }; -- cgit v1.2.3-55-g7522 From 8e568635afcce245d771c2fc527f3902b6d2e723 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:00:59 +0530 Subject: regulator: mc13783: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Acked-by: Marek Vasut Signed-off-by: Mark Brown --- drivers/regulator/mc13783-regulator.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 5ff99d2703db..f036b26d4cfc 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c @@ -400,7 +400,7 @@ static int mc13783_regulator_probe(struct platform_device *pdev) dev_get_platdata(&pdev->dev); struct mc13xxx_regulator_init_data *mc13xxx_data; struct regulator_config config = { }; - int i, ret, num_regulators; + int i, num_regulators; num_regulators = mc13xxx_get_num_regulators_dt(pdev); @@ -444,31 +444,15 @@ static int mc13783_regulator_probe(struct platform_device *pdev) config.driver_data = priv; config.of_node = node; - priv->regulators[i] = regulator_register(desc, &config); + priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, + &config); if (IS_ERR(priv->regulators[i])) { dev_err(&pdev->dev, "failed to register regulator %s\n", mc13783_regulators[i].desc.name); - ret = PTR_ERR(priv->regulators[i]); - goto err; + return PTR_ERR(priv->regulators[i]); } } - return 0; -err: - while (--i >= 0) - regulator_unregister(priv->regulators[i]); - - return ret; -} - -static int mc13783_regulator_remove(struct platform_device *pdev) -{ - struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < priv->num_regulators; i++) - regulator_unregister(priv->regulators[i]); - return 0; } @@ -477,7 +461,6 @@ static struct platform_driver mc13783_regulator_driver = { .name = "mc13783-regulator", .owner = THIS_MODULE, }, - .remove = mc13783_regulator_remove, .probe = mc13783_regulator_probe, }; -- cgit v1.2.3-55-g7522 From 8c0b4ab5024c7b7d3498957cdbe4fea151142f7a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:01:00 +0530 Subject: regulator: mc13892: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Acked-by: Marek Vasut Signed-off-by: Mark Brown --- drivers/regulator/mc13892-regulator.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 1037e07937cf..96c9f80d9550 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c @@ -611,43 +611,27 @@ static int mc13892_regulator_probe(struct platform_device *pdev) config.driver_data = priv; config.of_node = node; - priv->regulators[i] = regulator_register(desc, &config); + priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, + &config); if (IS_ERR(priv->regulators[i])) { dev_err(&pdev->dev, "failed to register regulator %s\n", mc13892_regulators[i].desc.name); - ret = PTR_ERR(priv->regulators[i]); - goto err; + return PTR_ERR(priv->regulators[i]); } } return 0; -err: - while (--i >= 0) - regulator_unregister(priv->regulators[i]); - return ret; err_unlock: mc13xxx_unlock(mc13892); return ret; } -static int mc13892_regulator_remove(struct platform_device *pdev) -{ - struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < priv->num_regulators; i++) - regulator_unregister(priv->regulators[i]); - - return 0; -} - static struct platform_driver mc13892_regulator_driver = { .driver = { .name = "mc13892-regulator", .owner = THIS_MODULE, }, - .remove = mc13892_regulator_remove, .probe = mc13892_regulator_probe, }; -- cgit v1.2.3-55-g7522 From 51c86b3eb80ebe0a35aba5ba3e96b22d61043ad1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:01:01 +0530 Subject: regulator: palmas: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 38 +++++++++++------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 488dfe7ce9a6..6c9670ff6be5 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -862,7 +862,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "reading TSTEP reg failed: %d\n", ret); - goto err_unregister_regulator; + return ret; } pmic->desc[id].ramp_delay = palmas_smps_ramp_delay[reg & 0x3]; @@ -874,7 +874,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) reg_init = pdata->reg_init[id]; ret = palmas_smps_init(palmas, id, reg_init); if (ret) - goto err_unregister_regulator; + return ret; } /* Register the regulators */ @@ -915,7 +915,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) ret = palmas_smps_read(pmic->palmas, addr, ®); if (ret) - goto err_unregister_regulator; + return ret; if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) pmic->range[id] = 1; @@ -931,7 +931,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) addr = palmas_regs_info[id].ctrl_addr; ret = palmas_smps_read(pmic->palmas, addr, ®); if (ret) - goto err_unregister_regulator; + return ret; pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; } @@ -947,13 +947,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) pmic->desc[id].supply_name = palmas_regs_info[id].sname; config.of_node = palmas_matches[id].of_node; - rdev = regulator_register(&pmic->desc[id], &config); + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], + &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register %s regulator\n", pdev->name); - ret = PTR_ERR(rdev); - goto err_unregister_regulator; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ @@ -1015,13 +1015,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) pmic->desc[id].supply_name = palmas_regs_info[id].sname; config.of_node = palmas_matches[id].of_node; - rdev = regulator_register(&pmic->desc[id], &config); + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], + &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register %s regulator\n", pdev->name); - ret = PTR_ERR(rdev); - goto err_unregister_regulator; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ @@ -1039,7 +1039,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) id, reg_init); if (ret) { regulator_unregister(pmic->rdev[id]); - goto err_unregister_regulator; + return ret; } } } @@ -1047,21 +1047,6 @@ static int palmas_regulators_probe(struct platform_device *pdev) return 0; - -err_unregister_regulator: - while (--id >= 0) - regulator_unregister(pmic->rdev[id]); - return ret; -} - -static int palmas_regulators_remove(struct platform_device *pdev) -{ - struct palmas_pmic *pmic = platform_get_drvdata(pdev); - int id; - - for (id = 0; id < PALMAS_NUM_REGS; id++) - regulator_unregister(pmic->rdev[id]); - return 0; } static struct of_device_id of_palmas_match_tbl[] = { @@ -1083,7 +1068,6 @@ static struct platform_driver palmas_driver = { .owner = THIS_MODULE, }, .probe = palmas_regulators_probe, - .remove = palmas_regulators_remove, }; static int __init palmas_init(void) -- cgit v1.2.3-55-g7522 From 1377530910da1502b07d09df1a368ce9a246c114 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:01:02 +0530 Subject: regulator: rc5t583: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Acked-by: Marek Vasut Signed-off-by: Mark Brown --- drivers/regulator/rc5t583-regulator.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c index 5885b4504596..b58affb33143 100644 --- a/drivers/regulator/rc5t583-regulator.c +++ b/drivers/regulator/rc5t583-regulator.c @@ -173,33 +173,16 @@ skip_ext_pwr_config: config.driver_data = reg; config.regmap = rc5t583->regmap; - rdev = regulator_register(&ri->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "Failed to register regulator %s\n", ri->desc.name); - ret = PTR_ERR(rdev); - goto clean_exit; + return PTR_ERR(rdev); } reg->rdev = rdev; } platform_set_drvdata(pdev, regs); return 0; - -clean_exit: - while (--id >= 0) - regulator_unregister(regs[id].rdev); - - return ret; -} - -static int rc5t583_regulator_remove(struct platform_device *pdev) -{ - struct rc5t583_regulator *regs = platform_get_drvdata(pdev); - int id; - - for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) - regulator_unregister(regs[id].rdev); - return 0; } static struct platform_driver rc5t583_regulator_driver = { @@ -208,7 +191,6 @@ static struct platform_driver rc5t583_regulator_driver = { .owner = THIS_MODULE, }, .probe = rc5t583_regulator_probe, - .remove = rc5t583_regulator_remove, }; static int __init rc5t583_regulator_init(void) -- cgit v1.2.3-55-g7522 From 91dfc80d84eee076a835fb34d053618e63667370 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 12:01:03 +0530 Subject: regulator: ti-abb: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/ti-abb-regulator.c | 79 ++++++++++-------------------------- 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index d8e3e1262bc2..8c2a8195d8a7 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -696,39 +696,31 @@ static int ti_abb_probe(struct platform_device *pdev) match = of_match_device(ti_abb_of_match, dev); if (!match) { /* We do not expect this to happen */ - ret = -ENODEV; dev_err(dev, "%s: Unable to match device\n", __func__); - goto err; + return -ENODEV; } if (!match->data) { - ret = -EINVAL; dev_err(dev, "%s: Bad data in match\n", __func__); - goto err; + return -EINVAL; } abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); - if (!abb) { - dev_err(dev, "%s: Unable to allocate ABB struct\n", __func__); - ret = -ENOMEM; - goto err; - } + if (!abb) + return -ENOMEM; abb->regs = match->data; /* Map ABB resources */ pname = "base-address"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); abb->base = devm_ioremap_resource(dev, res); - if (IS_ERR(abb->base)) { - ret = PTR_ERR(abb->base); - goto err; - } + if (IS_ERR(abb->base)) + return PTR_ERR(abb->base); pname = "int-address"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); if (!res) { dev_err(dev, "Missing '%s' IO resource\n", pname); - ret = -ENODEV; - goto err; + return -ENODEV; } /* * We may have shared interrupt register offsets which are @@ -738,8 +730,7 @@ static int ti_abb_probe(struct platform_device *pdev) resource_size(res)); if (!abb->int_base) { dev_err(dev, "Unable to map '%s'\n", pname); - ret = -ENOMEM; - goto err; + return -ENOMEM; } /* Map Optional resources */ @@ -759,17 +750,14 @@ static int ti_abb_probe(struct platform_device *pdev) resource_size(res)); if (!abb->efuse_base) { dev_err(dev, "Unable to map '%s'\n", pname); - ret = -ENOMEM; - goto err; + return -ENOMEM; } pname = "ldo-address"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); abb->ldo_base = devm_ioremap_resource(dev, res); - if (IS_ERR(abb->ldo_base)) { - ret = PTR_ERR(abb->ldo_base); - goto err; - } + if (IS_ERR(abb->ldo_base)) + return PTR_ERR(abb->ldo_base); /* IF ldo_base is set, the following are mandatory */ pname = "ti,ldovbb-override-mask"; @@ -778,12 +766,11 @@ static int ti_abb_probe(struct platform_device *pdev) &abb->ldovbb_override_mask); if (ret) { dev_err(dev, "Missing '%s' (%d)\n", pname, ret); - goto err; + return ret; } if (!abb->ldovbb_override_mask) { dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); - ret = -EINVAL; - goto err; + return -EINVAL; } pname = "ti,ldovbb-vset-mask"; @@ -792,12 +779,11 @@ static int ti_abb_probe(struct platform_device *pdev) &abb->ldovbb_vset_mask); if (ret) { dev_err(dev, "Missing '%s' (%d)\n", pname, ret); - goto err; + return ret; } if (!abb->ldovbb_vset_mask) { dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); - ret = -EINVAL; - goto err; + return -EINVAL; } skip_opt: @@ -807,31 +793,29 @@ skip_opt: &abb->txdone_mask); if (ret) { dev_err(dev, "Missing '%s' (%d)\n", pname, ret); - goto err; + return ret; } if (!abb->txdone_mask) { dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); - ret = -EINVAL; - goto err; + return -EINVAL; } initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); if (!initdata) { - ret = -ENOMEM; dev_err(dev, "%s: Unable to alloc regulator init data\n", __func__); - goto err; + return -ENOMEM; } /* init ABB opp_sel table */ ret = ti_abb_init_table(dev, abb, initdata); if (ret) - goto err; + return ret; /* init ABB timing */ ret = ti_abb_init_timings(dev, abb); if (ret) - goto err; + return ret; desc = &abb->rdesc; desc->name = dev_name(dev); @@ -849,12 +833,12 @@ skip_opt: config.driver_data = abb; config.of_node = pdev->dev.of_node; - rdev = regulator_register(desc, &config); + rdev = devm_regulator_register(dev, desc, &config); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); dev_err(dev, "%s: failed to register regulator(%d)\n", __func__, ret); - goto err; + return ret; } platform_set_drvdata(pdev, rdev); @@ -862,31 +846,12 @@ skip_opt: ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); return 0; - -err: - dev_err(dev, "%s: Failed to initialize(%d)\n", __func__, ret); - return ret; -} - -/** - * ti_abb_remove() - cleanups - * @pdev: ABB platform device - * - * Return: 0 - */ -static int ti_abb_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - return 0; } MODULE_ALIAS("platform:ti_abb"); static struct platform_driver ti_abb_driver = { .probe = ti_abb_probe, - .remove = ti_abb_remove, .driver = { .name = "ti_abb", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 1084081dc8e5556e91539de082eaae89e39516c9 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:44 +0530 Subject: regulator: tps51632: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps51632-regulator.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index 9392a7ca3d2d..b0a3f0917a27 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c @@ -343,7 +343,7 @@ static int tps51632_probe(struct i2c_client *client, config.regmap = tps->regmap; config.of_node = client->dev.of_node; - rdev = regulator_register(&tps->desc, &config); + rdev = devm_regulator_register(&client->dev, &tps->desc, &config); if (IS_ERR(rdev)) { dev_err(tps->dev, "regulator register failed\n"); return PTR_ERR(rdev); @@ -353,14 +353,6 @@ static int tps51632_probe(struct i2c_client *client, return 0; } -static int tps51632_remove(struct i2c_client *client) -{ - struct tps51632_chip *tps = i2c_get_clientdata(client); - - regulator_unregister(tps->rdev); - return 0; -} - static const struct i2c_device_id tps51632_id[] = { {.name = "tps51632",}, {}, @@ -375,7 +367,6 @@ static struct i2c_driver tps51632_i2c_driver = { .of_match_table = of_match_ptr(tps51632_of_match), }, .probe = tps51632_probe, - .remove = tps51632_remove, .id_table = tps51632_id, }; -- cgit v1.2.3-55-g7522 From 58c6e938c00de744d52f739aa426a4b1b13ef22b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:45 +0530 Subject: regulator: tps62360: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps62360-regulator.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 0b7ebb1ebf85..c2c0185a2dcd 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -476,7 +476,7 @@ static int tps62360_probe(struct i2c_client *client, config.of_node = client->dev.of_node; /* Register the regulators */ - rdev = regulator_register(&tps->desc, &config); + rdev = devm_regulator_register(&client->dev, &tps->desc, &config); if (IS_ERR(rdev)) { dev_err(tps->dev, "%s(): regulator register failed with err %s\n", @@ -488,20 +488,6 @@ static int tps62360_probe(struct i2c_client *client, return 0; } -/** - * tps62360_remove - tps62360 driver i2c remove handler - * @client: i2c driver client device structure - * - * Unregister TPS driver as an i2c client device driver - */ -static int tps62360_remove(struct i2c_client *client) -{ - struct tps62360_chip *tps = i2c_get_clientdata(client); - - regulator_unregister(tps->rdev); - return 0; -} - static void tps62360_shutdown(struct i2c_client *client) { struct tps62360_chip *tps = i2c_get_clientdata(client); @@ -535,7 +521,6 @@ static struct i2c_driver tps62360_i2c_driver = { .of_match_table = of_match_ptr(tps62360_of_match), }, .probe = tps62360_probe, - .remove = tps62360_remove, .shutdown = tps62360_shutdown, .id_table = tps62360_id, }; -- cgit v1.2.3-55-g7522 From 9c7c9eae5f7ac57465c0ac6adc8e3ad3afad2544 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:46 +0530 Subject: regulator: tps65023: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps65023-regulator.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index a15263d4bdff..a957579bd98b 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c @@ -277,12 +277,12 @@ static int tps_65023_probe(struct i2c_client *client, config.regmap = tps->regmap; /* Register the regulators */ - rdev = regulator_register(&tps->desc[i], &config); + rdev = devm_regulator_register(&client->dev, &tps->desc[i], + &config); if (IS_ERR(rdev)) { dev_err(&client->dev, "failed to register %s\n", id->name); - error = PTR_ERR(rdev); - goto fail; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ @@ -296,21 +296,6 @@ static int tps_65023_probe(struct i2c_client *client, TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); return 0; - - fail: - while (--i >= 0) - regulator_unregister(tps->rdev[i]); - return error; -} - -static int tps_65023_remove(struct i2c_client *client) -{ - struct tps_pmic *tps = i2c_get_clientdata(client); - int i; - - for (i = 0; i < TPS65023_NUM_REGULATOR; i++) - regulator_unregister(tps->rdev[i]); - return 0; } static const struct tps_info tps65020_regs[] = { @@ -430,7 +415,6 @@ static struct i2c_driver tps_65023_i2c_driver = { .owner = THIS_MODULE, }, .probe = tps_65023_probe, - .remove = tps_65023_remove, .id_table = tps_65023_id, }; -- cgit v1.2.3-55-g7522 From 71b710e705b3b152f0e5682aa179a8c2d2cbb4cd Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:47 +0530 Subject: regulator: tps6507x: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps6507x-regulator.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 4117ff52dba1..162a0fae20b3 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c @@ -508,13 +508,13 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) config.of_node = tps6507x_reg_matches[i].of_node; } - rdev = regulator_register(&tps->desc[i], &config); + rdev = devm_regulator_register(&pdev->dev, &tps->desc[i], + &config); if (IS_ERR(rdev)) { dev_err(tps6507x_dev->dev, "failed to register %s regulator\n", pdev->name); - error = PTR_ERR(rdev); - goto fail; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ @@ -525,22 +525,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tps6507x_dev); return 0; - -fail: - while (--i >= 0) - regulator_unregister(tps->rdev[i]); - return error; -} - -static int tps6507x_pmic_remove(struct platform_device *pdev) -{ - struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); - struct tps6507x_pmic *tps = tps6507x_dev->pmic; - int i; - - for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) - regulator_unregister(tps->rdev[i]); - return 0; } static struct platform_driver tps6507x_pmic_driver = { @@ -549,7 +533,6 @@ static struct platform_driver tps6507x_pmic_driver = { .owner = THIS_MODULE, }, .probe = tps6507x_pmic_probe, - .remove = tps6507x_pmic_remove, }; static int __init tps6507x_pmic_init(void) -- cgit v1.2.3-55-g7522 From 9738efae695733a9d367bd083e6ae0474dc5bd3c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:48 +0530 Subject: regulator: tps65090: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps65090-regulator.c | 35 +++++----------------------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index c8e70451df38..bd611cdf6e1c 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -279,7 +279,7 @@ static int tps65090_regulator_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "failed disable ext control\n"); - goto scrub; + return ret; } } } @@ -296,12 +296,11 @@ static int tps65090_regulator_probe(struct platform_device *pdev) else config.of_node = NULL; - rdev = regulator_register(ri->desc, &config); + rdev = devm_regulator_register(&pdev->dev, ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register regulator %s\n", ri->desc->name); - ret = PTR_ERR(rdev); - goto scrub; + return PTR_ERR(rdev); } ri->rdev = rdev; @@ -309,36 +308,13 @@ static int tps65090_regulator_probe(struct platform_device *pdev) if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && tps_pdata->enable_ext_control) { ret = tps65090_config_ext_control(ri, true); - if (ret < 0) { - /* Increment num to get unregister rdev */ - num++; - goto scrub; - } + if (ret < 0) + return ret; } } platform_set_drvdata(pdev, pmic); return 0; - -scrub: - while (--num >= 0) { - ri = &pmic[num]; - regulator_unregister(ri->rdev); - } - return ret; -} - -static int tps65090_regulator_remove(struct platform_device *pdev) -{ - struct tps65090_regulator *pmic = platform_get_drvdata(pdev); - struct tps65090_regulator *ri; - int num; - - for (num = 0; num < TPS65090_REGULATOR_MAX; ++num) { - ri = &pmic[num]; - regulator_unregister(ri->rdev); - } - return 0; } static struct platform_driver tps65090_regulator_driver = { @@ -347,7 +323,6 @@ static struct platform_driver tps65090_regulator_driver = { .owner = THIS_MODULE, }, .probe = tps65090_regulator_probe, - .remove = tps65090_regulator_remove, }; static int __init tps65090_regulator_init(void) -- cgit v1.2.3-55-g7522 From 4aac198ddcfe38c7cf10cb2d23497b4a5ad24fdf Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:49 +0530 Subject: regulator: tps65217: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps65217-regulator.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 90861d68a0b0..8860379fd6be 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -233,7 +233,7 @@ static int tps65217_regulator_probe(struct platform_device *pdev) struct regulator_init_data *reg_data; struct regulator_dev *rdev; struct regulator_config config = { }; - int i, ret; + int i; if (tps->dev->of_node) pdata = tps65217_parse_dt(pdev); @@ -269,35 +269,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev) if (tps->dev->of_node) config.of_node = pdata->of_node[i]; - rdev = regulator_register(®ulators[i], &config); + rdev = devm_regulator_register(&pdev->dev, ®ulators[i], + &config); if (IS_ERR(rdev)) { dev_err(tps->dev, "failed to register %s regulator\n", pdev->name); - ret = PTR_ERR(rdev); - goto err_unregister_regulator; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ tps->rdev[i] = rdev; } return 0; - -err_unregister_regulator: - while (--i >= 0) - regulator_unregister(tps->rdev[i]); - - return ret; -} - -static int tps65217_regulator_remove(struct platform_device *pdev) -{ - struct tps65217 *tps = platform_get_drvdata(pdev); - unsigned int i; - - for (i = 0; i < TPS65217_NUM_REGULATOR; i++) - regulator_unregister(tps->rdev[i]); - - return 0; } static struct platform_driver tps65217_regulator_driver = { @@ -305,7 +288,6 @@ static struct platform_driver tps65217_regulator_driver = { .name = "tps65217-pmic", }, .probe = tps65217_regulator_probe, - .remove = tps65217_regulator_remove, }; static int __init tps65217_regulator_init(void) -- cgit v1.2.3-55-g7522 From 884ea5570f1eda8a1e0f5235cba4f00bafed450e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:50 +0530 Subject: regulator: tps6586x: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps6586x-regulator.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 2c9155b66f09..45e5d683d3f8 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -379,15 +379,14 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) ri = find_regulator_info(id); if (!ri) { dev_err(&pdev->dev, "invalid regulator ID specified\n"); - err = -EINVAL; - goto fail; + return -EINVAL; } err = tps6586x_regulator_preinit(pdev->dev.parent, ri); if (err) { dev_err(&pdev->dev, "regulator %d preinit failed, e %d\n", id, err); - goto fail; + return err; } config.dev = pdev->dev.parent; @@ -397,12 +396,12 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) if (tps6586x_reg_matches) config.of_node = tps6586x_reg_matches[id].of_node; - rdev[id] = regulator_register(&ri->desc, &config); + rdev[id] = devm_regulator_register(&pdev->dev, &ri->desc, + &config); if (IS_ERR(rdev[id])) { dev_err(&pdev->dev, "failed to register regulator %s\n", ri->desc.name); - err = PTR_ERR(rdev[id]); - goto fail; + return PTR_ERR(rdev[id]); } if (reg_data) { @@ -411,30 +410,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) if (err < 0) { dev_err(&pdev->dev, "Slew rate config failed, e %d\n", err); - regulator_unregister(rdev[id]); - goto fail; + return err; } } } platform_set_drvdata(pdev, rdev); return 0; - -fail: - while (--id >= 0) - regulator_unregister(rdev[id]); - return err; -} - -static int tps6586x_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev **rdev = platform_get_drvdata(pdev); - int id = TPS6586X_ID_MAX_REGULATOR; - - while (--id >= 0) - regulator_unregister(rdev[id]); - - return 0; } static struct platform_driver tps6586x_regulator_driver = { @@ -443,7 +425,6 @@ static struct platform_driver tps6586x_regulator_driver = { .owner = THIS_MODULE, }, .probe = tps6586x_regulator_probe, - .remove = tps6586x_regulator_remove, }; static int __init tps6586x_regulator_init(void) -- cgit v1.2.3-55-g7522 From 95095e422e94afa5a286c2a015aad4c039c9cbd4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:51 +0530 Subject: regulator: tps65910: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps65910-regulator.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 45c16447744b..b8167df71170 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -1177,35 +1177,19 @@ static int tps65910_probe(struct platform_device *pdev) if (tps65910_reg_matches) config.of_node = tps65910_reg_matches[i].of_node; - rdev = regulator_register(&pmic->desc[i], &config); + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], + &config); if (IS_ERR(rdev)) { dev_err(tps65910->dev, "failed to register %s regulator\n", pdev->name); - err = PTR_ERR(rdev); - goto err_unregister_regulator; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ pmic->rdev[i] = rdev; } return 0; - -err_unregister_regulator: - while (--i >= 0) - regulator_unregister(pmic->rdev[i]); - return err; -} - -static int tps65910_remove(struct platform_device *pdev) -{ - struct tps65910_reg *pmic = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < pmic->num_regulators; i++) - regulator_unregister(pmic->rdev[i]); - - return 0; } static void tps65910_shutdown(struct platform_device *pdev) @@ -1244,7 +1228,6 @@ static struct platform_driver tps65910_driver = { .owner = THIS_MODULE, }, .probe = tps65910_probe, - .remove = tps65910_remove, .shutdown = tps65910_shutdown, }; -- cgit v1.2.3-55-g7522 From ab1d65e03afdafa991bb208ade089d36b0e1d2ad Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:52 +0530 Subject: regulator: tps65912: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps65912-regulator.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index 281e52ac64ba..1ed4d049abfe 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c @@ -461,7 +461,7 @@ static int tps65912_probe(struct platform_device *pdev) struct regulator_dev *rdev; struct tps65912_reg *pmic; struct tps65912_board *pmic_plat_data; - int i, err; + int i; pmic_plat_data = dev_get_platdata(tps65912->dev); if (!pmic_plat_data) @@ -504,34 +504,19 @@ static int tps65912_probe(struct platform_device *pdev) config.init_data = reg_data; config.driver_data = pmic; - rdev = regulator_register(&pmic->desc[i], &config); + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], + &config); if (IS_ERR(rdev)) { dev_err(tps65912->dev, "failed to register %s regulator\n", pdev->name); - err = PTR_ERR(rdev); - goto err; + return PTR_ERR(rdev); } /* Save regulator for cleanup */ pmic->rdev[i] = rdev; } return 0; - -err: - while (--i >= 0) - regulator_unregister(pmic->rdev[i]); - return err; -} - -static int tps65912_remove(struct platform_device *pdev) -{ - struct tps65912_reg *tps65912_reg = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < TPS65912_NUM_REGULATOR; i++) - regulator_unregister(tps65912_reg->rdev[i]); - return 0; } static struct platform_driver tps65912_driver = { @@ -540,7 +525,6 @@ static struct platform_driver tps65912_driver = { .owner = THIS_MODULE, }, .probe = tps65912_probe, - .remove = tps65912_remove, }; static int __init tps65912_init(void) -- cgit v1.2.3-55-g7522 From 0fb0c82e8135d3de9eff2a05202f6870ec378392 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 4 Sep 2013 17:17:53 +0530 Subject: regulator: tps80031: Use devm_regulator_register devm_* simplifies the code. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps80031-regulator.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c index 6511d0bfd896..71f457a42623 100644 --- a/drivers/regulator/tps80031-regulator.c +++ b/drivers/regulator/tps80031-regulator.c @@ -719,7 +719,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "regulator config failed, e %d\n", ret); - goto fail; + return ret; } ret = tps80031_power_req_config(pdev->dev.parent, @@ -727,41 +727,22 @@ static int tps80031_regulator_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "pwr_req config failed, err %d\n", ret); - goto fail; + return ret; } } - rdev = regulator_register(&ri->rinfo->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc, + &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "register regulator failed %s\n", ri->rinfo->desc.name); - ret = PTR_ERR(rdev); - goto fail; + return PTR_ERR(rdev); } ri->rdev = rdev; } platform_set_drvdata(pdev, pmic); return 0; -fail: - while (--num >= 0) { - ri = &pmic[num]; - regulator_unregister(ri->rdev); - } - return ret; -} - -static int tps80031_regulator_remove(struct platform_device *pdev) -{ - struct tps80031_regulator *pmic = platform_get_drvdata(pdev); - struct tps80031_regulator *ri = NULL; - int num; - - for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) { - ri = &pmic[num]; - regulator_unregister(ri->rdev); - } - return 0; } static struct platform_driver tps80031_regulator_driver = { @@ -770,7 +751,6 @@ static struct platform_driver tps80031_regulator_driver = { .owner = THIS_MODULE, }, .probe = tps80031_regulator_probe, - .remove = tps80031_regulator_remove, }; static int __init tps80031_regulator_init(void) -- cgit v1.2.3-55-g7522 From 42141f22e32a452b02b3dc8764d93223505e1c10 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 5 Sep 2013 09:22:02 +0530 Subject: regulator: core: Fix a trivial typo Changed automaticall -> automatically. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5f995d281672..85e8cbed1cbc 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3504,7 +3504,7 @@ static void devm_rdev_release(struct device *dev, void *res) * * Called by regulator drivers to register a regulator. Returns a * valid pointer to struct regulator_dev on success or an ERR_PTR() on - * error. The regulator will automaticall be released when the device + * error. The regulator will automatically be released when the device * is unbound. */ struct regulator_dev *devm_regulator_register(struct device *dev, -- cgit v1.2.3-55-g7522 From cab87f062d0c57c9734257e4079ced489a3189b1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 5 Sep 2013 09:22:03 +0530 Subject: regulator: Remove redundant NULL assignment NULL assignment corrupts the error pointer and is not necessary. Reported-by: kbuild test robot Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 1 - drivers/regulator/max77693.c | 1 - drivers/regulator/max8997.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index de5b30ea823c..ae001ccf26f4 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -483,7 +483,6 @@ static int max77686_pmic_probe(struct platform_device *pdev) if (IS_ERR(max77686->rdev[i])) { dev_err(&pdev->dev, "regulator init failed for %d\n", i); - max77686->rdev[i] = NULL; return PTR_ERR(max77686->rdev[i]); } } diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index 2054ae1c496e..feb20bf4ccab 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c @@ -271,7 +271,6 @@ static int max77693_pmic_probe(struct platform_device *pdev) if (IS_ERR(max77693_pmic->rdev[i])) { dev_err(max77693_pmic->dev, "Failed to initialize regulator-%d\n", id); - max77693_pmic->rdev[i] = NULL; return PTR_ERR(max77693_pmic->rdev[i]); } } diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 059e8ed7fa24..bcd2488d1252 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c @@ -1209,7 +1209,6 @@ static int max8997_pmic_probe(struct platform_device *pdev) if (IS_ERR(rdev[i])) { dev_err(max8997->dev, "regulator init failed for %d\n", id); - rdev[i] = NULL; return PTR_ERR(rdev[i]); } } -- cgit v1.2.3-55-g7522 From cb2e45e31615bc37b31b44fc257042a860ce82b8 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 5 Sep 2013 11:31:25 +0800 Subject: regulator: palmas: Drop regulator_unregister while using devm_regulator_register Commmit af40a94aba "regulator: palmas: Use devm_regulator_register" missed removing a regulator_unregister() call if palmas_extreg_init falis. Fix it. Signed-off-by: Axel Lin Acked-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 6c9670ff6be5..b5278ac4e6bd 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -1037,10 +1037,8 @@ static int palmas_regulators_probe(struct platform_device *pdev) else ret = palmas_extreg_init(palmas, id, reg_init); - if (ret) { - regulator_unregister(pmic->rdev[id]); + if (ret) return ret; - } } } } -- cgit v1.2.3-55-g7522 From cee8e355942c01f408bddf8a53596be1dff7a86b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 1 Sep 2013 12:24:17 +0800 Subject: regulator: core: Refactor devm_regulator_get* APIs The implementation of devm_regulator_get, devm_regulator_get_exclusive and devm_regulator_get_optional are almost the same. Introduce _devm_regulator_get helper function and refactor the code. Also move devm_regulator_get_exclusive to proper place, put it after regulator_get_exclusive() function. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/core.c | 127 +++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 65 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 85e8cbed1cbc..388397bb3192 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1334,6 +1334,50 @@ out: return regulator; } +enum { + NORMAL_GET, + EXCLUSIVE_GET, + OPTIONAL_GET, +}; + +static void devm_regulator_release(struct device *dev, void *res) +{ + regulator_put(*(struct regulator **)res); +} + +static struct regulator *_devm_regulator_get(struct device *dev, const char *id, + int get_type) +{ + struct regulator **ptr, *regulator; + + ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + switch (get_type) { + case NORMAL_GET: + regulator = regulator_get(dev, id); + break; + case EXCLUSIVE_GET: + regulator = regulator_get_exclusive(dev, id); + break; + case OPTIONAL_GET: + regulator = regulator_get_optional(dev, id); + break; + default: + regulator = ERR_PTR(-EINVAL); + } + + if (!IS_ERR(regulator)) { + *ptr = regulator; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return regulator; +} + /** * regulator_get - lookup and obtain a reference to a regulator. * @dev: device for regulator "consumer" @@ -1353,11 +1397,6 @@ struct regulator *regulator_get(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(regulator_get); -static void devm_regulator_release(struct device *dev, void *res) -{ - regulator_put(*(struct regulator **)res); -} - /** * devm_regulator_get - Resource managed regulator_get() * @dev: device for regulator "consumer" @@ -1369,21 +1408,7 @@ static void devm_regulator_release(struct device *dev, void *res) */ struct regulator *devm_regulator_get(struct device *dev, const char *id) { - struct regulator **ptr, *regulator; - - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - - regulator = regulator_get(dev, id); - if (!IS_ERR(regulator)) { - *ptr = regulator; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return regulator; + return _devm_regulator_get(dev, id, NORMAL_GET); } EXPORT_SYMBOL_GPL(devm_regulator_get); @@ -1414,6 +1439,22 @@ struct regulator *regulator_get_exclusive(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(regulator_get_exclusive); +/** + * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() + * @dev: device for regulator "consumer" + * @id: Supply name or regulator ID. + * + * Managed regulator_get_exclusive(). Regulators returned from this function + * are automatically regulator_put() on driver detach. See regulator_get() for + * more information. + */ +struct regulator *devm_regulator_get_exclusive(struct device *dev, + const char *id) +{ + return _devm_regulator_get(dev, id, EXCLUSIVE_GET); +} +EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); + /** * regulator_get_optional - obtain optional access to a regulator. * @dev: device for regulator "consumer" @@ -1455,21 +1496,7 @@ EXPORT_SYMBOL_GPL(regulator_get_optional); struct regulator *devm_regulator_get_optional(struct device *dev, const char *id) { - struct regulator **ptr, *regulator; - - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - - regulator = regulator_get_optional(dev, id); - if (!IS_ERR(regulator)) { - *ptr = regulator; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return regulator; + return _devm_regulator_get(dev, id, OPTIONAL_GET); } EXPORT_SYMBOL_GPL(devm_regulator_get_optional); @@ -1498,36 +1525,6 @@ static void _regulator_put(struct regulator *regulator) module_put(rdev->owner); } -/** - * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() - * @dev: device for regulator "consumer" - * @id: Supply name or regulator ID. - * - * Managed regulator_get_exclusive(). Regulators returned from this function - * are automatically regulator_put() on driver detach. See regulator_get() for - * more information. - */ -struct regulator *devm_regulator_get_exclusive(struct device *dev, - const char *id) -{ - struct regulator **ptr, *regulator; - - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - - regulator = _regulator_get(dev, id, 1); - if (!IS_ERR(regulator)) { - *ptr = regulator; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return regulator; -} -EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); - /** * regulator_put - "free" the regulator source * @regulator: regulator source -- cgit v1.2.3-55-g7522 From 0cdfcc0f9352a4c076fbb51299e2b12a35619a51 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 Sep 2013 13:15:40 +0100 Subject: regulator: core: Split devres code out into a separate file Cut down on the size of core.c a bit more and ensure that the devres versions of things don't do too much peering inside the internals of the APIs they wrap. Signed-off-by: Mark Brown --- drivers/regulator/Makefile | 2 +- drivers/regulator/core.c | 252 +------------------------------------------ drivers/regulator/devres.c | 252 +++++++++++++++++++++++++++++++++++++++++++ drivers/regulator/internal.h | 38 +++++++ 4 files changed, 292 insertions(+), 252 deletions(-) create mode 100644 drivers/regulator/devres.c create mode 100644 drivers/regulator/internal.h diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 185cce246022..69db4c8bb5c9 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -3,7 +3,7 @@ # -obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o +obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o obj-$(CONFIG_OF) += of_regulator.o obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 388397bb3192..906deb7354ed 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -36,6 +36,7 @@ #include #include "dummy.h" +#include "internal.h" #define rdev_crit(rdev, fmt, ...) \ pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) @@ -82,25 +83,6 @@ struct regulator_enable_gpio { unsigned int ena_gpio_invert:1; }; -/* - * struct regulator - * - * One for each consumer device. - */ -struct regulator { - struct device *dev; - struct list_head list; - unsigned int always_on:1; - unsigned int bypass:1; - int uA_load; - int min_uV; - int max_uV; - char *supply_name; - struct device_attribute dev_attr; - struct regulator_dev *rdev; - struct dentry *debugfs; -}; - static int _regulator_is_enabled(struct regulator_dev *rdev); static int _regulator_disable(struct regulator_dev *rdev); static int _regulator_get_voltage(struct regulator_dev *rdev); @@ -1334,50 +1316,6 @@ out: return regulator; } -enum { - NORMAL_GET, - EXCLUSIVE_GET, - OPTIONAL_GET, -}; - -static void devm_regulator_release(struct device *dev, void *res) -{ - regulator_put(*(struct regulator **)res); -} - -static struct regulator *_devm_regulator_get(struct device *dev, const char *id, - int get_type) -{ - struct regulator **ptr, *regulator; - - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - - switch (get_type) { - case NORMAL_GET: - regulator = regulator_get(dev, id); - break; - case EXCLUSIVE_GET: - regulator = regulator_get_exclusive(dev, id); - break; - case OPTIONAL_GET: - regulator = regulator_get_optional(dev, id); - break; - default: - regulator = ERR_PTR(-EINVAL); - } - - if (!IS_ERR(regulator)) { - *ptr = regulator; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return regulator; -} - /** * regulator_get - lookup and obtain a reference to a regulator. * @dev: device for regulator "consumer" @@ -1397,21 +1335,6 @@ struct regulator *regulator_get(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(regulator_get); -/** - * devm_regulator_get - Resource managed regulator_get() - * @dev: device for regulator "consumer" - * @id: Supply name or regulator ID. - * - * Managed regulator_get(). Regulators returned from this function are - * automatically regulator_put() on driver detach. See regulator_get() for more - * information. - */ -struct regulator *devm_regulator_get(struct device *dev, const char *id) -{ - return _devm_regulator_get(dev, id, NORMAL_GET); -} -EXPORT_SYMBOL_GPL(devm_regulator_get); - /** * regulator_get_exclusive - obtain exclusive access to a regulator. * @dev: device for regulator "consumer" @@ -1439,22 +1362,6 @@ struct regulator *regulator_get_exclusive(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(regulator_get_exclusive); -/** - * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() - * @dev: device for regulator "consumer" - * @id: Supply name or regulator ID. - * - * Managed regulator_get_exclusive(). Regulators returned from this function - * are automatically regulator_put() on driver detach. See regulator_get() for - * more information. - */ -struct regulator *devm_regulator_get_exclusive(struct device *dev, - const char *id) -{ - return _devm_regulator_get(dev, id, EXCLUSIVE_GET); -} -EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); - /** * regulator_get_optional - obtain optional access to a regulator. * @dev: device for regulator "consumer" @@ -1484,22 +1391,6 @@ struct regulator *regulator_get_optional(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(regulator_get_optional); -/** - * devm_regulator_get_optional - Resource managed regulator_get_optional() - * @dev: device for regulator "consumer" - * @id: Supply name or regulator ID. - * - * Managed regulator_get_optional(). Regulators returned from this - * function are automatically regulator_put() on driver detach. See - * regulator_get_optional() for more information. - */ -struct regulator *devm_regulator_get_optional(struct device *dev, - const char *id) -{ - return _devm_regulator_get(dev, id, OPTIONAL_GET); -} -EXPORT_SYMBOL_GPL(devm_regulator_get_optional); - /* Locks held by regulator_put() */ static void _regulator_put(struct regulator *regulator) { @@ -1541,35 +1432,6 @@ void regulator_put(struct regulator *regulator) } EXPORT_SYMBOL_GPL(regulator_put); -static int devm_regulator_match(struct device *dev, void *res, void *data) -{ - struct regulator **r = res; - if (!r || !*r) { - WARN_ON(!r || !*r); - return 0; - } - return *r == data; -} - -/** - * devm_regulator_put - Resource managed regulator_put() - * @regulator: regulator to free - * - * Deallocate a regulator allocated with devm_regulator_get(). Normally - * this function will not need to be called and the resource management - * code will ensure that the resource is freed. - */ -void devm_regulator_put(struct regulator *regulator) -{ - int rc; - - rc = devres_release(regulator->dev, devm_regulator_release, - devm_regulator_match, regulator); - if (rc != 0) - WARN_ON(rc); -} -EXPORT_SYMBOL_GPL(devm_regulator_put); - /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ static int regulator_ena_gpio_request(struct regulator_dev *rdev, const struct regulator_config *config) @@ -2909,52 +2771,6 @@ err: } EXPORT_SYMBOL_GPL(regulator_bulk_get); -/** - * devm_regulator_bulk_get - managed get multiple regulator consumers - * - * @dev: Device to supply - * @num_consumers: Number of consumers to register - * @consumers: Configuration of consumers; clients are stored here. - * - * @return 0 on success, an errno on failure. - * - * This helper function allows drivers to get several regulator - * consumers in one operation with management, the regulators will - * automatically be freed when the device is unbound. If any of the - * regulators cannot be acquired then any regulators that were - * allocated will be freed before returning to the caller. - */ -int devm_regulator_bulk_get(struct device *dev, int num_consumers, - struct regulator_bulk_data *consumers) -{ - int i; - int ret; - - for (i = 0; i < num_consumers; i++) - consumers[i].consumer = NULL; - - for (i = 0; i < num_consumers; i++) { - consumers[i].consumer = devm_regulator_get(dev, - consumers[i].supply); - if (IS_ERR(consumers[i].consumer)) { - ret = PTR_ERR(consumers[i].consumer); - dev_err(dev, "Failed to get supply '%s': %d\n", - consumers[i].supply, ret); - consumers[i].consumer = NULL; - goto err; - } - } - - return 0; - -err: - for (i = 0; i < num_consumers && consumers[i].consumer; i++) - devm_regulator_put(consumers[i].consumer); - - return ret; -} -EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); - static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) { struct regulator_bulk_data *bulk = data; @@ -3489,44 +3305,6 @@ clean: } EXPORT_SYMBOL_GPL(regulator_register); -static void devm_rdev_release(struct device *dev, void *res) -{ - regulator_unregister(*(struct regulator_dev **)res); -} - -/** - * devm_regulator_register - Resource managed regulator_register() - * @regulator_desc: regulator to register - * @config: runtime configuration for regulator - * - * Called by regulator drivers to register a regulator. Returns a - * valid pointer to struct regulator_dev on success or an ERR_PTR() on - * error. The regulator will automatically be released when the device - * is unbound. - */ -struct regulator_dev *devm_regulator_register(struct device *dev, - const struct regulator_desc *regulator_desc, - const struct regulator_config *config) -{ - struct regulator_dev **ptr, *rdev; - - ptr = devres_alloc(devm_rdev_release, sizeof(*ptr), - GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - - rdev = regulator_register(regulator_desc, config); - if (!IS_ERR(rdev)) { - *ptr = rdev; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return rdev; -} -EXPORT_SYMBOL_GPL(devm_regulator_register); - /** * regulator_unregister - unregister regulator * @rdev: regulator to unregister @@ -3556,34 +3334,6 @@ void regulator_unregister(struct regulator_dev *rdev) } EXPORT_SYMBOL_GPL(regulator_unregister); -static int devm_rdev_match(struct device *dev, void *res, void *data) -{ - struct regulator_dev **r = res; - if (!r || !*r) { - WARN_ON(!r || !*r); - return 0; - } - return *r == data; -} - -/** - * devm_regulator_unregister - Resource managed regulator_unregister() - * @regulator: regulator to free - * - * Unregister a regulator registered with devm_regulator_register(). - * Normally this function will not need to be called and the resource - * management code will ensure that the resource is freed. - */ -void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) -{ - int rc; - - rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev); - if (rc != 0) - WARN_ON(rc); -} -EXPORT_SYMBOL_GPL(devm_regulator_unregister); - /** * regulator_suspend_prepare - prepare regulators for system wide suspend * @state: system suspend state diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c new file mode 100644 index 000000000000..2672a029fa25 --- /dev/null +++ b/drivers/regulator/devres.c @@ -0,0 +1,252 @@ +/* + * devres.c -- Voltage/Current Regulator framework devres implementation. + * + * Copyright 2013 Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "internal.h" + +enum { + NORMAL_GET, + EXCLUSIVE_GET, + OPTIONAL_GET, +}; + +static void devm_regulator_release(struct device *dev, void *res) +{ + regulator_put(*(struct regulator **)res); +} + +static struct regulator *_devm_regulator_get(struct device *dev, const char *id, + int get_type) +{ + struct regulator **ptr, *regulator; + + ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + switch (get_type) { + case NORMAL_GET: + regulator = regulator_get(dev, id); + break; + case EXCLUSIVE_GET: + regulator = regulator_get_exclusive(dev, id); + break; + case OPTIONAL_GET: + regulator = regulator_get_optional(dev, id); + break; + default: + regulator = ERR_PTR(-EINVAL); + } + + if (!IS_ERR(regulator)) { + *ptr = regulator; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return regulator; +} + +/** + * devm_regulator_get - Resource managed regulator_get() + * @dev: device for regulator "consumer" + * @id: Supply name or regulator ID. + * + * Managed regulator_get(). Regulators returned from this function are + * automatically regulator_put() on driver detach. See regulator_get() for more + * information. + */ +struct regulator *devm_regulator_get(struct device *dev, const char *id) +{ + return _devm_regulator_get(dev, id, NORMAL_GET); +} +EXPORT_SYMBOL_GPL(devm_regulator_get); + +/** + * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() + * @dev: device for regulator "consumer" + * @id: Supply name or regulator ID. + * + * Managed regulator_get_exclusive(). Regulators returned from this function + * are automatically regulator_put() on driver detach. See regulator_get() for + * more information. + */ +struct regulator *devm_regulator_get_exclusive(struct device *dev, + const char *id) +{ + return _devm_regulator_get(dev, id, EXCLUSIVE_GET); +} +EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); + +/** + * devm_regulator_get_optional - Resource managed regulator_get_optional() + * @dev: device for regulator "consumer" + * @id: Supply name or regulator ID. + * + * Managed regulator_get_optional(). Regulators returned from this + * function are automatically regulator_put() on driver detach. See + * regulator_get_optional() for more information. + */ +struct regulator *devm_regulator_get_optional(struct device *dev, + const char *id) +{ + return _devm_regulator_get(dev, id, OPTIONAL_GET); +} +EXPORT_SYMBOL_GPL(devm_regulator_get_optional); + +static int devm_regulator_match(struct device *dev, void *res, void *data) +{ + struct regulator **r = res; + if (!r || !*r) { + WARN_ON(!r || !*r); + return 0; + } + return *r == data; +} + +/** + * devm_regulator_put - Resource managed regulator_put() + * @regulator: regulator to free + * + * Deallocate a regulator allocated with devm_regulator_get(). Normally + * this function will not need to be called and the resource management + * code will ensure that the resource is freed. + */ +void devm_regulator_put(struct regulator *regulator) +{ + int rc; + + rc = devres_release(regulator->dev, devm_regulator_release, + devm_regulator_match, regulator); + if (rc != 0) + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_regulator_put); + +/** + * devm_regulator_bulk_get - managed get multiple regulator consumers + * + * @dev: Device to supply + * @num_consumers: Number of consumers to register + * @consumers: Configuration of consumers; clients are stored here. + * + * @return 0 on success, an errno on failure. + * + * This helper function allows drivers to get several regulator + * consumers in one operation with management, the regulators will + * automatically be freed when the device is unbound. If any of the + * regulators cannot be acquired then any regulators that were + * allocated will be freed before returning to the caller. + */ +int devm_regulator_bulk_get(struct device *dev, int num_consumers, + struct regulator_bulk_data *consumers) +{ + int i; + int ret; + + for (i = 0; i < num_consumers; i++) + consumers[i].consumer = NULL; + + for (i = 0; i < num_consumers; i++) { + consumers[i].consumer = devm_regulator_get(dev, + consumers[i].supply); + if (IS_ERR(consumers[i].consumer)) { + ret = PTR_ERR(consumers[i].consumer); + dev_err(dev, "Failed to get supply '%s': %d\n", + consumers[i].supply, ret); + consumers[i].consumer = NULL; + goto err; + } + } + + return 0; + +err: + for (i = 0; i < num_consumers && consumers[i].consumer; i++) + devm_regulator_put(consumers[i].consumer); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); + +static void devm_rdev_release(struct device *dev, void *res) +{ + regulator_unregister(*(struct regulator_dev **)res); +} + +/** + * devm_regulator_register - Resource managed regulator_register() + * @regulator_desc: regulator to register + * @config: runtime configuration for regulator + * + * Called by regulator drivers to register a regulator. Returns a + * valid pointer to struct regulator_dev on success or an ERR_PTR() on + * error. The regulator will automatically be released when the device + * is unbound. + */ +struct regulator_dev *devm_regulator_register(struct device *dev, + const struct regulator_desc *regulator_desc, + const struct regulator_config *config) +{ + struct regulator_dev **ptr, *rdev; + + ptr = devres_alloc(devm_rdev_release, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + rdev = regulator_register(regulator_desc, config); + if (!IS_ERR(rdev)) { + *ptr = rdev; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return rdev; +} +EXPORT_SYMBOL_GPL(devm_regulator_register); + +static int devm_rdev_match(struct device *dev, void *res, void *data) +{ + struct regulator_dev **r = res; + if (!r || !*r) { + WARN_ON(!r || !*r); + return 0; + } + return *r == data; +} + +/** + * devm_regulator_unregister - Resource managed regulator_unregister() + * @regulator: regulator to free + * + * Unregister a regulator registered with devm_regulator_register(). + * Normally this function will not need to be called and the resource + * management code will ensure that the resource is freed. + */ +void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) +{ + int rc; + + rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev); + if (rc != 0) + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_regulator_unregister); diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h new file mode 100644 index 000000000000..84bbda10c396 --- /dev/null +++ b/drivers/regulator/internal.h @@ -0,0 +1,38 @@ +/* + * internal.h -- Voltage/Current Regulator framework internal code + * + * Copyright 2007, 2008 Wolfson Microelectronics PLC. + * Copyright 2008 SlimLogic Ltd. + * + * Author: Liam Girdwood + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __REGULATOR_INTERNAL_H +#define __REGULATOR_INTERNAL_H + +/* + * struct regulator + * + * One for each consumer device. + */ +struct regulator { + struct device *dev; + struct list_head list; + unsigned int always_on:1; + unsigned int bypass:1; + int uA_load; + int min_uV; + int max_uV; + char *supply_name; + struct device_attribute dev_attr; + struct regulator_dev *rdev; + struct dentry *debugfs; +}; + +#endif -- cgit v1.2.3-55-g7522 From 4ddfebd3b0d5b65c69492408bb67fd1202104643 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 13 Sep 2013 19:50:37 +0100 Subject: regulator: core: Provide a dummy regulator with full constraints When a system has said that it has fully specified constraints for its regulators it is still possible that some supplies may be missing, especially if regulator support has been added to a driver after the board was integrated. We can handle such situations more gracefully by providing a dummy regulator. Unless the caller has specifically indicated that the system design may not include a given regulator by using regulator_get_optional() or that it needs its interactions to have an effect using regulator_get_exclusive() provide a dummy regulator if we can't locate a real one. The kconfig option REGULATOR_DUMMY that provided similar behaviour for all regulators has been removed, systems that need it should flag that they have full constraints instead. Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 10 ---------- drivers/regulator/core.c | 36 +++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index dfe58096b374..0417ce327cd8 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -28,16 +28,6 @@ config REGULATOR_DEBUG help Say yes here to enable debugging support. -config REGULATOR_DUMMY - bool "Provide a dummy regulator if regulator lookups fail" - help - If this option is enabled then when a regulator lookup fails - and the board has not specified that it has provided full - constraints the regulator core will provide an always - enabled dummy regulator, allowing consumer drivers to continue. - - A warning will be generated when this substitution is done. - config REGULATOR_FIXED_VOLTAGE tristate "Fixed voltage regulator support" help diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..8fd170788c3e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1243,7 +1243,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, /* Internal regulator request function */ static struct regulator *_regulator_get(struct device *dev, const char *id, - bool exclusive) + bool exclusive, bool allow_dummy) { struct regulator_dev *rdev; struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); @@ -1268,30 +1268,32 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, * If we have return value from dev_lookup fail, we do not expect to * succeed, so, quit with appropriate error value */ - if (ret) { + if (ret && ret != -ENODEV) { regulator = ERR_PTR(ret); goto out; } - if (board_wants_dummy_regulator) { - rdev = dummy_regulator_rdev; - goto found; - } - -#ifdef CONFIG_REGULATOR_DUMMY if (!devname) devname = "deviceless"; - /* If the board didn't flag that it was fully constrained then - * substitute in a dummy regulator so consumers can continue. + /* + * Assume that a regulator is physically present and enabled + * even if it isn't hooked up and just provide a dummy. */ - if (!has_full_constraints) { - pr_warn("%s supply %s not found, using dummy regulator\n", - devname, id); + if (has_full_constraints && allow_dummy) { + /* + * Log the substitution if regulator configuration is + * not complete to help development. + */ + if (!has_full_constraints) + pr_warn("%s supply %s not found, using dummy regulator\n", + devname, id); + rdev = dummy_regulator_rdev; goto found; + } else { + dev_err(dev, "dummy supplies not allowed\n"); } -#endif mutex_unlock(®ulator_list_mutex); return regulator; @@ -1349,7 +1351,7 @@ out: */ struct regulator *regulator_get(struct device *dev, const char *id) { - return _regulator_get(dev, id, false); + return _regulator_get(dev, id, false, true); } EXPORT_SYMBOL_GPL(regulator_get); @@ -1410,7 +1412,7 @@ EXPORT_SYMBOL_GPL(devm_regulator_get); */ struct regulator *regulator_get_exclusive(struct device *dev, const char *id) { - return _regulator_get(dev, id, true); + return _regulator_get(dev, id, true, false); } EXPORT_SYMBOL_GPL(regulator_get_exclusive); @@ -1439,7 +1441,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive); */ struct regulator *regulator_get_optional(struct device *dev, const char *id) { - return _regulator_get(dev, id, 0); + return _regulator_get(dev, id, false, false); } EXPORT_SYMBOL_GPL(regulator_get_optional); -- cgit v1.2.3-55-g7522 From 4f0ac6dabf867095b31f851ba0d0ceaca2f87e2e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 13 Sep 2013 19:51:47 +0100 Subject: regulator: core: Remove unused regulator_use_dummy_regulator() No boards have used this functionality and the new default of providing dummy regulators by default provides a better solution to the problem it was trying to solve. Signed-off-by: Mark Brown --- drivers/regulator/core.c | 17 ----------------- include/linux/regulator/machine.h | 5 ----- 2 files changed, 22 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8fd170788c3e..ac3a864d3635 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -53,7 +53,6 @@ static LIST_HEAD(regulator_list); static LIST_HEAD(regulator_map_list); static LIST_HEAD(regulator_ena_gpio_list); static bool has_full_constraints; -static bool board_wants_dummy_regulator; static struct dentry *debugfs_root; @@ -3615,22 +3614,6 @@ void regulator_has_full_constraints(void) } EXPORT_SYMBOL_GPL(regulator_has_full_constraints); -/** - * regulator_use_dummy_regulator - Provide a dummy regulator when none is found - * - * Calling this function will cause the regulator API to provide a - * dummy regulator to consumers if no physical regulator is found, - * allowing most consumers to proceed as though a regulator were - * configured. This allows systems such as those with software - * controllable regulators for the CPU core only to be brought up more - * readily. - */ -void regulator_use_dummy_regulator(void) -{ - board_wants_dummy_regulator = true; -} -EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator); - /** * rdev_get_drvdata - get rdev regulator driver data * @rdev: regulator diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 999b20ce06cf..a9f7c55a4d4d 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -193,15 +193,10 @@ int regulator_suspend_finish(void); #ifdef CONFIG_REGULATOR void regulator_has_full_constraints(void); -void regulator_use_dummy_regulator(void); #else static inline void regulator_has_full_constraints(void) { } - -static inline void regulator_use_dummy_regulator(void) -{ -} #endif #endif -- cgit v1.2.3-55-g7522 From 32b6d3f6027a05f42987f74deed48dc13cd5a11d Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 21 Aug 2013 16:18:16 +0530 Subject: regulator: palmas: add support for external control of rails Palmas rails like LDOs, SMPSs, REGENs, SYSENs can be enable and disable by register programming through I2C communication as well as it can be enable/disable with the external control input ENABLE1, ENABLE2 and NSLEEP. Add support for configuring these rails to be controlled by external control inputs. This is require to configure the rail's control register as well as configuration of resource register. Provide the external input names through parameter "roof-floor". Updated the DT binding document to details different value of the roof-floor. Signed-off-by: Laxman Dewangan Acked-by: Stephen Warren Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/palmas-pmic.txt | 12 +- drivers/regulator/palmas-regulator.c | 164 ++++++++++++++++++++- 2 files changed, 167 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt index 875639ae0606..42e6b6bc48ff 100644 --- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt +++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt @@ -26,11 +26,17 @@ Optional nodes: For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP, smps45, smps457, smps7 depending on variant, smps6, smps[8-9], - smps10_out2, smps10_out1, do[1-9], ldoln, ldousb. + smps10_out2, smps10_out1, ldo[1-9], ldoln, ldousb. Optional sub-node properties: ti,warm-reset - maintain voltage during warm reset(boolean) - ti,roof-floor - control voltage selection by pin(boolean) + ti,roof-floor - This takes as optional argument on platform supporting + the rail from desired external control. If there is no argument then + it will be assume that it is controlled by NSLEEP pin. + The valid value for external pins are: + ENABLE1 then 1, + ENABLE2 then 2 or + NSLEEP then 3. ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto, 2 - eco, 3 - forced pwm ti,smps-range - OTP has the wrong range set for the hardware so override @@ -61,7 +67,7 @@ pmic { regulator-always-on; regulator-boot-on; ti,warm-reset; - ti,roof-floor; + ti,roof-floor = <1>; /* ENABLE1 control */ ti,mode-sleep = <0>; ti,smps-range = <1>; }; diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 488dfe7ce9a6..3c08e1b5b289 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -33,6 +33,7 @@ struct regs_info { u8 vsel_addr; u8 ctrl_addr; u8 tstep_addr; + int sleep_id; }; static const struct regs_info palmas_regs_info[] = { @@ -42,6 +43,7 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_SMPS12_VOLTAGE, .ctrl_addr = PALMAS_SMPS12_CTRL, .tstep_addr = PALMAS_SMPS12_TSTEP, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, }, { .name = "SMPS123", @@ -49,12 +51,14 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_SMPS12_VOLTAGE, .ctrl_addr = PALMAS_SMPS12_CTRL, .tstep_addr = PALMAS_SMPS12_TSTEP, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, }, { .name = "SMPS3", .sname = "smps3-in", .vsel_addr = PALMAS_SMPS3_VOLTAGE, .ctrl_addr = PALMAS_SMPS3_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS3, }, { .name = "SMPS45", @@ -62,6 +66,7 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_SMPS45_VOLTAGE, .ctrl_addr = PALMAS_SMPS45_CTRL, .tstep_addr = PALMAS_SMPS45_TSTEP, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, }, { .name = "SMPS457", @@ -69,6 +74,7 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_SMPS45_VOLTAGE, .ctrl_addr = PALMAS_SMPS45_CTRL, .tstep_addr = PALMAS_SMPS45_TSTEP, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, }, { .name = "SMPS6", @@ -76,12 +82,14 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_SMPS6_VOLTAGE, .ctrl_addr = PALMAS_SMPS6_CTRL, .tstep_addr = PALMAS_SMPS6_TSTEP, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS6, }, { .name = "SMPS7", .sname = "smps7-in", .vsel_addr = PALMAS_SMPS7_VOLTAGE, .ctrl_addr = PALMAS_SMPS7_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS7, }, { .name = "SMPS8", @@ -89,108 +97,128 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_SMPS8_VOLTAGE, .ctrl_addr = PALMAS_SMPS8_CTRL, .tstep_addr = PALMAS_SMPS8_TSTEP, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS8, }, { .name = "SMPS9", .sname = "smps9-in", .vsel_addr = PALMAS_SMPS9_VOLTAGE, .ctrl_addr = PALMAS_SMPS9_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS9, }, { .name = "SMPS10_OUT2", .sname = "smps10-in", .ctrl_addr = PALMAS_SMPS10_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, }, { .name = "SMPS10_OUT1", .sname = "smps10-out2", .ctrl_addr = PALMAS_SMPS10_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, }, { .name = "LDO1", .sname = "ldo1-in", .vsel_addr = PALMAS_LDO1_VOLTAGE, .ctrl_addr = PALMAS_LDO1_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO1, }, { .name = "LDO2", .sname = "ldo2-in", .vsel_addr = PALMAS_LDO2_VOLTAGE, .ctrl_addr = PALMAS_LDO2_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO2, }, { .name = "LDO3", .sname = "ldo3-in", .vsel_addr = PALMAS_LDO3_VOLTAGE, .ctrl_addr = PALMAS_LDO3_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO3, }, { .name = "LDO4", .sname = "ldo4-in", .vsel_addr = PALMAS_LDO4_VOLTAGE, .ctrl_addr = PALMAS_LDO4_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO4, }, { .name = "LDO5", .sname = "ldo5-in", .vsel_addr = PALMAS_LDO5_VOLTAGE, .ctrl_addr = PALMAS_LDO5_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO5, }, { .name = "LDO6", .sname = "ldo6-in", .vsel_addr = PALMAS_LDO6_VOLTAGE, .ctrl_addr = PALMAS_LDO6_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO6, }, { .name = "LDO7", .sname = "ldo7-in", .vsel_addr = PALMAS_LDO7_VOLTAGE, .ctrl_addr = PALMAS_LDO7_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO7, }, { .name = "LDO8", .sname = "ldo8-in", .vsel_addr = PALMAS_LDO8_VOLTAGE, .ctrl_addr = PALMAS_LDO8_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO8, }, { .name = "LDO9", .sname = "ldo9-in", .vsel_addr = PALMAS_LDO9_VOLTAGE, .ctrl_addr = PALMAS_LDO9_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO9, }, { .name = "LDOLN", .sname = "ldoln-in", .vsel_addr = PALMAS_LDOLN_VOLTAGE, .ctrl_addr = PALMAS_LDOLN_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOLN, }, { .name = "LDOUSB", .sname = "ldousb-in", .vsel_addr = PALMAS_LDOUSB_VOLTAGE, .ctrl_addr = PALMAS_LDOUSB_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOUSB, }, { .name = "REGEN1", .ctrl_addr = PALMAS_REGEN1_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN1, }, { .name = "REGEN2", .ctrl_addr = PALMAS_REGEN2_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN2, }, { .name = "REGEN3", .ctrl_addr = PALMAS_REGEN3_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN3, }, { .name = "SYSEN1", .ctrl_addr = PALMAS_SYSEN1_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN1, }, { .name = "SYSEN2", .ctrl_addr = PALMAS_SYSEN2_CTRL, + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN2, }, }; @@ -484,6 +512,17 @@ static struct regulator_ops palmas_ops_smps = { .set_ramp_delay = palmas_smps_set_ramp_delay, }; +static struct regulator_ops palmas_ops_ext_control_smps = { + .set_mode = palmas_set_mode_smps, + .get_mode = palmas_get_mode_smps, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .list_voltage = palmas_list_voltage_smps, + .map_voltage = palmas_map_voltage_smps, + .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, + .set_ramp_delay = palmas_smps_set_ramp_delay, +}; + static struct regulator_ops palmas_ops_smps10 = { .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, @@ -519,12 +558,37 @@ static struct regulator_ops palmas_ops_ldo = { .map_voltage = regulator_map_voltage_linear, }; +static struct regulator_ops palmas_ops_ext_control_ldo = { + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, +}; + static struct regulator_ops palmas_ops_extreg = { .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, }; +static struct regulator_ops palmas_ops_ext_control_extreg = { +}; + +static int palmas_regulator_config_external(struct palmas *palmas, int id, + struct palmas_reg_init *reg_init) +{ + int sleep_id = palmas_regs_info[id].sleep_id; + int ret; + + ret = palmas_ext_control_req_config(palmas, sleep_id, + reg_init->roof_floor, true); + if (ret < 0) + dev_err(palmas->dev, + "Ext control config for regulator %d failed %d\n", + id, ret); + return ret; +} + /* * setup the hardware based sleep configuration of the SMPS/LDO regulators * from the platform data. This is different to the software based control @@ -583,7 +647,22 @@ static int palmas_smps_init(struct palmas *palmas, int id, return ret; } + if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) && + (id != PALMAS_REG_SMPS10_OUT2)) { + /* Enable externally controlled regulator */ + addr = palmas_regs_info[id].ctrl_addr; + ret = palmas_smps_read(palmas, addr, ®); + if (ret < 0) + return ret; + if (!(reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK)) { + reg |= SMPS_CTRL_MODE_ON; + ret = palmas_smps_write(palmas, addr, reg); + if (ret < 0) + return ret; + } + return palmas_regulator_config_external(palmas, id, reg_init); + } return 0; } @@ -614,6 +693,20 @@ static int palmas_ldo_init(struct palmas *palmas, int id, if (ret) return ret; + if (reg_init->roof_floor) { + /* Enable externally controlled regulator */ + addr = palmas_regs_info[id].ctrl_addr; + ret = palmas_update_bits(palmas, PALMAS_LDO_BASE, + addr, PALMAS_LDO1_CTRL_MODE_ACTIVE, + PALMAS_LDO1_CTRL_MODE_ACTIVE); + if (ret < 0) { + dev_err(palmas->dev, + "LDO Register 0x%02x update failed %d\n", + addr, ret); + return ret; + } + return palmas_regulator_config_external(palmas, id, reg_init); + } return 0; } @@ -636,6 +729,21 @@ static int palmas_extreg_init(struct palmas *palmas, int id, addr, ret); return ret; } + + if (reg_init->roof_floor) { + /* Enable externally controlled regulator */ + addr = palmas_regs_info[id].ctrl_addr; + ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, + addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE, + PALMAS_REGEN1_CTRL_MODE_ACTIVE); + if (ret < 0) { + dev_err(palmas->dev, + "Resource Register 0x%02x update failed %d\n", + addr, ret); + return ret; + } + return palmas_regulator_config_external(palmas, id, reg_init); + } return 0; } @@ -746,9 +854,35 @@ static void palmas_dt_to_pdata(struct device *dev, of_property_read_bool(palmas_matches[idx].of_node, "ti,warm-reset"); - pdata->reg_init[idx]->roof_floor = - of_property_read_bool(palmas_matches[idx].of_node, - "ti,roof-floor"); + ret = of_property_read_u32(palmas_matches[idx].of_node, + "ti,roof-floor", &prop); + /* EINVAL: Property not found */ + if (ret != -EINVAL) { + int econtrol; + + /* use default value, when no value is specified */ + econtrol = PALMAS_EXT_CONTROL_NSLEEP; + if (!ret) { + switch (prop) { + case 1: + econtrol = PALMAS_EXT_CONTROL_ENABLE1; + break; + case 2: + econtrol = PALMAS_EXT_CONTROL_ENABLE2; + break; + case 3: + econtrol = PALMAS_EXT_CONTROL_NSLEEP; + break; + default: + WARN_ON(1); + dev_warn(dev, + "%s: Invalid roof-floor option: %u\n", + palmas_matches[idx].name, prop); + break; + } + } + pdata->reg_init[idx]->roof_floor = econtrol; + } ret = of_property_read_u32(palmas_matches[idx].of_node, "ti,mode-sleep", &prop); @@ -875,6 +1009,8 @@ static int palmas_regulators_probe(struct platform_device *pdev) ret = palmas_smps_init(palmas, id, reg_init); if (ret) goto err_unregister_regulator; + } else { + reg_init = NULL; } /* Register the regulators */ @@ -919,7 +1055,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) pmic->range[id] = 1; - pmic->desc[id].ops = &palmas_ops_smps; + if (reg_init && reg_init->roof_floor) + pmic->desc[id].ops = + &palmas_ops_ext_control_smps; + else + pmic->desc[id].ops = &palmas_ops_smps; pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, @@ -962,6 +1102,10 @@ static int palmas_regulators_probe(struct platform_device *pdev) /* Start this loop from the id left from previous loop */ for (; id < PALMAS_NUM_REGS; id++) { + if (pdata && pdata->reg_init[id]) + reg_init = pdata->reg_init[id]; + else + reg_init = NULL; /* Miss out regulators which are not available due * to alternate functions. @@ -975,7 +1119,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) if (id < PALMAS_REG_REGEN1) { pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; - pmic->desc[id].ops = &palmas_ops_ldo; + if (reg_init && reg_init->roof_floor) + pmic->desc[id].ops = + &palmas_ops_ext_control_ldo; + else + pmic->desc[id].ops = &palmas_ops_ldo; pmic->desc[id].min_uV = 900000; pmic->desc[id].uV_step = 50000; pmic->desc[id].linear_min_sel = 1; @@ -999,7 +1147,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) } } else { pmic->desc[id].n_voltages = 1; - pmic->desc[id].ops = &palmas_ops_extreg; + if (reg_init && reg_init->roof_floor) + pmic->desc[id].ops = + &palmas_ops_ext_control_extreg; + else + pmic->desc[id].ops = &palmas_ops_extreg; pmic->desc[id].enable_reg = PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, palmas_regs_info[id].ctrl_addr); -- cgit v1.2.3-55-g7522 From 5957e444d2aa01705749190c32ae88fc4a029156 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 10 Sep 2013 16:48:07 +0530 Subject: regulator: palmas: configure enable time for LDOs As per datasheet (Referred TPS65913), the on-time for LDO is 500micro second. If LDO6 is in vibrator mode then the on-time is 2000us. Set the enable_time on regulator descriptor accordingly. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 3c08e1b5b289..76ce09c6b594 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -1127,6 +1127,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) pmic->desc[id].min_uV = 900000; pmic->desc[id].uV_step = 50000; pmic->desc[id].linear_min_sel = 1; + pmic->desc[id].enable_time = 500; pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, palmas_regs_info[id].vsel_addr); @@ -1145,6 +1146,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) pmic->desc[id].min_uV = 450000; pmic->desc[id].uV_step = 25000; } + + /* LOD6 in vibrator mode will have enable time 2000us */ + if (pdata && pdata->ldo6_vibrator && + (id == PALMAS_REG_LDO6)) + pmic->desc[id].enable_time = 2000; } else { pmic->desc[id].n_voltages = 1; if (reg_init && reg_init->roof_floor) -- cgit v1.2.3-55-g7522 From 3615a34ea1a6c1040744449b3da223569f3221b0 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 13 Sep 2013 21:01:15 +0200 Subject: regulator: add STw481x VMMC driver The ST Microelectronics STw481x PMIC used for the Nomadik has one single software-controlled regulator for VMMC. This driver registers directly to the compatible string as there is just one regulator. Signed-off-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 8 +++ drivers/regulator/Makefile | 1 + drivers/regulator/stw481x-vmmc.c | 110 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 drivers/regulator/stw481x-vmmc.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index dfe58096b374..d957010b54fa 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -429,6 +429,14 @@ config REGULATOR_TI_ABB on TI SoCs may be unstable without enabling this as it provides device specific optimized bias to allow/optimize functionality. +config REGULATOR_STW481X_VMMC + bool "ST Microelectronics STW481X VMMC regulator" + depends on MFD_STW481X + default y if MFD_STW481X + help + This driver supports the internal VMMC regulator in the STw481x + PMIC chips. + config REGULATOR_TPS51632 tristate "TI TPS51632 Power Regulator" depends on I2C diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 185cce246022..f2cfc4528b96 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -56,6 +56,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o +obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c new file mode 100644 index 000000000000..5ae72a877259 --- /dev/null +++ b/drivers/regulator/stw481x-vmmc.c @@ -0,0 +1,110 @@ +/* + * Regulator driver for STw4810/STw4811 VMMC regulator. + * + * Copyright (C) 2013 ST-Ericsson SA + * Written on behalf of Linaro for ST-Ericsson + * + * Author: Linus Walleij + * + * License terms: GNU General Public License (GPL) version 2 + */ + +#include +#include +#include +#include +#include +#include +#include + +static const unsigned int stw481x_vmmc_voltages[] = { + 1800000, + 1800000, + 2850000, + 3000000, + 1850000, + 2600000, + 2700000, + 3300000, +}; + +static struct regulator_ops stw481x_vmmc_ops = { + .list_voltage = regulator_list_voltage_table, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, +}; + +static struct regulator_desc vmmc_regulator = { + .name = "VMMC", + .id = 0, + .ops = &stw481x_vmmc_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = ARRAY_SIZE(stw481x_vmmc_voltages), + .volt_table = stw481x_vmmc_voltages, + .enable_time = 200, /* FIXME: look this up */ + .enable_reg = STW_CONF1, + .enable_mask = STW_CONF1_PDN_VMMC, + .vsel_reg = STW_CONF1, + .vsel_mask = STW_CONF1_VMMC_MASK, +}; + +static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) +{ + struct stw481x *stw481x = dev_get_platdata(&pdev->dev); + struct regulator_config config = { }; + int ret; + + /* First disable the external VMMC if it's active */ + ret = regmap_update_bits(stw481x->map, STW_CONF2, + STW_CONF2_VMMC_EXT, 0); + if (ret) { + dev_err(&pdev->dev, "could not disable external VMMC\n"); + return ret; + } + + /* Register VMMC regulator */ + config.dev = &pdev->dev; + config.driver_data = stw481x; + config.regmap = stw481x->map; + config.of_node = pdev->dev.of_node; + config.init_data = of_get_regulator_init_data(&pdev->dev, + pdev->dev.of_node); + + stw481x->vmmc_regulator = regulator_register(&vmmc_regulator, &config); + if (IS_ERR(stw481x->vmmc_regulator)) { + dev_err(&pdev->dev, + "error initializing STw481x VMMC regulator\n"); + return PTR_ERR(stw481x->vmmc_regulator); + } + + dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n"); + return 0; +} + +static int stw481x_vmmc_regulator_remove(struct platform_device *pdev) +{ + struct stw481x *stw481x = dev_get_platdata(&pdev->dev); + + regulator_unregister(stw481x->vmmc_regulator); + return 0; +} + +static const struct of_device_id stw481x_vmmc_match[] = { + { .compatible = "st,stw481x-vmmc", }, + {}, +}; + +static struct platform_driver stw481x_vmmc_regulator_driver = { + .driver = { + .name = "stw481x-vmmc-regulator", + .owner = THIS_MODULE, + }, + .probe = stw481x_vmmc_regulator_probe, + .remove = stw481x_vmmc_regulator_remove, +}; + +module_platform_driver(stw481x_vmmc_regulator_driver); -- cgit v1.2.3-55-g7522 From 00c877c69ba315d6c565a4df51c71b11e82cdeb8 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 18 Sep 2013 18:18:02 +0530 Subject: regulator: core: add support for configuring turn-on time through constraints The turn-on time of the regulator depends on the regulator device's electrical characteristics. Sometimes regulator turn-on time also depends on the capacitive load on the given platform and it can be more than the datasheet value. The driver provides the enable-time as per datasheet. Add support for configure the enable ramp time through regulator constraints so that regulator core can take this value for enable time for that regulator. Signed-off-by: Laxman Dewangan Acked-by: Stephen Warren Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/regulator.txt | 5 +++++ drivers/regulator/core.c | 2 ++ drivers/regulator/of_regulator.c | 6 ++++++ include/linux/regulator/machine.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index 2bd8f0978765..e2c7f1e7251a 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt @@ -14,6 +14,11 @@ Optional properties: - regulator-ramp-delay: ramp delay for regulator(in uV/uS) For hardwares which support disabling ramp rate, it should be explicitly intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay. +- regulator-enable-ramp-delay: The time taken, in microseconds, for the supply + rail to reach the target voltage, plus/minus whatever tolerance the board + design requires. This property describes the total system ramp time + required due to the combination of internal ramping of the regulator itself, + and board design issues such as trace capacitance and load on the supply. Deprecated properties: - regulator-compatible: If a regulator chip contains multiple diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..5217c1964c32 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1186,6 +1186,8 @@ overflow_err: static int _regulator_get_enable_time(struct regulator_dev *rdev) { + if (rdev->constraints && rdev->constraints->enable_time) + return rdev->constraints->enable_time; if (!rdev->desc->ops->enable_time) return rdev->desc->enable_time; return rdev->desc->ops->enable_time(rdev); diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 7827384680d6..ea4f36f2cbe2 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -23,6 +23,8 @@ static void of_get_regulation_constraints(struct device_node *np, const __be32 *min_uA, *max_uA, *ramp_delay; struct property *prop; struct regulation_constraints *constraints = &(*init_data)->constraints; + int ret; + u32 pval; constraints->name = of_get_property(np, "regulator-name", NULL); @@ -73,6 +75,10 @@ static void of_get_regulation_constraints(struct device_node *np, else constraints->ramp_disable = true; } + + ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); + if (!ret) + constraints->enable_time = pval; } /** diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 999b20ce06cf..8108751acb86 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -95,6 +95,7 @@ struct regulator_state { * @initial_state: Suspend state to set by default. * @initial_mode: Mode to set at startup. * @ramp_delay: Time to settle down after voltage change (unit: uV/us) + * @enable_time: Turn-on time of the rails (unit: microseconds) */ struct regulation_constraints { @@ -129,6 +130,7 @@ struct regulation_constraints { unsigned int initial_mode; unsigned int ramp_delay; + unsigned int enable_time; /* constraint flags */ unsigned always_on:1; /* regulator never off when system is on */ -- cgit v1.2.3-55-g7522 From 78925b3a791b3ad485fe56d0b8951a5d043b7cae Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 20 Sep 2013 09:45:35 +0530 Subject: regulator: tps6524x: Remove redundant spi_set_drvdata Driver core sets driver data to NULL upon failure or remove. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/tps6524x-regulator.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 62e8d28beabd..8b9ee3983a6c 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c @@ -588,7 +588,6 @@ static int pmic_remove(struct spi_device *spi) regulator_unregister(hw->rdev[i]); hw->rdev[i] = NULL; } - spi_set_drvdata(spi, NULL); return 0; } -- cgit v1.2.3-55-g7522 From f8c1700dd7d2ce9b2238b20d364317b2968ac76b Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Fri, 20 Sep 2013 13:13:02 +0530 Subject: regulator: core: set current constraints while setting machine constraints Machine constraints is configured during regulator register. If current constraints are provided through machine constraints then it is observed that sometime the current configured on rail is out of range what machine constraint has. Set the current constraints when setting machine constraints to make sure that rail's current is within the range of given machine constraints. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/core.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5217c1964c32..66ae12d12c10 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -923,6 +923,36 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, return 0; } +static int machine_constraints_current(struct regulator_dev *rdev, + struct regulation_constraints *constraints) +{ + struct regulator_ops *ops = rdev->desc->ops; + int ret; + + if (!constraints->min_uA && !constraints->max_uA) + return 0; + + if (constraints->min_uA > constraints->max_uA) { + rdev_err(rdev, "Invalid current constraints\n"); + return -EINVAL; + } + + if (!ops->set_current_limit || !ops->get_current_limit) { + rdev_warn(rdev, "Operation of current configuration missing\n"); + return 0; + } + + /* Set regulator current in constraints range */ + ret = ops->set_current_limit(rdev, constraints->min_uA, + constraints->max_uA); + if (ret < 0) { + rdev_err(rdev, "Failed to set current constraint, %d\n", ret); + return ret; + } + + return 0; +} + /** * set_machine_constraints - sets regulator constraints * @rdev: regulator source @@ -953,6 +983,10 @@ static int set_machine_constraints(struct regulator_dev *rdev, if (ret != 0) goto out; + ret = machine_constraints_current(rdev, rdev->constraints); + if (ret != 0) + goto out; + /* do we need to setup our suspend state */ if (rdev->constraints->initial_state) { ret = suspend_prepare(rdev, rdev->constraints->initial_state); -- cgit v1.2.3-55-g7522 From 9b92da1f1205bd2591487051a93624dd6c258eef Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 20 Sep 2013 12:23:30 +0100 Subject: regulator: core: Fix default return value for _get() Now that we are defaulting to providing dummy regulators fix the logic for substituting a dummy by making the default return code -EPROBE_DEFER. Reported-by: Thierry Reding Tested-by: Thierry Reding Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ac3a864d3635..088b41ac9506 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1247,7 +1247,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, struct regulator_dev *rdev; struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); const char *devname = NULL; - int ret = 0; + int ret = -EPROBE_DEFER; if (id == NULL) { pr_err("get() with no identifier\n"); -- cgit v1.2.3-55-g7522 From bc407334e9a6a745de5360395282beb2690adf48 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Fri, 20 Sep 2013 18:00:13 +0530 Subject: regulator: as3722: add regulator driver for AMS AS3722 The AMS AS3722 is a compact system PMU suitable for mobile phones, tablets etc. It has 4 DCDC step down regulators, 3 DCDC step down controller, 11 LDOs. Add a driver to support accessing the DCDC/LDOs found on the AMS AS3722 PMIC using regulators. Signed-off-by: Laxman Dewangan Signed-off-by: Florian Lobmaier Signed-off-by: Mark Brown --- .../bindings/regulator/as3722-regulator.txt | 91 ++ drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/as3722-regulator.c | 917 +++++++++++++++++++++ 4 files changed, 1017 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/as3722-regulator.txt create mode 100644 drivers/regulator/as3722-regulator.c diff --git a/Documentation/devicetree/bindings/regulator/as3722-regulator.txt b/Documentation/devicetree/bindings/regulator/as3722-regulator.txt new file mode 100644 index 000000000000..caad0c8a258d --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/as3722-regulator.txt @@ -0,0 +1,91 @@ +Regulator of AMS AS3722 PMIC. +Name of the regulator subnode must be "regulators". + +Optional properties: +-------------------- +The input supply of regulators are the optional properties on the +regulator node. The AS3722 is having 7 DCDC step-down regulators as +sd[0-6], 10 LDOs as ldo[0-7], ldo[9-11]. The input supply of these +regulators are provided through following properties: +vsup-sd2-supply: Input supply for SD2. +vsup-sd3-supply: Input supply for SD3. +vsup-sd4-supply: Input supply for SD4. +vsup-sd5-supply: Input supply for SD5. +vin-ldo0-supply: Input supply for LDO0. +vin-ldo1-6-supply: Input supply for LDO1 and LDO6. +vin-ldo2-5-7-supply: Input supply for LDO2, LDO5 and LDO7. +vin-ldo3-4-supply: Input supply for LDO3 and LDO4. +vin-ldo9-10-supply: Input supply for LDO9 and LDO10. +vin-ldo11-supply: Input supply for LDO11. + +Optional nodes: +-------------- +- regulators : Must contain a sub-node per regulator from the list below. + Each sub-node should contain the constraints and initialization + information for that regulator. See regulator.txt for a + description of standard properties for these sub-nodes. + Additional custom properties are listed below. + sd[0-6], ldo[0-7], ldo[9-11]. + + Optional sub-node properties: + ---------------------------- + ams,ext-control: External control of the rail. The option of + this properties will tell which external input is + controlling this rail. Valid values are 0, 1, 2 ad 3. + 0: There is no external control of this rail. + 1: Rail is controlled by ENABLE1 input pin. + 2: Rail is controlled by ENABLE2 input pin. + 3: Rail is controlled by ENABLE3 input pin. + ams,enable-tracking: Enable tracking with SD1, only supported + by LDO3. + +Example: +------- + ams3722: ams3722 { + compatible = "ams,as3722"; + reg = <0x40>; + ... + + regulators { + vsup-sd2-supply = <...>; + ... + + sd0 { + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1400000>; + regulator-always-on; + ams,ext-control = <2>; + }; + + sd1 { + regulator-name = "vdd_core"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1400000>; + regulator-always-on; + ams,ext-control = <1>; + }; + + sd2 { + regulator-name = "vddio_ddr"; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; + regulator-always-on; + }; + + sd4 { + regulator-name = "avdd-hdmi-pex"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + regulator-always-on; + }; + + sd5 { + regulator-name = "vdd-1v8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + }; + .... + }; + }; diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index dfe58096b374..9869064f9f03 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -133,6 +133,14 @@ config REGULATOR_AS3711 This driver provides support for the voltage regulators on the AS3711 PMIC +config REGULATOR_AS3722 + tristate "AMS AS3722 PMIC Regulators" + depends on MFD_AS3722 + help + This driver provides support for the voltage regulators on the + AS3722 PMIC. This will enable support for all the software + controllable DCDC/LDO regulators. + config REGULATOR_DA903X tristate "Dialog Semiconductor DA9030/DA9034 regulators" depends on PMIC_DA903X diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 185cce246022..0b233bbe6734 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o +obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c new file mode 100644 index 000000000000..16a5d26a2d35 --- /dev/null +++ b/drivers/regulator/as3722-regulator.c @@ -0,0 +1,917 @@ +/* + * Voltage regulator support for AMS AS3722 PMIC + * + * Copyright (C) 2013 ams + * + * Author: Florian Lobmaier + * Author: Laxman Dewangan + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Regulator IDs */ +enum as3722_regulators_id { + AS3722_REGULATOR_ID_SD0, + AS3722_REGULATOR_ID_SD1, + AS3722_REGULATOR_ID_SD2, + AS3722_REGULATOR_ID_SD3, + AS3722_REGULATOR_ID_SD4, + AS3722_REGULATOR_ID_SD5, + AS3722_REGULATOR_ID_SD6, + AS3722_REGULATOR_ID_LDO0, + AS3722_REGULATOR_ID_LDO1, + AS3722_REGULATOR_ID_LDO2, + AS3722_REGULATOR_ID_LDO3, + AS3722_REGULATOR_ID_LDO4, + AS3722_REGULATOR_ID_LDO5, + AS3722_REGULATOR_ID_LDO6, + AS3722_REGULATOR_ID_LDO7, + AS3722_REGULATOR_ID_LDO9, + AS3722_REGULATOR_ID_LDO10, + AS3722_REGULATOR_ID_LDO11, + AS3722_REGULATOR_ID_MAX, +}; + +struct as3722_register_mapping { + u8 regulator_id; + const char *name; + const char *sname; + u8 vsel_reg; + u8 vsel_mask; + int n_voltages; + u32 enable_reg; + u8 enable_mask; + u32 control_reg; + u8 mode_mask; + u32 sleep_ctrl_reg; + u8 sleep_ctrl_mask; +}; + +struct as3722_regulator_config_data { + struct regulator_init_data *reg_init; + bool enable_tracking; + int ext_control; +}; + +struct as3722_regulators { + struct device *dev; + struct as3722 *as3722; + struct regulator_dev *rdevs[AS3722_REGULATOR_ID_MAX]; + struct regulator_desc desc[AS3722_REGULATOR_ID_MAX]; + struct as3722_regulator_config_data + reg_config_data[AS3722_REGULATOR_ID_MAX]; +}; + +static const struct as3722_register_mapping as3722_reg_lookup[] = { + { + .regulator_id = AS3722_REGULATOR_ID_SD0, + .name = "as3722-sd0", + .vsel_reg = AS3722_SD0_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(0), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, + .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, + .control_reg = AS3722_SD0_CONTROL_REG, + .mode_mask = AS3722_SD0_MODE_FAST, + .n_voltages = AS3722_SD0_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_SD1, + .name = "as3722-sd1", + .vsel_reg = AS3722_SD1_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(1), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, + .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, + .control_reg = AS3722_SD1_CONTROL_REG, + .mode_mask = AS3722_SD1_MODE_FAST, + .n_voltages = AS3722_SD0_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_SD2, + .name = "as3722-sd2", + .sname = "vsup-sd2", + .vsel_reg = AS3722_SD2_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(2), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, + .sleep_ctrl_mask = AS3722_SD2_EXT_ENABLE_MASK, + .control_reg = AS3722_SD23_CONTROL_REG, + .mode_mask = AS3722_SD2_MODE_FAST, + .n_voltages = AS3722_SD2_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_SD3, + .name = "as3722-sd3", + .sname = "vsup-sd3", + .vsel_reg = AS3722_SD3_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(3), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, + .sleep_ctrl_mask = AS3722_SD3_EXT_ENABLE_MASK, + .control_reg = AS3722_SD23_CONTROL_REG, + .mode_mask = AS3722_SD3_MODE_FAST, + .n_voltages = AS3722_SD2_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_SD4, + .name = "as3722-sd4", + .sname = "vsup-sd4", + .vsel_reg = AS3722_SD4_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(4), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, + .sleep_ctrl_mask = AS3722_SD4_EXT_ENABLE_MASK, + .control_reg = AS3722_SD4_CONTROL_REG, + .mode_mask = AS3722_SD4_MODE_FAST, + .n_voltages = AS3722_SD2_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_SD5, + .name = "as3722-sd5", + .sname = "vsup-sd5", + .vsel_reg = AS3722_SD5_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(5), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, + .sleep_ctrl_mask = AS3722_SD5_EXT_ENABLE_MASK, + .control_reg = AS3722_SD5_CONTROL_REG, + .mode_mask = AS3722_SD5_MODE_FAST, + .n_voltages = AS3722_SD2_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_SD6, + .name = "as3722-sd6", + .vsel_reg = AS3722_SD6_VOLTAGE_REG, + .vsel_mask = AS3722_SD_VSEL_MASK, + .enable_reg = AS3722_SD_CONTROL_REG, + .enable_mask = AS3722_SDn_CTRL(6), + .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, + .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, + .control_reg = AS3722_SD6_CONTROL_REG, + .mode_mask = AS3722_SD6_MODE_FAST, + .n_voltages = AS3722_SD0_VSEL_MAX, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO0, + .name = "as3722-ldo0", + .sname = "vin-ldo0", + .vsel_reg = AS3722_LDO0_VOLTAGE_REG, + .vsel_mask = AS3722_LDO0_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO0_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, + .sleep_ctrl_mask = AS3722_LDO0_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO0_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO1, + .name = "as3722-ldo1", + .sname = "vin-ldo1-6", + .vsel_reg = AS3722_LDO1_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO1_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, + .sleep_ctrl_mask = AS3722_LDO1_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO2, + .name = "as3722-ldo2", + .sname = "vin-ldo2-5-7", + .vsel_reg = AS3722_LDO2_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO2_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, + .sleep_ctrl_mask = AS3722_LDO2_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO3, + .name = "as3722-ldo3", + .name = "vin-ldo3-4", + .vsel_reg = AS3722_LDO3_VOLTAGE_REG, + .vsel_mask = AS3722_LDO3_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO3_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, + .sleep_ctrl_mask = AS3722_LDO3_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO3_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO4, + .name = "as3722-ldo4", + .name = "vin-ldo3-4", + .vsel_reg = AS3722_LDO4_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO4_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, + .sleep_ctrl_mask = AS3722_LDO4_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO5, + .name = "as3722-ldo5", + .sname = "vin-ldo2-5-7", + .vsel_reg = AS3722_LDO5_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO5_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, + .sleep_ctrl_mask = AS3722_LDO5_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO6, + .name = "as3722-ldo6", + .sname = "vin-ldo1-6", + .vsel_reg = AS3722_LDO6_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO6_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, + .sleep_ctrl_mask = AS3722_LDO6_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO7, + .name = "as3722-ldo7", + .sname = "vin-ldo2-5-7", + .vsel_reg = AS3722_LDO7_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL0_REG, + .enable_mask = AS3722_LDO7_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, + .sleep_ctrl_mask = AS3722_LDO7_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO9, + .name = "as3722-ldo9", + .sname = "vin-ldo9-10", + .vsel_reg = AS3722_LDO9_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL1_REG, + .enable_mask = AS3722_LDO9_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, + .sleep_ctrl_mask = AS3722_LDO9_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO10, + .name = "as3722-ldo10", + .sname = "vin-ldo9-10", + .vsel_reg = AS3722_LDO10_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL1_REG, + .enable_mask = AS3722_LDO10_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, + .sleep_ctrl_mask = AS3722_LDO10_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, + { + .regulator_id = AS3722_REGULATOR_ID_LDO11, + .name = "as3722-ldo11", + .sname = "vin-ldo11", + .vsel_reg = AS3722_LDO11_VOLTAGE_REG, + .vsel_mask = AS3722_LDO_VSEL_MASK, + .enable_reg = AS3722_LDOCONTROL1_REG, + .enable_mask = AS3722_LDO11_CTRL, + .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, + .sleep_ctrl_mask = AS3722_LDO11_EXT_ENABLE_MASK, + .n_voltages = AS3722_LDO_NUM_VOLT, + }, +}; + + +static const int as3722_ldo_current[] = { 150000, 300000 }; +static const int as3722_sd016_current[] = { 2500000, 3000000, 3500000 }; + +static int as3722_current_to_index(int min_uA, int max_uA, + const int *curr_table, int n_currents) +{ + int i; + + for (i = n_currents - 1; i >= 0; i--) { + if ((min_uA <= curr_table[i]) && (curr_table[i] <= max_uA)) + return i; + } + return -EINVAL; +} + +static int as3722_ldo_get_current_limit(struct regulator_dev *rdev) +{ + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); + struct as3722 *as3722 = as3722_regs->as3722; + int id = rdev_get_id(rdev); + u32 val; + int ret; + + ret = as3722_read(as3722, as3722_reg_lookup[id].vsel_reg, &val); + if (ret < 0) { + dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", + as3722_reg_lookup[id].vsel_reg, ret); + return ret; + } + if (val & AS3722_LDO_ILIMIT_MASK) + return 300000; + return 150000; +} + +static int as3722_ldo_set_current_limit(struct regulator_dev *rdev, + int min_uA, int max_uA) +{ + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); + struct as3722 *as3722 = as3722_regs->as3722; + int id = rdev_get_id(rdev); + int ret; + u32 reg = 0; + + ret = as3722_current_to_index(min_uA, max_uA, as3722_ldo_current, + ARRAY_SIZE(as3722_ldo_current)); + if (ret < 0) { + dev_err(as3722_regs->dev, + "Current range min:max = %d:%d does not support\n", + min_uA, max_uA); + return ret; + } + if (ret) + reg = AS3722_LDO_ILIMIT_BIT; + return as3722_update_bits(as3722, as3722_reg_lookup[id].vsel_reg, + AS3722_LDO_ILIMIT_MASK, reg); +} + +static struct regulator_ops as3722_ldo0_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_current_limit = as3722_ldo_get_current_limit, + .set_current_limit = as3722_ldo_set_current_limit, +}; + +static struct regulator_ops as3722_ldo0_extcntrl_ops = { + .list_voltage = regulator_list_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_current_limit = as3722_ldo_get_current_limit, + .set_current_limit = as3722_ldo_set_current_limit, +}; + +static int as3722_ldo3_set_tracking_mode(struct as3722_regulators *as3722_reg, + int id, u8 mode) +{ + struct as3722 *as3722 = as3722_reg->as3722; + + switch (mode) { + case AS3722_LDO3_MODE_PMOS: + case AS3722_LDO3_MODE_PMOS_TRACKING: + case AS3722_LDO3_MODE_NMOS: + case AS3722_LDO3_MODE_SWITCH: + return as3722_update_bits(as3722, + as3722_reg_lookup[id].vsel_reg, + AS3722_LDO3_MODE_MASK, mode); + + default: + return -EINVAL; + } +} + +static int as3722_ldo3_get_current_limit(struct regulator_dev *rdev) +{ + return 150000; +} + +static struct regulator_ops as3722_ldo3_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_current_limit = as3722_ldo3_get_current_limit, +}; + +static struct regulator_ops as3722_ldo3_extcntrl_ops = { + .list_voltage = regulator_list_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_current_limit = as3722_ldo3_get_current_limit, +}; + +#define regulator_lin_range(_min_sel, _max_sel, _min_uV, _step_uV) \ + { \ + .min_sel = _min_sel, \ + .max_sel = _max_sel, \ + .uV_step = _step_uV, \ + .min_uV = _min_uV, \ + .max_uV = _min_uV + (_max_sel - _min_sel + 1) * _step_uV, \ + } + +static const struct regulator_linear_range as3722_ldo_ranges[] = { + regulator_lin_range(0x01, 0x24, 800000, 25000), + regulator_lin_range(0x40, 0x7F, 1725000, 25000), +}; + +static struct regulator_ops as3722_ldo_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .map_voltage = regulator_map_voltage_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_linear_range, + .get_current_limit = as3722_ldo_get_current_limit, + .set_current_limit = as3722_ldo_set_current_limit, +}; + +static struct regulator_ops as3722_ldo_extcntrl_ops = { + .map_voltage = regulator_map_voltage_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_linear_range, + .get_current_limit = as3722_ldo_get_current_limit, + .set_current_limit = as3722_ldo_set_current_limit, +}; + +static unsigned int as3722_sd_get_mode(struct regulator_dev *rdev) +{ + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); + struct as3722 *as3722 = as3722_regs->as3722; + int id = rdev_get_id(rdev); + u32 val; + int ret; + + if (!as3722_reg_lookup[id].control_reg) + return -ENOTSUPP; + + ret = as3722_read(as3722, as3722_reg_lookup[id].control_reg, &val); + if (ret < 0) { + dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", + as3722_reg_lookup[id].control_reg, ret); + return ret; + } + + if (val & as3722_reg_lookup[id].mode_mask) + return REGULATOR_MODE_FAST; + else + return REGULATOR_MODE_NORMAL; +} + +static int as3722_sd_set_mode(struct regulator_dev *rdev, + unsigned int mode) +{ + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); + struct as3722 *as3722 = as3722_regs->as3722; + u8 id = rdev_get_id(rdev); + u8 val = 0; + int ret; + + if (!as3722_reg_lookup[id].control_reg) + return -ERANGE; + + switch (mode) { + case REGULATOR_MODE_FAST: + val = as3722_reg_lookup[id].mode_mask; + case REGULATOR_MODE_NORMAL: /* fall down */ + break; + default: + return -EINVAL; + } + + ret = as3722_update_bits(as3722, as3722_reg_lookup[id].control_reg, + as3722_reg_lookup[id].mode_mask, val); + if (ret < 0) { + dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n", + as3722_reg_lookup[id].control_reg, ret); + return ret; + } + return ret; +} + +static int as3722_sd016_get_current_limit(struct regulator_dev *rdev) +{ + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); + struct as3722 *as3722 = as3722_regs->as3722; + int id = rdev_get_id(rdev); + u32 val, reg; + int mask; + int ret; + + switch (id) { + case AS3722_REGULATOR_ID_SD0: + reg = AS3722_OVCURRENT_REG; + mask = AS3722_OVCURRENT_SD0_TRIP_MASK; + break; + case AS3722_REGULATOR_ID_SD1: + reg = AS3722_OVCURRENT_REG; + mask = AS3722_OVCURRENT_SD1_TRIP_MASK; + break; + case AS3722_REGULATOR_ID_SD6: + reg = AS3722_OVCURRENT_DEB_REG; + mask = AS3722_OVCURRENT_SD6_TRIP_MASK; + break; + default: + return -EINVAL; + } + ret = as3722_read(as3722, reg, &val); + if (ret < 0) { + dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", + reg, ret); + return ret; + } + val &= mask; + val >>= ffs(mask) - 1; + if (val == 3) + return -EINVAL; + return as3722_sd016_current[val]; +} + +static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, + int min_uA, int max_uA) +{ + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); + struct as3722 *as3722 = as3722_regs->as3722; + int id = rdev_get_id(rdev); + int ret; + int val; + int mask; + u32 reg; + + ret = as3722_current_to_index(min_uA, max_uA, as3722_sd016_current, + ARRAY_SIZE(as3722_sd016_current)); + if (ret < 0) { + dev_err(as3722_regs->dev, + "Current range min:max = %d:%d does not support\n", + min_uA, max_uA); + return ret; + } + + switch (id) { + case AS3722_REGULATOR_ID_SD0: + reg = AS3722_OVCURRENT_REG; + mask = AS3722_OVCURRENT_SD0_TRIP_MASK; + break; + case AS3722_REGULATOR_ID_SD1: + reg = AS3722_OVCURRENT_REG; + mask = AS3722_OVCURRENT_SD1_TRIP_MASK; + break; + case AS3722_REGULATOR_ID_SD6: + reg = AS3722_OVCURRENT_DEB_REG; + mask = AS3722_OVCURRENT_SD6_TRIP_MASK; + break; + default: + return -EINVAL; + } + val = ret & mask; + val <<= ffs(mask) - 1; + return as3722_update_bits(as3722, reg, mask, val); +} + +static const struct regulator_linear_range as3722_sd2345_ranges[] = { + regulator_lin_range(0x01, 0x40, 600000, 12500), + regulator_lin_range(0x41, 0x70, 1400000, 25000), + regulator_lin_range(0x71, 0x7F, 1725000, 50000), +}; + +static struct regulator_ops as3722_sd016_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_current_limit = as3722_sd016_get_current_limit, + .set_current_limit = as3722_sd016_set_current_limit, + .get_mode = as3722_sd_get_mode, + .set_mode = as3722_sd_set_mode, +}; + +static struct regulator_ops as3722_sd016_extcntrl_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_current_limit = as3722_sd016_get_current_limit, + .set_current_limit = as3722_sd016_set_current_limit, + .get_mode = as3722_sd_get_mode, + .set_mode = as3722_sd_set_mode, +}; + +static struct regulator_ops as3722_sd2345_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear_range, + .map_voltage = regulator_map_voltage_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .get_mode = as3722_sd_get_mode, + .set_mode = as3722_sd_set_mode, +}; + +static struct regulator_ops as3722_sd2345_extcntrl_ops = { + .list_voltage = regulator_list_voltage_linear_range, + .map_voltage = regulator_map_voltage_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .get_mode = as3722_sd_get_mode, + .set_mode = as3722_sd_set_mode, +}; + +static int as3722_extreg_init(struct as3722_regulators *as3722_regs, int id, + int ext_pwr_ctrl) +{ + int ret; + unsigned int val; + + if ((ext_pwr_ctrl < AS3722_EXT_CONTROL_ENABLE1) || + (ext_pwr_ctrl > AS3722_EXT_CONTROL_ENABLE3)) + return -EINVAL; + + val = ext_pwr_ctrl << (ffs(as3722_reg_lookup[id].sleep_ctrl_mask) - 1); + ret = as3722_update_bits(as3722_regs->as3722, + as3722_reg_lookup[id].sleep_ctrl_reg, + as3722_reg_lookup[id].sleep_ctrl_mask, val); + if (ret < 0) + dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n", + as3722_reg_lookup[id].sleep_ctrl_reg, ret); + return ret; +} + +static struct of_regulator_match as3722_regulator_matches[] = { + { .name = "sd0", }, + { .name = "sd1", }, + { .name = "sd2", }, + { .name = "sd3", }, + { .name = "sd4", }, + { .name = "sd5", }, + { .name = "sd6", }, + { .name = "ldo0", }, + { .name = "ldo1", }, + { .name = "ldo2", }, + { .name = "ldo3", }, + { .name = "ldo4", }, + { .name = "ldo5", }, + { .name = "ldo6", }, + { .name = "ldo7", }, + { .name = "ldo9", }, + { .name = "ldo10", }, + { .name = "ldo11", }, +}; + +static int as3722_get_regulator_dt_data(struct platform_device *pdev, + struct as3722_regulators *as3722_regs) +{ + struct device_node *np; + struct as3722_regulator_config_data *reg_config; + u32 prop; + int id; + int ret; + + np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); + if (!np) { + dev_err(&pdev->dev, "Device is not having regulators node\n"); + return -ENODEV; + } + pdev->dev.of_node = np; + + ret = of_regulator_match(&pdev->dev, np, as3722_regulator_matches, + ARRAY_SIZE(as3722_regulator_matches)); + if (ret < 0) { + dev_err(&pdev->dev, "Parsing of regulator node failed: %d\n", + ret); + return ret; + } + + for (id = 0; id < ARRAY_SIZE(as3722_regulator_matches); ++id) { + struct device_node *reg_node; + + reg_config = &as3722_regs->reg_config_data[id]; + reg_config->reg_init = as3722_regulator_matches[id].init_data; + reg_node = as3722_regulator_matches[id].of_node; + + if (!reg_config->reg_init || !reg_node) + continue; + + ret = of_property_read_u32(reg_node, "ams,ext-control", &prop); + if (!ret) { + if (prop < 3) + reg_config->ext_control = prop; + else + dev_warn(&pdev->dev, + "ext-control have invalid option: %u\n", + prop); + } + reg_config->enable_tracking = + of_property_read_bool(reg_node, "ams,enable-tracking"); + } + return 0; +} + +static int as3722_regulator_probe(struct platform_device *pdev) +{ + struct as3722 *as3722 = dev_get_drvdata(pdev->dev.parent); + struct as3722_regulators *as3722_regs; + struct as3722_regulator_config_data *reg_config; + struct regulator_dev *rdev; + struct regulator_config config = { }; + struct regulator_ops *ops; + int id; + int ret; + + as3722_regs = devm_kzalloc(&pdev->dev, sizeof(*as3722_regs), + GFP_KERNEL); + if (!as3722_regs) + return -ENOMEM; + + as3722_regs->dev = &pdev->dev; + as3722_regs->as3722 = as3722; + platform_set_drvdata(pdev, as3722_regs); + + ret = as3722_get_regulator_dt_data(pdev, as3722_regs); + if (ret < 0) + return ret; + + config.dev = &pdev->dev; + config.driver_data = as3722_regs; + config.regmap = as3722->regmap; + + for (id = 0; id < AS3722_REGULATOR_ID_MAX; id++) { + reg_config = &as3722_regs->reg_config_data[id]; + + as3722_regs->desc[id].name = as3722_reg_lookup[id].name; + as3722_regs->desc[id].supply_name = as3722_reg_lookup[id].sname; + as3722_regs->desc[id].id = as3722_reg_lookup[id].regulator_id; + as3722_regs->desc[id].n_voltages = + as3722_reg_lookup[id].n_voltages; + as3722_regs->desc[id].type = REGULATOR_VOLTAGE; + as3722_regs->desc[id].owner = THIS_MODULE; + as3722_regs->desc[id].enable_reg = + as3722_reg_lookup[id].enable_reg; + as3722_regs->desc[id].enable_mask = + as3722_reg_lookup[id].enable_mask; + as3722_regs->desc[id].vsel_reg = as3722_reg_lookup[id].vsel_reg; + as3722_regs->desc[id].vsel_mask = + as3722_reg_lookup[id].vsel_mask; + switch (id) { + case AS3722_REGULATOR_ID_LDO0: + if (reg_config->ext_control) + ops = &as3722_ldo0_extcntrl_ops; + else + ops = &as3722_ldo0_ops; + as3722_regs->desc[id].min_uV = 825000; + as3722_regs->desc[id].uV_step = 25000; + as3722_regs->desc[id].linear_min_sel = 1; + as3722_regs->desc[id].enable_time = 500; + break; + case AS3722_REGULATOR_ID_LDO3: + if (reg_config->ext_control) + ops = &as3722_ldo3_extcntrl_ops; + else + ops = &as3722_ldo3_ops; + as3722_regs->desc[id].min_uV = 620000; + as3722_regs->desc[id].uV_step = 20000; + as3722_regs->desc[id].linear_min_sel = 1; + as3722_regs->desc[id].enable_time = 500; + if (reg_config->enable_tracking) { + ret = as3722_ldo3_set_tracking_mode(as3722_regs, + id, AS3722_LDO3_MODE_PMOS_TRACKING); + if (ret < 0) { + dev_err(&pdev->dev, + "LDO3 tracking failed: %d\n", + ret); + return ret; + } + } + break; + case AS3722_REGULATOR_ID_SD0: + case AS3722_REGULATOR_ID_SD1: + case AS3722_REGULATOR_ID_SD6: + if (reg_config->ext_control) + ops = &as3722_sd016_extcntrl_ops; + else + ops = &as3722_sd016_ops; + as3722_regs->desc[id].min_uV = 610000; + as3722_regs->desc[id].uV_step = 10000; + as3722_regs->desc[id].linear_min_sel = 1; + break; + case AS3722_REGULATOR_ID_SD2: + case AS3722_REGULATOR_ID_SD3: + case AS3722_REGULATOR_ID_SD4: + case AS3722_REGULATOR_ID_SD5: + if (reg_config->ext_control) + ops = &as3722_sd2345_extcntrl_ops; + else + ops = &as3722_sd2345_ops; + as3722_regs->desc[id].linear_ranges = + as3722_sd2345_ranges; + as3722_regs->desc[id].n_linear_ranges = + ARRAY_SIZE(as3722_sd2345_ranges); + break; + default: + if (reg_config->ext_control) + ops = &as3722_ldo_extcntrl_ops; + else + ops = &as3722_ldo_ops; + as3722_regs->desc[id].min_uV = 825000; + as3722_regs->desc[id].uV_step = 25000; + as3722_regs->desc[id].linear_min_sel = 1; + as3722_regs->desc[id].enable_time = 500; + as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; + as3722_regs->desc[id].n_linear_ranges = + ARRAY_SIZE(as3722_ldo_ranges); + break; + } + as3722_regs->desc[id].ops = ops; + config.init_data = reg_config->reg_init; + config.of_node = as3722_regulator_matches[id].of_node; + rdev = devm_regulator_register(&pdev->dev, + &as3722_regs->desc[id], &config); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); + dev_err(&pdev->dev, "regulator %d register failed %d\n", + id, ret); + return ret; + } + + as3722_regs->rdevs[id] = rdev; + if (reg_config->ext_control) { + ret = regulator_enable_regmap(rdev); + if (ret < 0) { + dev_err(&pdev->dev, + "Regulator %d enable failed: %d\n", + id, ret); + return ret; + } + ret = as3722_extreg_init(as3722_regs, id, + reg_config->ext_control); + if (ret < 0) { + dev_err(&pdev->dev, + "AS3722 ext control failed: %d", ret); + return ret; + } + } + } + return 0; +} + +static const struct of_device_id of_as3722_regulator_match[] = { + { .compatible = "ams,as3722-regulator", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_as3722_regulator_match); + +static struct platform_driver as3722_regulator_driver = { + .driver = { + .name = "as3722-regulator", + .owner = THIS_MODULE, + .of_match_table = of_as3722_regulator_match, + }, + .probe = as3722_regulator_probe, +}; + +module_platform_driver(as3722_regulator_driver); + +MODULE_ALIAS("platform:as3722-regulator"); +MODULE_DESCRIPTION("AS3722 regulator driver"); +MODULE_AUTHOR("Florian Lobmaier "); +MODULE_AUTHOR("Laxman Dewangan "); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-55-g7522 From 043c998f95036e7fc796b240ab5ba49a8de36df3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 20 Sep 2013 12:32:18 +0100 Subject: regulator: core: Fix return code for invalid parameters We should be returning an error, a repeated call will never succeed. Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 66ae12d12c10..ad154247bb90 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1288,7 +1288,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, if (id == NULL) { pr_err("get() with no identifier\n"); - return regulator; + return ERR_PTR(-EINVAL); } if (dev) -- cgit v1.2.3-55-g7522 From ef60abbb6b406389245225ab4acfe73f66e7d92c Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 23 Sep 2013 16:12:52 +0100 Subject: regulator: core: Always use return value when regulator_dev_lookup() fails Ensure that the return value is always set when we return now that the logic has changed for regulator_get_optional() so we don't get missing codes leaking out. Reported-by: Thierry Reding Tested-by: Thierry Reding Signed-off-by: Mark Brown --- drivers/regulator/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 088b41ac9506..a40055edaae4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1263,12 +1263,13 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, if (rdev) goto found; + regulator = ERR_PTR(ret); + /* * If we have return value from dev_lookup fail, we do not expect to * succeed, so, quit with appropriate error value */ if (ret && ret != -ENODEV) { - regulator = ERR_PTR(ret); goto out; } -- cgit v1.2.3-55-g7522 From 937433c2502f663e5a0e8804462bc38c41b9021f Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 12 Sep 2013 14:28:35 +0200 Subject: regulator: da9210: add Device Tree support This patch adds basic Device Tree support to the da9210 regulator driver - with no special properties, since also driver's platform data only contains standard regulator initialisation parameters. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/da9210.txt | 21 +++++++++++++++++++++ drivers/regulator/da9210-regulator.c | 9 ++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/da9210.txt diff --git a/Documentation/devicetree/bindings/regulator/da9210.txt b/Documentation/devicetree/bindings/regulator/da9210.txt new file mode 100644 index 000000000000..f120f229d67d --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/da9210.txt @@ -0,0 +1,21 @@ +* Dialog Semiconductor DA9210 Voltage Regulator + +Required properties: + +- compatible: must be "diasemi,da9210" +- reg: the i2c slave address of the regulator. It should be 0x68. + +Any standard regulator properties can be used to configure the single da9210 +DCDC. + +Example: + + da9210@68 { + compatible = "diasemi,da9210"; + reg = <0x68>; + + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <1000000>; + regulator-boot-on; + regulator-always-on; + }; diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index f0fe54b38977..f7ccff14f763 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "da9210-regulator.h" @@ -126,7 +127,8 @@ static int da9210_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct da9210 *chip; - struct da9210_pdata *pdata = i2c->dev.platform_data; + struct device *dev = &i2c->dev; + struct da9210_pdata *pdata = dev_get_platdata(dev); struct regulator_dev *rdev = NULL; struct regulator_config config = { }; int error; @@ -147,10 +149,11 @@ static int da9210_i2c_probe(struct i2c_client *i2c, } config.dev = &i2c->dev; - if (pdata) - config.init_data = &pdata->da9210_constraints; + config.init_data = pdata ? &pdata->da9210_constraints : + of_get_regulator_init_data(dev, dev->of_node); config.driver_data = chip; config.regmap = chip->regmap; + config.of_node = dev->of_node; rdev = regulator_register(&da9210_reg, &config); if (IS_ERR(rdev)) { -- cgit v1.2.3-55-g7522 From bde251a9a813bfbb8f300abef265ecb7028c428f Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Fri, 27 Sep 2013 08:25:13 -0500 Subject: regulator: ti-abb: skip optional parameter for ldo-address On platforms like OMAP4460, LDO override is never used. Even though efuse determines the ABB bias mode to operate at, ABB voltage is preconfigured in internal efuse registers without the need for LDO override for bias voltage. So skip optional parameter if property is not present. Signed-off-by: Nishanth Menon Signed-off-by: Mark Brown --- drivers/regulator/ti-abb-regulator.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index d8e3e1262bc2..1e0280536e72 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -765,6 +765,11 @@ static int ti_abb_probe(struct platform_device *pdev) pname = "ldo-address"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); + if (!res) { + dev_dbg(dev, "Missing '%s' IO resource\n", pname); + ret = -ENODEV; + goto skip_opt; + } abb->ldo_base = devm_ioremap_resource(dev, res); if (IS_ERR(abb->ldo_base)) { ret = PTR_ERR(abb->ldo_base); -- cgit v1.2.3-55-g7522 From 5df529d440aa4f0e67be9af3718e7edf05db7d02 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 20 Sep 2013 13:51:56 +0200 Subject: regulator: core: Reduce busy-wait looping Keep busy-wait looping to a minimum while waiting for a regulator to ramp-up to the target voltage. This follows the guidelines set forth in Documentation/timers/timers-howto.txt and assumes that regulators are never enabled in atomic context. Signed-off-by: Thierry Reding Signed-off-by: Mark Brown --- drivers/regulator/core.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ad154247bb90..5075ed1e94a6 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1740,11 +1740,39 @@ static int _regulator_do_enable(struct regulator_dev *rdev) * together. */ trace_regulator_enable_delay(rdev_get_name(rdev)); - if (delay >= 1000) { - mdelay(delay / 1000); - udelay(delay % 1000); - } else if (delay) { - udelay(delay); + /* + * Delay for the requested amount of time as per the guidelines in: + * + * Documentation/timers/timers-howto.txt + * + * The assumption here is that regulators will never be enabled in + * atomic context and therefore sleeping functions can be used. + */ + if (delay) { + unsigned int ms = delay / 1000; + unsigned int us = delay % 1000; + + if (ms > 0) { + /* + * For small enough values, handle super-millisecond + * delays in the usleep_range() call below. + */ + if (ms < 20) + us += ms * 1000; + else + msleep(ms); + } + + /* + * Give the scheduler some room to coalesce with any other + * wakeup sources. For delays shorter than 10 us, don't even + * bother setting up high-resolution timers and just busy- + * loop. + */ + if (us >= 10) + usleep_range(us, us + 100); + else + udelay(us); } trace_regulator_enable_complete(rdev_get_name(rdev)); -- cgit v1.2.3-55-g7522 From fda5842cc62c36c5ed02b763f6045e720582b083 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:50:14 +0900 Subject: regulator: ab3100: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Acked-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/ab3100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 7d5eaa874b2d..77b46d0b37a6 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c @@ -535,7 +535,7 @@ static int ab3100_regulator_register(struct platform_device *pdev, config.dev = &pdev->dev; config.driver_data = reg; - rdev = regulator_register(desc, &config); + rdev = devm_regulator_register(&pdev->dev, desc, &config); if (IS_ERR(rdev)) { err = PTR_ERR(rdev); dev_err(&pdev->dev, @@ -616,7 +616,6 @@ static int ab3100_regulators_remove(struct platform_device *pdev) for (i = 0; i < AB3100_NUM_REGULATORS; i++) { struct ab3100_regulator *reg = &ab3100_regulators[i]; - regulator_unregister(reg->rdev); reg->rdev = NULL; } return 0; -- cgit v1.2.3-55-g7522 From a4a6b9de5c859ff953ce1b854cbfa112718a3f43 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:52:37 +0900 Subject: regulator: ab8500-ext: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/ab8500-ext.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index 02ff691cdb8b..29c0faaf8eba 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -413,16 +413,12 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) &pdata->ext_regulator[i]; /* register regulator with framework */ - info->rdev = regulator_register(&info->desc, &config); + info->rdev = devm_regulator_register(&pdev->dev, &info->desc, + &config); if (IS_ERR(info->rdev)) { err = PTR_ERR(info->rdev); dev_err(&pdev->dev, "failed to register regulator %s\n", info->desc.name); - /* when we fail, un-register all earlier regulators */ - while (--i >= 0) { - info = &ab8500_ext_regulator_info[i]; - regulator_unregister(info->rdev); - } return err; } @@ -433,26 +429,8 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) return 0; } -static int ab8500_ext_regulator_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ab8500_ext_regulator_info); i++) { - struct ab8500_ext_regulator_info *info = NULL; - info = &ab8500_ext_regulator_info[i]; - - dev_vdbg(rdev_get_dev(info->rdev), - "%s-remove\n", info->desc.name); - - regulator_unregister(info->rdev); - } - - return 0; -} - static struct platform_driver ab8500_ext_regulator_driver = { .probe = ab8500_ext_regulator_probe, - .remove = ab8500_ext_regulator_remove, .driver = { .name = "ab8500-ext-regulator", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From e97bba912eede5e813788bc9ead4a2c29130d377 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:53:09 +0900 Subject: regulator: da9063: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/da9063-regulator.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 1a7816390773..62b846916e22 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c @@ -847,13 +847,13 @@ static int da9063_regulator_probe(struct platform_device *pdev) if (da9063_reg_matches) config.of_node = da9063_reg_matches[id].of_node; config.regmap = da9063->regmap; - regl->rdev = regulator_register(®l->desc, &config); + regl->rdev = devm_regulator_register(&pdev->dev, ®l->desc, + &config); if (IS_ERR(regl->rdev)) { dev_err(&pdev->dev, "Failed to register %s regulator\n", regl->desc.name); - ret = PTR_ERR(regl->rdev); - goto err; + return PTR_ERR(regl->rdev); } id++; n++; @@ -862,9 +862,8 @@ static int da9063_regulator_probe(struct platform_device *pdev) /* LDOs overcurrent event support */ irq = platform_get_irq_byname(pdev, "LDO_LIM"); if (irq < 0) { - ret = irq; dev_err(&pdev->dev, "Failed to get IRQ.\n"); - goto err; + return irq; } regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); @@ -881,27 +880,15 @@ static int da9063_regulator_probe(struct platform_device *pdev) } return 0; - -err: - /* Wind back regulators registeration */ - while (--n >= 0) - regulator_unregister(regulators->regulator[n].rdev); - - return ret; } static int da9063_regulator_remove(struct platform_device *pdev) { struct da9063_regulators *regulators = platform_get_drvdata(pdev); - struct da9063_regulator *regl; free_irq(regulators->irq_ldo_lim, regulators); free_irq(regulators->irq_uvov, regulators); - for (regl = ®ulators->regulator[regulators->n_regulators - 1]; - regl >= ®ulators->regulator[0]; regl--) - regulator_unregister(regl->rdev); - return 0; } -- cgit v1.2.3-55-g7522 From ed602534df5d07251c074bafe75feed643c588d1 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:54:34 +0900 Subject: regulator: lp872x: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/lp872x.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 2b84b727a3c4..2e4734ff79fc 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -785,7 +785,7 @@ static int lp872x_regulator_register(struct lp872x *lp) struct regulator_desc *desc; struct regulator_config cfg = { }; struct regulator_dev *rdev; - int i, ret; + int i; for (i = 0; i < lp->num_regulators; i++) { desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : @@ -796,34 +796,16 @@ static int lp872x_regulator_register(struct lp872x *lp) cfg.driver_data = lp; cfg.regmap = lp->regmap; - rdev = regulator_register(desc, &cfg); + rdev = devm_regulator_register(lp->dev, desc, &cfg); if (IS_ERR(rdev)) { dev_err(lp->dev, "regulator register err"); - ret = PTR_ERR(rdev); - goto err; + return PTR_ERR(rdev); } *(lp->regulators + i) = rdev; } return 0; -err: - while (--i >= 0) { - rdev = *(lp->regulators + i); - regulator_unregister(rdev); - } - return ret; -} - -static void lp872x_regulator_unregister(struct lp872x *lp) -{ - struct regulator_dev *rdev; - int i; - - for (i = 0; i < lp->num_regulators; i++) { - rdev = *(lp->regulators + i); - regulator_unregister(rdev); - } } static const struct regmap_config lp872x_regmap_config = { @@ -979,14 +961,6 @@ err_dev: return ret; } -static int lp872x_remove(struct i2c_client *cl) -{ - struct lp872x *lp = i2c_get_clientdata(cl); - - lp872x_regulator_unregister(lp); - return 0; -} - static const struct of_device_id lp872x_dt_ids[] = { { .compatible = "ti,lp8720", }, { .compatible = "ti,lp8725", }, @@ -1008,7 +982,6 @@ static struct i2c_driver lp872x_driver = { .of_match_table = of_match_ptr(lp872x_dt_ids), }, .probe = lp872x_probe, - .remove = lp872x_remove, .id_table = lp872x_ids, }; -- cgit v1.2.3-55-g7522 From 3343fa174883b89c0151dac24df86e351eca85e4 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:55:12 +0900 Subject: regulator: lp8788-buck: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/lp8788-buck.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c index 0b015f2a7fd9..948afc249e29 100644 --- a/drivers/regulator/lp8788-buck.c +++ b/drivers/regulator/lp8788-buck.c @@ -515,7 +515,7 @@ static int lp8788_buck_probe(struct platform_device *pdev) cfg.driver_data = buck; cfg.regmap = lp->regmap; - rdev = regulator_register(&lp8788_buck_desc[id], &cfg); + rdev = devm_regulator_register(&pdev->dev, &lp8788_buck_desc[id], &cfg); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n", @@ -529,18 +529,8 @@ static int lp8788_buck_probe(struct platform_device *pdev) return 0; } -static int lp8788_buck_remove(struct platform_device *pdev) -{ - struct lp8788_buck *buck = platform_get_drvdata(pdev); - - regulator_unregister(buck->regulator); - - return 0; -} - static struct platform_driver lp8788_buck_driver = { .probe = lp8788_buck_probe, - .remove = lp8788_buck_remove, .driver = { .name = LP8788_DEV_BUCK, .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 0b7bb09054aebe66fd803c8f88015046b96cb47f Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:55:51 +0900 Subject: regulator: lp8788-ldo: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/lp8788-ldo.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index 0527d87c6dd5..b9a29a29933f 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c @@ -543,7 +543,7 @@ static int lp8788_dldo_probe(struct platform_device *pdev) cfg.driver_data = ldo; cfg.regmap = lp->regmap; - rdev = regulator_register(&lp8788_dldo_desc[id], &cfg); + rdev = devm_regulator_register(&pdev->dev, &lp8788_dldo_desc[id], &cfg); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); dev_err(&pdev->dev, "DLDO%d regulator register err = %d\n", @@ -557,18 +557,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev) return 0; } -static int lp8788_dldo_remove(struct platform_device *pdev) -{ - struct lp8788_ldo *ldo = platform_get_drvdata(pdev); - - regulator_unregister(ldo->regulator); - - return 0; -} - static struct platform_driver lp8788_dldo_driver = { .probe = lp8788_dldo_probe, - .remove = lp8788_dldo_remove, .driver = { .name = LP8788_DEV_DLDO, .owner = THIS_MODULE, @@ -603,7 +593,7 @@ static int lp8788_aldo_probe(struct platform_device *pdev) cfg.driver_data = ldo; cfg.regmap = lp->regmap; - rdev = regulator_register(&lp8788_aldo_desc[id], &cfg); + rdev = devm_regulator_register(&pdev->dev, &lp8788_aldo_desc[id], &cfg); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); dev_err(&pdev->dev, "ALDO%d regulator register err = %d\n", @@ -617,18 +607,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev) return 0; } -static int lp8788_aldo_remove(struct platform_device *pdev) -{ - struct lp8788_ldo *ldo = platform_get_drvdata(pdev); - - regulator_unregister(ldo->regulator); - - return 0; -} - static struct platform_driver lp8788_aldo_driver = { .probe = lp8788_aldo_probe, - .remove = lp8788_aldo_remove, .driver = { .name = LP8788_DEV_ALDO, .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 58765e24bec8940082068829a9d2c3a4431d60c0 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:56:24 +0900 Subject: regulator: max8925: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/max8925-regulator.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index d80b5fa758ae..759510789e71 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c @@ -312,7 +312,7 @@ static int max8925_regulator_probe(struct platform_device *pdev) if (pdata) config.init_data = pdata; - rdev = regulator_register(&ri->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register regulator %s\n", ri->desc.name); @@ -323,22 +323,12 @@ static int max8925_regulator_probe(struct platform_device *pdev) return 0; } -static int max8925_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - - return 0; -} - static struct platform_driver max8925_regulator_driver = { .driver = { .name = "max8925-regulator", .owner = THIS_MODULE, }, .probe = max8925_regulator_probe, - .remove = max8925_regulator_remove, }; static int __init max8925_regulator_init(void) -- cgit v1.2.3-55-g7522 From 15dc006af830d85417c97b60a40b5a0b991ee32e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:56:55 +0900 Subject: regulator: pcap: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/pcap-regulator.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index b49eaeedea84..3727b7d0e9ac 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c @@ -246,7 +246,8 @@ static int pcap_regulator_probe(struct platform_device *pdev) config.init_data = dev_get_platdata(&pdev->dev); config.driver_data = pcap; - rdev = regulator_register(&pcap_regulators[pdev->id], &config); + rdev = devm_regulator_register(&pdev->dev, &pcap_regulators[pdev->id], + &config); if (IS_ERR(rdev)) return PTR_ERR(rdev); @@ -255,22 +256,12 @@ static int pcap_regulator_probe(struct platform_device *pdev) return 0; } -static int pcap_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - - return 0; -} - static struct platform_driver pcap_regulator_driver = { .driver = { .name = "pcap-regulator", .owner = THIS_MODULE, }, .probe = pcap_regulator_probe, - .remove = pcap_regulator_remove, }; static int __init pcap_regulator_init(void) -- cgit v1.2.3-55-g7522 From 5e0165e5a91db2283e694023582c0fc23311ae59 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:57:23 +0900 Subject: regulator: pcf50633: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/pcf50633-regulator.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index 0f3576d48abf..d7da1c15a6da 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c @@ -90,7 +90,8 @@ static int pcf50633_regulator_probe(struct platform_device *pdev) config.driver_data = pcf; config.regmap = pcf->regmap; - rdev = regulator_register(®ulators[pdev->id], &config); + rdev = devm_regulator_register(&pdev->dev, ®ulators[pdev->id], + &config); if (IS_ERR(rdev)) return PTR_ERR(rdev); @@ -102,21 +103,11 @@ static int pcf50633_regulator_probe(struct platform_device *pdev) return 0; } -static int pcf50633_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - - return 0; -} - static struct platform_driver pcf50633_regulator_driver = { .driver = { .name = "pcf50633-regltr", }, .probe = pcf50633_regulator_probe, - .remove = pcf50633_regulator_remove, }; static int __init pcf50633_regulator_init(void) -- cgit v1.2.3-55-g7522 From 6a2b5a931f31c91cc2e261d99af7b3d881a41d86 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:57:54 +0900 Subject: regulator: tps6105x: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Acked-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/tps6105x-regulator.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c index ec9453ffb77f..e0e818d89f46 100644 --- a/drivers/regulator/tps6105x-regulator.c +++ b/drivers/regulator/tps6105x-regulator.c @@ -146,8 +146,9 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) config.driver_data = tps6105x; /* Register regulator with framework */ - tps6105x->regulator = regulator_register(&tps6105x_regulator_desc, - &config); + tps6105x->regulator = devm_regulator_register(&pdev->dev, + &tps6105x_regulator_desc, + &config); if (IS_ERR(tps6105x->regulator)) { ret = PTR_ERR(tps6105x->regulator); dev_err(&tps6105x->client->dev, @@ -159,20 +160,12 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) return 0; } -static int tps6105x_regulator_remove(struct platform_device *pdev) -{ - struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev); - regulator_unregister(tps6105x->regulator); - return 0; -} - static struct platform_driver tps6105x_regulator_driver = { .driver = { .name = "tps6105x-regulator", .owner = THIS_MODULE, }, .probe = tps6105x_regulator_probe, - .remove = tps6105x_regulator_remove, }; static __init int tps6105x_regulator_init(void) -- cgit v1.2.3-55-g7522 From 00ce070e51f96ee4c942b44d63b7a15f5b777fd6 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:59:04 +0900 Subject: regulator: twl: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Acked-by: Nishanth Menon Signed-off-by: Mark Brown --- drivers/regulator/twl-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 78aae4cbb004..8ebd785485c7 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -1188,7 +1188,7 @@ static int twlreg_probe(struct platform_device *pdev) config.driver_data = info; config.of_node = pdev->dev.of_node; - rdev = regulator_register(&info->desc, &config); + rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "can't register %s, %ld\n", info->desc.name, PTR_ERR(rdev)); @@ -1217,7 +1217,6 @@ static int twlreg_remove(struct platform_device *pdev) struct regulator_dev *rdev = platform_get_drvdata(pdev); struct twlreg_info *info = rdev->reg_data; - regulator_unregister(rdev); kfree(info); return 0; } -- cgit v1.2.3-55-g7522 From abf92a3d2e868fef808d4a205371b7e5417dd0f7 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:59:31 +0900 Subject: regulator: vexpress: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Acked-by: Pawel Moll Signed-off-by: Mark Brown --- drivers/regulator/vexpress.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c index 4668c7f8133d..f3ae28a7e663 100644 --- a/drivers/regulator/vexpress.c +++ b/drivers/regulator/vexpress.c @@ -96,7 +96,7 @@ static int vexpress_regulator_probe(struct platform_device *pdev) config.driver_data = reg; config.of_node = pdev->dev.of_node; - reg->regdev = regulator_register(®->desc, &config); + reg->regdev = devm_regulator_register(&pdev->dev, ®->desc, &config); if (IS_ERR(reg->regdev)) { err = PTR_ERR(reg->regdev); goto error_regulator_register; @@ -119,7 +119,6 @@ static int vexpress_regulator_remove(struct platform_device *pdev) struct vexpress_regulator *reg = platform_get_drvdata(pdev); vexpress_config_func_put(reg->func); - regulator_unregister(reg->regdev); return 0; } -- cgit v1.2.3-55-g7522 From 11c0da7bb414505ff9a157af2b1301877a3726bd Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:53:57 +0900 Subject: regulator: da9210: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/da9210-regulator.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index f7ccff14f763..6f5ecbe1132e 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c @@ -155,7 +155,7 @@ static int da9210_i2c_probe(struct i2c_client *i2c, config.regmap = chip->regmap; config.of_node = dev->of_node; - rdev = regulator_register(&da9210_reg, &config); + rdev = devm_regulator_register(&i2c->dev, &da9210_reg, &config); if (IS_ERR(rdev)) { dev_err(&i2c->dev, "Failed to register DA9210 regulator\n"); return PTR_ERR(rdev); @@ -168,13 +168,6 @@ static int da9210_i2c_probe(struct i2c_client *i2c, return 0; } -static int da9210_i2c_remove(struct i2c_client *i2c) -{ - struct da9210 *chip = i2c_get_clientdata(i2c); - regulator_unregister(chip->rdev); - return 0; -} - static const struct i2c_device_id da9210_i2c_id[] = { {"da9210", 0}, {}, @@ -188,7 +181,6 @@ static struct i2c_driver da9210_regulator_driver = { .owner = THIS_MODULE, }, .probe = da9210_i2c_probe, - .remove = da9210_i2c_remove, .id_table = da9210_i2c_id, }; -- cgit v1.2.3-55-g7522 From 5e0855759ca621bba454747fc1b5b76a7290f50f Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 30 Sep 2013 09:58:36 +0900 Subject: regulator: tps6524x: use devm_regulator_register() Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Reviewed-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps6524x-regulator.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 8b9ee3983a6c..9f6bfda711b7 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c @@ -577,20 +577,6 @@ static struct regulator_ops regulator_ops = { .get_current_limit = get_current_limit, }; -static int pmic_remove(struct spi_device *spi) -{ - struct tps6524x *hw = spi_get_drvdata(spi); - int i; - - if (!hw) - return 0; - for (i = 0; i < N_REGULATORS; i++) { - regulator_unregister(hw->rdev[i]); - hw->rdev[i] = NULL; - } - return 0; -} - static int pmic_probe(struct spi_device *spi) { struct tps6524x *hw; @@ -598,7 +584,7 @@ static int pmic_probe(struct spi_device *spi) const struct supply_info *info = supply_info; struct regulator_init_data *init_data; struct regulator_config config = { }; - int ret = 0, i; + int i; init_data = dev_get_platdata(dev); if (!init_data) { @@ -631,24 +617,17 @@ static int pmic_probe(struct spi_device *spi) config.init_data = init_data; config.driver_data = hw; - hw->rdev[i] = regulator_register(&hw->desc[i], &config); - if (IS_ERR(hw->rdev[i])) { - ret = PTR_ERR(hw->rdev[i]); - hw->rdev[i] = NULL; - goto fail; - } + hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i], + &config); + if (IS_ERR(hw->rdev[i])) + return PTR_ERR(hw->rdev[i]); } return 0; - -fail: - pmic_remove(spi); - return ret; } static struct spi_driver pmic_driver = { .probe = pmic_probe, - .remove = pmic_remove, .driver = { .name = "tps6524x", .owner = THIS_MODULE, -- cgit v1.2.3-55-g7522 From 18dca93eb7faa8d90fbc54bfb08560caebbf92cd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 2 Oct 2013 20:54:20 +0800 Subject: regulator: stw481x-vmmc: Set missing .of_match_table to stw481x_vmmc_match Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/stw481x-vmmc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c index 5ae72a877259..f78857bd6a15 100644 --- a/drivers/regulator/stw481x-vmmc.c +++ b/drivers/regulator/stw481x-vmmc.c @@ -102,6 +102,7 @@ static struct platform_driver stw481x_vmmc_regulator_driver = { .driver = { .name = "stw481x-vmmc-regulator", .owner = THIS_MODULE, + .of_match_table = stw481x_vmmc_match, }, .probe = stw481x_vmmc_regulator_probe, .remove = stw481x_vmmc_regulator_remove, -- cgit v1.2.3-55-g7522 From 43f6fc9542d6c42cc2e5783536ed31d90516c999 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 2 Oct 2013 20:47:56 +0800 Subject: regulator: as3722: Fix equation to calculate max_uV in regulator_lin_range macro Fix off-by-one in the equation to calculate max_uV and also adjust the _min_uV setting accordingly. For LDOs: The voltage select bits set the LDO output voltage 0.825V...3.3V, 25mV steps ....00h : LDO off 01h-24h : V_LDO4 = 0.8V + ldo4_vsel * 25mV = 0.825V + (ldo4_vsel - 1h) * 25mV 25h-3Fh : do not use 40h-7Fh : V_LDO4 = 1.725V + (ldo4_vsel - 40h) * 25mV For SD2345: The voltage select bits set the DC/DC output voltage level and power the DC/DC converter down. ....00h : DC/DC powered down 01h-40h : V_SD2 = 0.6V + sd2_vsel * 12.5mV = 0.6125V + (sd2_vsel - 1h) * 12.5mV 41h-70h : V_SD2 = 1.4V + (sd2_vsel - 40h) * 25mV = 1.425V + (sd2_vsel - 41h) * 25mV 71h-7Fh : V_SD2 = 2.6V + (sd2_vsel - 70h) * 50mV = 2.65V + (sd2_vsel - 71h) * 50mV Note, the third entry in as3722_sd2345_ranges is wrong in current code. Fix it based on the datasheet. Signed-off-by: Axel Lin Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/as3722-regulator.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c index 16a5d26a2d35..01a8b1788981 100644 --- a/drivers/regulator/as3722-regulator.c +++ b/drivers/regulator/as3722-regulator.c @@ -441,11 +441,11 @@ static struct regulator_ops as3722_ldo3_extcntrl_ops = { .max_sel = _max_sel, \ .uV_step = _step_uV, \ .min_uV = _min_uV, \ - .max_uV = _min_uV + (_max_sel - _min_sel + 1) * _step_uV, \ + .max_uV = _min_uV + (_max_sel - _min_sel) * _step_uV, \ } static const struct regulator_linear_range as3722_ldo_ranges[] = { - regulator_lin_range(0x01, 0x24, 800000, 25000), + regulator_lin_range(0x01, 0x24, 825000, 25000), regulator_lin_range(0x40, 0x7F, 1725000, 25000), }; @@ -605,9 +605,9 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, } static const struct regulator_linear_range as3722_sd2345_ranges[] = { - regulator_lin_range(0x01, 0x40, 600000, 12500), - regulator_lin_range(0x41, 0x70, 1400000, 25000), - regulator_lin_range(0x71, 0x7F, 1725000, 50000), + regulator_lin_range(0x01, 0x40, 612500, 12500), + regulator_lin_range(0x41, 0x70, 1425000, 25000), + regulator_lin_range(0x71, 0x7F, 2650000, 50000), }; static struct regulator_ops as3722_sd016_ops = { -- cgit v1.2.3-55-g7522 From 5e965704803dcbcbfbf97e8a976b3778b245834b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 2 Oct 2013 20:49:29 +0800 Subject: regulator: as3722: Fix off-by-one n_voltages setting for SDx AS3722_SDx_VSEL_MAX means the maximum selecter, the n_voltages should be AS3722_SDx_VSEL_MAX + 1. Signed-off-by: Axel Lin Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/as3722-regulator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c index 01a8b1788981..d7b71a9c41f1 100644 --- a/drivers/regulator/as3722-regulator.c +++ b/drivers/regulator/as3722-regulator.c @@ -99,7 +99,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, .control_reg = AS3722_SD0_CONTROL_REG, .mode_mask = AS3722_SD0_MODE_FAST, - .n_voltages = AS3722_SD0_VSEL_MAX, + .n_voltages = AS3722_SD0_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_SD1, @@ -112,7 +112,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, .control_reg = AS3722_SD1_CONTROL_REG, .mode_mask = AS3722_SD1_MODE_FAST, - .n_voltages = AS3722_SD0_VSEL_MAX, + .n_voltages = AS3722_SD0_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_SD2, @@ -126,7 +126,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD2_EXT_ENABLE_MASK, .control_reg = AS3722_SD23_CONTROL_REG, .mode_mask = AS3722_SD2_MODE_FAST, - .n_voltages = AS3722_SD2_VSEL_MAX, + .n_voltages = AS3722_SD2_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_SD3, @@ -140,7 +140,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD3_EXT_ENABLE_MASK, .control_reg = AS3722_SD23_CONTROL_REG, .mode_mask = AS3722_SD3_MODE_FAST, - .n_voltages = AS3722_SD2_VSEL_MAX, + .n_voltages = AS3722_SD2_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_SD4, @@ -154,7 +154,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD4_EXT_ENABLE_MASK, .control_reg = AS3722_SD4_CONTROL_REG, .mode_mask = AS3722_SD4_MODE_FAST, - .n_voltages = AS3722_SD2_VSEL_MAX, + .n_voltages = AS3722_SD2_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_SD5, @@ -168,7 +168,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD5_EXT_ENABLE_MASK, .control_reg = AS3722_SD5_CONTROL_REG, .mode_mask = AS3722_SD5_MODE_FAST, - .n_voltages = AS3722_SD2_VSEL_MAX, + .n_voltages = AS3722_SD2_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_SD6, @@ -181,7 +181,7 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, .control_reg = AS3722_SD6_CONTROL_REG, .mode_mask = AS3722_SD6_MODE_FAST, - .n_voltages = AS3722_SD0_VSEL_MAX, + .n_voltages = AS3722_SD0_VSEL_MAX + 1, }, { .regulator_id = AS3722_REGULATOR_ID_LDO0, -- cgit v1.2.3-55-g7522 From 4040394e12cb1eed21d1306cacdc8a6f0464c8e2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 4 Oct 2013 11:42:53 +0100 Subject: regulator: core: Always warn when using a dummy regulator This helps people spot if they have missed a supply from a device tree or equivalent data structure. Suggested-by: Stephen Warren Signed-off-by: Mark Brown --- drivers/regulator/core.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a40055edaae4..82805e2d8a64 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1281,13 +1281,8 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, * even if it isn't hooked up and just provide a dummy. */ if (has_full_constraints && allow_dummy) { - /* - * Log the substitution if regulator configuration is - * not complete to help development. - */ - if (!has_full_constraints) - pr_warn("%s supply %s not found, using dummy regulator\n", - devname, id); + pr_warn("%s supply %s not found, using dummy regulator\n", + devname, id); rdev = dummy_regulator_rdev; goto found; -- cgit v1.2.3-55-g7522 From 6653efb75dcac8fc61191cba9bd6dda99137bc44 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Oct 2013 15:18:18 +0530 Subject: regulator: gpio: Remove redundant break 'break' after goto has no effect. Remove it. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/gpio-regulator.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 98a98ffa7fe0..04406a918c04 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -283,7 +283,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) dev_err(&pdev->dev, "No regulator type set\n"); ret = -EINVAL; goto err_memgpio; - break; } drvdata->nr_gpios = config->nr_gpios; -- cgit v1.2.3-55-g7522 From acc1ccadb85fc47238e9d92b2336c04c9fc64d53 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Thu, 3 Oct 2013 19:36:37 +0530 Subject: regulator: palmas: get regulators node from parent node only The device tree binding of Palmas regulator driver says as: palmas_pmis { compatible = "ti,palmas-pmic"; ... regulators { ... } }; In this "regulators" subnode is expected to be part of parent node, not the outside of parent node. Hence to get the regulator node, the correct call is of_get_child_by_name() rather than of_find_node_by_name() which actually searches the "regulators" node from the parent node to end of DTS file. Signed-off-by: Laxman Dewangan Reviewed-by: Stephen Warren Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 1b31e414fde1..d68f05b105b5 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -826,7 +826,7 @@ static void palmas_dt_to_pdata(struct device *dev, int idx, ret; node = of_node_get(node); - regulators = of_find_node_by_name(node, "regulators"); + regulators = of_get_child_by_name(node, "regulators"); if (!regulators) { dev_info(dev, "regulator node not found\n"); return; -- cgit v1.2.3-55-g7522 From 4c850ead98ec52a00af5bedb3ef75963d914e844 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 8 Oct 2013 19:31:02 +0530 Subject: regulator: tps65090: get regulators node from parent node only As per the devicetree binding document of TPS65090, the "regulators" subnode should be under the parent node, not outside of parent node. Hence to get the regulator node, the correct call is of_get_child_by_name() rather than of_find_node_by_name() which searches the "regulators" node from the parent node to end of DTS file. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/tps65090-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index c8e70451df38..f302d3199fae 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -180,7 +180,7 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( return ERR_PTR(-ENOMEM); } - regulators = of_find_node_by_name(np, "regulators"); + regulators = of_get_child_by_name(np, "regulators"); if (!regulators) { dev_err(&pdev->dev, "regulator node not found\n"); return ERR_PTR(-ENODEV); -- cgit v1.2.3-55-g7522 From 712c967fec612f572d9eea5d031278512f642cf8 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 8 Oct 2013 19:31:03 +0530 Subject: regulator: tps6586x: get regulators node from parent node only As per the devicetree binding document of TPS6586x, the "regulators" subnode should be under the parent node, not outside of parent node. Hence to get the regulator node, the correct call is of_get_child_by_name() rather than of_find_node_by_name() which searches the "regulators" node from the parent node to end of DTS file. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/tps6586x-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 2c9155b66f09..c8e9742a4468 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -298,7 +298,7 @@ static struct tps6586x_platform_data *tps6586x_parse_regulator_dt( struct tps6586x_platform_data *pdata; int err; - regs = of_find_node_by_name(np, "regulators"); + regs = of_get_child_by_name(np, "regulators"); if (!regs) { dev_err(&pdev->dev, "regulator node not found\n"); return NULL; -- cgit v1.2.3-55-g7522 From 4ae1ff7fe8ad70dfe984ea7586ced00294359b47 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 8 Oct 2013 19:31:04 +0530 Subject: regulator: tps65910: get regulators node from parent node only As per the devicetree binding document of TPS65910, the "regulators" subnode should be under the parent node, not outside of parent node. Hence to get the regulator node, the correct call is of_get_child_by_name() rather than of_find_node_by_name() which searches the "regulators" node from the parent node to end of DTS file. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/tps65910-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 45c16447744b..95ebc67a3da4 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -982,7 +982,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( } np = of_node_get(pdev->dev.parent->of_node); - regulators = of_find_node_by_name(np, "regulators"); + regulators = of_get_child_by_name(np, "regulators"); if (!regulators) { dev_err(&pdev->dev, "regulator node not found\n"); return NULL; -- cgit v1.2.3-55-g7522 From 9a633a2bced158c57b73cf4d8e87be60473de1d2 Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Fri, 11 Oct 2013 05:04:12 -0500 Subject: regulator: ti-abb: Fix operator precedence typo commit 40b1936e (regulator: Introduce TI Adaptive Body Bias(ABB) on-chip LDO driver) missed a pair of brackets which cause the wrong vset data to be picked up from efuse, resulting in bad VBB voltage values. Signed-off-by: Nishanth Menon Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- drivers/regulator/ti-abb-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index 20c271d49dcb..b993ec570f66 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -615,7 +615,7 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, pname, *volt_table, vset_mask); continue; } - info->vset = efuse_val & vset_mask >> __ffs(vset_mask); + info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask); dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset); check_abb: switch (info->opp_sel) { -- cgit v1.2.3-55-g7522 From e277e656804c85a0729d4fd8cdd3c8ab3e6b3b86 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 11 Oct 2013 09:30:24 +0800 Subject: regulator: Remove max_uV from struct regulator_linear_range linear ranges means each range has linear voltage settings. So we can calculate max_uV for each linear range in regulator core rather than set the max_uV field in drivers. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/88pm800.c | 14 ++++++-------- drivers/regulator/as3711-regulator.c | 25 +++++++++++-------------- drivers/regulator/as3722-regulator.c | 1 - drivers/regulator/da903x.c | 6 ++---- drivers/regulator/helpers.c | 6 +++++- drivers/regulator/tps65217-regulator.c | 24 ++++++++---------------- drivers/regulator/tps65912-regulator.c | 9 +++------ drivers/regulator/wm831x-ldo.c | 12 ++++-------- drivers/regulator/wm8350-regulator.c | 6 ++---- drivers/regulator/wm8400-regulator.c | 6 ++---- include/linux/regulator/driver.h | 2 -- 11 files changed, 43 insertions(+), 68 deletions(-) diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index 3459f60dcfd1..22ba4c4280ee 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c @@ -141,18 +141,16 @@ struct pm800_regulators { /* Ranges are sorted in ascending order. */ static const struct regulator_linear_range buck1_volt_range[] = { - { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, - .uV_step = 12500 }, - { .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50, - .max_sel = 0x54, .uV_step = 50000 }, + { .min_uV = 600000, .min_sel = 0, .max_sel = 0x4f, .uV_step = 12500 }, + { .min_uV = 1600000, .min_sel = 0x50, .max_sel = 0x54, + .uV_step = 50000 }, }; /* BUCK 2~5 have same ranges. */ static const struct regulator_linear_range buck2_5_volt_range[] = { - { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, - .uV_step = 12500 }, - { .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50, - .max_sel = 0x72, .uV_step = 50000 }, + { .min_uV = 600000, .min_sel = 0, .max_sel = 0x4f, .uV_step = 12500 }, + { .min_uV = 1600000, .min_sel = 0x50, .max_sel = 0x72, + .uV_step = 50000 }, }; static const unsigned int ldo1_volt_table[] = { diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 8406cd745da2..d0a97e5ea431 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c @@ -117,26 +117,23 @@ static struct regulator_ops as3711_dldo_ops = { }; static const struct regulator_linear_range as3711_sd_ranges[] = { - { .min_uV = 612500, .max_uV = 1400000, - .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, - { .min_uV = 1425000, .max_uV = 2600000, - .min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 }, - { .min_uV = 2650000, .max_uV = 3350000, - .min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 }, + { .min_uV = 612500, .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, + { .min_uV = 1425000, .min_sel = 0x41, .max_sel = 0x70, + .uV_step = 25000 }, + { .min_uV = 2650000, .min_sel = 0x71, .max_sel = 0x7f, + .uV_step = 50000 }, }; static const struct regulator_linear_range as3711_aldo_ranges[] = { - { .min_uV = 1200000, .max_uV = 1950000, - .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, - { .min_uV = 1800000, .max_uV = 3300000, - .min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 }, + { .min_uV = 1200000, .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, + { .min_uV = 1800000, .min_sel = 0x10, .max_sel = 0x1f, + .uV_step = 100000 }, }; static const struct regulator_linear_range as3711_dldo_ranges[] = { - { .min_uV = 900000, .max_uV = 1700000, - .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, - { .min_uV = 1750000, .max_uV = 3300000, - .min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 }, + { .min_uV = 900000, .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, + { .min_uV = 1750000, .min_sel = 0x20, .max_sel = 0x3f, + .uV_step = 50000 }, }; #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c index d7b71a9c41f1..240ae6d2ee2a 100644 --- a/drivers/regulator/as3722-regulator.c +++ b/drivers/regulator/as3722-regulator.c @@ -441,7 +441,6 @@ static struct regulator_ops as3722_ldo3_extcntrl_ops = { .max_sel = _max_sel, \ .uV_step = _step_uV, \ .min_uV = _min_uV, \ - .max_uV = _min_uV + (_max_sel - _min_sel) * _step_uV, \ } static const struct regulator_linear_range as3722_ldo_ranges[] = { diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index f06854cf8cf5..90d55e066447 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c @@ -253,10 +253,8 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev, } static const struct regulator_linear_range da9034_ldo12_ranges[] = { - { .min_uV = 1700000, .max_uV = 2050000, .min_sel = 0, .max_sel = 7, - .uV_step = 50000 }, - { .min_uV = 2700000, .max_uV = 3050000, .min_sel = 8, .max_sel = 15, - .uV_step = 50000 }, + { .min_uV = 1700000, .min_sel = 0, .max_sel = 7, .uV_step = 50000 }, + { .min_uV = 2700000, .min_sel = 8, .max_sel = 15, .uV_step = 50000 }, }; static struct regulator_ops da903x_regulator_ldo_ops = { diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index 6e30df14714b..e221a271ba56 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -284,9 +284,13 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev, } for (i = 0; i < rdev->desc->n_linear_ranges; i++) { + int linear_max_uV; + range = &rdev->desc->linear_ranges[i]; + linear_max_uV = range->min_uV + + (range->max_sel - range->min_sel) * range->uV_step; - if (!(min_uV <= range->max_uV && max_uV >= range->min_uV)) + if (!(min_uV <= linear_max_uV && max_uV >= range->min_uV)) continue; if (min_uV <= range->min_uV) diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 90861d68a0b0..484866f43681 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -52,25 +52,17 @@ static const unsigned int LDO1_VSEL_table[] = { }; static const struct regulator_linear_range tps65217_uv1_ranges[] = { - { .min_uV = 900000, .max_uV = 1500000, .min_sel = 0, .max_sel = 24, - .uV_step = 25000 }, - { .min_uV = 1550000, .max_uV = 1800000, .min_sel = 25, .max_sel = 30, - .uV_step = 50000 }, - { .min_uV = 1850000, .max_uV = 2900000, .min_sel = 31, .max_sel = 52, - .uV_step = 50000 }, - { .min_uV = 3000000, .max_uV = 3200000, .min_sel = 53, .max_sel = 55, - .uV_step = 100000 }, - { .min_uV = 3300000, .max_uV = 3300000, .min_sel = 56, .max_sel = 62, - .uV_step = 0 }, + { .min_uV = 900000, .min_sel = 0, .max_sel = 24, .uV_step = 25000 }, + { .min_uV = 1550000, .min_sel = 25, .max_sel = 30, .uV_step = 50000 }, + { .min_uV = 1850000, .min_sel = 31, .max_sel = 52, .uV_step = 50000 }, + { .min_uV = 3000000, .min_sel = 53, .max_sel = 55, .uV_step = 100000 }, + { .min_uV = 3300000, .min_sel = 56, .max_sel = 62, .uV_step = 0 }, }; static const struct regulator_linear_range tps65217_uv2_ranges[] = { - { .min_uV = 1500000, .max_uV = 1900000, .min_sel = 0, .max_sel = 8, - .uV_step = 50000 }, - { .min_uV = 2000000, .max_uV = 2400000, .min_sel = 9, .max_sel = 13, - .uV_step = 100000 }, - { .min_uV = 2450000, .max_uV = 3300000, .min_sel = 14, .max_sel = 31, - .uV_step = 50000 }, + { .min_uV = 1500000, .min_sel = 0, .max_sel = 8, .uV_step = 50000 }, + { .min_uV = 2000000, .min_sel = 9, .max_sel = 13, .uV_step = 100000 }, + { .min_uV = 2450000, .min_sel = 14, .max_sel = 31, .uV_step = 50000 }, }; static int tps65217_pmic_enable(struct regulator_dev *dev) diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index 281e52ac64ba..9fc87d8c9ce5 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c @@ -119,12 +119,9 @@ struct tps65912_reg { }; static const struct regulator_linear_range tps65912_ldo_ranges[] = { - { .min_uV = 800000, .max_uV = 1600000, .min_sel = 0, .max_sel = 32, - .uV_step = 25000 }, - { .min_uV = 1650000, .max_uV = 3000000, .min_sel = 33, .max_sel = 60, - .uV_step = 50000 }, - { .min_uV = 3100000, .max_uV = 3300000, .min_sel = 61, .max_sel = 63, - .uV_step = 100000 }, + { .min_uV = 800000, .min_sel = 0, .max_sel = 32, .uV_step = 25000 }, + { .min_uV = 1650000, .min_sel = 33, .max_sel = 60, .uV_step = 50000 }, + { .min_uV = 3100000, .min_sel = 61, .max_sel = 63, .uV_step = 100000 }, }; static int tps65912_get_range(struct tps65912_reg *pmic, int id) diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 2205fbc2c37b..a95814027b24 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c @@ -63,10 +63,8 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data) */ static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { - { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, - .uV_step = 50000 }, - { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31, - .uV_step = 100000 }, + { .min_uV = 900000, .min_sel = 0, .max_sel = 14, .uV_step = 50000 }, + { .min_uV = 1700000, .min_sel = 15, .max_sel = 31, .uV_step = 100000 }, }; static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, @@ -332,10 +330,8 @@ static struct platform_driver wm831x_gp_ldo_driver = { */ static const struct regulator_linear_range wm831x_aldo_ranges[] = { - { .min_uV = 1000000, .max_uV = 1600000, .min_sel = 0, .max_sel = 12, - .uV_step = 50000 }, - { .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31, - .uV_step = 100000 }, + { .min_uV = 1000000, .min_sel = 0, .max_sel = 12, .uV_step = 50000 }, + { .min_uV = 1700000, .min_sel = 13, .max_sel = 31, .uV_step = 100000 }, }; static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 61ca9292a429..de9de26d0bfc 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c @@ -543,10 +543,8 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev, } static const struct regulator_linear_range wm8350_ldo_ranges[] = { - { .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 15, - .uV_step = 50000 }, - { .min_uV = 1800000, .max_uV = 3300000, .min_sel = 16, .max_sel = 31, - .uV_step = 100000 }, + { .min_uV = 900000, .min_sel = 0, .max_sel = 15, .uV_step = 50000 }, + { .min_uV = 1800000, .min_sel = 16, .max_sel = 31, .uV_step = 100000 }, }; static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 58f51bec13f2..3352b2090ed5 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c @@ -20,10 +20,8 @@ #include static const struct regulator_linear_range wm8400_ldo_ranges[] = { - { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, - .uV_step = 50000 }, - { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31, - .uV_step = 100000 }, + { .min_uV = 900000, .min_sel = 0, .max_sel = 14, .uV_step = 50000 }, + { .min_uV = 1700000, .min_sel = 15, .max_sel = 31, .uV_step = 100000 }, }; static struct regulator_ops wm8400_ldo_ops = { diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 9bdad43ad228..997ff5c4d880 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -46,14 +46,12 @@ enum regulator_status { * regulator_list_linear_range(). * * @min_uV: Lowest voltage in range - * @max_uV: Highest voltage in range * @min_sel: Lowest selector for range * @max_sel: Highest selector for range * @uV_step: Step size */ struct regulator_linear_range { unsigned int min_uV; - unsigned int max_uV; unsigned int min_sel; unsigned int max_sel; unsigned int uV_step; -- cgit v1.2.3-55-g7522 From 8828bae464b129abed95b748263f1ab53bdc5755 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 11 Oct 2013 09:32:18 +0800 Subject: regulator: Add REGULATOR_LINEAR_RANGE macro Add REGULATOR_LINEAR_RANGE macro and convert regulator drivers to use it. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/88pm800.c | 10 ++++------ drivers/regulator/as3711-regulator.c | 18 +++++++----------- drivers/regulator/as3722-regulator.c | 18 +++++------------- drivers/regulator/da903x.c | 4 ++-- drivers/regulator/tps65217-regulator.c | 16 ++++++++-------- drivers/regulator/tps65912-regulator.c | 6 +++--- drivers/regulator/wm831x-ldo.c | 8 ++++---- drivers/regulator/wm8350-regulator.c | 4 ++-- drivers/regulator/wm8400-regulator.c | 4 ++-- include/linux/regulator/driver.h | 9 +++++++++ 10 files changed, 46 insertions(+), 51 deletions(-) diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index 22ba4c4280ee..d333f7eac106 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c @@ -141,16 +141,14 @@ struct pm800_regulators { /* Ranges are sorted in ascending order. */ static const struct regulator_linear_range buck1_volt_range[] = { - { .min_uV = 600000, .min_sel = 0, .max_sel = 0x4f, .uV_step = 12500 }, - { .min_uV = 1600000, .min_sel = 0x50, .max_sel = 0x54, - .uV_step = 50000 }, + REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500), + REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x54, 50000), }; /* BUCK 2~5 have same ranges. */ static const struct regulator_linear_range buck2_5_volt_range[] = { - { .min_uV = 600000, .min_sel = 0, .max_sel = 0x4f, .uV_step = 12500 }, - { .min_uV = 1600000, .min_sel = 0x50, .max_sel = 0x72, - .uV_step = 50000 }, + REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500), + REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x72, 50000), }; static const unsigned int ldo1_volt_table[] = { diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index d0a97e5ea431..f8524f988bdc 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c @@ -117,23 +117,19 @@ static struct regulator_ops as3711_dldo_ops = { }; static const struct regulator_linear_range as3711_sd_ranges[] = { - { .min_uV = 612500, .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, - { .min_uV = 1425000, .min_sel = 0x41, .max_sel = 0x70, - .uV_step = 25000 }, - { .min_uV = 2650000, .min_sel = 0x71, .max_sel = 0x7f, - .uV_step = 50000 }, + REGULATOR_LINEAR_RANGE(612500, 0x1, 0x40, 12500), + REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), + REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7f, 50000), }; static const struct regulator_linear_range as3711_aldo_ranges[] = { - { .min_uV = 1200000, .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, - { .min_uV = 1800000, .min_sel = 0x10, .max_sel = 0x1f, - .uV_step = 100000 }, + REGULATOR_LINEAR_RANGE(1200000, 0, 0xf, 50000), + REGULATOR_LINEAR_RANGE(1800000, 0x10, 0x1f, 100000), }; static const struct regulator_linear_range as3711_dldo_ranges[] = { - { .min_uV = 900000, .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, - { .min_uV = 1750000, .min_sel = 0x20, .max_sel = 0x3f, - .uV_step = 50000 }, + REGULATOR_LINEAR_RANGE(900000, 0, 0x10, 50000), + REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000), }; #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c index 240ae6d2ee2a..5917fe3dc983 100644 --- a/drivers/regulator/as3722-regulator.c +++ b/drivers/regulator/as3722-regulator.c @@ -435,17 +435,9 @@ static struct regulator_ops as3722_ldo3_extcntrl_ops = { .get_current_limit = as3722_ldo3_get_current_limit, }; -#define regulator_lin_range(_min_sel, _max_sel, _min_uV, _step_uV) \ - { \ - .min_sel = _min_sel, \ - .max_sel = _max_sel, \ - .uV_step = _step_uV, \ - .min_uV = _min_uV, \ - } - static const struct regulator_linear_range as3722_ldo_ranges[] = { - regulator_lin_range(0x01, 0x24, 825000, 25000), - regulator_lin_range(0x40, 0x7F, 1725000, 25000), + REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000), + REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000), }; static struct regulator_ops as3722_ldo_ops = { @@ -604,9 +596,9 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, } static const struct regulator_linear_range as3722_sd2345_ranges[] = { - regulator_lin_range(0x01, 0x40, 612500, 12500), - regulator_lin_range(0x41, 0x70, 1425000, 25000), - regulator_lin_range(0x71, 0x7F, 2650000, 50000), + REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), + REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), + REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000), }; static struct regulator_ops as3722_sd016_ops = { diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index 90d55e066447..6d1b799ad86b 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c @@ -253,8 +253,8 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev, } static const struct regulator_linear_range da9034_ldo12_ranges[] = { - { .min_uV = 1700000, .min_sel = 0, .max_sel = 7, .uV_step = 50000 }, - { .min_uV = 2700000, .min_sel = 8, .max_sel = 15, .uV_step = 50000 }, + REGULATOR_LINEAR_RANGE(1700000, 0, 7, 50000), + REGULATOR_LINEAR_RANGE(2700000, 8, 15, 50000), }; static struct regulator_ops da903x_regulator_ldo_ops = { diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 484866f43681..bbc7277fa097 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -52,17 +52,17 @@ static const unsigned int LDO1_VSEL_table[] = { }; static const struct regulator_linear_range tps65217_uv1_ranges[] = { - { .min_uV = 900000, .min_sel = 0, .max_sel = 24, .uV_step = 25000 }, - { .min_uV = 1550000, .min_sel = 25, .max_sel = 30, .uV_step = 50000 }, - { .min_uV = 1850000, .min_sel = 31, .max_sel = 52, .uV_step = 50000 }, - { .min_uV = 3000000, .min_sel = 53, .max_sel = 55, .uV_step = 100000 }, - { .min_uV = 3300000, .min_sel = 56, .max_sel = 62, .uV_step = 0 }, + REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000), + REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000), + REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000), + REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000), + REGULATOR_LINEAR_RANGE(3300000, 56, 62, 0), }; static const struct regulator_linear_range tps65217_uv2_ranges[] = { - { .min_uV = 1500000, .min_sel = 0, .max_sel = 8, .uV_step = 50000 }, - { .min_uV = 2000000, .min_sel = 9, .max_sel = 13, .uV_step = 100000 }, - { .min_uV = 2450000, .min_sel = 14, .max_sel = 31, .uV_step = 50000 }, + REGULATOR_LINEAR_RANGE(1500000, 0, 8, 50000), + REGULATOR_LINEAR_RANGE(2000000, 9, 13, 100000), + REGULATOR_LINEAR_RANGE(2450000, 14, 31, 50000), }; static int tps65217_pmic_enable(struct regulator_dev *dev) diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index 9fc87d8c9ce5..697eab8e74d8 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c @@ -119,9 +119,9 @@ struct tps65912_reg { }; static const struct regulator_linear_range tps65912_ldo_ranges[] = { - { .min_uV = 800000, .min_sel = 0, .max_sel = 32, .uV_step = 25000 }, - { .min_uV = 1650000, .min_sel = 33, .max_sel = 60, .uV_step = 50000 }, - { .min_uV = 3100000, .min_sel = 61, .max_sel = 63, .uV_step = 100000 }, + REGULATOR_LINEAR_RANGE(800000, 0, 32, 25000), + REGULATOR_LINEAR_RANGE(1650000, 33, 60, 50000), + REGULATOR_LINEAR_RANGE(3100000, 61, 63, 100000), }; static int tps65912_get_range(struct tps65912_reg *pmic, int id) diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index a95814027b24..9111b651c353 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c @@ -63,8 +63,8 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data) */ static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { - { .min_uV = 900000, .min_sel = 0, .max_sel = 14, .uV_step = 50000 }, - { .min_uV = 1700000, .min_sel = 15, .max_sel = 31, .uV_step = 100000 }, + REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), + REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), }; static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, @@ -330,8 +330,8 @@ static struct platform_driver wm831x_gp_ldo_driver = { */ static const struct regulator_linear_range wm831x_aldo_ranges[] = { - { .min_uV = 1000000, .min_sel = 0, .max_sel = 12, .uV_step = 50000 }, - { .min_uV = 1700000, .min_sel = 13, .max_sel = 31, .uV_step = 100000 }, + REGULATOR_LINEAR_RANGE(1000000, 0, 12, 50000), + REGULATOR_LINEAR_RANGE(1700000, 13, 31, 100000), }; static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index de9de26d0bfc..3827539f3ad7 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c @@ -543,8 +543,8 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev, } static const struct regulator_linear_range wm8350_ldo_ranges[] = { - { .min_uV = 900000, .min_sel = 0, .max_sel = 15, .uV_step = 50000 }, - { .min_uV = 1800000, .min_sel = 16, .max_sel = 31, .uV_step = 100000 }, + REGULATOR_LINEAR_RANGE(900000, 0, 15, 50000), + REGULATOR_LINEAR_RANGE(1800000, 16, 31, 100000), }; static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 3352b2090ed5..8eedba2953f9 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c @@ -20,8 +20,8 @@ #include static const struct regulator_linear_range wm8400_ldo_ranges[] = { - { .min_uV = 900000, .min_sel = 0, .max_sel = 14, .uV_step = 50000 }, - { .min_uV = 1700000, .min_sel = 15, .max_sel = 31, .uV_step = 100000 }, + REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), + REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), }; static struct regulator_ops wm8400_ldo_ops = { diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 997ff5c4d880..edb11b716dd3 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -57,6 +57,15 @@ struct regulator_linear_range { unsigned int uV_step; }; +/* Initialize struct regulator_linear_range */ +#define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \ +{ \ + .min_uV = _min_uV, \ + .min_sel = _min_sel, \ + .max_sel = _max_sel, \ + .uV_step = _step_uV, \ +} + /** * struct regulator_ops - regulator operations. * -- cgit v1.2.3-55-g7522 From 34f7568510564726d33fe8248736ece7d76d0054 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:45:51 +0900 Subject: regulator: anatop: Fix checkpatch issue Fix the following checkpatch warning. WARNING: quoted string split across lines Signed-off-by: Jingoo Han Acked-by: Shawn Guo Signed-off-by: Mark Brown --- drivers/regulator/anatop-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 0d4a8ccbb536..75a9c7875a7a 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -256,7 +256,7 @@ static void __exit anatop_regulator_exit(void) } module_exit(anatop_regulator_exit); -MODULE_AUTHOR("Nancy Chen , " - "Ying-Chun Liu (PaulLiu) "); +MODULE_AUTHOR("Nancy Chen "); +MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) "); MODULE_DESCRIPTION("ANATOP Regulator driver"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3-55-g7522 From 609d5f6ddc18d05801646c869fcf4d0537b9110b Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:46:36 +0900 Subject: regulator: fixed: Fix checkpatch issue Fix the following checkpatch warnings. WARNING: braces {} are not necessary for any arm of this statement Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/fixed.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index de811f3b921b..5ea64b94341c 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -168,17 +168,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) cfg.ena_gpio = config->gpio; cfg.ena_gpio_invert = !config->enable_high; if (config->enabled_at_boot) { - if (config->enable_high) { + if (config->enable_high) cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; - } else { + else cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; - } } else { - if (config->enable_high) { + if (config->enable_high) cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; - } else { + else cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; - } } if (config->gpio_is_open_drain) cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; -- cgit v1.2.3-55-g7522 From 0a3ee93a3226a951dc32197f6fcfb1b535fbabf4 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:47:31 +0900 Subject: regulator: lp3971: Fix checkpatch issue Fix the following checkpatch warnings. WARNING: please, no spaces at the start of a line Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/lp3971.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 5a4604ee5ea5..947c05ffe0ab 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c @@ -474,8 +474,8 @@ static int lp3971_i2c_remove(struct i2c_client *i2c) } static const struct i2c_device_id lp3971_i2c_id[] = { - { "lp3971", 0 }, - { } + { "lp3971", 0 }, + { } }; MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id); -- cgit v1.2.3-55-g7522 From c4e3b1442a77e7fd7459168894f6416f00542f74 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:49:11 +0900 Subject: regulator: max8997: Fix checkpatch issue Fix the following checkpatch warning. WARNING: quoted string split across lines Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/max8997.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index df20069f0537..e789b4b96469 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c @@ -690,8 +690,9 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, if (max8997->ignore_gpiodvs_side_effect == false) return -EINVAL; - dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:" - " %d -> %d\n", max8997->buck125_gpioindex, tmp_idx); + dev_warn(&rdev->dev, + "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET: %d -> %d\n", + max8997->buck125_gpioindex, tmp_idx); out: if (new_idx < 0 || new_val < 0) -- cgit v1.2.3-55-g7522 From 6e044c3fa87e310f24ec8062d7d6954180761fea Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:49:55 +0900 Subject: regulator: mc13783: Fix checkpatch issue Fix the following checkpatch warnings. WARNING: Avoid unnecessary line continuations Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/mc13783-regulator.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 5ff99d2703db..4921bcbf711b 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c @@ -258,34 +258,34 @@ static struct mc13xxx_regulator mc13783_regulators[] = { MC13783_FIXED_DEFINE(REG, VAUDIO, REGULATORMODE0, mc13783_vaudio_val), MC13783_FIXED_DEFINE(REG, VIOHI, REGULATORMODE0, mc13783_viohi_val), - MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0, REGULATORSETTING0, mc13783_violo_val), - MC13783_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, mc13783_vdig_val), - MC13783_DEFINE_REGU(VGEN, REGULATORMODE0, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VGEN, REGULATORMODE0, REGULATORSETTING0, mc13783_vgen_val), - MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0, REGULATORSETTING0, mc13783_vrfdig_val), - MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0, REGULATORSETTING0, mc13783_vrfref_val), - MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0, REGULATORSETTING0, mc13783_vrfcp_val), - MC13783_DEFINE_REGU(VSIM, REGULATORMODE1, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VSIM, REGULATORMODE1, REGULATORSETTING0, mc13783_vsim_val), - MC13783_DEFINE_REGU(VESIM, REGULATORMODE1, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VESIM, REGULATORMODE1, REGULATORSETTING0, mc13783_vesim_val), - MC13783_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, \ + MC13783_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, mc13783_vcam_val), MC13783_FIXED_DEFINE(REG, VRFBG, REGULATORMODE1, mc13783_vrfbg_val), - MC13783_DEFINE_REGU(VVIB, REGULATORMODE1, REGULATORSETTING1, \ + MC13783_DEFINE_REGU(VVIB, REGULATORMODE1, REGULATORSETTING1, mc13783_vvib_val), - MC13783_DEFINE_REGU(VRF1, REGULATORMODE1, REGULATORSETTING1, \ + MC13783_DEFINE_REGU(VRF1, REGULATORMODE1, REGULATORSETTING1, mc13783_vrf_val), - MC13783_DEFINE_REGU(VRF2, REGULATORMODE1, REGULATORSETTING1, \ + MC13783_DEFINE_REGU(VRF2, REGULATORMODE1, REGULATORSETTING1, mc13783_vrf_val), - MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1, REGULATORSETTING1, \ + MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1, REGULATORSETTING1, mc13783_vmmc_val), - MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1, REGULATORSETTING1, \ + MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1, REGULATORSETTING1, mc13783_vmmc_val), MC13783_GPO_DEFINE(REG, GPO1, POWERMISC, mc13783_gpo_val), MC13783_GPO_DEFINE(REG, GPO2, POWERMISC, mc13783_gpo_val), -- cgit v1.2.3-55-g7522 From 4932e89d75f7b946d2f03a0157b8b9f6a0e12e10 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:51:51 +0900 Subject: regulator: tps6105x: Fix checkpatch issue Fix the following checkpatch warning. WARNING: unnecessary whitespace before a quoted newline Signed-off-by: Jingoo Han Acked-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/tps6105x-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c index ec9453ffb77f..3346e78fb960 100644 --- a/drivers/regulator/tps6105x-regulator.c +++ b/drivers/regulator/tps6105x-regulator.c @@ -137,7 +137,7 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) /* This instance is not set for regulator mode so bail out */ if (pdata->mode != TPS6105X_MODE_VOLTAGE) { dev_info(&pdev->dev, - "chip not in voltage mode mode, exit probe \n"); + "chip not in voltage mode mode, exit probe\n"); return 0; } -- cgit v1.2.3-55-g7522 From 5ee034e614a9e115763fa8d50ae18bf6a13b21d1 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:52:45 +0900 Subject: regulator: tps65023: Fix checkpatch issue Fix the following checkpatch warning. WARNING: line over 80 characters Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/tps65023-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index a15263d4bdff..f6e398240686 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c @@ -293,7 +293,8 @@ static int tps_65023_probe(struct i2c_client *client, /* Enable setting output voltage by I2C */ regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, - TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); + TPS65023_REG_CTRL2_CORE_ADJ, + TPS65023_REG_CTRL2_CORE_ADJ); return 0; -- cgit v1.2.3-55-g7522 From 4b57927045c30d8f8579a43177459782f45f5468 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 14 Oct 2013 17:53:40 +0900 Subject: regulator: tps65910: Fix checkpatch issue Fix the following checkpatch errors and warning. ERROR: spaces required around that '=' (ctx:VxV) ERROR: space required before the open parenthesis '(' WARNING: line over 80 characters Signed-off-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/regulator/tps65910-regulator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 95ebc67a3da4..10615d2a32e1 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -481,7 +481,7 @@ static int tps65910_get_voltage_dcdc_sel(struct regulator_dev *dev) /* multiplier 0 == 1 but 2,3 normal */ if (!mult) - mult=1; + mult = 1; if (sr) { /* normalise to valid range */ @@ -685,7 +685,7 @@ static int tps65910_list_voltage_dcdc(struct regulator_dev *dev, case TPS65910_REG_VDD2: mult = (selector / VDD1_2_NUM_VOLT_FINE) + 1; volt = VDD1_2_MIN_VOLT + - (selector % VDD1_2_NUM_VOLT_FINE) * VDD1_2_OFFSET; + (selector % VDD1_2_NUM_VOLT_FINE) * VDD1_2_OFFSET; break; case TPS65911_REG_VDDCTRL: volt = VDDCTRL_MIN_VOLT + (selector * VDDCTRL_OFFSET); @@ -703,7 +703,7 @@ static int tps65911_list_voltage(struct regulator_dev *dev, unsigned selector) struct tps65910_reg *pmic = rdev_get_drvdata(dev); int step_mv = 0, id = rdev_get_id(dev); - switch(id) { + switch (id) { case TPS65911_REG_LDO1: case TPS65911_REG_LDO2: case TPS65911_REG_LDO4: @@ -1074,7 +1074,7 @@ static int tps65910_probe(struct platform_device *pdev) tps65910_reg_set_bits(pmic->mfd, TPS65910_DEVCTRL, DEVCTRL_SR_CTL_I2C_SEL_MASK); - switch(tps65910_chip_id(tps65910)) { + switch (tps65910_chip_id(tps65910)) { case TPS65910: pmic->get_ctrl_reg = &tps65910_get_ctrl_register; pmic->num_regulators = ARRAY_SIZE(tps65910_regs); -- cgit v1.2.3-55-g7522 From a06ccd9c3785fa5550917ae036944f4e080b5749 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 15 Oct 2013 20:14:20 +0100 Subject: regulator: core: Add ability to create a lookup alias for supply These patches add the ability to create an alternative device on which a lookup for a certain supply should be conducted. A common use-case for this would be devices that are logically represented as a collection of drivers within Linux but are are presented as a single device from device tree. It this case it is necessary for each sub device to locate their supply data on the main device. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/regulator/core.c | 170 +++++++++++++++++++++++++++++++++++++ drivers/regulator/devres.c | 163 +++++++++++++++++++++++++++++++++++ include/linux/regulator/consumer.h | 79 +++++++++++++++++ 3 files changed, 412 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 906deb7354ed..16427de56ce8 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -53,6 +53,7 @@ static DEFINE_MUTEX(regulator_list_mutex); static LIST_HEAD(regulator_list); static LIST_HEAD(regulator_map_list); static LIST_HEAD(regulator_ena_gpio_list); +static LIST_HEAD(regulator_supply_alias_list); static bool has_full_constraints; static bool board_wants_dummy_regulator; @@ -83,6 +84,19 @@ struct regulator_enable_gpio { unsigned int ena_gpio_invert:1; }; +/* + * struct regulator_supply_alias + * + * Used to map lookups for a supply onto an alternative device. + */ +struct regulator_supply_alias { + struct list_head list; + struct device *src_dev; + const char *src_supply; + struct device *alias_dev; + const char *alias_supply; +}; + static int _regulator_is_enabled(struct regulator_dev *rdev); static int _regulator_disable(struct regulator_dev *rdev); static int _regulator_get_voltage(struct regulator_dev *rdev); @@ -1173,6 +1187,32 @@ static int _regulator_get_enable_time(struct regulator_dev *rdev) return rdev->desc->ops->enable_time(rdev); } +static struct regulator_supply_alias *regulator_find_supply_alias( + struct device *dev, const char *supply) +{ + struct regulator_supply_alias *map; + + list_for_each_entry(map, ®ulator_supply_alias_list, list) + if (map->src_dev == dev && strcmp(map->src_supply, supply) == 0) + return map; + + return NULL; +} + +static void regulator_supply_alias(struct device **dev, const char **supply) +{ + struct regulator_supply_alias *map; + + map = regulator_find_supply_alias(*dev, *supply); + if (map) { + dev_dbg(*dev, "Mapping supply %s to %s,%s\n", + *supply, map->alias_supply, + dev_name(map->alias_dev)); + *dev = map->alias_dev; + *supply = map->alias_supply; + } +} + static struct regulator_dev *regulator_dev_lookup(struct device *dev, const char *supply, int *ret) @@ -1182,6 +1222,8 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, struct regulator_map *map; const char *devname = NULL; + regulator_supply_alias(&dev, &supply); + /* first do a dt based lookup */ if (dev && dev->of_node) { node = of_get_regulator(dev, supply); @@ -1432,6 +1474,134 @@ void regulator_put(struct regulator *regulator) } EXPORT_SYMBOL_GPL(regulator_put); +/** + * regulator_register_supply_alias - Provide device alias for supply lookup + * + * @dev: device that will be given as the regulator "consumer" + * @id: Supply name or regulator ID + * @alias_dev: device that should be used to lookup the supply + * @alias_id: Supply name or regulator ID that should be used to lookup the + * supply + * + * All lookups for id on dev will instead be conducted for alias_id on + * alias_dev. + */ +int regulator_register_supply_alias(struct device *dev, const char *id, + struct device *alias_dev, + const char *alias_id) +{ + struct regulator_supply_alias *map; + + map = regulator_find_supply_alias(dev, id); + if (map) + return -EEXIST; + + map = kzalloc(sizeof(struct regulator_supply_alias), GFP_KERNEL); + if (!map) + return -ENOMEM; + + map->src_dev = dev; + map->src_supply = id; + map->alias_dev = alias_dev; + map->alias_supply = alias_id; + + list_add(&map->list, ®ulator_supply_alias_list); + + pr_info("Adding alias for supply %s,%s -> %s,%s\n", + id, dev_name(dev), alias_id, dev_name(alias_dev)); + + return 0; +} +EXPORT_SYMBOL_GPL(regulator_register_supply_alias); + +/** + * regulator_unregister_supply_alias - Remove device alias + * + * @dev: device that will be given as the regulator "consumer" + * @id: Supply name or regulator ID + * + * Remove a lookup alias if one exists for id on dev. + */ +void regulator_unregister_supply_alias(struct device *dev, const char *id) +{ + struct regulator_supply_alias *map; + + map = regulator_find_supply_alias(dev, id); + if (map) { + list_del(&map->list); + kfree(map); + } +} +EXPORT_SYMBOL_GPL(regulator_unregister_supply_alias); + +/** + * regulator_bulk_register_supply_alias - register multiple aliases + * + * @dev: device that will be given as the regulator "consumer" + * @id: List of supply names or regulator IDs + * @alias_dev: device that should be used to lookup the supply + * @alias_id: List of supply names or regulator IDs that should be used to + * lookup the supply + * @num_id: Number of aliases to register + * + * @return 0 on success, an errno on failure. + * + * This helper function allows drivers to register several supply + * aliases in one operation. If any of the aliases cannot be + * registered any aliases that were registered will be removed + * before returning to the caller. + */ +int regulator_bulk_register_supply_alias(struct device *dev, const char **id, + struct device *alias_dev, + const char **alias_id, + int num_id) +{ + int i; + int ret; + + for (i = 0; i < num_id; ++i) { + ret = regulator_register_supply_alias(dev, id[i], alias_dev, + alias_id[i]); + if (ret < 0) + goto err; + } + + return 0; + +err: + dev_err(dev, + "Failed to create supply alias %s,%s -> %s,%s\n", + id[i], dev_name(dev), alias_id[i], dev_name(alias_dev)); + + while (--i >= 0) + regulator_unregister_supply_alias(dev, id[i]); + + return ret; +} +EXPORT_SYMBOL_GPL(regulator_bulk_register_supply_alias); + +/** + * regulator_bulk_unregister_supply_alias - unregister multiple aliases + * + * @dev: device that will be given as the regulator "consumer" + * @id: List of supply names or regulator IDs + * @num_id: Number of aliases to unregister + * + * This helper function allows drivers to unregister several supply + * aliases in one operation. + */ +void regulator_bulk_unregister_supply_alias(struct device *dev, + const char **id, + int num_id) +{ + int i; + + for (i = 0; i < num_id; ++i) + regulator_unregister_supply_alias(dev, id[i]); +} +EXPORT_SYMBOL_GPL(regulator_bulk_unregister_supply_alias); + + /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ static int regulator_ena_gpio_request(struct regulator_dev *rdev, const struct regulator_config *config) diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c index 2672a029fa25..f44818b838dc 100644 --- a/drivers/regulator/devres.c +++ b/drivers/regulator/devres.c @@ -250,3 +250,166 @@ void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) WARN_ON(rc); } EXPORT_SYMBOL_GPL(devm_regulator_unregister); + +struct regulator_supply_alias_match { + struct device *dev; + const char *id; +}; + +static int devm_regulator_match_supply_alias(struct device *dev, void *res, + void *data) +{ + struct regulator_supply_alias_match *match = res; + struct regulator_supply_alias_match *target = data; + + return match->dev == target->dev && strcmp(match->id, target->id) == 0; +} + +static void devm_regulator_destroy_supply_alias(struct device *dev, void *res) +{ + struct regulator_supply_alias_match *match = res; + + regulator_unregister_supply_alias(match->dev, match->id); +} + +/** + * devm_regulator_register_supply_alias - Resource managed + * regulator_register_supply_alias() + * + * @dev: device that will be given as the regulator "consumer" + * @id: Supply name or regulator ID + * @alias_dev: device that should be used to lookup the supply + * @alias_id: Supply name or regulator ID that should be used to lookup the + * supply + * + * The supply alias will automatically be unregistered when the source + * device is unbound. + */ +int devm_regulator_register_supply_alias(struct device *dev, const char *id, + struct device *alias_dev, + const char *alias_id) +{ + struct regulator_supply_alias_match *match; + int ret; + + match = devres_alloc(devm_regulator_destroy_supply_alias, + sizeof(struct regulator_supply_alias_match), + GFP_KERNEL); + if (!match) + return -ENOMEM; + + match->dev = dev; + match->id = id; + + ret = regulator_register_supply_alias(dev, id, alias_dev, alias_id); + if (ret < 0) { + devres_free(match); + return ret; + } + + devres_add(dev, match); + + return 0; +} +EXPORT_SYMBOL_GPL(devm_regulator_register_supply_alias); + +/** + * devm_regulator_unregister_supply_alias - Resource managed + * regulator_unregister_supply_alias() + * + * @dev: device that will be given as the regulator "consumer" + * @id: Supply name or regulator ID + * + * Unregister an alias registered with + * devm_regulator_register_supply_alias(). Normally this function + * will not need to be called and the resource management code + * will ensure that the resource is freed. + */ +void devm_regulator_unregister_supply_alias(struct device *dev, const char *id) +{ + struct regulator_supply_alias_match match; + int rc; + + match.dev = dev; + match.id = id; + + rc = devres_release(dev, devm_regulator_destroy_supply_alias, + devm_regulator_match_supply_alias, &match); + if (rc != 0) + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_regulator_unregister_supply_alias); + +/** + * devm_regulator_bulk_register_supply_alias - Managed register + * multiple aliases + * + * @dev: device that will be given as the regulator "consumer" + * @id: List of supply names or regulator IDs + * @alias_dev: device that should be used to lookup the supply + * @alias_id: List of supply names or regulator IDs that should be used to + * lookup the supply + * @num_id: Number of aliases to register + * + * @return 0 on success, an errno on failure. + * + * This helper function allows drivers to register several supply + * aliases in one operation, the aliases will be automatically + * unregisters when the source device is unbound. If any of the + * aliases cannot be registered any aliases that were registered + * will be removed before returning to the caller. + */ +int devm_regulator_bulk_register_supply_alias(struct device *dev, + const char **id, + struct device *alias_dev, + const char **alias_id, + int num_id) +{ + int i; + int ret; + + for (i = 0; i < num_id; ++i) { + ret = devm_regulator_register_supply_alias(dev, id[i], + alias_dev, + alias_id[i]); + if (ret < 0) + goto err; + } + + return 0; + +err: + dev_err(dev, + "Failed to create supply alias %s,%s -> %s,%s\n", + id[i], dev_name(dev), alias_id[i], dev_name(alias_dev)); + + while (--i >= 0) + devm_regulator_unregister_supply_alias(dev, id[i]); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_regulator_bulk_register_supply_alias); + +/** + * devm_regulator_bulk_unregister_supply_alias - Managed unregister + * multiple aliases + * + * @dev: device that will be given as the regulator "consumer" + * @id: List of supply names or regulator IDs + * @num_id: Number of aliases to unregister + * + * Unregister aliases registered with + * devm_regulator_bulk_register_supply_alias(). Normally this function + * will not need to be called and the resource management code + * will ensure that the resource is freed. + */ +void devm_regulator_bulk_unregister_supply_alias(struct device *dev, + const char **id, + int num_id) +{ + int i; + + for (i = 0; i < num_id; ++i) + devm_regulator_unregister_supply_alias(dev, id[i]); +} +EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias); diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 27be915caa96..e530681bea70 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -146,6 +146,32 @@ struct regulator *__must_check devm_regulator_get_optional(struct device *dev, void regulator_put(struct regulator *regulator); void devm_regulator_put(struct regulator *regulator); +int regulator_register_supply_alias(struct device *dev, const char *id, + struct device *alias_dev, + const char *alias_id); +void regulator_unregister_supply_alias(struct device *dev, const char *id); + +int regulator_bulk_register_supply_alias(struct device *dev, const char **id, + struct device *alias_dev, + const char **alias_id, int num_id); +void regulator_bulk_unregister_supply_alias(struct device *dev, + const char **id, int num_id); + +int devm_regulator_register_supply_alias(struct device *dev, const char *id, + struct device *alias_dev, + const char *alias_id); +void devm_regulator_unregister_supply_alias(struct device *dev, + const char *id); + +int devm_regulator_bulk_register_supply_alias(struct device *dev, + const char **id, + struct device *alias_dev, + const char **alias_id, + int num_id); +void devm_regulator_bulk_unregister_supply_alias(struct device *dev, + const char **id, + int num_id); + /* regulator output control and status */ int __must_check regulator_enable(struct regulator *regulator); int regulator_disable(struct regulator *regulator); @@ -250,6 +276,59 @@ static inline void devm_regulator_put(struct regulator *regulator) { } +static inline int regulator_register_supply_alias(struct device *dev, + const char *id, + struct device *alias_dev, + const char *alias_id) +{ + return 0; +} + +static inline void regulator_unregister_supply_alias(struct device *dev, + const char *id) +{ +} + +static inline int regulator_bulk_register_supply_alias(struct device *dev, + const char **id, + struct device *alias_dev, + const char **alias_id, + int num_id) +{ + return 0; +} + +static inline void regulator_bulk_unregister_supply_alias(struct device *dev, + const char **id, + int num_id) +{ +} + +static inline int devm_regulator_register_supply_alias(struct device *dev, + const char *id, + struct device *alias_dev, + const char *alias_id) +{ + return 0; +} + +static inline void devm_regulator_unregister_supply_alias(struct device *dev, + const char *id) +{ +} + +static inline int devm_regulator_bulk_register_supply_alias( + struct device *dev, const char **id, struct device *alias_dev, + const char **alias_id, int num_id) +{ + return 0; +} + +static inline void devm_regulator_bulk_unregister_supply_alias( + struct device *dev, const char **id, int num_id) +{ +} + static inline int regulator_enable(struct regulator *regulator) { return 0; -- cgit v1.2.3-55-g7522 From 7fcd427465e710d0c4e2737d2f02b2ffa14b9bb3 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 15 Oct 2013 20:14:21 +0100 Subject: mfd: Allow mapping regulator supplies to MFD device from children Occasionally, it is useful to map supplies from a child device onto the MFD device. A typical usecase for this would be if the MFD device is represented as a single node in device tree. All supplies will be defined in device tree as existing on the MFD device. When a child depends on frameworks which might have no knowledge of MFD to lookup supplies on its behalf the supply will not be found. This patch adds a list of supplies that should be looked up on the parent rather than the child as part of the mfd_cell structure. Signed-off-by: Charles Keepax Acked-by: Lee Jones Signed-off-by: Mark Brown --- drivers/mfd/mfd-core.c | 22 +++++++++++++++++----- include/linux/mfd/core.h | 6 ++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index f421586f29fb..adc8ea36e7c4 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -20,6 +20,7 @@ #include #include #include +#include static struct device_type mfd_dev_type = { .name = "mfd_device", @@ -99,6 +100,13 @@ static int mfd_add_device(struct device *parent, int id, pdev->dev.dma_mask = parent->dma_mask; pdev->dev.dma_parms = parent->dma_parms; + ret = devm_regulator_bulk_register_supply_alias( + &pdev->dev, cell->parent_supplies, + parent, cell->parent_supplies, + cell->num_parent_supplies); + if (ret < 0) + goto fail_res; + if (parent->of_node && cell->of_compatible) { for_each_child_of_node(parent->of_node, np) { if (of_device_is_compatible(np, cell->of_compatible)) { @@ -112,12 +120,12 @@ static int mfd_add_device(struct device *parent, int id, ret = platform_device_add_data(pdev, cell->platform_data, cell->pdata_size); if (ret) - goto fail_res; + goto fail_alias; } ret = mfd_platform_add_cell(pdev, cell); if (ret) - goto fail_res; + goto fail_alias; for (r = 0; r < cell->num_resources; r++) { res[r].name = cell->resources[r].name; @@ -152,17 +160,17 @@ static int mfd_add_device(struct device *parent, int id, if (!cell->ignore_resource_conflicts) { ret = acpi_check_resource_conflict(&res[r]); if (ret) - goto fail_res; + goto fail_alias; } } ret = platform_device_add_resources(pdev, res, cell->num_resources); if (ret) - goto fail_res; + goto fail_alias; ret = platform_device_add(pdev); if (ret) - goto fail_res; + goto fail_alias; if (cell->pm_runtime_no_callbacks) pm_runtime_no_callbacks(&pdev->dev); @@ -171,6 +179,10 @@ static int mfd_add_device(struct device *parent, int id, return 0; +fail_alias: + devm_regulator_bulk_unregister_supply_alias(&pdev->dev, + cell->parent_supplies, + cell->num_parent_supplies); fail_res: kfree(res); fail_device: diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index cebe97ee98b8..7314fc4e6d25 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -59,6 +59,12 @@ struct mfd_cell { * pm_runtime_no_callbacks(). */ bool pm_runtime_no_callbacks; + + /* A list of regulator supplies that should be mapped to the MFD + * device rather than the child device when requested + */ + const char **parent_supplies; + int num_parent_supplies; }; /* -- cgit v1.2.3-55-g7522 From 32dadef2190efd2e06331825b11881daf100d6d9 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 15 Oct 2013 20:14:22 +0100 Subject: mfd: arizona: Specify supply mappings for Arizona CODECs The CODEC power supplies should be looked up on the Arizona device as they will be created here by device tree also update the only user of non-device tree bindings. Signed-off-by: Charles Keepax Acked-by: Lee Jones Signed-off-by: Mark Brown --- arch/arm/mach-s3c64xx/mach-crag6410.c | 12 ------------ drivers/mfd/arizona-core.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index eb8e5a1aca42..f27ca3b89f4c 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -310,10 +310,6 @@ static struct regulator_consumer_supply wallvdd_consumers[] = { REGULATOR_SUPPLY("SPKVDDL", "spi0.1"), REGULATOR_SUPPLY("SPKVDDR", "spi0.1"), - REGULATOR_SUPPLY("SPKVDDL", "wm5102-codec"), - REGULATOR_SUPPLY("SPKVDDR", "wm5102-codec"), - REGULATOR_SUPPLY("SPKVDDL", "wm5110-codec"), - REGULATOR_SUPPLY("SPKVDDR", "wm5110-codec"), REGULATOR_SUPPLY("DC1VDD", "0-0034"), REGULATOR_SUPPLY("DC2VDD", "0-0034"), @@ -653,14 +649,6 @@ static struct regulator_consumer_supply pvdd_1v8_consumers[] = { REGULATOR_SUPPLY("DBVDD3", "spi0.1"), REGULATOR_SUPPLY("LDOVDD", "spi0.1"), REGULATOR_SUPPLY("CPVDD", "spi0.1"), - - REGULATOR_SUPPLY("DBVDD2", "wm5102-codec"), - REGULATOR_SUPPLY("DBVDD3", "wm5102-codec"), - REGULATOR_SUPPLY("CPVDD", "wm5102-codec"), - - REGULATOR_SUPPLY("DBVDD2", "wm5110-codec"), - REGULATOR_SUPPLY("DBVDD3", "wm5110-codec"), - REGULATOR_SUPPLY("CPVDD", "wm5110-codec"), }; static struct regulator_init_data pvdd_1v8 = { diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 5ac3aa48473b..022b1863d36c 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -569,13 +569,25 @@ static struct mfd_cell early_devs[] = { { .name = "arizona-ldo1" }, }; +static const char *wm5102_supplies[] = { + "DBVDD2", + "DBVDD3", + "CPVDD", + "SPKVDDL", + "SPKVDDR", +}; + static struct mfd_cell wm5102_devs[] = { { .name = "arizona-micsupp" }, { .name = "arizona-extcon" }, { .name = "arizona-gpio" }, { .name = "arizona-haptics" }, { .name = "arizona-pwm" }, - { .name = "wm5102-codec" }, + { + .name = "wm5102-codec", + .parent_supplies = wm5102_supplies, + .num_parent_supplies = ARRAY_SIZE(wm5102_supplies), + }, }; static struct mfd_cell wm5110_devs[] = { @@ -584,7 +596,17 @@ static struct mfd_cell wm5110_devs[] = { { .name = "arizona-gpio" }, { .name = "arizona-haptics" }, { .name = "arizona-pwm" }, - { .name = "wm5110-codec" }, + { + .name = "wm5110-codec", + .parent_supplies = wm5102_supplies, + .num_parent_supplies = ARRAY_SIZE(wm5102_supplies), + }, +}; + +static const char *wm8997_supplies[] = { + "DBVDD2", + "CPVDD", + "SPKVDD", }; static struct mfd_cell wm8997_devs[] = { @@ -593,7 +615,11 @@ static struct mfd_cell wm8997_devs[] = { { .name = "arizona-gpio" }, { .name = "arizona-haptics" }, { .name = "arizona-pwm" }, - { .name = "wm8997-codec" }, + { + .name = "wm8997-codec", + .parent_supplies = wm8997_supplies, + .num_parent_supplies = ARRAY_SIZE(wm8997_supplies), + }, }; int arizona_dev_init(struct arizona *arizona) -- cgit v1.2.3-55-g7522 From d706b1e4930fec12cc3b8d6e0e28d9e8321abcea Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 16 Oct 2013 17:33:59 +0800 Subject: regulator: da9052: Revert se apply_[reg|bit] with regmap based voltage_sel operations This reverts commit 68f7506017ba67f1334cf086ffab76606f2c5ac4. Michael reported that with this patch we loose the fix_io code path from da9052_reg_update. Thus revert it. Reported-by: Michael Grzeschik Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/da9052-regulator.c | 41 ++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 1e4d483f6163..e4bbe64ca867 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c @@ -70,6 +70,7 @@ struct da9052_regulator_info { int step_uV; int min_uV; int max_uV; + unsigned char activate_bit; }; struct da9052_regulator { @@ -209,6 +210,36 @@ static int da9052_map_voltage(struct regulator_dev *rdev, return sel; } +static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev, + unsigned int selector) +{ + struct da9052_regulator *regulator = rdev_get_drvdata(rdev); + struct da9052_regulator_info *info = regulator->info; + int id = rdev_get_id(rdev); + int ret; + + ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg, + rdev->desc->vsel_mask, selector); + if (ret < 0) + return ret; + + /* Some LDOs and DCDCs are DVC controlled which requires enabling of + * the activate bit to implment the changes on the output. + */ + switch (id) { + case DA9052_ID_BUCK1: + case DA9052_ID_BUCK2: + case DA9052_ID_BUCK3: + case DA9052_ID_LDO2: + case DA9052_ID_LDO3: + ret = da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG, + info->activate_bit, info->activate_bit); + break; + } + + return ret; +} + static struct regulator_ops da9052_dcdc_ops = { .get_current_limit = da9052_dcdc_get_current_limit, .set_current_limit = da9052_dcdc_set_current_limit, @@ -216,7 +247,7 @@ static struct regulator_ops da9052_dcdc_ops = { .list_voltage = da9052_list_voltage, .map_voltage = da9052_map_voltage, .get_voltage_sel = regulator_get_voltage_sel_regmap, - .set_voltage_sel = regulator_set_voltage_sel_regmap, + .set_voltage_sel = da9052_regulator_set_voltage_sel, .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, @@ -226,7 +257,7 @@ static struct regulator_ops da9052_ldo_ops = { .list_voltage = da9052_list_voltage, .map_voltage = da9052_map_voltage, .get_voltage_sel = regulator_get_voltage_sel_regmap, - .set_voltage_sel = regulator_set_voltage_sel_regmap, + .set_voltage_sel = da9052_regulator_set_voltage_sel, .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, @@ -243,14 +274,13 @@ static struct regulator_ops da9052_ldo_ops = { .owner = THIS_MODULE,\ .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ .vsel_mask = (1 << (sbits)) - 1,\ - .apply_reg = DA9052_SUPPLY_REG, \ - .apply_bit = (abits), \ .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ .enable_mask = 1 << (ebits),\ },\ .min_uV = (min) * 1000,\ .max_uV = (max) * 1000,\ .step_uV = (step) * 1000,\ + .activate_bit = (abits),\ } #define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \ @@ -264,14 +294,13 @@ static struct regulator_ops da9052_ldo_ops = { .owner = THIS_MODULE,\ .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ .vsel_mask = (1 << (sbits)) - 1,\ - .apply_reg = DA9052_SUPPLY_REG, \ - .apply_bit = (abits), \ .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ .enable_mask = 1 << (ebits),\ },\ .min_uV = (min) * 1000,\ .max_uV = (max) * 1000,\ .step_uV = (step) * 1000,\ + .activate_bit = (abits),\ } static struct da9052_regulator_info da9052_regulator_info[] = { -- cgit v1.2.3-55-g7522 From 033054e8603036e43ddfad3155b3e5b78ed49e04 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 10 Oct 2013 10:41:35 +0900 Subject: regulator: s5m8767: Modify parse_dt function to parse data related to ramp This patch parse 'buck[2-4]_ramp_enable and buck_ramp_delay' platform data from dts file. Signed-off-by: Chanwoo Choi Signed-off-by: Kyungmin Park Signed-off-by: Mark Brown --- drivers/regulator/s5m8767.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index c24448bc43cf..cb6cdb3c0bdc 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -640,6 +640,22 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, return -EINVAL; } + if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL)) + pdata->buck2_ramp_enable = true; + + if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL)) + pdata->buck3_ramp_enable = true; + + if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL)) + pdata->buck4_ramp_enable = true; + + if (pdata->buck2_ramp_enable || pdata->buck3_ramp_enable + || pdata->buck4_ramp_enable) { + if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay", + &pdata->buck_ramp_delay)) + pdata->buck_ramp_delay = 0; + } + return 0; } #else -- cgit v1.2.3-55-g7522 From 04f9f068a619cc45a8e656e7121df2c772fa14ba Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 10 Oct 2013 10:41:36 +0900 Subject: regulator: s5m8767: Modify parsing method of the voltage table of buck2/3/4 The s5m8767 regulator driver parse always the voltage table of buck2/3/4. If gpio_dvs feature isn't used and dts haven't included the voltage table of buck2/3/4, s5m8767 regulator driver return error and file probe state. This patch check only voltage table of buck on s5m8767_pmic_dt_parse_pdata() if buck[2-4]_gpiodvs is true. Signed-off-by: Chanwoo Choi Signed-off-by: YoungJun Cho Signed-off-by: Kyungmin Park Signed-off-by: Mark Brown --- drivers/regulator/s5m8767.c | 54 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index cb6cdb3c0bdc..29999c042d69 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -522,7 +522,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, struct device_node *pmic_np, *regulators_np, *reg_np; struct sec_regulator_data *rdata; struct sec_opmode_data *rmode; - unsigned int i, dvs_voltage_nr = 1, ret; + unsigned int i, dvs_voltage_nr = 8, ret; pmic_np = iodev->dev->of_node; if (!pmic_np) { @@ -586,15 +586,39 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rmode++; } - if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) + if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) { pdata->buck2_gpiodvs = true; - if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) + if (of_property_read_u32_array(pmic_np, + "s5m8767,pmic-buck2-dvs-voltage", + pdata->buck2_voltage, dvs_voltage_nr)) { + dev_err(iodev->dev, "buck2 voltages not specified\n"); + return -EINVAL; + } + } + + if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) { pdata->buck3_gpiodvs = true; - if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) + if (of_property_read_u32_array(pmic_np, + "s5m8767,pmic-buck3-dvs-voltage", + pdata->buck3_voltage, dvs_voltage_nr)) { + dev_err(iodev->dev, "buck3 voltages not specified\n"); + return -EINVAL; + } + } + + if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) { pdata->buck4_gpiodvs = true; + if (of_property_read_u32_array(pmic_np, + "s5m8767,pmic-buck4-dvs-voltage", + pdata->buck4_voltage, dvs_voltage_nr)) { + dev_err(iodev->dev, "buck4 voltages not specified\n"); + return -EINVAL; + } + } + if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || pdata->buck4_gpiodvs) { ret = s5m8767_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); @@ -612,34 +636,12 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, "invalid value for default dvs index, use 0\n"); } } - dvs_voltage_nr = 8; } ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np); if (ret) return -EINVAL; - if (of_property_read_u32_array(pmic_np, - "s5m8767,pmic-buck2-dvs-voltage", - pdata->buck2_voltage, dvs_voltage_nr)) { - dev_err(iodev->dev, "buck2 voltages not specified\n"); - return -EINVAL; - } - - if (of_property_read_u32_array(pmic_np, - "s5m8767,pmic-buck3-dvs-voltage", - pdata->buck3_voltage, dvs_voltage_nr)) { - dev_err(iodev->dev, "buck3 voltages not specified\n"); - return -EINVAL; - } - - if (of_property_read_u32_array(pmic_np, - "s5m8767,pmic-buck4-dvs-voltage", - pdata->buck4_voltage, dvs_voltage_nr)) { - dev_err(iodev->dev, "buck4 voltages not specified\n"); - return -EINVAL; - } - if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL)) pdata->buck2_ramp_enable = true; -- cgit v1.2.3-55-g7522