mbox series

[v4,0/9] usb: rework usb_maxpacket() and remove its third argument

Message ID 20220317035514.6378-1-mailhol.vincent@wanadoo.fr
Headers show
Series usb: rework usb_maxpacket() and remove its third argument | expand

Message

Vincent MAILHOL March 17, 2022, 3:55 a.m. UTC
This series rework usb_maxpacket() to change its prototype from:
| static inline __u16
| usb_maxpacket(struct usb_device *udev, int pipe, int is_out)

into:
| static inline u16 usb_maxpacket(struct usb_device *udev, int pipe)

and rewrite the function using usb_pipe_endpoint().

Rationale:

  * The third argument of usb_maxpacket(): is_out can be derived from
    its second one: pipe using usb_pipeout(pipe). Furthermore,
    usb_pipeout(pipe) is being called within usb_maxpacket()
    regardless to confirm the input.

  * This function is not exposed to the UAPI so return type should be
    u16, not __u16.

  * usb_pipe_endpoint() (defined a couple of lines before) does most
    of the work. Use it instead of reimplementing the same thing
    again.

In order to do so, usb_maxpacket() is temporarily changed into a variadic
function to ignore its third argument.

The series goes as follow:

    * Patch 1: make usb_maxpacket() variadic to accommodate during the
      migration

    * Patch 2 to 7: migrate all the users of usb_maxpacket() (one
      patch per tree)

    * Patch 8: remove the third argument of usb_maxpacket() now that
      everyone is migrated

    * Patch 9: rework usb_maxpacket()'s body using usb_pipe_endpoint()



** Changelog: **

  v3 -> v4:

    * [Patch 9] check that the output of usb_pipe_endpoint() is not
      NULL.

  c.f.:
  https://lore.kernel.org/linux-usb/YiIgGOkNntEiu78O@kroah.com/T/#mb6f348628a0cdc104e6fb3b0d5212a71e60281e9


  v2 -> v3:

    * remove patch 1 and 2 from the series because already applied to
      usb-testing.

    * split the change on usb_maxpacket in tiny steps:
       - a first patch to make the function variadic (patch 1 of this
         series)
       - a second one to remove the third argrument (patch 8 of this
         series)
       - a third and last one to fully rework the body and use
         usb_pipe_endpoint() (patch 9 of this series)

    * keep current variable names (do not rename usb_maxpacket
      parameter from udev to dev).

    c.f.:
    https://lore.kernel.org/linux-usb/YiIgGOkNntEiu78O@kroah.com/T/#m6a218544713670448c156ead95e72e8e1aa2373b


  v1 -> v2:

    * v1 contained a single patch, split it into a series. c.f.:
    https://lore.kernel.org/linux-usb/YiIgGOkNntEiu78O@kroah.com/T/#m6d25529f1cab1332b45e3e24480d541963684446

