Re: [PATCH 07/17] can: ems_usb: Added CPC_ClearCmdQueue routine to get access to the interface even it is flooded with messages which cannot successfully be sent. Set timestamp to 0 in ems_usb_control_cmd.

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

 



Is this a fix that is interesting for the stable tree?

On 11/6/20 6:01 PM, Gerhard Uttenthaler wrote:
> Signed-off-by: Gerhard Uttenthaler <uttenthaler@xxxxxxxxxxxxxxxx>
> ---
>  drivers/net/can/usb/ems_usb.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
> index 66418e5af87d..c664af4499a1 100644
> --- a/drivers/net/can/usb/ems_usb.c
> +++ b/drivers/net/can/usb/ems_usb.c
> @@ -637,12 +637,29 @@ static int ems_usb_control_cmd(struct ems_usb *dev, u8 val)
>  	cmd.length = CPC_MSG_HEADER_LEN + 1;
>  
>  	cmd.msgid = 0;
> +	cmd.ts_sec = 0;
> +	cmd.ts_nsec = 0;
>  
>  	cmd.msg.generic[0] = val;
>  
>  	return ems_usb_command_msg(dev, &cmd);
>  }
>  
> +/* Send a CPC_ClearCmdQueue command
> + */
> +static int ems_usb_clear_cmd_queue(struct ems_usb *dev)
> +{
> +	struct ems_cpc_msg cmd;

please use C99 style initialization:

struct ems_cpc_msg cmd = {
	.type = CPC_CMD_TYPE_CLEAR_CMD_QUEUE,
	.length = CPC_MSG_HEADER_LEN,
};

> +
> +	cmd.type = CPC_CMD_TYPE_CLEAR_CMD_QUEUE;
> +	cmd.length = CPC_MSG_HEADER_LEN;
> +	cmd.msgid = 0;
> +	cmd.ts_sec = 0;
> +	cmd.ts_nsec = 0;
> +
> +	return ems_usb_command_msg(dev, &cmd);
> +}
> +
>  /* Start interface
>   */
>  static int ems_usb_start(struct ems_usb *dev)
> @@ -978,11 +995,19 @@ static int ems_usb_set_bittiming_arm7(struct net_device *netdev)
>  	struct can_bittiming *bt = &dev->can.bittiming;
>  	struct cpc_sja1000_params *sja1000 =
>  		&dev->active_params.msg.can_params.cc_params.sja1000;
> +	int err;
>  
>  	sja1000->btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
>  	sja1000->btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
>  		(((bt->phase_seg2 - 1) & 0x7) << 4);
>  
> +	/* If the command queue in the device is full of sending requests
> +	 * a reinitialization would not be possible before the queue is cleared.
> +	 */
> +	err = ems_usb_clear_cmd_queue(dev);
> +	if (err)
> +		return err;
> +
>  	netdev_info(netdev, "Set bit timing for CPC-USB/ARM7\n");
>  	netdev_info(netdev, "BTR0=0x%02x, BTR1=0x%02x\n",
>  		    sja1000->btr0, sja1000->btr1);
> 

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