All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Andri Yngvason <andri.yngvason@marel.com>, linux-can@vger.kernel.org
Cc: wg@grandegger.com
Subject: Re: [PATCH] can: flexcan: fix bus-off error state handling.
Date: Fri, 20 Mar 2015 10:11:59 +0100	[thread overview]
Message-ID: <550BE45F.8040100@pengutronix.de> (raw)
In-Reply-To: <40e1c77d-546d-48b6-b4bd-fe76f7692e90@GRBSR0089.marel.net>

[-- 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 --]

      reply	other threads:[~2015-03-20  9:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=550BE45F.8040100@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=andri.yngvason@marel.com \
    --cc=linux-can@vger.kernel.org \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.