From: "krumboeck@universalnet.at" <krumboeck@universalnet.at>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, linux-usb@vger.kernel.org,
info@gerhard-bertelsmann.de, gediminas@8devices.com
Subject: Re: [PATCH v2] usb_8dev: Add support for USB2CAN interface from 8 devices
Date: Mon, 03 Dec 2012 21:42:07 +0100 [thread overview]
Message-ID: <50BD0E9F.2060302@universalnet.at> (raw)
In-Reply-To: <50BCB1E8.2070705@pengutronix.de>
Hi Marc!
>> +/* Send open command to device */
>> +static int usb_8dev_cmd_open(struct usb_8dev *dev)
>> +{
>> + struct can_bittiming *bt = &dev->can.bittiming;
>> + struct usb_8dev_cmd_msg outmsg;
>> + struct usb_8dev_cmd_msg inmsg;
>> + u32 flags = 0;
>> + u32 beflags;
>> + u16 bebrp;
>> + u32 ctrlmode = dev->can.ctrlmode;
>> +
>> + if (ctrlmode & CAN_CTRLMODE_LOOPBACK)
>> + flags |= USB_8DEV_LOOPBACK;
>> + if (ctrlmode & CAN_CTRLMODE_LISTENONLY)
>> + flags |= USB_8DEV_SILENT;
>> + if (ctrlmode & CAN_CTRLMODE_ONE_SHOT)
>> + flags |= USB_8DEV_DISABLE_AUTO_RESTRANS;
>> +
>> + flags |= USB_8DEV_STATUS_FRAME;
>> +
>> + memset(&outmsg, 0, sizeof(struct usb_8dev_cmd_msg));
>> + outmsg.command = USB_8DEV_OPEN;
>> + outmsg.opt1 = USB_8DEV_BAUD_MANUAL;
>> + outmsg.data[0] = (bt->prop_seg + bt->phase_seg1);
>> + outmsg.data[1] = bt->phase_seg2;
>> + outmsg.data[2] = bt->sjw;
>
> But you should not use usb_bulk_msg() to send data which is on the
> stack, please use you already allocated memory in priv or kmalloc
> something here.
The function usb_8dev_send_cmd copies the data to dev->cmd_msg_buffer (allocated with kzalloc, GFP_KERNEL).
>
>> +
>> + /* BRP */
>> + bebrp = cpu_to_be16((u16) bt->brp);
>> + memcpy(&outmsg.data[3], &bebrp, sizeof(bebrp));
>
> Are you sure about the endianess? Some data types are BE some are LE?
Where is LE used?
>
>> +
>> + /* flags */
>> + beflags = cpu_to_be32(flags);
>> + memcpy(&outmsg.data[5], &beflags, sizeof(beflags));
>> +
>> + return usb_8dev_send_cmd(dev, &outmsg, &inmsg);
>> +}
>> +
>> +/* Send close command to device */
>> +static int usb_8dev_cmd_close(struct usb_8dev *dev)
>> +{
>> + struct usb_8dev_cmd_msg outmsg;
>> + struct usb_8dev_cmd_msg inmsg;
>> +
>> + memset(&outmsg, 0, sizeof(struct usb_8dev_cmd_msg));
>> + outmsg.command = USB_8DEV_CLOSE;
>
> Same here, don't use stack allocated mem for usb_bulk_msg
All command functions use usb_8dev_send_cmd.
>
> Are you sure?....Do you really want to wake the queue?
>
No, I've removed.
>
> needed?
>
I don't know. -> removed.
Thanks for your comments.
best regards,
Bernd
next prev parent reply other threads:[~2012-12-03 19:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 0:50 [PATCH v2] usb_8dev: Add support for USB2CAN interface from 8 devices krumboeck
2012-12-03 8:11 ` Wolfgang Grandegger
2012-12-03 20:32 ` krumboeck
2012-12-03 20:15 ` Wolfgang Grandegger
2012-12-04 10:14 ` Marc Kleine-Budde
[not found] ` <c003ee227fe9e5a754a78fd8575ce977.squirrel@webmail.universalnet.at>
2012-12-04 20:22 ` Marc Kleine-Budde
2012-12-04 22:09 ` Bernd Krumboeck
2012-12-03 14:06 ` Marc Kleine-Budde
2012-12-03 20:42 ` krumboeck [this message]
[not found] ` <50BD0E9F.2060302-Hi41barv6paIERSsAYjmKA@public.gmane.org>
2012-12-04 10:07 ` Marc Kleine-Budde
[not found] ` <50BD09D1.6040009@universalnet.at>
[not found] ` <50BD00A2.8010300@pengutronix.de>
[not found] ` <50BD0FD2.5060002@universalnet.at>
2012-12-04 10:13 ` Marc Kleine-Budde
[not found] ` <afcf5a63bd9cbc8324d8d6ebdda93b07.squirrel@webmail.universalnet.at>
2012-12-04 19:22 ` Marc Kleine-Budde
2012-12-04 19:35 ` "Bernd Krumböck"
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50BD0E9F.2060302@universalnet.at \
--to=krumboeck@universalnet.at \
--cc=gediminas@8devices.com \
--cc=info@gerhard-bertelsmann.de \
--cc=linux-can@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mkl@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.