linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] mfd: wm8400-core: signedness bug in wm8400_reg_read()
@ 2016-04-14  9:40 Dan Carpenter
  2016-04-14 10:01 ` Charles Keepax
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2016-04-14  9:40 UTC (permalink / raw)
  To: Lee Jones, Mark Brown; +Cc: patches, linux-kernel, kernel-janitors

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 <dan.carpenter@oracle.com>

diff --git a/include/linux/mfd/wm8400-private.h b/include/linux/mfd/wm8400-private.h
index 2de565b..53b2021 100644
--- a/include/linux/mfd/wm8400-private.h
+++ b/include/linux/mfd/wm8400-private.h
@@ -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,
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 3bd44a4..8fe2aa9 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] mfd: wm8400-core: signedness bug in wm8400_reg_read()
  2016-04-14  9:40 [patch] mfd: wm8400-core: signedness bug in wm8400_reg_read() Dan Carpenter
@ 2016-04-14 10:01 ` Charles Keepax
  2016-04-15 14:44   ` [patch v2] mfd: wm8400-core: delete wm8400_reg_read() Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Charles Keepax @ 2016-04-14 10:01 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Lee Jones, Mark Brown, patches, linux-kernel, kernel-janitors

On Thu, Apr 14, 2016 at 12:40:55PM +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>

That patch looks fine, but the function appears to be completely
unused, perhaps just a patch to remove it would be better?

Thanks,
Charles

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch v2] mfd: wm8400-core: delete wm8400_reg_read()
  2016-04-14 10:01 ` Charles Keepax
@ 2016-04-15 14:44   ` Dan Carpenter
  2016-04-15 15:15     ` Charles Keepax
  2016-04-25 11:00     ` Lee Jones
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2016-04-15 14:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: patches, linux-kernel, kernel-janitors, Mark Brown, Charles Keepax

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 <dan.carpenter@oracle.com>
---
v2: just delete the function

diff --git a/include/linux/mfd/wm8400-private.h b/include/linux/mfd/wm8400-private.h
index 2de565b..4ee908f 100644
--- a/include/linux/mfd/wm8400-private.h
+++ b/include/linux/mfd/wm8400-private.h
@@ -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,
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 3bd44a4..c1adfc1 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch v2] mfd: wm8400-core: delete wm8400_reg_read()
  2016-04-15 14:44   ` [patch v2] mfd: wm8400-core: delete wm8400_reg_read() Dan Carpenter
@ 2016-04-15 15:15     ` Charles Keepax
  2016-04-25 11:00     ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2016-04-15 15:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Lee Jones, patches, linux-kernel, kernel-janitors, Mark Brown

On Fri, Apr 15, 2016 at 05:44:18PM +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch v2] mfd: wm8400-core: delete wm8400_reg_read()
  2016-04-15 14:44   ` [patch v2] mfd: wm8400-core: delete wm8400_reg_read() Dan Carpenter
  2016-04-15 15:15     ` Charles Keepax
@ 2016-04-25 11:00     ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Lee Jones @ 2016-04-25 11:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: patches, linux-kernel, kernel-janitors, Mark Brown, Charles Keepax

On Fri, 15 Apr 2016, Dan Carpenter wrote:

> 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 <dan.carpenter@oracle.com>
> ---
> v2: just delete the function

No diff?

I've fixed the $SUBJECT line and applied the patch.

> diff --git a/include/linux/mfd/wm8400-private.h b/include/linux/mfd/wm8400-private.h
> index 2de565b..4ee908f 100644
> --- a/include/linux/mfd/wm8400-private.h
> +++ b/include/linux/mfd/wm8400-private.h
> @@ -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,
> diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
> index 3bd44a4..c1adfc1 100644
> --- a/drivers/mfd/wm8400-core.c
> +++ b/drivers/mfd/wm8400-core.c
> @@ -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);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-25 11:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14  9:40 [patch] mfd: wm8400-core: signedness bug in wm8400_reg_read() Dan Carpenter
2016-04-14 10:01 ` Charles Keepax
2016-04-15 14:44   ` [patch v2] mfd: wm8400-core: delete wm8400_reg_read() Dan Carpenter
2016-04-15 15:15     ` Charles Keepax
2016-04-25 11:00     ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).