regulator: palmas: Fix warning message
[linux-2.6.git] / drivers / regulator / mc13783-regulator.c
index cb2841f..6c0face 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/err.h>
+#include <linux/module.h>
 #include "mc13xxx.h"
 
 #define MC13783_REG_SWITCHERS5                 29
@@ -343,7 +344,10 @@ static int __devinit mc13783_regulator_probe(struct platform_device *pdev)
 
        dev_dbg(&pdev->dev, "%s id %d\n", __func__, pdev->id);
 
-       priv = kzalloc(sizeof(*priv) +
+       if (!pdata)
+               return -EINVAL;
+
+       priv = devm_kzalloc(&pdev->dev, sizeof(*priv) +
                        pdata->num_regulators * sizeof(priv->regulators[0]),
                        GFP_KERNEL);
        if (!priv)
@@ -356,7 +360,7 @@ static int __devinit mc13783_regulator_probe(struct platform_device *pdev)
                init_data = &pdata->regulators[i];
                priv->regulators[i] = regulator_register(
                                &mc13783_regulators[init_data->id].desc,
-                               &pdev->dev, init_data->init_data, priv);
+                               &pdev->dev, init_data->init_data, priv, NULL);
 
                if (IS_ERR(priv->regulators[i])) {
                        dev_err(&pdev->dev, "failed to register regulator %s\n",
@@ -373,8 +377,6 @@ err:
        while (--i >= 0)
                regulator_unregister(priv->regulators[i]);
 
-       kfree(priv);
-
        return ret;
 }
 
@@ -390,7 +392,6 @@ static int __devexit mc13783_regulator_remove(struct platform_device *pdev)
        for (i = 0; i < pdata->num_regulators; i++)
                regulator_unregister(priv->regulators[i]);
 
-       kfree(priv);
        return 0;
 }