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]

 



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.

-- 
Gerhard

-- 
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106

Phone: +49-8441-490260
Fax  : +49-8441-81860
http://www.ems-wuensche.com



[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