linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ira W. Snyder" <iws@ovro.caltech.edu>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH 5/9] can: janz-ican3: cleanup of ican3_to_can_frame and can_frame_to_ican3
Date: Fri, 20 Jul 2012 08:39:34 -0700	[thread overview]
Message-ID: <20120720153933.GA18481@ovro.caltech.edu> (raw)
In-Reply-To: <1342782709-4868-6-git-send-email-mkl@pengutronix.de>

On Fri, Jul 20, 2012 at 01:11:45PM +0200, Marc Kleine-Budde wrote:
> This patch cleans up the ICAN3 to Linux CAN frame and vice versa
> conversion functions:
> 
> - RX: Use get_can_dlc() to limit the dlc value.
> - RX+TX: Don't copy the whole frame, only copy the amount of bytes
>   specified in cf->can_dlc.
> 
> Cc: Ira W. Snyder <iws@ovro.caltech.edu>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---

It looks good to me, and works perfectly.

Acked-by: Ira W. Snyder <iws@ovro.caltech.edu>
Tested-by: Ira W. Snyder <iws@ovro.caltech.edu>

>  drivers/net/can/janz-ican3.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
> index 754b803..b19aca5 100644
> --- a/drivers/net/can/janz-ican3.c
> +++ b/drivers/net/can/janz-ican3.c
> @@ -811,10 +811,10 @@ static void ican3_to_can_frame(struct ican3_dev *mod,
>  
>  		cf->can_id |= desc->data[0] << 3;
>  		cf->can_id |= (desc->data[1] & 0xe0) >> 5;
> -		cf->can_dlc = desc->data[1] & ICAN3_CAN_DLC_MASK;
> -		memcpy(cf->data, &desc->data[2], sizeof(cf->data));
> +		cf->can_dlc = get_can_dlc(desc->data[1] & ICAN3_CAN_DLC_MASK);
> +		memcpy(cf->data, &desc->data[2], cf->can_dlc);
>  	} else {
> -		cf->can_dlc = desc->data[0] & ICAN3_CAN_DLC_MASK;
> +		cf->can_dlc = get_can_dlc(desc->data[0] & ICAN3_CAN_DLC_MASK);
>  		if (desc->data[0] & ICAN3_EFF_RTR)
>  			cf->can_id |= CAN_RTR_FLAG;
>  
> @@ -829,7 +829,7 @@ static void ican3_to_can_frame(struct ican3_dev *mod,
>  			cf->can_id |= desc->data[3] >> 5;  /* 2-0   */
>  		}
>  
> -		memcpy(cf->data, &desc->data[6], sizeof(cf->data));
> +		memcpy(cf->data, &desc->data[6], cf->can_dlc);
>  	}
>  }
>  
> @@ -861,7 +861,7 @@ static void can_frame_to_ican3(struct ican3_dev *mod,
>  	}
>  
>  	/* copy the data bits into the descriptor */
> -	memcpy(&desc->data[6], cf->data, sizeof(cf->data));
> +	memcpy(&desc->data[6], cf->data, cf->can_dlc);
>  }
>  
>  /*
> -- 
> 1.7.10
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2012-07-20 15:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 11:11 [PATCH 0/9] upcoming pull request: const annoations + flexcan + janz-ican3 update Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 1/9] can: mark bittiming_const pointer in struct can_priv as const Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 2/9] can: flexcan: add 2nd clock to support imx53 and newer Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 3/9] can: janz-ican3: remove dead code Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 4/9] can: janz-ican3: drop invalid skbs Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 5/9] can: janz-ican3: cleanup of ican3_to_can_frame and can_frame_to_ican3 Marc Kleine-Budde
2012-07-20 15:39   ` Ira W. Snyder [this message]
2012-07-20 11:11 ` [PATCH 6/9] can: janz-ican3: fix error and byte counters Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 7/9] can: janz-ican3: fix support for CAN_RAW_RECV_OWN_MSGS Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 8/9] can: janz-ican3: avoid firmware lockup caused by infinite bus error quota Marc Kleine-Budde
2012-07-20 11:11 ` [PATCH 9/9] can: janz-ican3: add support for one shot mode Marc Kleine-Budde
2012-07-20 11:15 ` [PATCH 0/9] upcoming pull request: const annoations + flexcan + janz-ican3 update Marc Kleine-Budde

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=20120720153933.GA18481@ovro.caltech.edu \
    --to=iws@ovro.caltech.edu \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /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).