diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-30 19:24:24 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-30 19:24:24 -0500 |
| commit | d6e92d360c21494ed4ce3bcfa7c84b90cb075bba (patch) | |
| tree | c438e085b6b21b93b3caface078e7990cc6992d4 | |
| parent | cd5b49bce361caeb7488f5fa801326bcd799f6f2 (diff) | |
| parent | ba305e31e88ea5c2f598ff9fbc5424711a429e30 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
regulator: twl: fix twl4030 support for smps regulators
regulator: fix use after free bug
regulator: aat2870: Fix the logic of checking if no id is matched in aat2870_get_regulator
| -rw-r--r-- | drivers/regulator/aat2870-regulator.c | 2 | ||||
| -rw-r--r-- | drivers/regulator/core.c | 2 | ||||
| -rw-r--r-- | drivers/regulator/twl-regulator.c | 46 |
3 files changed, 46 insertions, 4 deletions
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 5abeb3ac3e8d..298c6c6a2795 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c | |||
| @@ -160,7 +160,7 @@ static struct aat2870_regulator *aat2870_get_regulator(int id) | |||
| 160 | break; | 160 | break; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | if (!ri) | 163 | if (i == ARRAY_SIZE(aat2870_regulators)) |
| 164 | return NULL; | 164 | return NULL; |
| 165 | 165 | ||
| 166 | ri->enable_addr = AAT2870_LDO_EN; | 166 | ri->enable_addr = AAT2870_LDO_EN; |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 669d02160221..938398f3e869 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -2799,8 +2799,8 @@ void regulator_unregister(struct regulator_dev *rdev) | |||
| 2799 | list_del(&rdev->list); | 2799 | list_del(&rdev->list); |
| 2800 | if (rdev->supply) | 2800 | if (rdev->supply) |
| 2801 | regulator_put(rdev->supply); | 2801 | regulator_put(rdev->supply); |
| 2802 | device_unregister(&rdev->dev); | ||
| 2803 | kfree(rdev->constraints); | 2802 | kfree(rdev->constraints); |
| 2803 | device_unregister(&rdev->dev); | ||
| 2804 | mutex_unlock(®ulator_list_mutex); | 2804 | mutex_unlock(®ulator_list_mutex); |
| 2805 | } | 2805 | } |
| 2806 | EXPORT_SYMBOL_GPL(regulator_unregister); | 2806 | EXPORT_SYMBOL_GPL(regulator_unregister); |
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index ee8747f4fa08..11cc308d66e9 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
| @@ -71,6 +71,7 @@ struct twlreg_info { | |||
| 71 | #define VREG_TYPE 1 | 71 | #define VREG_TYPE 1 |
| 72 | #define VREG_REMAP 2 | 72 | #define VREG_REMAP 2 |
| 73 | #define VREG_DEDICATED 3 /* LDO control */ | 73 | #define VREG_DEDICATED 3 /* LDO control */ |
| 74 | #define VREG_VOLTAGE_SMPS_4030 9 | ||
| 74 | /* TWL6030 register offsets */ | 75 | /* TWL6030 register offsets */ |
| 75 | #define VREG_TRANS 1 | 76 | #define VREG_TRANS 1 |
| 76 | #define VREG_STATE 2 | 77 | #define VREG_STATE 2 |
| @@ -514,6 +515,32 @@ static struct regulator_ops twl4030ldo_ops = { | |||
| 514 | .get_status = twl4030reg_get_status, | 515 | .get_status = twl4030reg_get_status, |
| 515 | }; | 516 | }; |
| 516 | 517 | ||
| 518 | static int | ||
| 519 | twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, | ||
| 520 | unsigned *selector) | ||
| 521 | { | ||
| 522 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
| 523 | int vsel = DIV_ROUND_UP(min_uV - 600000, 12500); | ||
| 524 | |||
| 525 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS_4030, | ||
| 526 | vsel); | ||
| 527 | return 0; | ||
| 528 | } | ||
| 529 | |||
| 530 | static int twl4030smps_get_voltage(struct regulator_dev *rdev) | ||
| 531 | { | ||
| 532 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
| 533 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, | ||
| 534 | VREG_VOLTAGE_SMPS_4030); | ||
| 535 | |||
| 536 | return vsel * 12500 + 600000; | ||
| 537 | } | ||
| 538 | |||
| 539 | static struct regulator_ops twl4030smps_ops = { | ||
| 540 | .set_voltage = twl4030smps_set_voltage, | ||
| 541 | .get_voltage = twl4030smps_get_voltage, | ||
| 542 | }; | ||
| 543 | |||
| 517 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) | 544 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) |
| 518 | { | 545 | { |
| 519 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 546 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| @@ -856,6 +883,21 @@ static struct regulator_ops twlsmps_ops = { | |||
| 856 | }, \ | 883 | }, \ |
| 857 | } | 884 | } |
| 858 | 885 | ||
| 886 | #define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \ | ||
| 887 | { \ | ||
| 888 | .base = offset, \ | ||
| 889 | .id = num, \ | ||
| 890 | .delay = turnon_delay, \ | ||
| 891 | .remap = remap_conf, \ | ||
| 892 | .desc = { \ | ||
| 893 | .name = #label, \ | ||
| 894 | .id = TWL4030_REG_##label, \ | ||
| 895 | .ops = &twl4030smps_ops, \ | ||
| 896 | .type = REGULATOR_VOLTAGE, \ | ||
| 897 | .owner = THIS_MODULE, \ | ||
| 898 | }, \ | ||
| 899 | } | ||
| 900 | |||
| 859 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \ | 901 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \ |
| 860 | .base = offset, \ | 902 | .base = offset, \ |
| 861 | .min_mV = min_mVolts, \ | 903 | .min_mV = min_mVolts, \ |
| @@ -947,8 +989,8 @@ static struct twlreg_info twl_regs[] = { | |||
| 947 | TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08), | 989 | TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08), |
| 948 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08), | 990 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08), |
| 949 | TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08), | 991 | TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08), |
| 950 | TWL4030_ADJUSTABLE_LDO(VDD1, 0x55, 15, 1000, 0x08), | 992 | TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08), |
| 951 | TWL4030_ADJUSTABLE_LDO(VDD2, 0x63, 16, 1000, 0x08), | 993 | TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08), |
| 952 | TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08), | 994 | TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08), |
| 953 | TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08), | 995 | TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08), |
| 954 | TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08), | 996 | TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08), |
