[U-Boot] [PATCH 7/8] drivers/power/regulator/max77686.c: Fix comparisons of unsigned expressions
Jaehoon Chung
jh80.chung at samsung.com
Thu May 25 13:17:46 UTC 2017
On 05/11/2017 04:20 AM, Tom Rini wrote:
> Inside of
> max77686_buck_volt2hex/max77686_buck_hex2volt/max77686_ldo_volt2hex we
> check that the value we calculate is >= 0 however we declare 'hex' as
> unsigned int making these always true. Mark these as 'int' instead. We
> also move hex_max to int as they are constants that are 0x3f/0xff.
> Given that the above functions are marked as returning an int, make the
> variables we assign their return value to also be int to be able to
> catch the error condition now. Reported by clang-3.8.
>
> Cc: Jaehoon Chung <jh80.chung at samsung.com>
> Signed-off-by: Tom Rini <trini at konsulko.com>
Applied to u-boot-mmc for pmic. Thanks.
> ---
> drivers/power/regulator/max77686.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/power/regulator/max77686.c b/drivers/power/regulator/max77686.c
> index 7479af734ade..5e5815f39789 100644
> --- a/drivers/power/regulator/max77686.c
> +++ b/drivers/power/regulator/max77686.c
> @@ -71,8 +71,8 @@ static const char max77686_buck_out[] = {
>
> static int max77686_buck_volt2hex(int buck, int uV)
> {
> - unsigned int hex = 0;
> - unsigned int hex_max = 0;
> + int hex = 0;
> + int hex_max = 0;
>
> switch (buck) {
> case 2:
> @@ -105,7 +105,7 @@ static int max77686_buck_volt2hex(int buck, int uV)
> static int max77686_buck_hex2volt(int buck, int hex)
> {
> unsigned uV = 0;
> - unsigned int hex_max = 0;
> + int hex_max = 0;
>
> if (hex < 0)
> goto bad_hex;
> @@ -140,7 +140,7 @@ bad_hex:
>
> static int max77686_ldo_volt2hex(int ldo, int uV)
> {
> - unsigned int hex = 0;
> + int hex = 0;
>
> switch (ldo) {
> case 1:
> @@ -319,9 +319,9 @@ static int max77686_ldo_modes(int ldo, struct dm_regulator_mode **modesp,
>
> static int max77686_ldo_val(struct udevice *dev, int op, int *uV)
> {
> - unsigned int hex, adr;
> + unsigned int adr;
> unsigned char val;
> - int ldo, ret;
> + int hex, ldo, ret;
>
> if (op == PMIC_OP_GET)
> *uV = 0;
> @@ -360,9 +360,9 @@ static int max77686_ldo_val(struct udevice *dev, int op, int *uV)
>
> static int max77686_buck_val(struct udevice *dev, int op, int *uV)
> {
> - unsigned int hex, mask, adr;
> + unsigned int mask, adr;
> unsigned char val;
> - int buck, ret;
> + int hex, buck, ret;
>
> buck = dev->driver_data;
> if (buck < 1 || buck > MAX77686_BUCK_NUM) {
>
More information about the U-Boot
mailing list