regulator: s2mps11: Simplify expression used in BUILD_BUG_ON

Following BUILD_BUG_ON using a variable fails for some of the compilers
and optimization levels (reported for gcc 4.9):
	var = ARRAY_SIZE(s2mps15_regulators);
	BUILD_BUG_ON(S2MPS_REGULATOR_MAX < var);
Fix this by using ARRAY_SIZE directly.

Additionally add missing BUILD_BUG_ON check for S2MPS15 device (the
check ensures that internal arrays are big enough to hold data for all
of regulators on all devices).

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Krzysztof Kozlowski 2016-02-18 09:35:07 +09:00 committed by Mark Brown
parent 92e963f50f
commit 297eaaa6d0

View File

@ -1090,26 +1090,27 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
case S2MPS11X: case S2MPS11X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
regulators = s2mps11_regulators; regulators = s2mps11_regulators;
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps11_regulators));
break; break;
case S2MPS13X: case S2MPS13X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators); s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
regulators = s2mps13_regulators; regulators = s2mps13_regulators;
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps13_regulators));
break; break;
case S2MPS14X: case S2MPS14X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
regulators = s2mps14_regulators; regulators = s2mps14_regulators;
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps14_regulators));
break; break;
case S2MPS15X: case S2MPS15X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps15_regulators); s2mps11->rdev_num = ARRAY_SIZE(s2mps15_regulators);
regulators = s2mps15_regulators; regulators = s2mps15_regulators;
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps15_regulators));
break; break;
case S2MPU02: case S2MPU02:
s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators); s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
regulators = s2mpu02_regulators; regulators = s2mpu02_regulators;
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mpu02_regulators));
break; break;
default: default:
dev_err(&pdev->dev, "Invalid device type: %u\n", dev_err(&pdev->dev, "Invalid device type: %u\n",