regulator: regulator for Palmas Kconfig
[linux-2.6.git] / drivers / regulator / da903x.c
index 362e082..1851f09 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/err.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
@@ -118,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
                return -EINVAL;
        }
 
-       val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+       val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
        *selector = val;
        val <<= info->vol_shift;
        mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
@@ -201,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
                return -EINVAL;
        }
 
-       val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+       val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
        *selector = val;
        val <<= info->vol_shift;
        mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
@@ -232,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
 
        thresh = (info->max_uV + info->min_uV) / 2;
        if (min_uV < thresh) {
-               val = (thresh - min_uV + info->step_uV - 1) / info->step_uV;
+               val = DIV_ROUND_UP(thresh - min_uV, info->step_uV);
                val |= 0x4;
        } else {
-               val = (min_uV - thresh + info->step_uV - 1) / info->step_uV;
+               val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
        }
 
        *selector = val;
@@ -280,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
                return -EINVAL;
        }
 
-       val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+       val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
        *selector = val;
        val <<= info->vol_shift;
        mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
@@ -306,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
                return -EINVAL;
        }
 
-       val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+       val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
        val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
        *selector = val;
        val <<= info->vol_shift;
@@ -536,7 +537,7 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev)
                ri->desc.ops = &da9030_regulator_ldo1_15_ops;
 
        rdev = regulator_register(&ri->desc, &pdev->dev,
-                                 pdev->dev.platform_data, ri);
+                                 pdev->dev.platform_data, ri, NULL);
        if (IS_ERR(rdev)) {
                dev_err(&pdev->dev, "failed to register regulator %s\n",
                                ri->desc.name);