Hi!

Am 2012-12-06 17:44, schrieb Shawn Fisher:
    +static int usb_8dev_send_cmd(struct usb_8dev_priv *priv,

    +                            struct usb_8dev_cmd_msg *out,
    +                            struct usb_8dev_cmd_msg *in)
    +{
    +       int err;
    +       int num_bytes_read;
    +       struct net_device *netdev;
    +
    +       netdev = priv->netdev;
    +
    +       out->begin = USB_8DEV_CMD_START;
    +       out->end = USB_8DEV_CMD_END;
    +
    +       mutex_lock(&priv->usb_8dev_cmd_lock);
    +
    +       memcpy(priv->cmd_msg_buffer, out,
    +               sizeof(struct usb_8dev_cmd_msg));
    +
    +       err = usb_8dev_send_cmd_msg(priv, priv->cmd_msg_buffer,
    +                                   sizeof(struct usb_8dev_cmd_msg));
    +       if (err < 0) {
    +               netdev_err(netdev, "sending command message failed\n");
    +               return err;
    +       }
    +
    +       err = usb_8dev_wait_cmd_msg(priv, priv->cmd_msg_buffer,
    +                                   sizeof(struct usb_8dev_cmd_msg),
    +                                   &num_bytes_read);
    +       if (err < 0) {
    +               netdev_err(netdev, "no command message answer\n");
    +               return err;
    +       }
    +
    +       memcpy(in, priv->cmd_msg_buffer, sizeof(struct usb_8dev_cmd_msg));
    +
    +       mutex_unlock(&priv->usb_8dev_cmd_lock);
    +
    +       if (in->begin != USB_8DEV_CMD_START || in->end != USB_8DEV_CMD_END 
||
    +                       num_bytes_read != 16 || in->opt1 != 0)
    +               return -EPROTO;
    +
    +       return 0;
    +}


Don't forget to unlock that mutex when an error occurs.


Thanks! I will create a new patch in the next days.

In the meanwhile you can find the fixed version here: 
https://github.com/krumboeck/usb2can

regards,
Bernd

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to