diff mbox series

[1/2] ieee802154: mcr20a: Replace magic number with constants

Message ID 20180831214642.30711-2-liuxuenetmail@gmail.com (mailing list archive)
State Accepted
Headers show
Series ieee802154: mcr20a: clean and improve the driver | expand

Commit Message

Xue Liu Aug. 31, 2018, 9:46 p.m. UTC
The combination of defined constants are used to present the
state of IRQ so the magic numbers has been replaced.

This is a simple coding style change which should have no impact on
runtime code execution.

Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
---
 drivers/net/ieee802154/mcr20a.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefan Schmidt Sept. 27, 2018, 3:27 p.m. UTC | #1
Hello Xue.

On 31/08/2018 23:46, Xue Liu wrote:
> The combination of defined constants are used to present the
> state of IRQ so the magic numbers has been replaced.
> 
> This is a simple coding style change which should have no impact on
> runtime code execution.
> 
> Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
> ---
>  drivers/net/ieee802154/mcr20a.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> index e428277781ac..04891429a554 100644
> --- a/drivers/net/ieee802154/mcr20a.c
> +++ b/drivers/net/ieee802154/mcr20a.c
> @@ -903,19 +903,19 @@ mcr20a_irq_clean_complete(void *context)
>  
>  	switch (seq_state) {
>  	/* TX IRQ, RX IRQ and SEQ IRQ */
> -	case (0x03):
> +	case (DAR_IRQSTS1_TXIRQ | DAR_IRQSTS1_SEQIRQ):
>  		if (lp->is_tx) {
>  			lp->is_tx = 0;
>  			dev_dbg(printdev(lp), "TX is done. No ACK\n");
>  			mcr20a_handle_tx_complete(lp);
>  		}
>  		break;
> -	case (0x05):
> +	case (DAR_IRQSTS1_RXIRQ | DAR_IRQSTS1_SEQIRQ):
>  			/* rx is starting */
>  			dev_dbg(printdev(lp), "RX is starting\n");
>  			mcr20a_handle_rx(lp);
>  		break;
> -	case (0x07):
> +	case (DAR_IRQSTS1_RXIRQ | DAR_IRQSTS1_TXIRQ | DAR_IRQSTS1_SEQIRQ):
>  		if (lp->is_tx) {
>  			/* tx is done */
>  			lp->is_tx = 0;
> @@ -927,7 +927,7 @@ mcr20a_irq_clean_complete(void *context)
>  			mcr20a_handle_rx(lp);
>  		}
>  		break;
> -	case (0x01):
> +	case (DAR_IRQSTS1_SEQIRQ):
>  		if (lp->is_tx) {
>  			dev_dbg(printdev(lp), "TX is starting\n");
>  			mcr20a_handle_tx(lp);
> 

This patch has been applied to the wpan tree and will be
part of the next pull request to net. Thanks!

I decided to put this into wpan directly as it clearly is cleanup
material. The second patch will need to go through wpan-next though.

regards
Stefan Schmidt
diff mbox series

Patch

diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index e428277781ac..04891429a554 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -903,19 +903,19 @@  mcr20a_irq_clean_complete(void *context)
 
 	switch (seq_state) {
 	/* TX IRQ, RX IRQ and SEQ IRQ */
-	case (0x03):
+	case (DAR_IRQSTS1_TXIRQ | DAR_IRQSTS1_SEQIRQ):
 		if (lp->is_tx) {
 			lp->is_tx = 0;
 			dev_dbg(printdev(lp), "TX is done. No ACK\n");
 			mcr20a_handle_tx_complete(lp);
 		}
 		break;
-	case (0x05):
+	case (DAR_IRQSTS1_RXIRQ | DAR_IRQSTS1_SEQIRQ):
 			/* rx is starting */
 			dev_dbg(printdev(lp), "RX is starting\n");
 			mcr20a_handle_rx(lp);
 		break;
-	case (0x07):
+	case (DAR_IRQSTS1_RXIRQ | DAR_IRQSTS1_TXIRQ | DAR_IRQSTS1_SEQIRQ):
 		if (lp->is_tx) {
 			/* tx is done */
 			lp->is_tx = 0;
@@ -927,7 +927,7 @@  mcr20a_irq_clean_complete(void *context)
 			mcr20a_handle_rx(lp);
 		}
 		break;
-	case (0x01):
+	case (DAR_IRQSTS1_SEQIRQ):
 		if (lp->is_tx) {
 			dev_dbg(printdev(lp), "TX is starting\n");
 			mcr20a_handle_tx(lp);