Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Andrzej Pietrasiewicz <andrzej.p <at> samsung.com>
Subject: [PATCHv4 00/11] Equivalent of tcm_usb_gadget with configfs
Newsgroups: gmane.linux.scsi.target.devel
Date: Tuesday 1st December 2015 13:25:59 UTC (over 2 years ago)
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

v3..v4:
- rebased onto current Nicholas' tree
(b1c06ebadd277421c3f59569708ed356eb5dded5,
tcm_usb_gadget: Fix enabled attribute failure)

v2..v3:
- dropped a patch adding unlocked versions of depend/undepend item,
instead this series depends on a series from Krzysztof:

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

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.

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


*** BLURB HERE ***

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

 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               | 2404
+++++++++++++++++++++
 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        | 2174
+------------------
 drivers/usb/gadget/legacy/tcm_usb_gadget.h        |  133 --
 9 files changed, 2661 insertions(+), 2258 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
 
CD: 3ms