> -----Original Message----- > From: Marc Kleine-Budde [mailto:mkl@xxxxxxxxxxxxxx] > Sent: Tuesday, July 31, 2018 12:47 PM > To: Alexander Stein <alexander.stein@xxxxxxxxxxxxxxxxxxxxx>; Pankaj > Bansal <pankaj.bansal@xxxxxxx> > Cc: linux-can@xxxxxxxxxxxxxxx > Subject: Re: [PATCH 4/6] net: can: flexcan: Add provision for variable > payload size > > On 07/31/2018 07:34 AM, Alexander Stein wrote: > > On Monday, July 30, 2018, 6:07:13 PM CEST Pankaj Bansal wrote: > >> [...] > >> @@ -666,8 +670,13 @@ static unsigned int > flexcan_mailbox_read(struct > >> can_rx_offload *offload, { > >> struct flexcan_priv *priv = rx_offload_to_priv(offload); > >> struct flexcan_regs __iomem *regs = priv->regs; > >> - struct flexcan_mb __iomem *mb = ®s->mb[n]; > >> - u32 reg_ctrl, reg_id, reg_iflag1; > >> + struct flexcan_mb __iomem *mb; > >> + u32 reg_ctrl, reg_id, reg_iflag1, i, data; > > > > Shouldn't data be __be32 instead? > > Yes... > > > > >> + u8 mb_size, can_dlc_dword; > >> + > >> + mb_size = sizeof(struct flexcan_mb) + > >> +priv->devtype_data->payload_size; > >> + > >> + mb = (struct flexcan_mb __iomem *)((u8 *)®s->mb + (mb_size > * > >> +n)); > >> > >> if (priv->devtype_data->quirks & > FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) { > >> u32 code; > >> @@ -708,8 +717,11 @@ static unsigned int > flexcan_mailbox_read(struct can_rx_offload *offload, > >> cf->can_id |= CAN_RTR_FLAG; > >> cf->can_dlc = get_can_dlc((reg_ctrl >> 16) & 0xf); > >> > >> - *(__be32 *)(cf->data + 0) = cpu_to_be32(priv->read(&mb- > >data[0])); > >> - *(__be32 *)(cf->data + 4) = cpu_to_be32(priv->read(&mb- > >data[1])); > >> + can_dlc_dword = (cf->can_dlc + sizeof(u32) - 1) / sizeof(u32); > >> + for (i = 0; i < can_dlc_dword; i++) { > >> + data = cpu_to_be32(priv->read(&mb->data[i])); > > ...as it's assigned from a _to_be32 here. Understood. Will incorporate in V2 > > >> + *(__be32 *)(cf->data + (i * sizeof(u32))) = data; > > > > So sparse can help here when dealing with little/big-endianess when > compiling using C=2. > ACK > > 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 | ��.n��������+%������w��{.n�����{����*jg��������ݢj����G�������j:+v���w�m������w�������h�����٥