linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Nikita Edward Baruzdin <nebaruzdin@gmail.com>, linux-can@vger.kernel.org
Subject: Re: [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
Date: Thu, 10 Jul 2014 16:25:49 +0200	[thread overview]
Message-ID: <53BEA26D.2040007@pengutronix.de> (raw)
In-Reply-To: <1404934273-19233-1-git-send-email-nebaruzdin@gmail.com>

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

On 07/09/2014 09:31 PM, Nikita Edward Baruzdin wrote:
> This adds support for hardware loopback in SJA1000 by utilising its self
> reception request (SRR) feature. Upon SRR the message is transmitted and
> received simultaneously, meaning you can't have hardware loopback
> without actually sending a message to the CAN bus in case of SJA1000.
> 
> Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>

Looks good, coding style nitpick inline...

> ---
>  drivers/net/can/sja1000/sja1000.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
> index f31499a..c480bce 100644
> --- a/drivers/net/can/sja1000/sja1000.c
> +++ b/drivers/net/can/sja1000/sja1000.c
> @@ -278,6 +278,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
>  	uint8_t dlc;
>  	canid_t id;
>  	uint8_t dreg;
> +	u8 cmd_reg_val = 0x00;
>  	int i;
>  
>  	if (can_dropped_invalid_skb(dev, skb))
> @@ -312,9 +313,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
>  	can_put_echo_skb(skb, dev, 0);
>  
>  	if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
> -		sja1000_write_cmdreg(priv, CMD_TR | CMD_AT);
> +		cmd_reg_val |= CMD_AT;
> +
> +	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
> +		cmd_reg_val |= CMD_SRR;
>  	else
> -		sja1000_write_cmdreg(priv, CMD_TR);
> +		cmd_reg_val |= CMD_TR;
> +
> +	sja1000_write_cmdreg(priv, cmd_reg_val);
>  
>  	return NETDEV_TX_OK;
>  }
> @@ -622,9 +628,11 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
>  	priv->can.do_set_bittiming = sja1000_set_bittiming;
>  	priv->can.do_set_mode = sja1000_set_mode;
>  	priv->can.do_get_berr_counter = sja1000_get_berr_counter;
> -	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
> -		CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY |
> -		CAN_CTRLMODE_ONE_SHOT;
> +	priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK
> +				     | CAN_CTRLMODE_LISTENONLY
> +				     | CAN_CTRLMODE_3_SAMPLES
> +				     | CAN_CTRLMODE_ONE_SHOT
> +				     | CAN_CTRLMODE_BERR_REPORTING;

Please keep the '|' at the end of the lines.

>  
>  	spin_lock_init(&priv->cmdreg_lock);
>  
> 

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: 242 bytes --]

  parent reply	other threads:[~2014-07-10 14:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 19:31 [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
2014-07-09 19:31 ` [PATCH 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
2014-07-09 19:31 ` [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
2014-07-10 14:06   ` Oliver Hartkopp
2014-07-10 14:12     ` Marc Kleine-Budde
2014-07-11 13:18       ` Oliver Hartkopp
2014-07-11 14:42         ` Nikita Edward Baruzdin
2014-07-14 12:21     ` Marc Kleine-Budde
2014-07-15  1:32       ` Oliver Hartkopp
2014-07-09 19:31 ` [PATCH 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
2014-07-10 14:25 ` Marc Kleine-Budde [this message]
2014-07-11 12:13   ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
2014-07-15  7:35     ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
2014-07-15  8:44       ` Nikita Edward Baruzdin

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=53BEA26D.2040007@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=nebaruzdin@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).