public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Walle" <mwalle@kernel.org>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: f_acm: make bInterfaceProtocol configurable
Date: Wed, 31 Jul 2024 10:57:04 +0200	[thread overview]
Message-ID: <D33LLE6K8QGH.1BCZM42INRVEX@kernel.org> (raw)
In-Reply-To: <2024073151-violator-unskilled-6866@gregkh>

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

Hi Greg,

On Wed Jul 31, 2024 at 10:32 AM CEST, Greg Kroah-Hartman wrote:
> On Tue, Jul 30, 2024 at 09:43:37PM +0200, Michael Walle wrote:
> >  struct f_serial_opts {
> >  	struct usb_function_instance func_inst;
> >  	u8 port_num;
> > +	u8 protocol;
> > +
> > +	struct mutex lock;
> > +	int refcnt;
>
> Attempting to "roll your own" reference count is almost never a good
> idea.  If you really need one, please use the proper in-kernel apis for
> this.  But you need to justify it as well, I didn't see why this was
> needed at all.

Honestly, I couldn't grok all that usb gadget magic, so I've looked
at similar gadgets and took that from there:
  grep refcnt drivers/usb/gadget/function/ -r

They are all doing the same, so maybe that code is old or didn't use
the proper APIs back then.

The refcnt will prevent changing the options (the protocol here)
while a gadget is still in use/bound.

-michael

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]

  reply	other threads:[~2024-07-31  8:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 19:43 [PATCH] usb: gadget: f_acm: make bInterfaceProtocol configurable Michael Walle
2024-07-31  8:32 ` Greg Kroah-Hartman
2024-07-31  8:57   ` Michael Walle [this message]
2024-07-31  9:16     ` Greg Kroah-Hartman
2024-07-31 20:11       ` Michael Walle

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=D33LLE6K8QGH.1BCZM42INRVEX@kernel.org \
    --to=mwalle@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.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