Vincent Mailhol (9):
  usb: deprecate the third argument of usb_maxpacket()
  HID: usbhid: remove third argument of usb_maxpacket()
  Input: remove third argument of usb_maxpacket()
  media: remove third argument of usb_maxpacket()
  net: remove third argument of usb_maxpacket()
  usb: remove third argument of usb_maxpacket()
  sound: usb: remove third argument of usb_maxpacket()
  usb: remove third argument of usb_maxpacket()
  usb: rework usb_maxpacket() using usb_pipe_endpoint()

 drivers/hid/usbhid/hid-core.c                  |  2 +-
 drivers/hid/usbhid/usbkbd.c                    |  2 +-
 drivers/hid/usbhid/usbmouse.c                  |  2 +-
 drivers/input/misc/ati_remote2.c               |  2 +-
 drivers/input/misc/cm109.c                     |  2 +-
 drivers/input/misc/powermate.c                 |  2 +-
 drivers/input/misc/yealink.c                   |  2 +-
 drivers/input/tablet/acecad.c                  |  2 +-
 drivers/input/tablet/pegasus_notetaker.c       |  2 +-
 drivers/media/rc/ati_remote.c                  |  4 ++--
 drivers/media/rc/mceusb.c                      |  2 +-
 drivers/media/rc/streamzap.c                   |  2 +-
 drivers/media/rc/xbox_remote.c                 |  2 +-
 drivers/media/usb/tm6000/tm6000-dvb.c          |  2 +-
 drivers/media/usb/tm6000/tm6000-input.c        |  2 +-
 drivers/media/usb/tm6000/tm6000-video.c        |  2 +-
 drivers/net/usb/cdc_ncm.c                      |  4 ++--
 drivers/net/usb/lan78xx.c                      |  4 ++--
 drivers/net/usb/rndis_host.c                   |  2 +-
 drivers/net/usb/usbnet.c                       |  4 ++--
 drivers/net/wireless/mediatek/mt76/usb.c       |  2 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c |  4 ++--
 drivers/usb/atm/usbatm.c                       |  2 +-
 drivers/usb/c67x00/c67x00-sched.c              |  4 ++--
 drivers/usb/core/hub.c                         |  2 +-
 drivers/usb/host/ehci-q.c                      |  4 ++--
 drivers/usb/host/fhci-hcd.c                    |  3 +--
 drivers/usb/host/fotg210-hcd.c                 |  2 +-
 drivers/usb/host/isp116x-hcd.c                 |  5 ++---
 drivers/usb/host/isp1362-hcd.c                 |  6 +++---
 drivers/usb/host/max3421-hcd.c                 |  6 +++---
 drivers/usb/host/ohci-hcd.c                    |  3 +--
 drivers/usb/host/oxu210hp-hcd.c                |  4 ++--
 drivers/usb/host/r8a66597-hcd.c                |  3 +--
 drivers/usb/host/sl811-hcd.c                   |  6 +++---
 drivers/usb/isp1760/isp1760-hcd.c              |  6 ++----
 drivers/usb/misc/ftdi-elan.c                   | 15 +++++----------
 drivers/usb/misc/lvstest.c                     |  2 +-
 drivers/usb/storage/onetouch.c                 |  2 +-
 drivers/usb/storage/transport.c                |  2 +-
 include/linux/usb.h                            | 17 ++---------------
 sound/usb/line6/pcm.c                          |  4 ++--
 sound/usb/midi.c                               |  4 ++--
 sound/usb/usx2y/usb_stream.c                   |  6 +++---
 sound/usb/usx2y/usbusx2yaudio.c                |  2 +-
 sound/usb/usx2y/usx2yhwdeppcm.c                |  2 +-
 46 files changed, 71 insertions(+), 95 deletions(-)

Comments

Vincent MAILHOL April 22, 2022, 2 p.m. UTC | #1
On Fri. 22 Apr. 2022 at 22:38, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Thu, Mar 17, 2022 at 12:55:05PM +0900, Vincent Mailhol wrote:
> > This series rework usb_maxpacket() to change its prototype from:
> > | static inline __u16
> > | usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
> >
> > into:
> > | static inline u16 usb_maxpacket(struct usb_device *udev, int pipe)
> >
> > and rewrite the function using usb_pipe_endpoint().
> >
> > Rationale:
> >
> >   * The third argument of usb_maxpacket(): is_out can be derived from
> >     its second one: pipe using usb_pipeout(pipe). Furthermore,
> >     usb_pipeout(pipe) is being called within usb_maxpacket()
> >     regardless to confirm the input.
> >
> >   * This function is not exposed to the UAPI so return type should be
> >     u16, not __u16.
> >
> >   * usb_pipe_endpoint() (defined a couple of lines before) does most
> >     of the work. Use it instead of reimplementing the same thing
> >     again.
> >
> > In order to do so, usb_maxpacket() is temporarily changed into a variadic
> > function to ignore its third argument.
> >
> > The series goes as follow:
> >
> >     * Patch 1: make usb_maxpacket() variadic to accommodate during the
> >       migration
> >
> >     * Patch 2 to 7: migrate all the users of usb_maxpacket() (one
> >       patch per tree)
> >
> >     * Patch 8: remove the third argument of usb_maxpacket() now that
> >       everyone is migrated
> >
> >     * Patch 9: rework usb_maxpacket()'s body using usb_pipe_endpoint()
>
> Now queued up, thanks for sticking with this!

