Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6
[linux-2.6.git] / drivers / regulator / virtual.c
index 5c1d756..addc032 100644 (file)
@@ -34,6 +34,8 @@ static void update_voltage_constraints(struct device *dev,
 
        if (data->min_uV && data->max_uV
            && data->min_uV <= data->max_uV) {
+               dev_dbg(dev, "Requesting %d-%duV\n",
+                       data->min_uV, data->max_uV);
                ret = regulator_set_voltage(data->regulator,
                                        data->min_uV, data->max_uV);
                if (ret != 0) {
@@ -44,6 +46,7 @@ static void update_voltage_constraints(struct device *dev,
        }
 
        if (data->min_uV && data->max_uV && !data->enabled) {
+               dev_dbg(dev, "Enabling regulator\n");
                ret = regulator_enable(data->regulator);
                if (ret == 0)
                        data->enabled = 1;
@@ -53,6 +56,7 @@ static void update_voltage_constraints(struct device *dev,
        }
 
        if (!(data->min_uV && data->max_uV) && data->enabled) {
+               dev_dbg(dev, "Disabling regulator\n");
                ret = regulator_disable(data->regulator);
                if (ret == 0)
                        data->enabled = 0;
@@ -69,6 +73,8 @@ static void update_current_limit_constraints(struct device *dev,
 
        if (data->max_uA
            && data->min_uA <= data->max_uA) {
+               dev_dbg(dev, "Requesting %d-%duA\n",
+                       data->min_uA, data->max_uA);
                ret = regulator_set_current_limit(data->regulator,
                                        data->min_uA, data->max_uA);
                if (ret != 0) {
@@ -80,6 +86,7 @@ static void update_current_limit_constraints(struct device *dev,
        }
 
        if (data->max_uA && !data->enabled) {
+               dev_dbg(dev, "Enabling regulator\n");
                ret = regulator_enable(data->regulator);
                if (ret == 0)
                        data->enabled = 1;
@@ -89,6 +96,7 @@ static void update_current_limit_constraints(struct device *dev,
        }
 
        if (!(data->min_uA && data->max_uA) && data->enabled) {
+               dev_dbg(dev, "Disabling regulator\n");
                ret = regulator_disable(data->regulator);
                if (ret == 0)
                        data->enabled = 0;
@@ -278,8 +286,7 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)
 
        drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL);
        if (drvdata == NULL) {
-               ret = -ENOMEM;
-               goto err;
+               return -ENOMEM;
        }
 
        mutex_init(&drvdata->lock);
@@ -294,8 +301,11 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)
 
        for (i = 0; i < ARRAY_SIZE(attributes); i++) {
                ret = device_create_file(&pdev->dev, attributes[i]);
-               if (ret != 0)
-                       goto err;
+               if (ret != 0) {
+                       dev_err(&pdev->dev, "Failed to create attr %d: %d\n",
+                               i, ret);
+                       goto err_regulator;
+               }
        }
 
        drvdata->mode = regulator_get_mode(drvdata->regulator);
@@ -304,6 +314,8 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)
 
        return 0;
 
+err_regulator:
+       regulator_put(drvdata->regulator);
 err:
        for (i = 0; i < ARRAY_SIZE(attributes); i++)
                device_remove_file(&pdev->dev, attributes[i]);