aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/wm831x-dcdc.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-03 19:50:22 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-09 07:37:09 -0400
commitc172708d38a401b2f3f841dfcd862b469fa0b670 (patch)
tree75e89c63fd0c76a2c69bb5ad6e45b3762bceb6b6 /drivers/regulator/wm831x-dcdc.c
parent1474e4dbcae04125ed6e503eadcef266846f4675 (diff)
regulator: core: Use a struct to pass in regulator runtime configuration
Rather than adding new arguments to regulator_register() every time we want to add a new bit of dynamic information at runtime change the function to take these via a struct. By doing this we avoid needing to do further changes like the recent addition of device tree support which required each regulator driver to be updated to take an additional parameter. The regulator_desc which should (mostly) be static data is still passed separately as most drivers are able to configure this statically at build time. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/wm831x-dcdc.c')
-rw-r--r--drivers/regulator/wm831x-dcdc.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 909c53b70375..c754eae18c4a 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -495,6 +495,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
495{ 495{
496 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 496 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
497 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 497 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
498 struct regulator_config config = { };
498 int id; 499 int id;
499 struct wm831x_dcdc *dcdc; 500 struct wm831x_dcdc *dcdc;
500 struct resource *res; 501 struct resource *res;
@@ -553,8 +554,11 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
553 if (pdata->dcdc[id]) 554 if (pdata->dcdc[id])
554 wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); 555 wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data);
555 556
556 dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, 557 config.dev = pdev->dev.parent;
557 pdata->dcdc[id], dcdc, NULL); 558 config.init_data = pdata->dcdc[id];
559 config.driver_data = dcdc;
560
561 dcdc->regulator = regulator_register(&dcdc->desc, &config);
558 if (IS_ERR(dcdc->regulator)) { 562 if (IS_ERR(dcdc->regulator)) {
559 ret = PTR_ERR(dcdc->regulator); 563 ret = PTR_ERR(dcdc->regulator);
560 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", 564 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
@@ -705,6 +709,7 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
705{ 709{
706 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 710 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
707 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 711 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
712 struct regulator_config config = { };
708 int id; 713 int id;
709 struct wm831x_dcdc *dcdc; 714 struct wm831x_dcdc *dcdc;
710 struct resource *res; 715 struct resource *res;
@@ -746,8 +751,11 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
746 dcdc->desc.ops = &wm831x_buckp_ops; 751 dcdc->desc.ops = &wm831x_buckp_ops;
747 dcdc->desc.owner = THIS_MODULE; 752 dcdc->desc.owner = THIS_MODULE;
748 753
749 dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, 754 config.dev = pdev->dev.parent;
750 pdata->dcdc[id], dcdc, NULL); 755 config.init_data = pdata->dcdc[id];
756 config.driver_data = dcdc;
757
758 dcdc->regulator = regulator_register(&dcdc->desc, &config);
751 if (IS_ERR(dcdc->regulator)) { 759 if (IS_ERR(dcdc->regulator)) {
752 ret = PTR_ERR(dcdc->regulator); 760 ret = PTR_ERR(dcdc->regulator);
753 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", 761 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
@@ -838,6 +846,7 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
838{ 846{
839 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 847 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
840 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 848 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
849 struct regulator_config config = { };
841 int id = pdev->id % ARRAY_SIZE(pdata->dcdc); 850 int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
842 struct wm831x_dcdc *dcdc; 851 struct wm831x_dcdc *dcdc;
843 struct resource *res; 852 struct resource *res;
@@ -871,8 +880,11 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
871 dcdc->desc.ops = &wm831x_boostp_ops; 880 dcdc->desc.ops = &wm831x_boostp_ops;
872 dcdc->desc.owner = THIS_MODULE; 881 dcdc->desc.owner = THIS_MODULE;
873 882
874 dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, 883 config.dev = pdev->dev.parent;
875 pdata->dcdc[id], dcdc, NULL); 884 config.init_data = pdata->dcdc[id];
885 config.driver_data = dcdc;
886
887 dcdc->regulator = regulator_register(&dcdc->desc, &config);
876 if (IS_ERR(dcdc->regulator)) { 888 if (IS_ERR(dcdc->regulator)) {
877 ret = PTR_ERR(dcdc->regulator); 889 ret = PTR_ERR(dcdc->regulator);
878 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", 890 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
@@ -941,6 +953,7 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev)
941{ 953{
942 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 954 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
943 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 955 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
956 struct regulator_config config = { };
944 int id = pdev->id % ARRAY_SIZE(pdata->epe); 957 int id = pdev->id % ARRAY_SIZE(pdata->epe);
945 struct wm831x_dcdc *dcdc; 958 struct wm831x_dcdc *dcdc;
946 int ret; 959 int ret;
@@ -968,8 +981,11 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev)
968 dcdc->desc.type = REGULATOR_VOLTAGE; 981 dcdc->desc.type = REGULATOR_VOLTAGE;
969 dcdc->desc.owner = THIS_MODULE; 982 dcdc->desc.owner = THIS_MODULE;
970 983
971 dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, 984 config.dev = pdev->dev.parent;
972 pdata->epe[id], dcdc, NULL); 985 config.init_data = pdata->epe[id];
986 config.driver_data = dcdc;
987
988 dcdc->regulator = regulator_register(&dcdc->desc, &config);
973 if (IS_ERR(dcdc->regulator)) { 989 if (IS_ERR(dcdc->regulator)) {
974 ret = PTR_ERR(dcdc->regulator); 990 ret = PTR_ERR(dcdc->regulator);
975 dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", 991 dev_err(wm831x->dev, "Failed to register EPE%d: %d\n",