1. 04 3月, 2016 2 次提交
  2. 10 10月, 2015 1 次提交
    • I
      usb: gadget: composite: fill bcdUSB for any gadget max speed · 5527e733
      Igor Kotrasinski 提交于
      When handling device GET_DESCRIPTOR, composite gadget driver fills
      the bcdUSB field only if the gadget supports USB 3.0. Otherwise
      the field is left unfilled.
      
      For consistency, set bcdUSB to 0x0200 for gadgets that don't
      support superspeed.
      
      It's correct to use 0x0200 for any setting that doesn't use
      superspeed, since USB 2.0 devices can restrict themselves to
      full speed only. It is NOT correct to use 0x0210, since BOS
      descriptors are handled only if gadget_is_superspeed() is
      satisfied, otherwise it results in a stall.
      Signed-off-by: NIgor Kotrasinski <i.kotrasinsk@samsung.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      5527e733
  3. 27 9月, 2015 1 次提交
  4. 07 8月, 2015 1 次提交
  5. 29 7月, 2015 4 次提交
  6. 07 7月, 2015 1 次提交
  7. 11 3月, 2015 3 次提交
  8. 27 1月, 2015 1 次提交
  9. 04 11月, 2014 3 次提交
    • A
      usb: gadget: configfs: add suspend/resume · 3a571870
      Andrzej Pietrasiewicz 提交于
      USB gadgets composed with configfs lack suspend and resume
      methods. This patch uses composite_suspend()/composite_resume()
      the same way e.g. composite_setup() or composite_disconnect()
      are used in a configfs-based gadget.
      Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      3a571870
    • F
      usb: gadget: composite: conditionally dequeue os_desc and setup requests · a7c12eaf
      Felipe Balbi 提交于
      In case we unload a gadget driver while any of
      os_desc_req or req are still pending, we need
      to make sure to dequeue them.
      
      By using our setup_pending and os_desc_pending
      flags we achieve that in a way that doesn't
      cause any regressions because we won't dequeue
      a request which was already completed.
      
      The original idea came from Li Jun's commit
      f2267089
      (usb: gadget: composite: dequeue cdev->req
      before free it in composite_dev_cleanup) which,
      unfortunately, caused two regressions (kfree()
      being called before usb_ep_dequeue() and calling
      usb_ep_dequeue() when the request was already
      completed). That commit also didn't take care
      of os_desc_req which can fall into the same
      situation so we must care for that one too.
      
      Note that in order to make code slightly easier
      to read, we introduce composite_ep_queue() which
      hides details about how to fiddle with our pending
      flags.
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      a7c12eaf
    • F
      usb: gadget: composite: set our req->context to cdev · 57943716
      Felipe Balbi 提交于
      by doing that we will be able to match our
      requests against req and os_desc_req and also
      clear our pending flags from complete callback.
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      57943716
  10. 23 10月, 2014 1 次提交
  11. 23 9月, 2014 1 次提交
  12. 18 9月, 2014 1 次提交
  13. 09 9月, 2014 1 次提交
  14. 02 9月, 2014 1 次提交
    • L
      usb: gadget: composite: dequeue cdev->req before free its buffer · be0a8887
      Li Jun 提交于
      commit f2267089(usb: gadget: composite: dequeue cdev->req before free it in
      composite_dev_cleanup) fixed a bug: free the usb request(i.e. cdev->req) but
      does not dequeue it beforehand. This fix is not proper enough because it
      dequeues the request after free its data buffer, considering the hardware can
      access the buffer's memory anytime before the request's complettion rountine
      runs, and usb_ep_dequeue always call the complettion rountine before it returns,
      so the best way is to dequeue the request before free its buffer.
      Suggested-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NLi Jun <b47624@freescale.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      be0a8887
  15. 16 7月, 2014 1 次提交
  16. 28 5月, 2014 1 次提交
  17. 14 5月, 2014 2 次提交
    • A
      usb: gadget: OS Feature Descriptors support · 37a3a533
      Andrzej Pietrasiewicz 提交于
      There is a custom (non-USB IF) extension to the USB standard:
      
      http://msdn.microsoft.com/library/windows/hardware/gg463182
      
      They grant permission to use the specification - there is
      "Microsoft OS Descriptor Specification License Agreement"
      under the link mentioned above, and its Section 2 "Grant
      of License", letter (b) reads:
      
      "Patent license. Microsoft hereby grants to You a nonexclusive,
      royalty-free, nontransferable, worldwide license under Microsoft’s
      patents embodied solely within the Specification and that are owned
      or licensable by Microsoft to make, use, import, offer to sell,
      sell and distribute directly or indirectly to Your Licensees Your
      Implementation. You may sublicense this patent license to Your
      Licensees under the same terms and conditions."
      
      The said extension is maintained by Microsoft for Microsoft.
      
      Yet it is fairly common for various devices to use it, and a
      popular proprietary operating system expects devices to provide
      "OS descriptors", so Linux-based USB gadgets whishing to be able
      to talk to a variety of operating systems should be able to provide
      the "OS descriptors".
      
      This patch adds optional support for gadgets whishing to expose
      the so called "OS Feature Descriptors", that is "Extended Compatibility ID"
      and "Extended Properties".
      
      Hosts which do request "OS descriptors" from gadgets do so during
      the enumeration phase and before the configuration is set with
      SET_CONFIGURATION. What is more, those hosts never ask for configurations
      at indices other than 0. Therefore, gadgets whishing to provide
      "OS descriptors" must designate one configuration to be used with
      this kind of hosts - this is what os_desc_config is added for in
      struct usb_composite_dev. There is an additional advantage to it:
      if a gadget provides "OS descriptors" and designates one configuration
      to be used with such non-USB-compliant hosts it can invoke
      "usb_add_config" in any order because the designated configuration
      will be reported to be at index 0 anyway.
      
      This patch also adds handling vendor-specific requests addressed
      at device or interface and related to handling "OS descriptors".
      Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      37a3a533
    • A
      usb: gadget: OS String support · 19824d5e
      Andrzej Pietrasiewicz 提交于
      There is a custom (non-USB IF) extension to the USB standard:
      
      http://msdn.microsoft.com/library/windows/hardware/gg463182
      
      They grant permission to use the specification - there is
      "Microsoft OS Descriptor Specification License Agreement"
      under the link mentioned above, and its Section 2 "Grant
      of License", letter (b) reads:
      
      "Patent license. Microsoft hereby grants to You a nonexclusive,
      royalty-free, nontransferable, worldwide license under Microsoft’s
      patents embodied solely within the Specification and that are owned
      or licensable by Microsoft to make, use, import, offer to sell,
      sell and distribute directly or indirectly to Your Licensees Your
      Implementation. You may sublicense this patent license to Your
      Licensees under the same terms and conditions."
      
      The said extension is maintained by Microsoft for Microsoft.
      
      Yet it is fairly common for various devices to use it, and a
      popular proprietary operating system expects devices to provide
      "OS descriptors", so Linux-based USB gadgets whishing to be able
      to talk to a variety of operating systems should be able to provide
      the "OS descriptors".
      
      This patch adds optional support for gadgets whishing to expose
      the so called "OS String" under index 0xEE of language 0.
      The contents of the string is generated based on the qw_sign
      array and b_vendor_code.
      
      Interested gadgets need to set the cdev->use_os_string flag,
      fill cdev->qw_sign with appropriate values and fill cdev->b_vendor_code
      with a value of their choice.
      
      This patch does not however implement responding to any vendor-specific
      USB requests.
      Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      19824d5e
  18. 13 5月, 2014 1 次提交
  19. 18 3月, 2014 1 次提交
  20. 19 12月, 2013 1 次提交
  21. 27 11月, 2013 1 次提交
  22. 26 11月, 2013 1 次提交
  23. 12 10月, 2013 1 次提交
  24. 28 8月, 2013 1 次提交
    • G
      USB: gadget: audit sysfs attribute permissions · ce26bd23
      Greg Kroah-Hartman 提交于
      Convert all USB gadget sysfs attributes to use the _RO or _RW variants,
      to make them easier to audit and ensure that the permissions are
      correct.
      
      Note, two are left using the DEVICE_ATTR() macro, as there is no
      DEVICE_ATTR_WO() in Linus's tree, that will happen after 3.12-rc1 is
      out, a follow-on patch will be sent then.
      Reviewed-by: NFelipe Balbi <balbi@ti.com>
      Acked-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      --
       drivers/usb/gadget/composite.c      |    8 +++-----
       drivers/usb/gadget/dummy_hcd.c      |    8 ++++----
       drivers/usb/gadget/f_mass_storage.c |   14 ++++++--------
       drivers/usb/gadget/net2272.c        |    4 ++--
       drivers/usb/gadget/net2280.c        |   18 +++++++++---------
       drivers/usb/gadget/storage_common.c |   25 ++++++++++++-------------
       drivers/usb/gadget/udc-core.c       |   14 +++++++-------
       7 files changed, 43 insertions(+), 48 deletions(-)
      ce26bd23
  25. 03 4月, 2013 1 次提交
    • S
      usb: gadget: the start of the configfs interface · 88af8bbe
      Sebastian Andrzej Siewior 提交于
      |# modprobe dummy_hcd num=2
      |# modprobe libcomposite
      
      |# lsmod
      |Module                  Size  Used by
      |libcomposite           31648  0
      |dummy_hcd              19871  0
      
      |# mkdir /sys/kernel/config/usb_gadget/oha
      |# cd /sys/kernel/config/usb_gadget/oha
      |# mkdir configs/def.1
      |# mkdir configs/def.2
      |# mkdir functions/acm.ttyS1
      |# mkdir strings/0x1
      |mkdir: cannot create directory `strings/0x1': Invalid argument
      |# mkdir strings/0x409
      |# mkdir strings/1033
      |mkdir: cannot create directory `strings/1033': File exists
      |# mkdir strings/1032
      |# mkdir configs/def.1/strings/0x409
      |# mkdir configs/def.2/strings/0x409
      
      |#find . -ls
      |   975    0 drwxr-xr-x   5 root     root            0 Dec 23 17:40 .
      |   978    0 drwxr-xr-x   4 root     root            0 Dec 23 17:43 ./strings
      |  4100    0 drwxr-xr-x   2 root     root            0 Dec 23 17:43 ./strings/1032
      |   995    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/1032/serialnumber
      |   996    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/1032/product
      |   997    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/1032/manufacturer
      |  2002    0 drwxr-xr-x   2 root     root            0 Dec 23 17:41 ./strings/0x409
      |   998    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/0x409/serialnumber
      |   999    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/0x409/product
      |  1000    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/0x409/manufacturer
      |   977    0 drwxr-xr-x   4 root     root            0 Dec 23 17:41 ./configs
      |  4081    0 drwxr-xr-x   3 root     root            0 Dec 23 17:41 ./configs/def.2
      |  4082    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 ./configs/def.2/strings
      |  2016    0 drwxr-xr-x   2 root     root            0 Dec 23 17:42 ./configs/def.2/strings/0x409
      |  1001    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.2/strings/0x409/configuration
      |  1002    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.2/bmAttributes
      |  1003    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.2/MaxPower
      |   979    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 ./configs/def.1
      |   980    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 ./configs/def.1/strings
      |  5122    0 drwxr-xr-x   2 root     root            0 Dec 23 17:42 ./configs/def.1/strings/0x409
      |  1004    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.1/strings/0x409/configuration
      |  1005    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.1/bmAttributes
      |  1006    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.1/MaxPower
      |   976    0 drwxr-xr-x   3 root     root            0 Dec 23 17:41 ./functions
      |   981    0 drwxr-xr-x   2 root     root            0 Dec 23 17:41 ./functions/acm.ttyS1
      |  1007    0 -r--r--r--   1 root     root         4096 Dec 23 17:43 ./functions/acm.ttyS1/port_num
      |  1008    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./UDC
      |  1009    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bcdUSB
      |  1010    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bcdDevice
      |  1011    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./idProduct
      |  1012    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./idVendor
      |  1013    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bMaxPacketSize0
      |  1014    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bDeviceProtocol
      |  1015    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bDeviceSubClass
      |  1016    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bDeviceClass
      
      |# cat functions/acm.ttyS1/port_num
      |0
      |# ls -lah /dev/ttyGS*
      |crw-rw---T 1 root dialout 252, 0 Dec 23 17:41 /dev/ttyGS0
      |
      |# echo 0x1234 > idProduct
      |# echo 0xabcd > idVendor
      |# echo 1122 > strings/0x409/serialnumber
      |# echo "The manufacturer" > strings/0x409/manufacturer
      |# echo 1 > strings/1032/manufacturer
      |# echo 1sa > strings/1032/product
      |# echo tada > strings/1032/serialnumber
      |echo "Primary configuration" > configs/def.1/strings/0x409/configuration
      |# echo "Secondary configuration" > configs/def.2/strings/0x409/configuration
      |# ln -s functions/acm.ttyS1 configs/def.1/
      |# ln -s functions/acm.ttyS1 configs/def.2/
      |find configs/def.1/ -ls
      |   979    0 drwxr-xr-x   3 root     root            0 Dec 23 17:49 configs/def.1/
      |  6264    0 lrwxrwxrwx   1 root     root            0 Dec 23 17:48 configs/def.1/acm.ttyS1 -> ../../../../usb_gadget/oha/functions/acm.ttyS1
      |   980    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 configs/def.1/strings
      |  5122    0 drwxr-xr-x   2 root     root            0 Dec 23 17:49 configs/def.1/strings/0x409
      |  6284    0 -rw-r--r--   1 root     root         4096 Dec 23 17:47 configs/def.1/strings/0x409/configuration
      |  6285    0 -rw-r--r--   1 root     root         4096 Dec 23 17:49 configs/def.1/bmAttributes
      |  6286    0 -rw-r--r--   1 root     root         4096 Dec 23 17:49 configs/def.1/MaxPower
      |
      |echo 120 > configs/def.1/MaxPower
      |
      |# ls -lh /sys/class/udc/
      |total 0
      |lrwxrwxrwx 1 root root 0 Dec 23 17:50 dummy_udc.0 -> ../../devices/platform/dummy_udc.0/udc/dummy_udc.0
      |lrwxrwxrwx 1 root root 0 Dec 23 17:50 dummy_udc.1 -> ../../devices/platform/dummy_udc.1/udc/dummy_udc.1
      |# echo dummy_udc.0 > UDC
      |# lsusb
      |Bus 001 Device 002: ID abcd:1234 Unknown
      |
      |lsusb -d abcd:1234 -v
      |Device Descriptor:
      …
      |  idVendor           0xabcd Unknown
      |  idProduct          0x1234
      |  bcdDevice            3.06
      |  iManufacturer           1 The manufacturer
      |  iProduct                2
      |  iSerial                 3 1122
      |  bNumConfigurations      2
      …
      |echo "" > UDC
      
      v5…v6
      - wired up strings with usb_gstrings_attach()
      - add UDC attribe. Write "udc-name" will bind the gadget. Write an empty
        string (it should contain \n since 0 bytes write get optimzed away)
        will unbind the UDC from the gadget. The name of available UDCs can be
        obtained from /sys/class/udc/
      
      v4…v5
      - string rework. This will add a strings folder incl. language code like
          strings/409/manufacturer
        as suggested by Alan.
      - rebased ontop reworked functions.c which has usb_function_instance
        which is used prior after "mkdir acm.instance" and can be directly
        used for configuration via configfs.
      
      v3…v4
       - moved functions from the root folde down to the gadget as suggested
         by Michał
       - configs have now their own configs folder as suggested by Michał.
         The folder is still name.bConfigurationValue where name becomes the
         sConfiguration. Is this usefull should we just stilc
         configs/bConfigurationValue/ ?
       - added configfs support to the ACM function. The port_num attribute is
         exported by f_acm. An argument has been added to the USB alloc
         function to distinguish between "old" (use facm_configure() to
         configure and configfs interface (expose a config_node).
         The port_num is currently a dumb counter. It will
         require some function re-work to make it work.
      
      scheduled for v5:
      - sym linking function into config.
      
      v2…v3
      - replaced one ifndef by ifdef as suggested by Micahał
      - strstr()/strchr() function_make as suggested by Micahł
      - replace [iSerialNumber|iProduct|iManufacturer] with
        [sSerialNumber|sProduct|sManufacturer] as suggested by Alan
      - added creation of config descriptors
      
      v1…v2
      - moved gadgets from configfs' root directory into /udcs/ within our
        "usb_gadget" folder. Requested by Andrzej & Michał
      - use a dot as a delimiter between function's name and its instance's name
        as suggested by Michał
      - renamed all config_item_type, configfs_group_operations, make_group,
        drop_item as suggested by suggested by Andrzej to remain consisten
        within this file and within other configfs users
      - Since configfs.c and functions.c are now part of the udc-core module,
        the module itself is now called udc. Also added a tiny ifdef around
        init code becuase udc-core is subsys init and this is too early for
        configfs in the built-in case. In the module case, we can only have
        one init function.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      88af8bbe
  26. 05 3月, 2013 1 次提交
    • N
      usb: gadget: composite: fix kernel-doc warnings · 43febb27
      Nishanth Menon 提交于
      A few trivial fixes for composite driver:
      
      Warning(include/linux/usb/composite.h:165): No description found for parameter
      	'fs_descriptors'
      Warning(include/linux/usb/composite.h:165): Excess struct/union/enum/typedef
      	member 'descriptors' description in 'usb_function'
      Warning(include/linux/usb/composite.h:321): No description found for parameter
      	'gadget_driver'
      Warning(drivers/usb/gadget/composite.c:1777): Excess function parameter 'bind'
      	description in 'usb_composite_probe'
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Kosina <trivial@kernel.org>
      Cc: linux-usb@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NNishanth Menon <nm@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      43febb27
  27. 22 1月, 2013 5 次提交