linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: get rid of 'choice' for legacy gadget drivers
@ 2020-03-15 15:49 Masahiro Yamada
  2020-03-16  7:05 ` Felipe Balbi
  0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2020-03-15 15:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb
  Cc: linux-kernel, Masahiro Yamada, Bartlomiej Zolnierkiewicz,
	Felipe Balbi, Johan Hovold, Krzysztof Kozlowski,
	Mauro Carvalho Chehab

drivers/usb/gadget/legacy/Kconfig creates a 'choice' inside another
'choice'.

The outer choice: line 17 "USB Gadget precomposed configurations"
The inner choice: line 484 "EHCI Debug Device mode"

I wondered why the whole legacy gadget drivers reside in such a big
choice block.

This dates back to 2003, "[PATCH] USB: fix for multiple definition of
`usb_gadget_get_string'". [1]

At that time, the global function, usb_gadget_get_string(), was linked
into multiple drivers. That was why only one driver was able to become
built-in at the same time.

Later, commit a84d9e5361bc ("usb: gadget: start with libcomposite")
moved usb_gadget_get_string() to a separate module, libcomposite.ko
instead of including usbstring.c from multiple modules.

More and more refactoring was done, and after commit 1bcce939478f
("usb: gadget: multi: convert to new interface of f_mass_storage"),
you can link multiple gadget drivers into vmlinux without causing
multiple definition error.

This is the only user of the nested choice structure ever. Removing
this mess will make some Kconfig cleanups possible.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=fee4cf49a81381e072c063571d1aadbb29207408

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 drivers/usb/gadget/legacy/Kconfig | 48 ++++++++++++++-----------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig
index 6e7e1a9202e6..cc20f61d48a0 100644
--- a/drivers/usb/gadget/legacy/Kconfig
+++ b/drivers/usb/gadget/legacy/Kconfig
@@ -13,32 +13,28 @@
 # With help from a special transceiver and a "Mini-AB" jack, systems with
 # both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
 #
+# A Linux "Gadget Driver" talks to the USB Peripheral Controller
+# driver through the abstract "gadget" API.  Some other operating
+# systems call these "client" drivers, of which "class drivers"
+# are a subset (implementing a USB device class specification).
+# A gadget driver implements one or more USB functions using
+# the peripheral hardware.
+#
+# Gadget drivers are hardware-neutral, or "platform independent",
+# except that they sometimes must understand quirks or limitations
+# of the particular controllers they work with.  For example, when
+# a controller doesn't support alternate configurations or provide
+# enough of the right types of endpoints, the gadget driver might
+# not be able work with that controller, or might need to implement
+# a less common variant of a device class protocol.
+#
+# The available choices each represent a single precomposed USB
+# gadget configuration. In the device model, each option contains
+# both the device instantiation as a child for a USB gadget
+# controller, and the relevant drivers for each function declared
+# by the device.
 
-choice
-	tristate "USB Gadget precomposed configurations"
-	default USB_ETH
-	optional
-	help
-	  A Linux "Gadget Driver" talks to the USB Peripheral Controller
-	  driver through the abstract "gadget" API.  Some other operating
-	  systems call these "client" drivers, of which "class drivers"
-	  are a subset (implementing a USB device class specification).
-	  A gadget driver implements one or more USB functions using
-	  the peripheral hardware.
-
-	  Gadget drivers are hardware-neutral, or "platform independent",
-	  except that they sometimes must understand quirks or limitations
-	  of the particular controllers they work with.  For example, when
-	  a controller doesn't support alternate configurations or provide
-	  enough of the right types of endpoints, the gadget driver might
-	  not be able work with that controller, or might need to implement
-	  a less common variant of a device class protocol.
-
-	  The available choices each represent a single precomposed USB
-	  gadget configuration. In the device model, each option contains
-	  both the device instantiation as a child for a USB gadget
-	  controller, and the relevant drivers for each function declared
-	  by the device.
+menu "USB Gadget precomposed configurations"
 
 config USB_ZERO
 	tristate "Gadget Zero (DEVELOPMENT)"
@@ -516,4 +512,4 @@ config USB_G_WEBCAM
 	  Say "y" to link the driver statically, or "m" to build a
 	  dynamically linked module called "g_webcam".
 
