All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: Andreas Larsson <andreas@gaisler.com>
Cc: linux-can@vger.kernel.org, software@gaisler.com
Subject: Re: [PATCH v3] can: sja1000: Add support for listen-only mode and one-shot mode
Date: Wed, 19 Sep 2012 09:33:10 +0200	[thread overview]
Message-ID: <50597536.10703@grandegger.com> (raw)
In-Reply-To: <1348038735-3218-1-git-send-email-andreas@gaisler.com>

Hi Andreas,

looks nice now. Just some final comments from my side...

On 09/19/2012 09:12 AM, Andreas Larsson wrote:
> One-shot mode uses the TCS bit of the status register to discern
> whether the transmission was successful or not. On a failed
> transmission frames are not echoed back.
> 
> When one-shot mode is not enabled, no transmit interrupt is generated
> by a failed transmission. Therefore, the branch in the interrupt
> handler that frees the echo skb is never triggered unless one-shot
> mode is enabled.
> 
> Signed-off-by: Andreas Larsson <andreas@gaisler.com>
> ---
>  drivers/net/can/sja1000/sja1000.c |   29 ++++++++++++++++++++++-------
>  1 files changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
> index 4c4f33d..fb39461 100644
> --- a/drivers/net/can/sja1000/sja1000.c
> +++ b/drivers/net/can/sja1000/sja1000.c
> @@ -156,7 +156,10 @@ static void set_normal_mode(struct net_device *dev)
>  		}
>  
>  		/* set chip to normal mode */
> -		priv->write_reg(priv, REG_MOD, 0x00);
> +		if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
> +			priv->write_reg(priv, REG_MOD, MOD_LOM);
> +		else
> +			priv->write_reg(priv, REG_MOD, 0x00);
>  		udelay(10);
>  		status = priv->read_reg(priv, REG_MOD);
>  	}
> @@ -310,7 +313,10 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
>  
>  	can_put_echo_skb(skb, dev, 0);
>  
> -	sja1000_write_cmdreg(priv, CMD_TR);
> +	if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
> +		sja1000_write_cmdreg(priv, CMD_TR | CMD_AT);
> +	else
> +		sja1000_write_cmdreg(priv, CMD_TR);
>  
>  	return NETDEV_TX_OK;
>  }
> @@ -505,10 +511,18 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
>  			netdev_warn(dev, "wakeup interrupt\n");
>  
>  		if (isrc & IRQ_TI) {
> -			/* transmission complete interrupt */
> -			stats->tx_bytes += priv->read_reg(priv, REG_FI) & 0xf;
> -			stats->tx_packets++;
> -			can_get_echo_skb(dev, 0);
> +			/* transmission buffer released */
> +			if (status & SR_TCS) {
> +				/* transmission complete */
> +				stats->tx_bytes +=
> +					priv->read_reg(priv, REG_FI) & 0xf;
> +				stats->tx_packets++;
> +				can_get_echo_skb(dev, 0);
> +			} else {
> +				/* reachable only in one-shot mode */
> +				stats->tx_errors++;
> +				can_free_echo_skb(dev, 0);
> +			}

I would prefer not touching the original path:

			if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT &&
			    !(status & SR_TCS) {
				/* reachable only in one-shot mode */
				stats->tx_errors++;
				can_free_echo_skb(dev, 0);
			} else {
				/* transmission complete */
				stats->tx_bytes +=
					priv->read_reg(priv, REG_FI) & 0xf;
				stats->tx_packets++;
				can_get_echo_skb(dev, 0);
			}

With that change you can add my:

Acked-by: Wolfgang Grandegger <wg@grandegger.com>

Thanks,

Wolfgang.

  reply	other threads:[~2012-09-19  7:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 15:58 [PATCH] can: sja1000: Add support for listen-only mode and one-shot mode Andreas Larsson
2012-09-18 13:46 ` Marc Kleine-Budde
2012-09-18 14:11   ` Wolfgang Grandegger
2012-09-18 15:54     ` Andreas Larsson
2012-09-18 16:16       ` Ira W. Snyder
2012-09-18 16:20         ` Marc Kleine-Budde
2012-09-18 16:34       ` [PATCH v2] " Andreas Larsson
2012-09-18 17:17         ` Marc Kleine-Budde
2012-09-18 17:23           ` Oliver Hartkopp
2012-09-19  5:55             ` Andreas Larsson
2012-09-18 18:27         ` Wolfgang Grandegger
2012-09-19  5:56           ` Andreas Larsson
2012-09-19  7:12             ` [PATCH v3] " Andreas Larsson
2012-09-19  7:33               ` Wolfgang Grandegger [this message]
2012-09-19 10:24                 ` [PATCH v4] " Andreas Larsson
2012-09-19 16:49                   ` Oliver Hartkopp
2012-09-20  7:50                     ` [PATCH v5] " Andreas Larsson
2012-09-21  8:08                       ` Marc Kleine-Budde
2012-09-21  8:12                         ` Andreas Larsson

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=50597536.10703@grandegger.com \
    --to=wg@grandegger.com \
    --cc=andreas@gaisler.com \
    --cc=linux-can@vger.kernel.org \
    --cc=software@gaisler.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.