Linux USB
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ivan Orlov <ivan.orlov0322@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] USB: make usb class a const structure
Date: Wed, 21 Jun 2023 18:09:29 +0200	[thread overview]
Message-ID: <2023062157-disobey-kung-a565@gregkh> (raw)
In-Reply-To: <20230621150903.1219439-1-ivan.orlov0322@gmail.com>

On Wed, Jun 21, 2023 at 07:09:03PM +0400, Ivan Orlov wrote:
> Now that the driver core allows for struct class to be in read-only
> memory, remove the usb_class structure and create the usbmisc_class
> const class structure declared at build time which places it into
> read-only memory, instead of having it to be dynamically allocated
> at load time.
> 
> Additionally, now we register usb class at startup and unregister it
> when shutting down, so we don't have to count uses of the class.
> Therefore we don't need the 'usb_class' structure anymore. Due to this
> fact, remove all static functions related to class initialization and
> deinitialization. We can't use them in 'usb.c' since they are static
> and we don't really need them anymore.
> 
> Since we have to register the class in usb_init function in 'usb.c'
> and use it in 'file.c' as well, declare the usbmisc_class structure
> as 'export' in the 'usb.h' file.
> 
> Debatable moment: the class registration and unregistration functions
> could be extracted to the 'file.c'. I think we don't want to do this
> since it would be one-line functions. They would make the code paths
> more confusing and add calling overhead.

Nah, your cleanup here was much nicer overall:

>  drivers/usb/core/file.c | 63 ++++-------------------------------------
>  drivers/usb/core/usb.c  |  6 ++++
>  drivers/usb/core/usb.h  |  1 +
>  3 files changed, 13 insertions(+), 57 deletions(-)

Deleting more lines than added is always a good thing, thanks for the
revision!

greg k-h

      reply	other threads:[~2023-06-21 16:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21 15:09 [PATCH v2] USB: make usb class a const structure Ivan Orlov
2023-06-21 16:09 ` Greg KH [this message]

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=2023062157-disobey-kung-a565@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=ivan.orlov0322@gmail.com \
    --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