usb: gadget: midi2: Add configfs support
authorTakashi Iwai <tiwai@suse.de>
Tue, 25 Jul 2023 06:22:01 +0000 (08:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Jul 2023 04:38:14 +0000 (06:38 +0200)
commit29ee7a4dddd5caa18d1cef000f20c6af43f762f1
tree821b6c61d28335a7797fa0398d37e5d40a3c7731
parent8b645922b22303cec4628dbbbf6c8553d1cdec87
usb: gadget: midi2: Add configfs support

This patch adds the support of configfs to MIDI 2.0 function driver
for users to allow configuring the UMP Endpoint and Function Blocks
more flexibly.  The configuration is in a tree form.  The top-most
contains some card-level configurations.  UMP Endpoints are defined in
subdirectories (ep.0, ep.1, etc) that contain Endpoint-specific
configurations such as ep_name, etc.  And, UMP Function Blocks are
defined in the subdirectories (block.0, block.1, etc) under EP
subdirectory.  As default, the driver creates a single UMP Endpoint
(ep.0) and a single Function Block (block.0) to work in a minimalistic
manner.  User can modify those attributes freely to fit with the
demands.

When multiple Function Blocks are required, user can create another
directory as block.1, block.2, and so on (up to block.31).  A block.*
directory can be deleted dynamically, too.  A caveat is that the block
number has to be continuous.

Similarly, when multiple UMP Endpoints are required, user can create
another directory as ep.1, ep.2, up to ep.3.

Also, some driver behavior can be controlled in the card top-level
configs.  e.g. you can pass process_ump=0 to disable the processing of
UMP Stream messages.  This would be equivalent with the older MIDI 2.0
spec that doesn't support UMP v1.1 features.

The configfs interface checks upper- / lower-bound of input values,
and more sanity checks are performed at binding.

Attributes can't be changed any longer once when the instance is
linked to UDC.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230725062206.9674-3-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/configfs-usb-gadget-midi2 [new file with mode: 0644]
drivers/usb/gadget/function/f_midi2.c