diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2010-10-21 12:39:26 -0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2012-07-20 11:48:53 -0400 |
commit | 9e4d6909a273ada78cf48379e478855bc13ae0cb (patch) | |
tree | bb07dcb34ec9019c4ee5b98b2f8eb82e0941b863 | |
parent | 007890d726602c925077381500f0b633cfacd711 (diff) |
can: janz-ican3: cleanup of ican3_to_can_frame and can_frame_to_ican3
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.
Acked-by: Ira W. Snyder <iws@ovro.caltech.edu>
Tested-by: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | drivers/net/can/janz-ican3.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c index 754b803fa926..b19aca591c7a 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, | |||
811 | 811 | ||
812 | cf->can_id |= desc->data[0] << 3; | 812 | cf->can_id |= desc->data[0] << 3; |
813 | cf->can_id |= (desc->data[1] & 0xe0) >> 5; | 813 | cf->can_id |= (desc->data[1] & 0xe0) >> 5; |
814 | cf->can_dlc = desc->data[1] & ICAN3_CAN_DLC_MASK; | 814 | cf->can_dlc = get_can_dlc(desc->data[1] & ICAN3_CAN_DLC_MASK); |
815 | memcpy(cf->data, &desc->data[2], sizeof(cf->data)); | 815 | memcpy(cf->data, &desc->data[2], cf->can_dlc); |
816 | } else { | 816 | } else { |
817 | cf->can_dlc = desc->data[0] & ICAN3_CAN_DLC_MASK; | 817 | cf->can_dlc = get_can_dlc(desc->data[0] & ICAN3_CAN_DLC_MASK); |
818 | if (desc->data[0] & ICAN3_EFF_RTR) | 818 | if (desc->data[0] & ICAN3_EFF_RTR) |
819 | cf->can_id |= CAN_RTR_FLAG; | 819 | cf->can_id |= CAN_RTR_FLAG; |
820 | 820 | ||
@@ -829,7 +829,7 @@ static void ican3_to_can_frame(struct ican3_dev *mod, | |||
829 | cf->can_id |= desc->data[3] >> 5; /* 2-0 */ | 829 | cf->can_id |= desc->data[3] >> 5; /* 2-0 */ |
830 | } | 830 | } |
831 | 831 | ||
832 | memcpy(cf->data, &desc->data[6], sizeof(cf->data)); | 832 | memcpy(cf->data, &desc->data[6], cf->can_dlc); |
833 | } | 833 | } |
834 | } | 834 | } |
835 | 835 | ||
@@ -861,7 +861,7 @@ static void can_frame_to_ican3(struct ican3_dev *mod, | |||
861 | } | 861 | } |
862 | 862 | ||
863 | /* copy the data bits into the descriptor */ | 863 | /* copy the data bits into the descriptor */ |
864 | memcpy(&desc->data[6], cf->data, sizeof(cf->data)); | 864 | memcpy(&desc->data[6], cf->data, cf->can_dlc); |
865 | } | 865 | } |
866 | 866 | ||
867 | /* | 867 | /* |