diff options
Diffstat (limited to 'drivers/regulator/s2mps11.c')
-rw-r--r-- | drivers/regulator/s2mps11.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 326ffb553371..72fc3c32db49 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <linux/mfd/samsung/s2mps14.h> | 34 | #include <linux/mfd/samsung/s2mps14.h> |
35 | #include <linux/mfd/samsung/s2mpu02.h> | 35 | #include <linux/mfd/samsung/s2mpu02.h> |
36 | 36 | ||
37 | /* The highest number of possible regulators for supported devices. */ | ||
38 | #define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX | ||
37 | struct s2mps11_info { | 39 | struct s2mps11_info { |
38 | unsigned int rdev_num; | 40 | unsigned int rdev_num; |
39 | int ramp_delay2; | 41 | int ramp_delay2; |
@@ -49,7 +51,7 @@ struct s2mps11_info { | |||
49 | * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether | 51 | * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether |
50 | * the suspend mode was enabled. | 52 | * the suspend mode was enabled. |
51 | */ | 53 | */ |
52 | unsigned long long s2mps14_suspend_state:50; | 54 | DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX); |
53 | 55 | ||
54 | /* Array of size rdev_num with GPIO-s for external sleep control */ | 56 | /* Array of size rdev_num with GPIO-s for external sleep control */ |
55 | int *ext_control_gpio; | 57 | int *ext_control_gpio; |
@@ -500,7 +502,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) | |||
500 | switch (s2mps11->dev_type) { | 502 | switch (s2mps11->dev_type) { |
501 | case S2MPS13X: | 503 | case S2MPS13X: |
502 | case S2MPS14X: | 504 | case S2MPS14X: |
503 | if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) | 505 | if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) |
504 | val = S2MPS14_ENABLE_SUSPEND; | 506 | val = S2MPS14_ENABLE_SUSPEND; |
505 | else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) | 507 | else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) |
506 | val = S2MPS14_ENABLE_EXT_CONTROL; | 508 | val = S2MPS14_ENABLE_EXT_CONTROL; |
@@ -508,7 +510,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) | |||
508 | val = rdev->desc->enable_mask; | 510 | val = rdev->desc->enable_mask; |
509 | break; | 511 | break; |
510 | case S2MPU02: | 512 | case S2MPU02: |
511 | if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) | 513 | if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) |
512 | val = S2MPU02_ENABLE_SUSPEND; | 514 | val = S2MPU02_ENABLE_SUSPEND; |
513 | else | 515 | else |
514 | val = rdev->desc->enable_mask; | 516 | val = rdev->desc->enable_mask; |
@@ -562,7 +564,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev) | |||
562 | if (ret < 0) | 564 | if (ret < 0) |
563 | return ret; | 565 | return ret; |
564 | 566 | ||
565 | s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev)); | 567 | set_bit(rdev_get_id(rdev), s2mps11->suspend_state); |
566 | /* | 568 | /* |
567 | * Don't enable suspend mode if regulator is already disabled because | 569 | * Don't enable suspend mode if regulator is already disabled because |
568 | * this would effectively for a short time turn on the regulator after | 570 | * this would effectively for a short time turn on the regulator after |
@@ -960,18 +962,22 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
960 | case S2MPS11X: | 962 | case S2MPS11X: |
961 | s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); | 963 | s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); |
962 | regulators = s2mps11_regulators; | 964 | regulators = s2mps11_regulators; |
965 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); | ||
963 | break; | 966 | break; |
964 | case S2MPS13X: | 967 | case S2MPS13X: |
965 | s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators); | 968 | s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators); |
966 | regulators = s2mps13_regulators; | 969 | regulators = s2mps13_regulators; |
970 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); | ||
967 | break; | 971 | break; |
968 | case S2MPS14X: | 972 | case S2MPS14X: |
969 | s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); | 973 | s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); |
970 | regulators = s2mps14_regulators; | 974 | regulators = s2mps14_regulators; |
975 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); | ||
971 | break; | 976 | break; |
972 | case S2MPU02: | 977 | case S2MPU02: |
973 | s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators); | 978 | s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators); |
974 | regulators = s2mpu02_regulators; | 979 | regulators = s2mpu02_regulators; |
980 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); | ||
975 | break; | 981 | break; |
976 | default: | 982 | default: |
977 | dev_err(&pdev->dev, "Invalid device type: %u\n", | 983 | dev_err(&pdev->dev, "Invalid device type: %u\n", |