Le 29/01/2014 08:16, Wolfgang Grandegger a écrit :
On Tue, 28 Jan 2014 23:06:54 +0100, Gilles Chanteperdrix
<gilles.chanteperd...@xenomai.org> wrote:
On 01/27/2014 08:56 AM, Wolfgang Grandegger wrote:
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
IMO, it is not just for the flexcan driver, it will avoid unaligned
accesses for all drivers which access data 4 bytes at a time. And I do
not think it "breaks" anything. What I do not know is:


But it's just the Flexcan driver which is doing unaligned accesses.
Ok, can we agree on the following patch then?

diff --git a/ksrc/drivers/can/rtcan_flexcan.c
b/ksrc/drivers/can/rtcan_flexcan.c
index 8f0e8d1..1674b73 100644
--- a/ksrc/drivers/can/rtcan_flexcan.c
+++ b/ksrc/drivers/can/rtcan_flexcan.c
@@ -38,6 +38,7 @@
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  #include <linux/pinctrl/consumer.h>
  #endif
+#include <asm/unaligned.h>
#include <rtdm/rtdm_driver.h> @@ -497,11 +498,9 @@ static void flexcan_rx_interrupt(struct
rtcan_device
*dev,
                cf->can_id |= CAN_RTR_FLAG;
                skb->rb_frame_size = EMPTY_RB_FRAME_SIZE;
        } else {
-               skb->rb_frame_size = EMPTY_RB_FRAME_SIZE + cf->can_dlc ;
-               *(__be32 *)(cf->data + 0) =
-                       cpu_to_be32(flexcan_read(&mb->data[0]));
-               *(__be32 *)(cf->data + 4) =
-                       cpu_to_be32(flexcan_read(&mb->data[1]));
+               skb->rb_frame_size = EMPTY_RB_FRAME_SIZE + cf->can_dlc;
+               put_unaligned_be32(flexcan_read(&mb->data[0]), cf->data + 0);
+               put_unaligned_be32(flexcan_read(&mb->data[1]), cf->data + 4);
        }
/* Store the interface index */
D'accord, thanks.

Wolfgang.

Thank you all for your replies

Alexandre.



_______________________________________________
Xenomai mailing list
Xenomai@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai

Reply via email to