Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8df9ffb8 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

can: make use of preallocated can_ml_priv for per device struct can_dev_rcv_lists



This patch removes the old method of allocating the per device protocol
specific memory via a netdevice_notifier. This had the drawback, that
the allocation can fail, leading to a lot of null pointer checks in the
code. This also makes the live cycle management of this memory quite
complicated.

This patch switches from the allocating the struct can_dev_rcv_lists in
a NETDEV_REGISTER call to using the dev->ml_priv, which is allocated by
the driver since the previous patch.

Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent ffd956ee
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -746,6 +746,8 @@ struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
	priv = netdev_priv(dev);
	priv->dev = dev;

	dev->ml_priv = (void *)priv + ALIGN(sizeof_priv, NETDEV_ALIGN);

	if (echo_skb_max) {
		priv->echo_skb_max = echo_skb_max;
		priv->echo_skb = (void *)priv +
+1 −0
Original line number Diff line number Diff line
@@ -536,6 +536,7 @@ static struct slcan *slc_alloc(void)

	dev->base_addr  = i;
	sl = netdev_priv(dev);
	dev->ml_priv = (void *)sl + ALIGN(sizeof(*sl), NETDEV_ALIGN);

	/* Initialize channel control data */
	sl->magic = SLCAN_MAGIC;
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ static void vcan_setup(struct net_device *dev)
	dev->addr_len		= 0;
	dev->tx_queue_len	= 0;
	dev->flags		= IFF_NOARP;
	dev->ml_priv		= netdev_priv(dev);

	/* set flags according to driver capabilities */
	if (echo)
+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ static void vxcan_setup(struct net_device *dev)
	dev->flags		= (IFF_NOARP|IFF_ECHO);
	dev->netdev_ops		= &vxcan_netdev_ops;
	dev->needs_free_netdev	= true;
	dev->ml_priv		= netdev_priv(dev) + ALIGN(sizeof(struct vxcan_priv), NETDEV_ALIGN);
}

/* forward declaration for rtnl_create_link() */
+0 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ struct can_dev_rcv_lists {
	struct hlist_head rx[RX_MAX];
	struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
	struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
	int remove_on_zero_entries;
	int entries;
};

Loading