diff mbox series

i2c-xiic: Fix the type check for xiic_wakeup

Message ID 20220526040914.4159495-1-shubhrajyoti.datta@xilinx.com
State Superseded
Headers show
Series i2c-xiic: Fix the type check for xiic_wakeup | expand

Commit Message

Shubhrajyoti Datta May 26, 2022, 4:09 a.m. UTC
Fix the coverity warning
mixed_enum_type: enumerated type mixed with another type

Enum is passed to xiic_wakeup, change the function parameter
to reflect it.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---

 drivers/i2c/busses/i2c-xiic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Simek May 31, 2022, 11:03 a.m. UTC | #1
On 5/26/22 06:09, Shubhrajyoti Datta wrote:
> Fix the coverity warning
> mixed_enum_type: enumerated type mixed with another type
> 
> Enum is passed to xiic_wakeup, change the function parameter
> to reflect it.
> 
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> 
>   drivers/i2c/busses/i2c-xiic.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index 9a1c3f8b7048..2b6341f08d71 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -367,7 +367,7 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c)
>   	}
>   }
>   
> -static void xiic_wakeup(struct xiic_i2c *i2c, int code)
> +static void xiic_wakeup(struct xiic_i2c *i2c, enum xilinx_i2c_state code)
>   {
>   	i2c->tx_msg = NULL;
>   	i2c->rx_msg = NULL;


Change itself is fine but

wakeup_code in xiic_process should be also fixed because it is defined as int 
now and you are using initial value as 0.

It means your change and this one too.

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index ffefe3c482e9..b369b42fffd7 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -34,9 +34,9 @@
  #define DRIVER_NAME "xiic-i2c"

  enum xilinx_i2c_state {
-       STATE_DONE,
-       STATE_ERROR,
-       STATE_START
+       STATE_DONE = 0,
+       STATE_ERROR = 1,
+       STATE_START = 2
  };

  enum xiic_endian {
@@ -380,7 +380,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)
         u32 clr = 0;
         int xfer_more = 0;
         int wakeup_req = 0;
-       int wakeup_code = 0;
+       enum xilinx_i2c_state wakeup_code = STATE_DONE;

         /* Get the interrupt Status from the IPIF. There is no clearing of
          * interrupts in the IPIF. Interrupts must be cleared at the source.

M
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 9a1c3f8b7048..2b6341f08d71 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -367,7 +367,7 @@  static void xiic_fill_tx_fifo(struct xiic_i2c *i2c)
 	}
 }
 
-static void xiic_wakeup(struct xiic_i2c *i2c, int code)
+static void xiic_wakeup(struct xiic_i2c *i2c, enum xilinx_i2c_state code)
 {
 	i2c->tx_msg = NULL;
 	i2c->rx_msg = NULL;