3434#include <linux/mfd/samsung/s2mps14.h>
3535#include <linux/mfd/samsung/s2mpu02.h>
3636
37+ /* The highest number of possible regulators for supported devices. */
38+ #define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
3739struct s2mps11_info {
3840 unsigned int rdev_num ;
3941 int ramp_delay2 ;
@@ -49,7 +51,7 @@ struct s2mps11_info {
4951 * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether
5052 * the suspend mode was enabled.
5153 */
52- unsigned long long s2mps14_suspend_state : 50 ;
54+ DECLARE_BITMAP ( suspend_state , S2MPS_REGULATOR_MAX ) ;
5355
5456 /* Array of size rdev_num with GPIO-s for external sleep control */
5557 int * ext_control_gpio ;
@@ -500,15 +502,15 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
500502 switch (s2mps11 -> dev_type ) {
501503 case S2MPS13X :
502504 case S2MPS14X :
503- if (s2mps11 -> s2mps14_suspend_state & ( 1 << rdev_get_id (rdev )))
505+ if (test_bit ( rdev_get_id (rdev ), s2mps11 -> suspend_state ))
504506 val = S2MPS14_ENABLE_SUSPEND ;
505507 else if (gpio_is_valid (s2mps11 -> ext_control_gpio [rdev_get_id (rdev )]))
506508 val = S2MPS14_ENABLE_EXT_CONTROL ;
507509 else
508510 val = rdev -> desc -> enable_mask ;
509511 break ;
510512 case S2MPU02 :
511- if (s2mps11 -> s2mps14_suspend_state & ( 1 << rdev_get_id (rdev )))
513+ if (test_bit ( rdev_get_id (rdev ), s2mps11 -> suspend_state ))
512514 val = S2MPU02_ENABLE_SUSPEND ;
513515 else
514516 val = rdev -> desc -> enable_mask ;
@@ -562,7 +564,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
562564 if (ret < 0 )
563565 return ret ;
564566
565- s2mps11 -> s2mps14_suspend_state |= ( 1 << rdev_get_id (rdev ));
567+ set_bit ( rdev_get_id (rdev ), s2mps11 -> suspend_state );
566568 /*
567569 * Don't enable suspend mode if regulator is already disabled because
568570 * 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)
960962 case S2MPS11X :
961963 s2mps11 -> rdev_num = ARRAY_SIZE (s2mps11_regulators );
962964 regulators = s2mps11_regulators ;
965+ BUILD_BUG_ON (S2MPS_REGULATOR_MAX < s2mps11 -> rdev_num );
963966 break ;
964967 case S2MPS13X :
965968 s2mps11 -> rdev_num = ARRAY_SIZE (s2mps13_regulators );
966969 regulators = s2mps13_regulators ;
970+ BUILD_BUG_ON (S2MPS_REGULATOR_MAX < s2mps11 -> rdev_num );
967971 break ;
968972 case S2MPS14X :
969973 s2mps11 -> rdev_num = ARRAY_SIZE (s2mps14_regulators );
970974 regulators = s2mps14_regulators ;
975+ BUILD_BUG_ON (S2MPS_REGULATOR_MAX < s2mps11 -> rdev_num );
971976 break ;
972977 case S2MPU02 :
973978 s2mps11 -> rdev_num = ARRAY_SIZE (s2mpu02_regulators );
974979 regulators = s2mpu02_regulators ;
980+ BUILD_BUG_ON (S2MPS_REGULATOR_MAX < s2mps11 -> rdev_num );
975981 break ;
976982 default :
977983 dev_err (& pdev -> dev , "Invalid device type: %u\n" ,
0 commit comments