summaryrefslogtreecommitdiffstats
path: root/drivers/net/can/ti_hecc.c
diff options
context:
space:
mode:
authorJoakim Zhang <qiangqing.zhang@nxp.com>2019-07-12 10:02:38 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2019-11-11 21:58:10 +0100
commit4e9c9484b085dbba60b299182dd490eaeb84d18a (patch)
tree2132ffbed1a86dc3085c9a2c0cad7fd2d1f9c2f8 /drivers/net/can/ti_hecc.c
parentcan: rx-offload: can_rx_offload_reset(): remove no-op function (diff)
downloadlinux-4e9c9484b085dbba60b299182dd490eaeb84d18a.tar.xz
linux-4e9c9484b085dbba60b299182dd490eaeb84d18a.zip
can: rx-offload: Prepare for CAN FD support
The skbs for classic CAN and CAN FD frames are allocated with seperate functions: alloc_can_skb() and alloc_canfd_skb(). In order to support CAN FD frames via the rx-offload helper, the driver itself has to allocate the skb (depending whether it received a classic CAN or CAN FD frame), as the rx-offload helper cannot know which kind of CAN frame the driver has received. This patch moves the allocation of the skb into the struct can_rx_offload::mailbox_read callbacks of the the flexcan and ti_hecc driver and adjusts the rx-offload helper accordingly. Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/ti_hecc.c')
-rw-r--r--drivers/net/can/ti_hecc.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 31ad364a89bb..94b1491b569f 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -535,15 +535,28 @@ struct ti_hecc_priv *rx_offload_to_priv(struct can_rx_offload *offload)
return container_of(offload, struct ti_hecc_priv, offload);
}
-static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
- struct can_frame *cf,
- u32 *timestamp, unsigned int mbxno)
+static struct sk_buff *ti_hecc_mailbox_read(struct can_rx_offload *offload,
+ unsigned int mbxno, u32 *timestamp,
+ bool drop)
{
struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
+ struct sk_buff *skb;
+ struct can_frame *cf;
u32 data, mbx_mask;
- int ret = 1;
mbx_mask = BIT(mbxno);
+
+ if (unlikely(drop)) {
+ skb = ERR_PTR(-ENOBUFS);
+ goto mark_as_read;
+ }
+
+ skb = alloc_can_skb(offload->dev, &cf);
+ if (unlikely(!skb)) {
+ skb = ERR_PTR(-ENOMEM);
+ goto mark_as_read;
+ }
+
data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
if (data & HECC_CANMID_IDE)
cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG;
@@ -578,11 +591,12 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
*/
if (unlikely(mbxno == HECC_RX_LAST_MBOX &&
hecc_read(priv, HECC_CANRML) & mbx_mask))
- ret = -ENOBUFS;
+ skb = ERR_PTR(-ENOBUFS);
+ mark_as_read:
hecc_write(priv, HECC_CANRMP, mbx_mask);
- return ret;
+ return skb;
}
static int ti_hecc_error(struct net_device *ndev, int int_status,