Thanks to you for your patience and explanations!

> Can you send the follow-up patch that removes the vararg?  I'll keep
> that in my tree to try to catch any remaining things that come in and
> get it merged when it's ok to.

It is this patch:
https://lore.kernel.org/linux-usb/20220317035514.6378-9-mailhol.vincent@wanadoo.fr/

Or do you prefer me to resend it on the mailing list?


Yours sincerely,
Vincent Mailhol
Greg Kroah-Hartman April 22, 2022, 2:19 p.m. UTC | #2
On Fri, Apr 22, 2022 at 11:07:17PM +0900, Vincent MAILHOL wrote:
> On Fri. 22 Apr. 2022 at 23:00, Vincent MAILHOL
> <mailhol.vincent@wanadoo.fr> wrote:
> > On Fri. 22 Apr. 2022 at 22:38, Greg Kroah-Hartman
> > <gregkh@linuxfoundation.org> wrote:
> > > On Thu, Mar 17, 2022 at 12:55:05PM +0900, Vincent Mailhol wrote:
> > > > This series rework usb_maxpacket() to change its prototype from:
> > > > | static inline __u16
> > > > | usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
> > > >
> > > > into:
> > > > | static inline u16 usb_maxpacket(struct usb_device *udev, int pipe)
> > > >
> > > > and rewrite the function using usb_pipe_endpoint().
> > > >
> > > > Rationale:
> > > >
> > > >   * The third argument of usb_maxpacket(): is_out can be derived from
> > > >     its second one: pipe using usb_pipeout(pipe). Furthermore,
> > > >     usb_pipeout(pipe) is being called within usb_maxpacket()
> > > >     regardless to confirm the input.
> > > >
> > > >   * This function is not exposed to the UAPI so return type should be
> > > >     u16, not __u16.
> > > >
> > > >   * usb_pipe_endpoint() (defined a couple of lines before) does most
> > > >     of the work. Use it instead of reimplementing the same thing
> > > >     again.
> > > >
> > > > In order to do so, usb_maxpacket() is temporarily changed into a variadic
> > > > function to ignore its third argument.
> > > >
> > > > The series goes as follow:
> > > >
> > > >     * Patch 1: make usb_maxpacket() variadic to accommodate during the
> > > >       migration
> > > >
> > > >     * Patch 2 to 7: migrate all the users of usb_maxpacket() (one
> > > >       patch per tree)
> > > >
> > > >     * Patch 8: remove the third argument of usb_maxpacket() now that
> > > >       everyone is migrated
> > > >
> > > >     * Patch 9: rework usb_maxpacket()'s body using usb_pipe_endpoint()
> > >
> > > Now queued up, thanks for sticking with this!
> >
> > Thanks to you for your patience and explanations!
> >
> > > Can you send the follow-up patch that removes the vararg?  I'll keep
> > > that in my tree to try to catch any remaining things that come in and
> > > get it merged when it's ok to.
> >
> > It is this patch:
> > https://lore.kernel.org/linux-usb/20220317035514.6378-9-mailhol.vincent@wanadoo.fr/
> >
> > Or do you prefer me to resend it on the mailing list?
> 
> Actually, you already added it to your tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=386311fd6ef976eb1e3febd836b4ce2425f0ef37
> 
> I am not sure I understand what you want me to do here. Sorry.

Ah, sorry, you are right, I was expecting it to be the last patch in the
series, not second-to-last.  All is good!