Thread (10 messages) 10 messages, 2 authors, 2021-03-05

Re: [PATCH v4 5/6] can: c_can: prepare to up the message objects number

From: Dario Binacchi <hidden>
Date: 2021-03-05 11:14:59
Also in: linux-can, lkml

Il 04/03/2021 16:26 Marc Kleine-Budde [off-list ref] ha scritto:

 
On 02.03.2021 22:54:34, Dario Binacchi wrote:
quoted
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 77b9aee56154..0052ba5197e0 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
[...]
quoted
-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(*priv) + sizeof(u32) * msg_obj_tx_num,
+			   msg_obj_tx_num);
I've converted this to make use of the struct_size() macro:

+       dev = alloc_candev(struct_size(priv, dlc, msg_obj_tx_num),
+                          msg_obj_tx_num);
Nice!
I learned a new thing.

Thanks and regards,
Dario
regards,
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 |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help