regulator: Fix WM831x regulator ID lookups for multiple WM831xs
[pandora-kernel.git] / drivers / regulator / wm831x-dcdc.c
index a0982e8..0c7a9d5 100644 (file)
@@ -504,11 +504,17 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
 {
        struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
        struct wm831x_pdata *pdata = wm831x->dev->platform_data;
-       int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
+       int id;
        struct wm831x_dcdc *dcdc;
        struct resource *res;
        int ret, irq;
 
+       if (pdata && pdata->wm831x_num)
+               id = (pdata->wm831x_num * 10) + 1;
+       else
+               id = 0;
+       id = pdev->id - id;
+
        dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
 
        if (pdata == NULL || pdata->dcdc[id] == NULL)
@@ -709,11 +715,17 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
 {
        struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
        struct wm831x_pdata *pdata = wm831x->dev->platform_data;
-       int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
+       int id;
        struct wm831x_dcdc *dcdc;
        struct resource *res;
        int ret, irq;
 
+       if (pdata && pdata->wm831x_num)
+               id = (pdata->wm831x_num * 10) + 1;
+       else
+               id = 0;
+       id = pdev->id - id;
+
        dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
 
        if (pdata == NULL || pdata->dcdc[id] == NULL)