Re: [RFCv4 PATCH 02/13] usb: gadget: Add USB Functions Gadget

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

 



On Thu, Nov 22 2012, Andrzej Pietrasiewicz wrote:
> mount -t configfs none /cfg
> mkdir -p /cfg/usb-function-gadget/G1/C1/F1
> echo 0x<some id> > /cfg/usb-function-gadget/G1/idVendor
> echo 0x<some id> > /cfg/usb-function-gadget/G1/idProduct
> echo 0x<some id> > /cfg/usb-function-gadget/G1/bcdDevice
> echo <name> > /cfg/usb-function-gadget/G1/iManufacturer
> echo <something> > /cfg/usb-function-gadget/G1/iSerialNumber
> echo <something> > /cfg/usb-function-gadget/G1/iProduct
>
> Please note that directories names are only example and
> can be discussed.
> G1 corresponds to the whole gadget.
> C1 corresponds to the usb configuration it will use (just
> one in this example).
> F1 corresponds to the usb function which will be used.
> Whether there should be a generic name at this level,
> and a "name" attribute inside it, or just a function's
> name at this level can be discussed. The former was
> chosen in order to enable instantiating a function multiple
> times in one configuration.
>
> Then specific functions to be run follow, e.g.:
>
> echo MassStorage > /cfg/usb-function-gadget/G1/C1/F1/name

Why not

	mkdir /cfg/usb-function-gadget/G1/C1/F1/MassStorage

?

> After the last command the MassStorage function module
> (f_mass_storage.ko) is requested and function's configfs
> directory hierarchy is created:
>
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/luns
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/stall
>
> Then the function needs to be configured with
>
> echo 1 > /cfg/usb-function-gadget/G1/C1/F1/MassStorage/luns
>
> After the last command the lunX directories are created:
>
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/file
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/nofua
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/removable
> /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/ro
>
> Now we configure the single lun we have:
>
> echo <some file>.img > /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/file
>
> Do the similar thing to other functions, then
>
> echo 1 > /cfg/usb-function-gadget/G1/ready

This is temporary though, right?  In the future, we want to have UDCs in
configfs as well and link the two together?

> to actually probe and bind the gadget.
>
> In this case, under F1 there will be automatically created interface00
> directory with the contents similar to this:
>
> /cfg/usb-function-gadget/G1/C1/F1/interface00
> /cfg/usb-function-gadget/G1/C1/F1/interface00/altsetting
> /cfg/usb-function-gadget/G1/C1/F1/interface00/interface_class
> /cfg/usb-function-gadget/G1/C1/F1/interface00/interface_number
> /cfg/usb-function-gadget/G1/C1/F1/interface00/interface_protocol
> /cfg/usb-function-gadget/G1/C1/F1/interface00/interface_subclass
> /cfg/usb-function-gadget/G1/C1/F1/interface00/n_endpoints
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint02
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint02/attributes
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint02/endpoint_address
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint02/interval
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint02/max_packet_size
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint81
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint81/attributes
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint81/endpoint_address
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint81/interval
> /cfg/usb-function-gadget/G1/C1/F1/interface00/endpoint81/max_packet_size

I'd use endpoint00 and endpoint01 and have the address in
endpoint_address, but no strong feelings.

> In order to unload the gadget:
>
> echo 0 > /cfg/usb-function-gadget/G1/ready
> echo > /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/file
> rmdir /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0
> rmdir /cfg/usb-function-gadget/G1/C1/F1/MassStorage
> rmdir /cfg/usb-function-gadget/G1/C1/F1
> rmdir /cfg/usb-function-gadget/G1/C1
> rmdir /cfg/usb-function-gadget/G1

Would it be possible to let the user just do:

	rmdir /cfg/usb-function-gadget/G1

and make the module unbind the gadget and recursively remove all the
directories?  Specifically the requirement of:

	echo > /cfg/usb-function-gadget/G1/C1/F1/MassStorage/lun0/file

seems shady to me because this makes it impossible to have a generic
way of unloading gadgets.  Ie. if I don't know that this gadget has
a mass storage function which requires empty string to be written to
LUN's file, than I won't be able to unload it.

> umount cfg
> rmmod g_usb_functions.ko
> rmmod f_mass_storage.ko
> rmmod libcomposite.ko
>
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@xxxxxxxxxx>--------------ooO--(_)--Ooo--

Attachment: pgp4AeXxznp1_.pgp
Description: PGP signature


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

  Powered by Linux