linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: "krumboeck-Hi41barv6paIERSsAYjmKA@public.gmane.org"
	<krumboeck-Hi41barv6paIERSsAYjmKA@public.gmane.org>
Cc: linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	info-La43T0Mi4bH5xCKuJOYmCvaTkwRoYoCU@public.gmane.org,
	gediminas-LljXPT5IorFWk0Htik3J/w@public.gmane.org
Subject: Re: [PATCH v2] usb_8dev: Add support for USB2CAN interface from 8 devices
Date: Tue, 04 Dec 2012 11:07:06 +0100	[thread overview]
Message-ID: <50BDCB4A.5040709@pengutronix.de> (raw)
In-Reply-To: <50BD0E9F.2060302-Hi41barv6paIERSsAYjmKA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1998 bytes --]

On 12/03/2012 09:42 PM, krumboeck-Hi41barv6paIERSsAYjmKA@public.gmane.org wrote:
> 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).

Okay, then you might want to set outmsg via C99 initializers.

>>> +
>>> +    /* 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?

Opps, yeah right. only BE.


Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]

  parent reply	other threads:[~2012-12-04 10:07 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
     [not found]     ` <50BD0E9F.2060302-Hi41barv6paIERSsAYjmKA@public.gmane.org>
2012-12-04 10:07       ` Marc Kleine-Budde [this message]
     [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=50BDCB4A.5040709@pengutronix.de \
    --to=mkl-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=gediminas-LljXPT5IorFWk0Htik3J/w@public.gmane.org \
    --cc=info-La43T0Mi4bH5xCKuJOYmCvaTkwRoYoCU@public.gmane.org \
    --cc=krumboeck-Hi41barv6paIERSsAYjmKA@public.gmane.org \
    --cc=linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).