Re: [PATCH 12/17] can: ems_usb: In ems_usb_start_xmit send only bytes with valid content to interface and not the complete buffer. Set first four bytes of buffer to 0. Wrapped long lines.

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

 



On 11/12/20 9:31 AM, Gerhard Uttenthaler wrote:
> Am 06.11.20 um 18:58 schrieb Marc Kleine-Budde:
>> On 11/6/20 6:02 PM, Gerhard Uttenthaler wrote:
>>> Signed-off-by: Gerhard Uttenthaler <uttenthaler@xxxxxxxxxxxxxxxx>
>>> ---
>>>  drivers/net/can/usb/ems_usb.c | 31 +++++++++++++++++++++++--------
>>>  1 file changed, 23 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
>>> index b51a5eb65946..c464d644c833 100644
>>> --- a/drivers/net/can/usb/ems_usb.c
>>> +++ b/drivers/net/can/usb/ems_usb.c
>>> @@ -902,25 +902,37 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
>>>  	struct can_frame *cf = (struct can_frame *)skb->data;
>>>  	struct ems_cpc_msg *msg;
>>>  	struct urb *urb;
>>> -	u8 *buf;
>>>  	int i, err;
>>> -	size_t size = CPC_HEADER_SIZE + CPC_MSG_HEADER_LEN
>>> -			+ sizeof(struct cpc_can_msg);
>>> +
>>> +	u8 *buf;
>>> +	size_t buf_size;
>>> +	size_t buf_len = CPC_HEADER_SIZE + CPC_MSG_HEADER_LEN;
>>>  
>>>  	if (can_dropped_invalid_skb(netdev, skb))
>>>  		return NETDEV_TX_OK;
>>>  
>>> -	/* create a URB, and a buffer for it, and copy the data to the URB */
>>> +	buf_size = CPC_HEADER_SIZE +
>>> +		   CPC_MSG_HEADER_LEN +
>>> +		   sizeof(struct cpc_can_msg);
>>
>> does it make sense to only allocate the length of the buffer needed to hold the
>> data?
>
> I have considered that, but actual length depends on DLC, however not
> when the frame is an RTR and this is different for Classic and FD. I
> think code will get more complicated with the benefit only to save a few
> bytes.

Ok

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: OpenPGP digital signature


[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