[RFC v5 0/3] configfs integration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All,

This is the fifth version of what used to be called "USB Functions Gadget".
It includes changes after Michal's and Sebastian's reviews - thanks, guys.

This is what I have been working on since June'12 and starts looking usable.
As an example I ported the mass storage function, which is a nontrivial one.

I am also working on adapter modules to provide the legacy interface.
The general idea is like here:

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

but after the change of programmatic configfs folder creation the adapter
needs to be changed.

Naming is to be adjusted, not a big deal.

This series requires

126c4896cd5ca94f5e1d77d7526870f99019ea48
fs/configfs: allow to create groups on demand

and

f7e4ec2ed0eddd63b93d0ca1beb45ffec6bb12b2
usb/gadget: add some infracture to register/unregister functions

Example use with mass storage:

$ mount -t configfs none /cfg
$ cd /cfg/usb-function-gadget/
$ ls

gadgets	udcs

$ ls udcs

s3c-hsotg

$ cd gadgets
$ mkdir g1
$ ls

g1

$ cd g1
$ ls

bcdDevice	functions	iProduct	idProduct
configs		iManufacturer	iSerialNumber	idVendor

$ echo Samsung > iManufacturer
$ echo 12345 > iSerialNumber
$ echo 0x0109 > idProduct
$ echo 0x04e8 > idVendor
$ cd functions
$ mkdir MassStorage.0
[  110.485345] Mass Storage Function, version: 2009/09/11
[  110.489669] Number of LUNs=0
[  110.491871] I/O thread pid: 2491
$ ls

MassStorage.0

$ lsmod

f_mass_storage

$ echo 1 > MassStorage.0/luns
[  139.969099] LUN: file: (no medium)

$ echo /root/file.img > MassStorage.0/lun0/file
$ cd ../configs
$ mkdir 0
$ ls

0

$ cd 0
$ ls

configuration_number	functions	maximum_power	number_of_interfaces

$ cd functions
$ ln -s ../../../functions/MassStorage.0 # points to /cfg/usb_function_gadget/
					 # gadgets/g1/functions/MassStorage.0
$ ls

MassStorage.0

$ cd ../../../
$ ln -s ../../udcs/s3c-hsotg	# points to /cfg/usb_function_gadget/
				# udcs/s3c-hsotg
				# the gadget is probed, host sees a new disk

$ ls /cfg/usb-function-gadget/gadgets/g1/functions/MassStorage.0

interface00	lun0	luns	stall

$ ls /cfg/usb-function-gadget/gadgets/g1/functions/MassStorage.0\
/interface00

altsetting	endpoint81	interface_number	interface_subclass
endpoint02	interface_class	interface_protocol	n_endpoints

$ ls /cfg/usb-function-gadget/gadgets/g1/functions/MassStorage.0\
/interface00/endpoint02

attributes	endpoint_address	interval	max_packet_size

$ rm s3c-hsotg # the gadget is removed

Rebased on 3.7-rc8.

v5:

Changes since v4:

- fixes according to Michal's and Sebastian's reviews
- adapted to new directory layout as proposed by Michal and Sebastian
- binding the gadget using symlink to udc
- binding the functions using symlinks

v4:

Changes since v3:

- use Sebastian's function registration framework
- code cleanup and small improvements
- differently squashed commits in order to show the steps

v3:

Changes since v2:

- improved ufg_gadget_bind
- some attributes have real values instead of dummy values
- added interfaces and endpoints directories in configfs
- added a local header file in drivers/usb/gadget



Andrzej Pietrasiewicz (3):
  usb: composite: add make_group and add_function operations
  usb: gadget: Add USB Functions Gadget
  usb: gadget: example port of mass storage to UFG: create
    storage_common.h and factor out code from storage_common.c

 Documentation/usb/ufg.txt           |    2 +
 drivers/usb/gadget/Kconfig          |   17 +
 drivers/usb/gadget/Makefile         |    8 +-
 drivers/usb/gadget/f_mass_storage.c |  825 ++++++++++++-------------
 drivers/usb/gadget/f_mass_storage.h |   99 +++
 drivers/usb/gadget/storage_common.c |  175 ++++---
 drivers/usb/gadget/storage_common.h |   43 ++
 drivers/usb/gadget/udc-core.c       |   27 +-
 drivers/usb/gadget/usb_functions.c  | 1142 +++++++++++++++++++++++++++++++++++
 drivers/usb/gadget/usb_functions.h  |  188 ++++++
 include/linux/usb/composite.h       |    6 +
 include/linux/usb/gadget.h          |    5 +
 12 files changed, 2033 insertions(+), 504 deletions(-)
 create mode 100644 Documentation/usb/ufg.txt
 create mode 100644 drivers/usb/gadget/f_mass_storage.h
 create mode 100644 drivers/usb/gadget/storage_common.h
 create mode 100644 drivers/usb/gadget/usb_functions.c
 create mode 100644 drivers/usb/gadget/usb_functions.h

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux