regulator: palmas: implement sleep mode configuration
[linux-2.6.git] / drivers / regulator / wm8994-regulator.c
index 1a6a690..75ed402 100644 (file)
@@ -140,6 +140,14 @@ static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
                return (selector * 100000) + 900000;
        case WM8958:
                return (selector * 100000) + 1000000;
+       case WM1811:
+               switch (selector) {
+               case 0:
+                       return -EINVAL;
+               default:
+                       return (selector * 100000) + 950000;
+               }
+               break;
        default:
                return -EINVAL;
        }
@@ -170,6 +178,11 @@ static int wm8994_ldo2_set_voltage(struct regulator_dev *rdev,
        case WM8958:
                selector = (min_uV - 1000000) / 100000;
                break;
+       case WM1811:
+               selector = (min_uV - 950000) / 100000;
+               if (selector == 0)
+                       selector = 1;
+               break;
        default:
                return -EINVAL;
        }
@@ -228,7 +241,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
        if (!pdata)
                return -ENODEV;
 
-       ldo = kzalloc(sizeof(struct wm8994_ldo), GFP_KERNEL);
+       ldo = devm_kzalloc(&pdev->dev, sizeof(struct wm8994_ldo), GFP_KERNEL);
        if (ldo == NULL) {
                dev_err(&pdev->dev, "Unable to allocate private data\n");
                return -ENOMEM;
@@ -256,7 +269,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
                ldo->is_enabled = true;
 
        ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &pdev->dev,
-                                            pdata->ldo[id].init_data, ldo);
+                                            pdata->ldo[id].init_data, ldo, NULL);
        if (IS_ERR(ldo->regulator)) {
                ret = PTR_ERR(ldo->regulator);
                dev_err(wm8994->dev, "Failed to register LDO%d: %d\n",
@@ -272,7 +285,6 @@ err_gpio:
        if (gpio_is_valid(ldo->enable))
                gpio_free(ldo->enable);
 err:
-       kfree(ldo);
        return ret;
 }
 
@@ -285,7 +297,6 @@ static __devexit int wm8994_ldo_remove(struct platform_device *pdev)
        regulator_unregister(ldo->regulator);
        if (gpio_is_valid(ldo->enable))
                gpio_free(ldo->enable);
-       kfree(ldo);
 
        return 0;
 }