mfd: wm8400-core: signedness bug in wm8400_reg_read()
PATCH 1/1 mfd: wm8400-core: signedness bug in wm8400_reg_read()
This is harmless because the function is not called, but we're trying to return negative error codes so the function needs to return an int instead of a u16.
include/linux/mfd/wm8400-private.h +1 -1
@@ -923,7 +923,7 @@ struct wm8400 {#define WM8400_LINE_CMP_VTHD_SHIFT 0/* LINE_CMP_VTHD - [3:0] */ #define WM8400_LINE_CMP_VTHD_WIDTH 4/* LINE_CMP_VTHD - [3:0] */ -u16 wm8400_reg_read (struct wm8400 *wm8400,u8 reg); +int wm8400_reg_read (struct wm8400 *wm8400,u8 reg);int wm8400_block_read (struct wm8400 *wm8400,u8 reg,int count,u16 *data); static inline int wm8400_set_bits(struct wm8400 *wm8400, u8 reg,
drivers/mfd/wm8400-core.c +1 -1
@@ -43,7 +43,7 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg)* * @return Read value */ -u16 wm8400_reg_read (struct wm8400 *wm8400,u8 reg) +int wm8400_reg_read (struct wm8400 *wm8400,u8 reg) {unsigned int val;int ret;
Quoted 5 lines · Dan Carpenter
This is harmless because the function is not called, but we're trying to return negative error codes so the function needs to return an int instead of a u16.
Signed-off-by Dan Carpenter <[email protected]>
That patch looks fine, but the function appears to be completely unused, perhaps just a patch to remove it would be better?
Thanks,
Charles
PATCH v2 1/1 mfd: wm8400-core: delete wm8400_reg_read()
There was a static checker warning in wm8400_reg_read() because we were returning u16 and that can't hold the negative error codes. The function isn't used, so let's just delete it.
---
v2: just delete the function
include/linux/mfd/wm8400-private.h +0 -1
@@ -923,7 +923,6 @@ struct wm8400 {#define WM8400_LINE_CMP_VTHD_SHIFT 0/* LINE_CMP_VTHD - [3:0] */ #define WM8400_LINE_CMP_VTHD_WIDTH 4/* LINE_CMP_VTHD - [3:0] */ -u16 wm8400_reg_read (struct wm8400 *wm8400,u8 reg);int wm8400_block_read (struct wm8400 *wm8400,u8 reg,int count,u16 *data); static inline int wm8400_set_bits(struct wm8400 *wm8400, u8 reg,
drivers/mfd/wm8400-core.c +0 -21
@@ -35,27 +35,6 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg) } } -/** -* wm8400_reg_read - Single register read -* -* @wm8400: Pointer to wm8400 control structure -* @reg: Register to read -* -* @return Read value -*/ -u16 wm8400_reg_read (struct wm8400 *wm8400,u8 reg) -{ -unsigned int val; -int ret; - - ret =regmap_read (wm8400->regmap, reg, &val); -if (ret <0 ) -return ret; - -return val; -} -EXPORT_SYMBOL_GPL (wm8400_reg_read); -int wm8400_block_read (struct wm8400 *wm8400,u8 reg,int count,u16 *data) {return regmap_bulk_read (wm8400->regmap, reg, data, count);
Re: [patch v2] mfd: wm8400-core: delete wm8400_reg_read()
Quoted 6 lines · Dan Carpenter
There was a static checker warning in
wm8400_reg_read()because we were returning u16 and that can't hold the negative error codes. The function isn't used, so let's just delete it.Signed-off-by Dan Carpenter <[email protected]>---
Thanks,
Charles
Re: [patch v2] mfd: wm8400-core: delete wm8400_reg_read()
In reply to Dan CarpenterQuoted 7 lines · Dan Carpenter
There was a static checker warning in
wm8400_reg_read()because we were returning u16 and that can't hold the negative error codes. The function isn't used, so let's just delete it.Signed-off-by Dan Carpenter <[email protected]>---
v2: just delete the function
No diff?
I've fixed the $SUBJECT line and applied the patch.
Quoted 44 lines
include/linux/mfd/wm8400-private.h +0
-1@@ -923,7 +923,6 @@ struct wm8400 {#define WM8400_LINE_CMP_VTHD_SHIFT 0/* LINE_CMP_VTHD - [3:0] */ #define WM8400_LINE_CMP_VTHD_WIDTH 4/* LINE_CMP_VTHD - [3:0] */ -u16 wm8400_reg_read (struct wm8400 *wm8400,u8 reg);int wm8400_block_read (struct wm8400 *wm8400,u8 reg,int count,u16 *data); static inline int wm8400_set_bits(struct wm8400 *wm8400, u8 reg,drivers/mfd/wm8400-core.c +0
-21@@ -35,27 +35,6 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg) } } -/** -* wm8400_reg_read - Single register read -* -* @wm8400: Pointer to wm8400 control structure -* @reg: Register to read -* -* @return Read value -*/ -u16 wm8400_reg_read (struct wm8400 *wm8400,u8 reg) -{ -unsigned int val; -int ret; - - ret =regmap_read (wm8400->regmap, reg, &val); -if (ret <0 ) -return ret; - -return val; -} -EXPORT_SYMBOL_GPL (wm8400_reg_read); -int wm8400_block_read (struct wm8400 *wm8400,u8 reg,int count,u16 *data) {return regmap_bulk_read (wm8400->regmap, reg, data, count);
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html