Hey Dario, just a quick note... On 24.02.2021 23:52:45, Dario Binacchi wrote: > -struct net_device *alloc_c_can_dev(void) > +struct net_device *alloc_c_can_dev(int msg_obj_num) > { > struct net_device *dev; > struct c_can_priv *priv; > + int msg_obj_tx_num = msg_obj_num / 2; > > - dev = alloc_candev(sizeof(struct c_can_priv), C_CAN_MSG_OBJ_TX_NUM); > + dev = alloc_candev(sizeof(struct c_can_priv), msg_obj_tx_num); > if (!dev) > return NULL; > > priv = netdev_priv(dev); > - netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT); > + priv->msg_obj_num = msg_obj_num; > + priv->msg_obj_rx_num = msg_obj_num - msg_obj_tx_num; > + priv->msg_obj_rx_first = 1; > + priv->msg_obj_rx_last = > + priv->msg_obj_rx_first + priv->msg_obj_rx_num - 1; > + priv->msg_obj_rx_mask = ((u64)1 << priv->msg_obj_rx_num) - 1; > + > + priv->msg_obj_tx_num = msg_obj_tx_num; > + priv->msg_obj_tx_first = priv->msg_obj_rx_last + 1; > + priv->msg_obj_tx_last = > + priv->msg_obj_tx_first + priv->msg_obj_tx_num - 1; > + > + priv->dlc = kcalloc(msg_obj_tx_num, sizeof(*priv->dlc), GFP_KERNEL); You can pass a larger size to alloc_candev() so that it includes the mem you allocate here. > + if (!priv->dlc) { > + free_candev(dev); > + return NULL; > + } > + > + netif_napi_add(dev, &priv->napi, c_can_poll, priv->msg_obj_rx_num); Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Attachment:
signature.asc
Description: PGP signature