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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Il 04/03/2021 16:26 Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> ha scritto:
> 
>  
> On 02.03.2021 22:54:34, Dario Binacchi wrote:
> > 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
> [...]
> > -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 |



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux