All of lore.kernel.org
 help / color / mirror / Atom feed
From: Loic Poulain <loic.poulain@linaro.org>
To: "Pali Rohár" <pali@kernel.org>
Cc: marex@denx.de, lukma@denx.de, u-boot@lists.denx.de
Subject: Re: [PATCH v2 2/2] usb: gadget: Add CDC ACM function
Date: Mon, 22 Nov 2021 17:31:15 +0100	[thread overview]
Message-ID: <CAMZdPi-qF0NHd7=uYgYeGP6vBFi6hRE+BUreMK5zut4pt60jQA@mail.gmail.com> (raw)
In-Reply-To: <20211122154810.fafl6aq3yur7yzg6@pali>

Hi Pali,

On Mon, 22 Nov 2021 at 16:48, Pali Rohár <pali@kernel.org> wrote:
>
> Hello! I have just few notes, see below.
>
> > diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
> > index f560068..d5d891b 100644
> > --- a/drivers/usb/gadget/Makefile
> > +++ b/drivers/usb/gadget/Makefile
> > @@ -30,6 +30,7 @@ obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o
> >  obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o
> >  obj-$(CONFIG_USB_FUNCTION_SDP) += f_sdp.o
> >  obj-$(CONFIG_USB_FUNCTION_ROCKUSB) += f_rockusb.o
> > +obj-$(CONFIG_USB_FUNCTION_ACM)       += f_acm.o
> >  endif
> >  endif
> >  ifdef CONFIG_USB_ETHER
> > diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
> > new file mode 100644
> > index 0000000..3ea3b4a
> > --- /dev/null
> > +++ b/drivers/usb/gadget/f_acm.c
> ...
> > +static struct usb_cdc_header_desc acm_header_desc = {
> > +     .bLength =              sizeof(acm_header_desc),
> > +     .bDescriptorType =      USB_DT_CS_INTERFACE,
> > +     .bDescriptorSubType =   USB_CDC_HEADER_TYPE,
> > +     .bcdCDC =               cpu_to_le16(0x0110),
>
> This is global structure initialization. So should not it use
> __constant_cpu_to_le16() macro instead of cpu_to_le16()? I guess that on
> armel or x86 is cpu_to_le16() just identity macro, but on big endian
> systems it is needed to use constant initialization. Other gadget
> drivers are using those __constant_cpu* macros.

Indeed, going to use it.

>
> > +};
> ...
> > +int drv_usb_acm_stdio_init(void)
> > +{
> > +     struct stdio_dev stdio;
> > +
> > +     strcpy(stdio.name, "stdio_acm");
>
> Just suggestion: What about "usbacm" or just "acm"?

usbacm sounds good.

>
> > +     stdio.flags = DEV_FLAGS_INPUT | DEV_FLAGS_OUTPUT;
> > +     stdio.tstc = acm_stdio_tstc;
> > +     stdio.getc = acm_stdio_getc;
> > +     stdio.putc = acm_stdio_putc;
> > +     stdio.puts = acm_stdio_puts;
> > +     stdio.start = acm_stdio_start;
> > +     stdio.stop = acm_stdio_stop;
> > +     stdio.priv = NULL;
> > +     stdio.ext = 0;
> > +
> > +     return stdio_register(&stdio);
> > +}
> > diff --git a/include/stdio_dev.h b/include/stdio_dev.h
> > index 8fb9a12..d584793 100644
> > --- a/include/stdio_dev.h
> > +++ b/include/stdio_dev.h
> > @@ -103,6 +103,7 @@ int drv_lcd_init(void);
> >  int drv_video_init(void);
> >  int drv_keyboard_init(void);
> >  int drv_usbtty_init(void);
> > +int drv_usb_acm_stdio_init(void);
>
> Other functions do not have stdio in name too. So what about shorting
> it? E.g. just drv_usbacm_init()?

Yes, I've named it _stdio because it's a subpart of the driver. There
is the core cdc_acm function implementation and one client of this
function which is stdio. But I'm fine with shortening that.

Regards,
Loic

  reply	other threads:[~2021-11-22 16:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 12:30 [PATCH v2 1/2] lib/circbuf: Make circbuf selectable symbol Loic Poulain
2021-11-22 12:30 ` [PATCH v2 2/2] usb: gadget: Add CDC ACM function Loic Poulain
2021-11-22 15:48   ` Pali Rohár
2021-11-22 16:31     ` Loic Poulain [this message]
2021-11-22 12:50 ` [PATCH v2 1/2] lib/circbuf: Make circbuf selectable symbol Wolfgang Denk
2021-11-22 16:47   ` Loic Poulain

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='CAMZdPi-qF0NHd7=uYgYeGP6vBFi6hRE+BUreMK5zut4pt60jQA@mail.gmail.com' \
    --to=loic.poulain@linaro.org \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.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.