Dear All,

This series adds support to tcm usb gadget for composing it with configfs.

@target-devel folks: You might be wondering why add configfs for something
which already supports configfs. In tcm_usb_gadget configfs has beeen
used for configuring the SCSI target part, but the usb gadget part
is considered a legacy gadget. A legacy gadget is a composite usb gadget
whose composition is defined statically at compilation time.
Composite gadgets can consist of a number of "functions" and configurations.
In legacy gadgets the selection is hardcoded in a dedicated kernel
module. But with configfs the selection can be made at runtime without
writing any kernel code. The conversion process started almost three
years ago.

The series aims at integrating configfs into tcm, the way it has been
done with 19 of 20 usb functions. In other words this concludes the
process of conversion to configfs in usb gadgets.

The series depends on the series from Chrisoph:
http://www.spinics.net/lists/target-devel/msg10730.html

@Nicholas: In order to use the series from Christoph (simplifying
configfs attributes) I rebased my series on top of your for-next,
which happens not to contain your patches which strip off nexus
WWPN prefix, fix nexus leak and fix enabled attribute failure.
I re-post them here. I have split one of them to separate
unrelated changes.

@Joel: I resend the patch which adds unlocked versions of
configfs_(un)depend_item(). The purpose of configfs_(un)depend_item()
is to allow other kernel subsystems to prohibit deletion of a config
item until they can live without it. This is exactly the case with
tcm usb gadget, but the other kernel subsystem happens to be another
subsystem in configfs: the user must create an instance of the tcm
function in usb_gadget subsystem in order to be able to create
a tpg in target subsystem. But once a tpg goes live its corresponding
tcm function must not be removed until the tpg is deleted.
Even though these are two distinct configfs subsystems the
configfs_(un)depend_item() will not work from a configfs callback.
That is why there is a need to provide the "unlocked" variant.

v1..v2:
- added missing comments
- used the next version of configfs_(un)depend_item_unlocked()
- fixed bug: THIS_MODULE is NULL if a module is compiled-in, so we cannot
rely on opts->dependent being non-NULL if a dependent module is present
- added passing configfs subsystem to configfs_(un)depend_item_unlocked()

BACKWARD COMPATIBILITY
======================

Please note that the old tcm_usb_gadget.ko is still available and works.

USING THE NEW "GADGET"
======================

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/tcm.<instance name>

e.g. mkdir functions/tcm.usb0.

In the tcm.usb0 directory there are no attributes, because all the
configuration is performed with the target subsystem in configfs.

Below is a script which creates a tcm gadget on a board with dwc3:

# mount -t configfs none /sys/kernel/config
# modprobe usb_f_tcm
# cd /sys/kernel/config/usb_gadget
# mkdir tcm
# cd tcm
# mkdir functions/tcm.0
# cd /sys/kernel/config/target/
# mkdir usb_gadget
# cd usb_gadget
# mkdir naa.0123456789abcdef
# cd naa.0123456789abcdef
# mkdir tpgt_1
# cd tpgt_1
# echo naa.01234567890abcdef > nexus
# echo 1 > enable
# cd /sys/kernel/config/usb_gadget/tcm
# mkdir configs/c.1
# ln -s functions/tcm.0 configs/c.1
# echo $VENDOR_ID > idVendor
# echo $PRODUCT_ID > idProduct
# echo 12400000.dwc3 > UDC

TESTING THE FUNCTION
====================

The most basic testing

device: run the script above

host: see the gadget enumerated

Andrzej Pietrasiewicz (11):
  usb: gadget: tcm: split string definitions into function and device
  usb: gadget: tcm: follow naming conventions
  usb: gadget: tcm: use strtobool for a boolean value
  usb: gadget: tcm: simplify attribute store function
  usb: gadget: tcm: factor out f_tcm
  usb: gadget: f_tcm: convert to new function interface with backward
    compatibility
  usb: gadget: tcm: convert to use new function registration interface
  usb: gadget: f_tcm: remove compatibility layer
  usb: gadget: f_tcm: remove redundant singleton
  usb: gadget: f_tcm: use usb_gstrings_attach
  usb: gadget: f_tcm: add configfs support

Krzysztof Opasiak (1):
  fs: configfs: Add unlocked version of configfs_depend_item()

Nicholas Bellinger (3):
  tcm_usb_gadget: Don't strip off nexus WWPN prefix
  tcm_usb_gadget: Fix nexus leak
  tcm_usb_gadget: Fix enabled attribute failure

 Documentation/ABI/testing/configfs-usb-gadget-tcm |    6 +
 drivers/usb/gadget/Kconfig                        |   17 +
 drivers/usb/gadget/function/Makefile              |    2 +
 drivers/usb/gadget/function/f_tcm.c               | 2425 +++++++++++++++++++++
 drivers/usb/gadget/function/tcm.h                 |  132 ++
 drivers/usb/gadget/function/u_tcm.h               |   50 +
 drivers/usb/gadget/legacy/Kconfig                 |    1 +
 drivers/usb/gadget/legacy/tcm_usb_gadget.c        | 2183 +------------------
 drivers/usb/gadget/legacy/tcm_usb_gadget.h        |  133 --
 fs/configfs/dir.c                                 |   97 +
 include/linux/configfs.h                          |   12 +
 11 files changed, 2791 insertions(+), 2267 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-tcm
 create mode 100644 drivers/usb/gadget/function/f_tcm.c
 create mode 100644 drivers/usb/gadget/function/tcm.h
 create mode 100644 drivers/usb/gadget/function/u_tcm.h
 delete mode 100644 drivers/usb/gadget/legacy/tcm_usb_gadget.h

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to