platform/chrome: cros_ec_typec: fix clang -Wformat warning
authorArnd Bergmann <arnd@arndb.de>
Mon, 22 Mar 2021 11:55:55 +0000 (12:55 +0100)
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>
Tue, 30 Mar 2021 16:28:50 +0000 (18:28 +0200)
Clang warns about using the %h format modifier to truncate an
integer:

drivers/platform/chrome/cros_ec_typec.c:1031:3: error: format specifies type 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat]
                typec->pd_ctrl_ver);
                ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:131:47: note: expanded from macro 'dev_dbg'
                dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
                                                    ~~~     ^~~~~~~~~~~

Use an explicit bit mask to limit the number to its lower eight bits
instead.

Fixes: ad7c0510c99e ("platform/chrome: cros_ec_typec: Update port info from EC")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20210322115602.4003221-1-arnd@kernel.org
drivers/platform/chrome/cros_ec_typec.c

index 8e7fde3..d3df171 100644 (file)
@@ -1027,8 +1027,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
        else
                typec->pd_ctrl_ver = 0;
 
-       dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",
-               typec->pd_ctrl_ver);
+       dev_dbg(typec->dev, "PD Control has version mask 0x%02x\n",
+               typec->pd_ctrl_ver & 0xff);
 
        return 0;
 }