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; + + 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); -- 2.26.2 -- 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