All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: flexcan: fix bus-off error state handling.
@ 2015-03-17 13:03 Andri Yngvason
  2015-03-20  9:11 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Andri Yngvason @ 2015-03-17 13:03 UTC (permalink / raw)
  To: linux-can; +Cc: mkl, wg

Making sure that the bus-off state gets passed to can_change_state().

Signed-off-by: Andri Yngvason <andri.yngvason@marel.com>
---
 drivers/net/can/flexcan.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 80c46ad..ee944ae 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -592,13 +592,12 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
 		rx_state = unlikely(reg_esr & FLEXCAN_ESR_RX_WRN) ?
 			   CAN_STATE_ERROR_WARNING : CAN_STATE_ERROR_ACTIVE;
 		new_state = max(tx_state, rx_state);
-	} else if (unlikely(flt == FLEXCAN_ESR_FLT_CONF_PASSIVE)) {
+	} else {
 		__flexcan_get_berr_counter(dev, &bec);
-		new_state = CAN_STATE_ERROR_PASSIVE;
+		new_state = flt == FLEXCAN_ESR_FLT_CONF_PASSIVE ?
+			    CAN_STATE_ERROR_PASSIVE : CAN_STATE_BUS_OFF;
 		rx_state = bec.rxerr >= bec.txerr ? new_state : 0;
 		tx_state = bec.rxerr <= bec.txerr ? new_state : 0;
-	} else {
-		new_state = CAN_STATE_BUS_OFF;
 	}
 
 	/* state hasn't changed */
-- 
1.9.1


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

* Re: [PATCH] can: flexcan: fix bus-off error state handling.
  2015-03-17 13:03 [PATCH] can: flexcan: fix bus-off error state handling Andri Yngvason
@ 2015-03-20  9:11 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2015-03-20  9:11 UTC (permalink / raw)
  To: Andri Yngvason, linux-can; +Cc: wg

[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]

On 03/17/2015 02:03 PM, Andri Yngvason wrote:
> Making sure that the bus-off state gets passed to can_change_state().
> 
> Signed-off-by: Andri Yngvason <andri.yngvason@marel.com>

Applied to can with a minor change.

> ---
>  drivers/net/can/flexcan.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index 80c46ad..ee944ae 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -592,13 +592,12 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
>  		rx_state = unlikely(reg_esr & FLEXCAN_ESR_RX_WRN) ?
>  			   CAN_STATE_ERROR_WARNING : CAN_STATE_ERROR_ACTIVE;
>  		new_state = max(tx_state, rx_state);
> -	} else if (unlikely(flt == FLEXCAN_ESR_FLT_CONF_PASSIVE)) {
> +	} else {
>  		__flexcan_get_berr_counter(dev, &bec);
> -		new_state = CAN_STATE_ERROR_PASSIVE;
> +		new_state = flt == FLEXCAN_ESR_FLT_CONF_PASSIVE ?
> +			    CAN_STATE_ERROR_PASSIVE : CAN_STATE_BUS_OFF;

converted this into a if...else

>  		rx_state = bec.rxerr >= bec.txerr ? new_state : 0;
>  		tx_state = bec.rxerr <= bec.txerr ? new_state : 0;
> -	} else {
> -		new_state = CAN_STATE_BUS_OFF;
>  	}
>  
>  	/* state hasn't changed */
> 

Thanks,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-03-20  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-17 13:03 [PATCH] can: flexcan: fix bus-off error state handling Andri Yngvason
2015-03-20  9:11 ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.