-endchoice
+endmenu
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: get rid of 'choice' for legacy gadget drivers
  2020-03-15 15:49 [PATCH] usb: get rid of 'choice' for legacy gadget drivers Masahiro Yamada
@ 2020-03-16  7:05 ` Felipe Balbi
  2020-03-16  7:19   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Balbi @ 2020-03-16  7:05 UTC (permalink / raw)
  To: Masahiro Yamada, Greg Kroah-Hartman, linux-usb
  Cc: linux-kernel, Masahiro Yamada, Bartlomiej Zolnierkiewicz,
	Johan Hovold, Krzysztof Kozlowski, Mauro Carvalho Chehab

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


Hi,

Masahiro Yamada <masahiroy@kernel.org> writes:
> drivers/usb/gadget/legacy/Kconfig creates a 'choice' inside another
> 'choice'.
>
> The outer choice: line 17 "USB Gadget precomposed configurations"
> The inner choice: line 484 "EHCI Debug Device mode"
>
> I wondered why the whole legacy gadget drivers reside in such a big
> choice block.
>
> This dates back to 2003, "[PATCH] USB: fix for multiple definition of
> `usb_gadget_get_string'". [1]
>
> At that time, the global function, usb_gadget_get_string(), was linked
> into multiple drivers. That was why only one driver was able to become
> built-in at the same time.
>
> Later, commit a84d9e5361bc ("usb: gadget: start with libcomposite")
> moved usb_gadget_get_string() to a separate module, libcomposite.ko
> instead of including usbstring.c from multiple modules.
>
> More and more refactoring was done, and after commit 1bcce939478f
> ("usb: gadget: multi: convert to new interface of f_mass_storage"),
> you can link multiple gadget drivers into vmlinux without causing
> multiple definition error.
>
> This is the only user of the nested choice structure ever. Removing
> this mess will make some Kconfig cleanups possible.
>
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=fee4cf49a81381e072c063571d1aadbb29207408
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Greg, if you want to pick this for v5.7, please go ahead:

Acked-by: Felipe Balbi <balbi@kernel.org>

-- 
balbi

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: get rid of 'choice' for legacy gadget drivers
  2020-03-16  7:05 ` Felipe Balbi
@ 2020-03-16  7:19   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2020-03-16  7:19 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Masahiro Yamada, linux-usb, linux-kernel,
	Bartlomiej Zolnierkiewicz, Johan Hovold, Krzysztof Kozlowski,
	Mauro Carvalho Chehab

On Mon, Mar 16, 2020 at 09:05:12AM +0200, Felipe Balbi wrote:
> 
> Hi,
> 
> Masahiro Yamada <masahiroy@kernel.org> writes:
> > drivers/usb/gadget/legacy/Kconfig creates a 'choice' inside another
> > 'choice'.
> >
> > The outer choice: line 17 "USB Gadget precomposed configurations"
> > The inner choice: line 484 "EHCI Debug Device mode"
> >
> > I wondered why the whole legacy gadget drivers reside in such a big
> > choice block.
> >
> > This dates back to 2003, "[PATCH] USB: fix for multiple definition of
> > `usb_gadget_get_string'". [1]
> >
> > At that time, the global function, usb_gadget_get_string(), was linked
> > into multiple drivers. That was why only one driver was able to become
> > built-in at the same time.
> >
> > Later, commit a84d9e5361bc ("usb: gadget: start with libcomposite")
> > moved usb_gadget_get_string() to a separate module, libcomposite.ko
> > instead of including usbstring.c from multiple modules.
> >
> > More and more refactoring was done, and after commit 1bcce939478f
> > ("usb: gadget: multi: convert to new interface of f_mass_storage"),
> > you can link multiple gadget drivers into vmlinux without causing
> > multiple definition error.
> >
> > This is the only user of the nested choice structure ever. Removing
> > this mess will make some Kconfig cleanups possible.
> >
> > [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=fee4cf49a81381e072c063571d1aadbb29207408
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> 
> Greg, if you want to pick this for v5.7, please go ahead:
> 
> Acked-by: Felipe Balbi <balbi@kernel.org>

Thanks, will take it later today.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-16  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 15:49 [PATCH] usb: get rid of 'choice' for legacy gadget drivers Masahiro Yamada
2020-03-16  7:05 ` Felipe Balbi
2020-03-16  7:19   ` Greg Kroah-Hartman

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).