Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323349
b: refs/heads/master
c: 0ffff5a
h: refs/heads/master
i:
  323347: 4f6bd57
v: v3
  • Loading branch information
Arnd Bergmann authored and Mark Brown committed Aug 28, 2012
1 parent 3557afd commit 3c496de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9cfbde723ba89b7bf7d1ec0b8adeea0c3c4a091
refs/heads/master: 0ffff5a60fdd7455c83855ee788a8aae9a79aab4
38 changes: 24 additions & 14 deletions trunk/drivers/regulator/twl-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,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), \
Expand All @@ -881,7 +881,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, \
Expand All @@ -896,7 +896,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, \
Expand All @@ -907,7 +907,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, \
Expand All @@ -922,7 +922,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, \
Expand All @@ -938,7 +938,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, \
Expand Down Expand Up @@ -968,7 +968,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, \
Expand Down Expand Up @@ -1125,6 +1125,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;
Expand All @@ -1134,17 +1135,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))
Expand All @@ -1155,12 +1156,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;
Expand Down Expand Up @@ -1221,6 +1226,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);
Expand All @@ -1242,7 +1248,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;
}

Expand Down

0 comments on commit 3c496de

Please sign in to comment.