regulator: remove use of __devexit_p
[linux-3.10.git] / drivers / regulator / twl-regulator.c
index 89d447d..eac8540 100644 (file)
@@ -10,6 +10,8 @@
  */
 
 #include <linux/module.h>
+#include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
@@ -624,18 +626,9 @@ static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
        return info->min_mV * 1000;
 }
 
-static int twlfixed_get_voltage(struct regulator_dev *rdev)
-{
-       struct twlreg_info      *info = rdev_get_drvdata(rdev);
-
-       return info->min_mV * 1000;
-}
-
 static struct regulator_ops twl4030fixed_ops = {
        .list_voltage   = twlfixed_list_voltage,
 
-       .get_voltage    = twlfixed_get_voltage,
-
        .enable         = twl4030reg_enable,
        .disable        = twl4030reg_disable,
        .is_enabled     = twl4030reg_is_enabled,
@@ -648,8 +641,6 @@ static struct regulator_ops twl4030fixed_ops = {
 static struct regulator_ops twl6030fixed_ops = {
        .list_voltage   = twlfixed_list_voltage,
 
-       .get_voltage    = twlfixed_get_voltage,
-
        .enable         = twl6030reg_enable,
        .disable        = twl6030reg_disable,
        .is_enabled     = twl6030reg_is_enabled,
@@ -659,13 +650,6 @@ static struct regulator_ops twl6030fixed_ops = {
        .get_status     = twl6030reg_get_status,
 };
 
-static struct regulator_ops twl6030_fixed_resource = {
-       .enable         = twl6030reg_enable,
-       .disable        = twl6030reg_disable,
-       .is_enabled     = twl6030reg_is_enabled,
-       .get_status     = twl6030reg_get_status,
-};
-
 /*
  * SMPS status and control
  */
@@ -874,7 +858,7 @@ static struct regulator_ops twlsmps_ops = {
                        0x0, TWL6030, twl6030fixed_ops)
 
 #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
-static struct twlreg_info TWL4030_INFO_##label = { \
+static const struct twlreg_info TWL4030_INFO_##label = { \
        .base = offset, \
        .id = num, \
        .table_len = ARRAY_SIZE(label##_VSEL_table), \
@@ -892,7 +876,7 @@ static struct twlreg_info TWL4030_INFO_##label = { \
        }
 
 #define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
-static struct twlreg_info TWL4030_INFO_##label = { \
+static const struct twlreg_info TWL4030_INFO_##label = { \
        .base = offset, \
        .id = num, \
        .remap = remap_conf, \
@@ -907,7 +891,7 @@ static struct twlreg_info TWL4030_INFO_##label = { \
        }
 
 #define TWL6030_ADJUSTABLE_SMPS(label) \
-static struct twlreg_info TWL6030_INFO_##label = { \
+static const struct twlreg_info TWL6030_INFO_##label = { \
        .desc = { \
                .name = #label, \
                .id = TWL6030_REG_##label, \
@@ -918,7 +902,7 @@ static struct twlreg_info TWL6030_INFO_##label = { \
        }
 
 #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
-static struct twlreg_info TWL6030_INFO_##label = { \
+static const struct twlreg_info TWL6030_INFO_##label = { \
        .base = offset, \
        .min_mV = min_mVolts, \
        .max_mV = max_mVolts, \
@@ -933,7 +917,7 @@ static struct twlreg_info TWL6030_INFO_##label = { \
        }
 
 #define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
-static struct twlreg_info TWL6025_INFO_##label = { \
+static const struct twlreg_info TWL6025_INFO_##label = { \
        .base = offset, \
        .min_mV = min_mVolts, \
        .max_mV = max_mVolts, \
@@ -949,7 +933,7 @@ static struct twlreg_info TWL6025_INFO_##label = { \
 
 #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
                family, operations) \
-static struct twlreg_info TWLFIXED_INFO_##label = { \
+static const struct twlreg_info TWLFIXED_INFO_##label = { \
        .base = offset, \
        .id = num, \
        .min_mV = mVolts, \
@@ -979,7 +963,7 @@ static struct twlreg_info TWLRES_INFO_##label = { \
        }
 
 #define TWL6025_ADJUSTABLE_SMPS(label, offset) \
-static struct twlreg_info TWLSMPS_INFO_##label = { \
+static const struct twlreg_info TWLSMPS_INFO_##label = { \
        .base = offset, \
        .min_mV = 600, \
        .max_mV = 2100, \
@@ -1136,6 +1120,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
 {
        int                             i, id;
        struct twlreg_info              *info;
+       const struct twlreg_info        *template;
        struct regulator_init_data      *initdata;
        struct regulation_constraints   *c;
        struct regulator_dev            *rdev;
@@ -1145,17 +1130,17 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
 
        match = of_match_device(twl_of_match, &pdev->dev);
        if (match) {
-               info = match->data;
-               id = info->desc.id;
+               template = match->data;
+               id = template->desc.id;
                initdata = of_get_regulator_init_data(&pdev->dev,
                                                      pdev->dev.of_node);
                drvdata = NULL;
        } else {
                id = pdev->id;
                initdata = pdev->dev.platform_data;
-               for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
-                       info = twl_of_match[i].data;
-                       if (info && info->desc.id == id)
+               for (i = 0, template = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
+                       template = twl_of_match[i].data;
+                       if (template && template->desc.id == id)
                                break;
                }
                if (i == ARRAY_SIZE(twl_of_match))
@@ -1166,12 +1151,16 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
                        return -EINVAL;
        }
 
-       if (!info)
+       if (!template)
                return -ENODEV;
 
        if (!initdata)
                return -EINVAL;
 
+       info = kmemdup(template, sizeof (*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
        if (drvdata) {
                /* copy the driver data into regulator data */
                info->features = drvdata->features;
@@ -1232,6 +1221,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
        if (IS_ERR(rdev)) {
                dev_err(&pdev->dev, "can't register %s, %ld\n",
                                info->desc.name, PTR_ERR(rdev));
+               kfree(info);
                return PTR_ERR(rdev);
        }
        platform_set_drvdata(pdev, rdev);
@@ -1253,7 +1243,11 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
 
 static int __devexit twlreg_remove(struct platform_device *pdev)
 {
-       regulator_unregister(platform_get_drvdata(pdev));
+       struct regulator_dev *rdev = platform_get_drvdata(pdev);
+       struct twlreg_info *info = rdev->reg_data;
+
+       regulator_unregister(rdev);
+       kfree(info);
        return 0;
 }
 
@@ -1261,7 +1255,7 @@ MODULE_ALIAS("platform:twl_reg");
 
 static struct platform_driver twlreg_driver = {
        .probe          = twlreg_probe,
-       .remove         = __devexit_p(twlreg_remove),
+       .remove         = twlreg_remove,
        /* NOTE: short name, to work around driver model truncation of
         * "twl_regulator.12" (and friends) to "twl_regulator.1".
         */