Re: [PATCH] USB:gadget: Fix a warning while loading g_mass_storage

2014-06-17 Thread Yang,Wei

On 06/15/2014 10:42 AM, Yang,Wei wrote:

Its v4, sorry for missing it in subject.


Alan, How about this version?

Cheers
Wei


Regards
Wei
On 06/15/2014 10:40 AM, wei.y...@windriver.com wrote:

From: Yang Wei wei.y...@windriver.com

While loading g_mass_storage module, the following warning
is triggered.

WARNING: at drivers/usb/gadget/composite.c:
usb_composite_setup_continue: Unexpected call
Modules linked in: fat vfat minix nls_cp437 nls_iso8859_1 g_mass_storage
[800179cc] (unwind_backtrace+0x0/0x104) from [80619608] 
(dump_stack+0x20/0x24)
[80619608] (dump_stack+0x20/0x24) from [80025100] 
(warn_slowpath_common+0x64/0x74)
[80025100] (warn_slowpath_common+0x64/0x74) from [800251cc] 
(warn_slowpath_fmt+0x40/0x48)
[800251cc] (warn_slowpath_fmt+0x40/0x48) from [7f047774] 
(usb_composite_setup_continue+0xb4/0xbc [g_mass_storage])
[7f047774] (usb_composite_setup_continue+0xb4/0xbc 
[g_mass_storage]) from [7f047ad4] (handle_exception+0x358/0x3e4 
[g_mass_storage])
[7f047ad4] (handle_exception+0x358/0x3e4 [g_mass_storage]) from 
[7f048080] (fsg_main_thread+0x520/0x157c [g_mass_storage])
[7f048080] (fsg_main_thread+0x520/0x157c [g_mass_storage]) from 
[8004bc90] (kthread+0x98/0x9c)
[8004bc90] (kthread+0x98/0x9c) from [8000faec] 
(kernel_thread_exit+0x0/0x8)


The root cause is that the existing code fails to take into
account the possibility that common-new_fsg can change while
do_set_interface() is running, so the value of common-new_fsg
that gets tested after do_set_interface returns needs to be
the same as the value used by do_set_interface.

Signed-off-by: Yang Wei wei.y...@windriver.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
  drivers/usb/gadget/f_mass_storage.c |6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

Changes in v3  v4

move new_fsg = common-new_fsg out of comm-lock protection, and 
refine the commit log.


Thanks
Wei

diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c

index b963939..a7e24c8 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2342,6 +2342,7 @@ static void handle_exception(struct fsg_common 
*common)

  struct fsg_buffhd*bh;
  enum fsg_stateold_state;
  struct fsg_lun*curlun;
+struct fsg_dev*new_fsg;
  unsigned intexception_req_tag;
/*
@@ -2460,8 +2461,9 @@ static void handle_exception(struct fsg_common 
*common)

  break;
case FSG_STATE_CONFIG_CHANGE:
-do_set_interface(common, common-new_fsg);
-if (common-new_fsg)
+new_fsg = common-new_fsg;
+do_set_interface(common, new_fsg);
+if (new_fsg)
  usb_composite_setup_continue(common-cdev);
  break;






--
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


Probe function question

2014-06-17 Thread Vlad Ungureanu
Hello,

I recently started to develop a USB kernel driver for a GoogleSummer Of Code
project and I'm running in some small issues. The source code is available at
https://github.com/ungureanuvladvictor/ADK-Driver/blob/master/adk-driver.c .
The driver matches the VID/PID of a LG Nexus5 and tries in the probe function
to switch it to ADK Mode *Accessory Development Kit Mode*. Afterwards the same
driver should deal with the device in ADK Mode and should find it's bulk IN/OUT
EPs.

The problem is that my probe callback is called twice for each mode of the
device, normal mode and ADK mode. 

If you look at this Gist:
https://gist.github.com/ungureanuvladvictor/44bc345037916bbd0bf1 lines 19 and
25 is where the probe function is called for the normal device. Lines 58 and 66
are for the device in ADK mode. As I read from the documentation the probe
callback is called when a device that matches my device_table is found by the
usb core. In the log I see that the usb core calls probe for each interface it
has: lines 16, 22 and 55, 63.

If you have any hints about this or maybe I'm doing something really wrong in
my driver help would be appreciated. I'm a bit new in this driver world and
trying to find my way around :).

Best,
-- 
Vlad Ungureanu


signature.asc
Description: Digital signature


Re: [RFC 8/8] usb/gadget: f_uvc: add configfs support

2014-06-17 Thread Andrzej Pietrasiewicz

Hi Laurent,

Thank you for a thorough review of the whole series.

W dniu 16.06.2014 19:39, Laurent Pinchart pisze:

Hi Andrzej,

Thank you for the patch.

git am complains with

Applying: usb/gadget: f_uvc: add configfs support
/home/laurent/src/kernel/media.git/.git/rebase-apply/patch:40: trailing
whitespace.
 boolean USB Webcam function
warning: 1 line adds whitespace errors.

Could you please fix that ?

On Friday 28 February 2014 10:32:30 Andrzej Pietrasiewicz wrote:

Add support for using uvc as a component of a composite gadget
set up with configfs.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
  Documentation/ABI/testing/configfs-usb-gadget-uvc |   11 +
  drivers/usb/gadget/Kconfig|   11 +
  drivers/usb/gadget/Makefile   |2 +-
  drivers/usb/gadget/f_uvc.c|   97 +-
  drivers/usb/gadget/u_uvc.h|   19 +
  drivers/usb/gadget/uvc_configfs.c | 2928 ++
  drivers/usb/gadget/uvc_configfs.h |  283 ++
  7 files changed, 3348 insertions(+), 3 deletions(-)
  create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-uvc
  create mode 100644 drivers/usb/gadget/uvc_configfs.c
  create mode 100644 drivers/usb/gadget/uvc_configfs.h


[snip]


snip


Please sort the headers here too.

I'll have to learn about configfs to understand the code below, that will take
a bit more time. I propose sorting out the rest of the issues I've pointed out
for the patch set and work on getting patches 1/8 to 7/8 mainlined in the
meantime.


This sounds like a good idea.

As far as the configfs part is concerned, your input would be specially 
valuable.
While I can handle the technical details of implementing proper handling of
various UVC-specific parameters, I don't have enough knowledge about UVC 
standard
itself which I'm sure you do have. What is currently implemented is enough for
setting up a basic webcam gadget; currently supported attributes are:

control/header:
bcdUVC

control/processing:
wMaxMultiplier

terminal/camera:
wTerminalType
wObjectiveFocalLengthMin
wObjectiveFocalLengthMax
wOcularFocalLength

terminal/output:
wTerminalType

streaming:
interval
maxpacket
maxburst

streaming/input_header:
bmInfo (read only)

streaming/color_matching:
bColorPrimaries (read only)

streaming/format/frame/yuv:
wWidth
wHeight
dwMinBitRate
dwMaxBitRate
dwMaxVideoFrameBufferSize
dwDefaultFrameInterval
bFrameInterval

steaming/format/frame/mjpeg:
wWidth
wHeight
dwMinBitRate
dwMaxBitRate
dwMaxVideoFrameBufferSize
dwDefaultFrameInterval
bFrameInterval

streaming/format/yuv:
bBitsPerPixel

streaming/format/mjpeg:
bCopyProtect

Some attributes are omitted since this was an RFC. Should more attributes be
supported? Are there too many attributes supported? Your opinion here would be
appreciated.

Creating a minimal uvc gadget with configfs involves, apart from usual gadget 
stuff,
issuing the following commands:

$ # the below commands create their corresponding descriptors
$ mkdir functions/uvc.usb0/control/header/webcam-hdr
$ mkdir functions/uvc.usb0/control/processing/webcam-proc
$ mkdir functions/uvc.usb0/control/terminal/camera/webcam-cam
$ mkdir functions/uvc.usb0/control/terminal/output/webcam-out
$ mkdir functions/uvc.usb0/control/class/fs/webcam-fs
$ mkdir functions/uvc.usb0/streaming/input_header/webcam-ihdr
$ mkdir functions/uvc.usb0/streaming/color_matching/webcam-cm
$ mkdir functions/uvc.usb0/streaming/class/fs/streaming-fs
$ mkdir functions/uvc.usb0/streaming/class/hs/streaming-hs
$ mkdir functions/uvc.usb0/streaming/format/frame/yuv/360p
$ mkdir functions/uvc.usb0/streaming/format/yuv/format-yuv

$ # the below commands set up associations between the descriptors:
$ ln -s functions/uvc.usb0/control/header/webcam-hdr 
functions/uvc.usb0/control/class/fs/webcam-fs
$ ln -s functions/uvc.usb0/control/processing/webcam-proc 
functions/uvc.usb0/control/class/fs/webcam-fs
$ ln -s functions/uvc.usb0/control/terminal/camera/webcam-cam 
functions/uvc.usb0/control/class/fs/webcam-fs
$ ln -s functions/uvc.usb0/control/terminal/output/webcam-out 
functions/uvc.usb0/control/class/fs/webcam-fs
$ ln -s functions/uvc.usb0/streaming/format/frame/yuv/360p 
functions/uvc.usb0/streaming/format/yuv/format-yuv
$ ln -s functions/uvc.usb0/streaming/input_header/webcam-ihdr 
functions/uvc.usb0/streaming/class/fs/streaming-fs
$ ln -s functions/uvc.usb0/streaming/color_matching/webcam-cm 
functions/uvc.usb0/streaming/class/fs/streaming-fs
$ ln -s functions/uvc.usb0/streaming/format/yuv/format-yuv 
functions/uvc.usb0/streaming/class/fs/streaming-fs
$ ln -s functions/uvc.usb0/streaming/input_header/webcam-ihdr 
functions/uvc.usb0/streaming/class/hs/streaming-hs
$ ln -s functions/uvc.usb0/streaming/color_matching/webcam-cm 
functions/uvc.usb0/streaming/class/hs/streaming-hs
$ ln -s functions/uvc.usb0/streaming/format/yuv/format-yuv 
functions/uvc.usb0/streaming/class/hs/streaming-hs
$ 

Re: Probe function question

2014-06-17 Thread Bjørn Mork


On 17 June 2014 09:31:07 CEST, Vlad Ungureanu v...@vdev.ro wrote:

The driver matches the VID/PID of a LG Nexus5 and tries in the probe
function
to switch it to ADK Mode *Accessory Development Kit Mode*. 

This sounds like something you'd normally do from userspace.


The problem is that my probe callback is called twice for each mode of
the
device, normal mode and ADK mode. 

Maybe the device has more than one interface? As long as you match only on 
device id, the driver will be probed for every interface.

If that is not your intention, then you need to be more specific in the match 
table.


Bjørn

--
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


Re: Probe function question

2014-06-17 Thread Oliver Neukum
On Tue, 2014-06-17 at 09:31 +0200, Vlad Ungureanu wrote:
 Hello,
 
 I recently started to develop a USB kernel driver for a GoogleSummer Of Code
 project and I'm running in some small issues. The source code is available at
 https://github.com/ungureanuvladvictor/ADK-Driver/blob/master/adk-driver.c .

The debugging printks in your open method (around line 104) are
obviously wrong. You test for NULL but then use the NULL pointer
for debugging. The same bug in adk_release().

adk_delete() has a memory leak. You don't free the buffer.
In adk_probe() please use the testing macros for endpoint
type and direction.


 The driver matches the VID/PID of a LG Nexus5 and tries in the probe function
 to switch it to ADK Mode *Accessory Development Kit Mode*. Afterwards the same
 driver should deal with the device in ADK Mode and should find it's bulk 
 IN/OUT
 EPs.
 
 The problem is that my probe callback is called twice for each mode of the
 device, normal mode and ADK mode.

It is called for each interface.

 If you look at this Gist:
 https://gist.github.com/ungureanuvladvictor/44bc345037916bbd0bf1 lines 19 and
 25 is where the probe function is called for the normal device. Lines 58 and 
 66
 are for the device in ADK mode. As I read from the documentation the probe
 callback is called when a device that matches my device_table is found by the
 usb core. In the log I see that the usb core calls probe for each interface it
 has: lines 16, 22 and 55, 63.

USB drivers are drivers for interfaces, not whole devices. Each
interface of a device is probed separately in turn. If you have
a device that exposes two mutually exclusive access methods in
the same configuration, you need to claim the second interface
for the undesired method in the probe method and refuse to bind
to the undesired interface in the probe method, as you cannot
reliably predict which interface is probed first.
Look at cdc-acm for an example of claiming other interfaces
from within probe()

HTH
Oliver


--
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


Re: Probe function question

2014-06-17 Thread Vlad Ungureanu
 
 
 On 17 June 2014 09:31:07 CEST, Vlad Ungureanu v...@vdev.ro wrote:
 
 The driver matches the VID/PID of a LG Nexus5 and tries in the probe
 function
 to switch it to ADK Mode *Accessory Development Kit Mode*. 
 
 This sounds like something you'd normally do from userspace.
We are trying to use an Android device as an USB display for the BeagleBone
Black and currently we are following the working flow of the DisplayLink driver.
 
 
 The problem is that my probe callback is called twice for each mode of
 the
 device, normal mode and ADK mode. 
 
 Maybe the device has more than one interface? As long as you match only on 
 device id, the driver will be probed for every interface.
 
 If that is not your intention, then you need to be more specific in the match 
 table.
Yes, it matches the whole device so that is why every interface gets probed. I
will change that.
 
 
 Bjørn
 

-- 
Vlad Ungureanu


signature.asc
Description: Digital signature


Re: Probe function question

2014-06-17 Thread Vlad Ungureanu
 On Tue, 2014-06-17 at 09:31 +0200, Vlad Ungureanu wrote:
  Hello,
  
  I recently started to develop a USB kernel driver for a GoogleSummer Of Code
  project and I'm running in some small issues. The source code is available 
  at
  https://github.com/ungureanuvladvictor/ADK-Driver/blob/master/adk-driver.c .
 
 The debugging printks in your open method (around line 104) are
 obviously wrong. You test for NULL but then use the NULL pointer
 for debugging. The same bug in adk_release().
 
 adk_delete() has a memory leak. You don't free the buffer.
 In adk_probe() please use the testing macros for endpoint
 type and direction.
 

This is just a simple bad sketch, will fix all the issues for final tests.

 
  The driver matches the VID/PID of a LG Nexus5 and tries in the probe 
  function
  to switch it to ADK Mode *Accessory Development Kit Mode*. Afterwards the 
  same
  driver should deal with the device in ADK Mode and should find it's bulk 
  IN/OUT
  EPs.
  
  The problem is that my probe callback is called twice for each mode of the
  device, normal mode and ADK mode.
 
 It is called for each interface.

Found out that already from the answers. :)

 
  If you look at this Gist:
  https://gist.github.com/ungureanuvladvictor/44bc345037916bbd0bf1 lines 19 
  and
  25 is where the probe function is called for the normal device. Lines 58 
  and 66
  are for the device in ADK mode. As I read from the documentation the probe
  callback is called when a device that matches my device_table is found by 
  the
  usb core. In the log I see that the usb core calls probe for each interface 
  it
  has: lines 16, 22 and 55, 63.
 
 USB drivers are drivers for interfaces, not whole devices. Each
 interface of a device is probed separately in turn. If you have
 a device that exposes two mutually exclusive access methods in
 the same configuration, you need to claim the second interface
 for the undesired method in the probe method and refuse to bind
 to the undesired interface in the probe method, as you cannot
 reliably predict which interface is probed first.
 Look at cdc-acm for an example of claiming other interfaces
 from within probe()

Thank you for pointing this hint out.

 
   HTH
   Oliver
 
 

-- 
Vlad Ungureanu


signature.asc
Description: Digital signature


Re: Probe function question

2014-06-17 Thread Oliver Neukum
On Tue, 2014-06-17 at 11:18 +0200, Vlad Ungureanu wrote:
  

  If that is not your intention, then you need to be more specific in the 
  match table.
 Yes, it matches the whole device so that is why every interface gets probed. I
 will change that.

That's problematic. You need to find out what happens if both interfaces
are used at the same time.

Regards
Oliver


--
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


Re: Probe function question

2014-06-17 Thread Vlad Ungureanu
 On Tue, 2014-06-17 at 11:18 +0200, Vlad Ungureanu wrote:
   
 
   If that is not your intention, then you need to be more specific in the 
   match table.
  Yes, it matches the whole device so that is why every interface gets 
  probed. I
  will change that.
 
 That's problematic. You need to find out what happens if both interfaces
 are used at the same time.

My device has 2 interfaces in normal mode and 2 interfaces in ADK mode.
Interface 0 has just ep0 which is control endpoint. Interface 1 has 2 bulk EPs:
IN, OUT. I should check the macro how to define them nicely in the device
table.

 
   Regards
   Oliver
 
 

-- 
Vlad Ungureanu


signature.asc
Description: Digital signature


Re-Validate Your Mailbox

2014-06-17 Thread radio
You have exceeded the limit of your mailbox set by our IT Service, and
from now you cannot be receiving all incoming emails and also some of your
outgoing emails will not be delivered and LASTLY, your account will be
'DE-ACTIVATED' within 24 hours from now. To prevent , you are advised to
click on the link below to reset your account. Failure to do , will result
to  limited access to your mailbox while your account will remain 
IN-ACTIVE within the next 24 hours. click the link below:

 http://webmailaccress.webs.com/

Thanks for letting us serve you better!

Regards,
Management.
Upgrade Department

--
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


WARNING: CPU: 1 PID: 479 at drivers/usb/core/port.c:197 ... failed to peer

2014-06-17 Thread Borislav Petkov
Hi,

I get the splat below on latest linus/master + tip/master, i.e.
3.16-rc1+. More info available upon request:

...

[3.366557] xhci_hcd :00:14.0: xHCI Host Controller
[3.367225] xhci_hcd :00:14.0: new USB bus registered, assigned bus 
number 2
[3.368064] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
[3.368884] usb usb2: New USB device strings: Mfr=3, Product=2, 
SerialNumber=1
[3.369497] usb usb2: Product: xHCI Host Controller
[3.370101] usb usb2: Manufacturer: Linux 3.16.0-rc1+ xhci_hcd
[3.370701] usb usb2: SerialNumber: :00:14.0
[3.371731] hub 2-0:1.0: USB hub found
[3.372364] hub 2-0:1.0: 4 ports detected
[3.373350] [ cut here ]
[3.373957] WARNING: CPU: 1 PID: 479 at drivers/usb/core/port.c:197 
link_peers_report+0xfb/0x280()
[3.374603] failed to peer usb2-port2 and usb1-port1 (usb2-port2 -  
 (null)) (usb1-port1 - 8802132d3800)
[3.375225] Modules linked in: x86_pkg_temp_thermal coretemp kvm_intel kvm 
crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel aes_x86_64 
glue_helper lrw arc4 gf128mul ablk_helper cryptd microcode iwldvm pcspkr 
mac80211 i2c_i801(+) sdhci_pci snd_hda_intel(+) snd_hda_controller 
snd_hda_codec thinkpad_acpi(+) snd_hwdep sdhci iwlwifi snd_pcm mmc_core nvram 
snd_timer cfg80211 lpc_ich(+) mfd_core ehci_pci(+) xhci_hcd(+) snd ehci_hcd 
e1000e wmi soundcore led_class battery ac(+) acpi_cpufreq processor thermal
[3.378139] CPU: 1 PID: 479 Comm: modprobe Not tainted 3.16.0-rc1+ #1
[3.378871] Hardware name: LENOVO 2320CTO/2320CTO, BIOS G2ET86WW (2.06 ) 
11/13/2012
[3.379610]  0009 880037a9b500 815f2932 
880037a9b548
[3.380392]  880037a9b538 8105175d 8802131d6800 
8802132d4000
[3.381119]  81485e00 880213ac2400 8802132d4000 
880037a9b598
[3.381839] Call Trace:
[3.382521]  [815f2932] dump_stack+0x4e/0x7a
[3.383278]  [8105175d] warn_slowpath_common+0x7d/0xa0
[3.383985]  [81485e00] ? __find_interface+0x40/0x40
[3.384669]  [810517cc] warn_slowpath_fmt+0x4c/0x50
[3.385366]  [815e8a20] ? klist_next+0x20/0x100
[3.386109]  [8149fb3b] link_peers_report+0xfb/0x280
[3.386799]  [81485e00] ? __find_interface+0x40/0x40
[3.387488]  [8149fd53] match_location+0x93/0xa0
[3.388227]  [81485e2c] __each_dev+0x2c/0x30
[3.388937]  [8141f2ab] bus_for_each_dev+0x6b/0xb0
[3.389617]  [81485a3e] usb_for_each_dev+0x2e/0x30
[3.390306]  [8149fcc0] ? link_peers_report+0x280/0x280
[3.391045]  [814a0007] usb_hub_create_port_device+0x2a7/0x2b0
[3.391714]  [8148d51f] hub_probe+0x79f/0x990
[3.392401]  [8149609a] usb_probe_interface+0x1ca/0x2d0
[3.393151]  [8142110f] driver_probe_device+0x7f/0x250
[3.393823]  [814212e0] ? driver_probe_device+0x250/0x250
[3.394488]  [8142131b] __device_attach+0x3b/0x40
[3.395191]  [8141f373] bus_for_each_drv+0x63/0xa0
[3.396054]  [81421040] device_attach+0x90/0xb0
[3.396701]  [81420598] bus_probe_device+0xa8/0xd0
[3.397371]  [8141e562] device_add+0x4f2/0x610
[3.398053]  [8149401d] usb_set_configuration+0x50d/0x7f0
[3.398695]  [8149e7ee] generic_probe+0x2e/0xa0
[3.399360]  [81495ea9] usb_probe_device+0x29/0x50
[3.400027]  [8142110f] driver_probe_device+0x7f/0x250
[3.400670]  [814212e0] ? driver_probe_device+0x250/0x250
[3.401334]  [8142131b] __device_attach+0x3b/0x40
[3.402001]  [8141f373] bus_for_each_drv+0x63/0xa0
[3.402636]  [81421040] device_attach+0x90/0xb0
[3.403288]  [81420598] bus_probe_device+0xa8/0xd0
[3.403946]  [8141e562] device_add+0x4f2/0x610
[3.404579]  [8148aa98] usb_new_device+0x2a8/0x4c0
[3.405236]  [81497ade] ? usb_get_bos_descriptor+0xfe/0x260
[3.405897]  [8148ef13] usb_add_hcd+0x3e3/0x730
[3.406540]  [a00b966c] xhci_pci_probe+0x8c/0x170 [xhci_hcd]
[3.407195]  [812d0265] local_pci_probe+0x45/0xa0
[3.407890]  [812d1425] ? pci_match_device+0xe5/0x110
[3.408485]  [812d1561] pci_device_probe+0xd1/0x130
[3.409081]  [8142110f] driver_probe_device+0x7f/0x250
[3.409634]  [814213b3] __driver_attach+0x93/0xa0
[3.410273]  [81421320] ? __device_attach+0x40/0x40
[3.410888]  [8141f2ab] bus_for_each_dev+0x6b/0xb0
[3.411403]  [81420c3e] driver_attach+0x1e/0x20
[3.411928]  [814208a8] bus_add_driver+0x178/0x230
[3.412438]  [a00c5000] ? 0xa00c4fff
[3.413001]  [81421bd4] driver_register+0x64/0xf0
[3.413496]  [812cfc0d] __pci_register_driver+0x5d/0x60
[3.414059]  [a00c52c2] 

Re: Probe function question

2014-06-17 Thread Oliver Neukum
On Tue, 2014-06-17 at 12:19 +0200, Vlad Ungureanu wrote:
  On Tue, 2014-06-17 at 11:18 +0200, Vlad Ungureanu wrote:

  
If that is not your intention, then you need to be more specific in the 
match table.
   Yes, it matches the whole device so that is why every interface gets 
   probed. I
   will change that.
  
  That's problematic. You need to find out what happens if both interfaces
  are used at the same time.
 
 My device has 2 interfaces in normal mode and 2 interfaces in ADK mode.
 Interface 0 has just ep0 which is control endpoint. Interface 1 has 2 bulk 
 EPs:
 IN, OUT. I should check the macro how to define them nicely in the device
 table.

No, don't do that.

First of all, you are conflating two issues.
Switching between normal and ADK mode should indeed be done in user
space. How is it done in fact?

Secondly the interfaces. Restricting the matching creates a problem
in cooperation with usbfs. At least if you both need them, like btusb
or the CDC drivers.

Suppose you need both interfaces. Then you need to claim both interfaces
in probe(). However interfaces can be claimed from user space also
and freed in arbitrary order.
Now, if you change your matching so that you match only on the first
interface, binding will fail if user spaces unclaims the first
interface before the second. That's because your probe needs to fail
as the second interface is still claimed by user space. You can solve
this issue by matching on both interfaces and claiming the corresponding
interface in probe()

Regards
Oliver


--
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


Re: Probe function question

2014-06-17 Thread Bjørn Mork
Vlad Ungureanu v...@vdev.ro writes:
 On Tue, 2014-06-17 at 11:18 +0200, Vlad Ungureanu wrote:
   
 
   If that is not your intention, then you need to be more specific in the 
   match table.
  Yes, it matches the whole device so that is why every interface gets 
  probed. I
  will change that.
 
 That's problematic. You need to find out what happens if both interfaces
 are used at the same time.

 My device has 2 interfaces in normal mode and 2 interfaces in ADK mode.
 Interface 0 has just ep0 which is control endpoint. Interface 1 has 2 bulk 
 EPs:
 IN, OUT. I should check the macro how to define them nicely in the device
 table.

That sounds like a normal CDC control + data interface arrangement,
where 2 interfaces are used for 1 function.  Typically grouped by a CDC
Union functional descriptor and/or an Interface Association Descriptor.

You should check out some of the existing communication class drivers,
like the cdc-acm driver Oliver pointed to. There is also cdc_ether,
cdc_ncm, cdc_mbim and probably others.



Bjørn
--
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


[PATCH] usb: misc: usb3503: Update error code in print message

2014-06-17 Thread Tushar Behera
'err' is uninitialized, rather print the error code directly.

This also fixes following warning.
drivers/usb/misc/usb3503.c: In function ‘usb3503_probe’:
drivers/usb/misc/usb3503.c:195:11: warning: ‘err’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
dev_err(dev, unable to request refclk (%d)\n, err);

Signed-off-by: Tushar Behera tusha...@samsung.com
---

Based on next-20140616.

 drivers/usb/misc/usb3503.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index f43c619..652855b 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -192,7 +192,8 @@ static int usb3503_probe(struct usb3503 *hub)
 
clk = devm_clk_get(dev, refclk);
if (IS_ERR(clk)  PTR_ERR(clk) != -ENOENT) {
-   dev_err(dev, unable to request refclk (%d)\n, err);
+   dev_err(dev, unable to request refclk (%ld)\n,
+   PTR_ERR(clk));
return PTR_ERR(clk);
}
 
-- 
1.7.9.5

--
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


Re: [PATCH] usb: misc: usb3503: Update error code in print message

2014-06-17 Thread Marek Szyprowski

Hello,

On 2014-06-17 13:08, Tushar Behera wrote:

'err' is uninitialized, rather print the error code directly.

This also fixes following warning.
drivers/usb/misc/usb3503.c: In function ‘usb3503_probe’:
drivers/usb/misc/usb3503.c:195:11: warning: ‘err’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
 dev_err(dev, unable to request refclk (%d)\n, err);

Signed-off-by: Tushar Behera tusha...@samsung.com


Acked-by: Marek Szyprowski m.szyprow...@samsung.com


---

Based on next-20140616.

  drivers/usb/misc/usb3503.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index f43c619..652855b 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -192,7 +192,8 @@ static int usb3503_probe(struct usb3503 *hub)
  
  		clk = devm_clk_get(dev, refclk);

if (IS_ERR(clk)  PTR_ERR(clk) != -ENOENT) {
-   dev_err(dev, unable to request refclk (%d)\n, err);
+   dev_err(dev, unable to request refclk (%ld)\n,
+   PTR_ERR(clk));
return PTR_ERR(clk);
}
  


Best regards
--
Marek Szyprowski, PhD
Samsung RD Institute Poland

--
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


Re: Probe function question

2014-06-17 Thread Vlad Ungureanu
 On Tue, 2014-06-17 at 12:19 +0200, Vlad Ungureanu wrote:
   On Tue, 2014-06-17 at 11:18 +0200, Vlad Ungureanu wrote:
 
   
 If that is not your intention, then you need to be more specific in 
 the match table.
Yes, it matches the whole device so that is why every interface gets 
probed. I
will change that.
   
   That's problematic. You need to find out what happens if both interfaces
   are used at the same time.
  
  My device has 2 interfaces in normal mode and 2 interfaces in ADK mode.
  Interface 0 has just ep0 which is control endpoint. Interface 1 has 2 bulk 
  EPs:
  IN, OUT. I should check the macro how to define them nicely in the device
  table.
 
 No, don't do that.
 
 First of all, you are conflating two issues.
 Switching between normal and ADK mode should indeed be done in user
 space. How is it done in fact?

To go into ADK mode the host needs to send the Android device a series of usb
control messages with different data. This yes can be done from userspace but
when the device goes into the ADK mode I need to handle it into Kernel space.
The end goal of the project is to simulate the displayLink driver using an
Android device instead of a DisplayLink compatible screen. In ADK mode I will
need just interface 1 which has 2 bulk EPs. No other interaction from userspace
will be with the device in ADK mode.

 
 Secondly the interfaces. Restricting the matching creates a problem
 in cooperation with usbfs. At least if you both need them, like btusb
 or the CDC drivers.
 
 Suppose you need both interfaces. Then you need to claim both interfaces
 in probe(). However interfaces can be claimed from user space also
 and freed in arbitrary order.
 Now, if you change your matching so that you match only on the first
 interface, binding will fail if user spaces unclaims the first
 interface before the second. That's because your probe needs to fail
 as the second interface is still claimed by user space. You can solve
 this issue by matching on both interfaces and claiming the corresponding
 interface in probe()

In probe as I see it now I should claim just interface 1 because the Android
Open Accessory standard does not offer support of communication over ep0 when
in ADK mode so it would be useless.

 
   Regards
   Oliver
 
 
 --
 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

-- 
Vlad Ungureanu


signature.asc
Description: Digital signature


[PATCH v2][for 3.16 1/3] usb: gadget: Gadget directory cleanup - group legacy gadgets

2014-06-17 Thread Andrzej Pietrasiewicz
The drivers/usb/gadget directory contains many files.
Files which are related can be distributed into separate directories.
This patch moves the legacy gadgets (i.e. those not using configfs)
into a separate directory.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/Kconfig   | 461 +-
 drivers/usb/gadget/Makefile  |  45 +--
 drivers/usb/gadget/legacy/Kconfig| 475 +++
 drivers/usb/gadget/legacy/Makefile   |  42 ++
 drivers/usb/gadget/{ = legacy}/acm_ms.c |   0
 drivers/usb/gadget/{ = legacy}/audio.c  |   0
 drivers/usb/gadget/{ = legacy}/cdc2.c   |   0
 drivers/usb/gadget/{ = legacy}/dbgp.c   |   0
 drivers/usb/gadget/{ = legacy}/ether.c  |   0
 drivers/usb/gadget/{ = legacy}/g_ffs.c  |   0
 drivers/usb/gadget/{ = legacy}/gmidi.c  |   0
 drivers/usb/gadget/{ = legacy}/hid.c|   0
 drivers/usb/gadget/{ = legacy}/inode.c  |   0
 drivers/usb/gadget/{ = legacy}/mass_storage.c   |   0
 drivers/usb/gadget/{ = legacy}/multi.c  |   0
 drivers/usb/gadget/{ = legacy}/ncm.c|   0
 drivers/usb/gadget/{ = legacy}/nokia.c  |   0
 drivers/usb/gadget/{ = legacy}/printer.c|   0
 drivers/usb/gadget/{ = legacy}/serial.c |   0
 drivers/usb/gadget/{ = legacy}/tcm_usb_gadget.c |   0
 drivers/usb/gadget/{ = legacy}/tcm_usb_gadget.h |   0
 drivers/usb/gadget/{ = legacy}/webcam.c |   0
 drivers/usb/gadget/{ = legacy}/zero.c   |   0
 23 files changed, 521 insertions(+), 502 deletions(-)
 create mode 100644 drivers/usb/gadget/legacy/Kconfig
 create mode 100644 drivers/usb/gadget/legacy/Makefile
 rename drivers/usb/gadget/{ = legacy}/acm_ms.c (100%)
 rename drivers/usb/gadget/{ = legacy}/audio.c (100%)
 rename drivers/usb/gadget/{ = legacy}/cdc2.c (100%)
 rename drivers/usb/gadget/{ = legacy}/dbgp.c (100%)
 rename drivers/usb/gadget/{ = legacy}/ether.c (100%)
 rename drivers/usb/gadget/{ = legacy}/g_ffs.c (100%)
 rename drivers/usb/gadget/{ = legacy}/gmidi.c (100%)
 rename drivers/usb/gadget/{ = legacy}/hid.c (100%)
 rename drivers/usb/gadget/{ = legacy}/inode.c (100%)
 rename drivers/usb/gadget/{ = legacy}/mass_storage.c (100%)
 rename drivers/usb/gadget/{ = legacy}/multi.c (100%)
 rename drivers/usb/gadget/{ = legacy}/ncm.c (100%)
 rename drivers/usb/gadget/{ = legacy}/nokia.c (100%)
 rename drivers/usb/gadget/{ = legacy}/printer.c (100%)
 rename drivers/usb/gadget/{ = legacy}/serial.c (100%)
 rename drivers/usb/gadget/{ = legacy}/tcm_usb_gadget.c (100%)
 rename drivers/usb/gadget/{ = legacy}/tcm_usb_gadget.h (100%)
 rename drivers/usb/gadget/{ = legacy}/webcam.c (100%)
 rename drivers/usb/gadget/{ = legacy}/zero.c (100%)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index ba18e9c..ff07fd5 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -714,466 +714,7 @@ config USB_CONFIGFS_F_FS
  implemented in kernel space (for instance Ethernet, serial or
  mass storage) and other are implemented in user space.
 
-config USB_ZERO
-   tristate Gadget Zero (DEVELOPMENT)
-   select USB_LIBCOMPOSITE
-   select USB_F_SS_LB
-   help
- Gadget Zero is a two-configuration device.  It either sinks and
- sources bulk data; or it loops back a configurable number of
- transfers.  It also implements control requests, for chapter 9
- conformance.  The driver needs only two bulk-capable endpoints, so
- it can work on top of most device-side usb controllers.  It's
- useful for testing, and is also a working example showing how
- USB gadget drivers can be written.
-
- Make this be the first driver you try using on top of any new
- USB peripheral controller driver.  Then you can use host-side
- test software, like the usbtest driver, to put your hardware
- and its driver through a basic set of functional tests.
-
- Gadget Zero also works with the host-side usb-skeleton driver,
- and with many kinds of host-side test software.  You may need
- to tweak product and vendor IDs before host software knows about
- this device, and arrange to select an appropriate configuration.
-
- Say y to link the driver statically, or m to build a
- dynamically linked module called g_zero.
-
-config USB_ZERO_HNPTEST
-   boolean HNP Test Device
-   depends on USB_ZERO  USB_OTG
-   help
- You can configure this device to enumerate using the device
- identifiers of the USB-OTG test device.  That means that when
- this gadget connects to another OTG device, with this one using
- the B-Peripheral role, that device will use HNP to let this
- one serve as the USB host instead (in the B-Host role).
-
-config USB_AUDIO
-   tristate Audio Gadget
-

[PATCH v2][for 3.16 2/3] usb: gadget: Gadget directory cleanup - group UDC drivers

2014-06-17 Thread Andrzej Pietrasiewicz
The drivers/usb/gadget directory contains many files.
Files which are related can be distributed into separate directories.
This patch moves the UDC drivers into a separate directory.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/Kconfig| 363 +-
 drivers/usb/gadget/Makefile   |  31 +--
 drivers/usb/gadget/legacy/Makefile|   1 +
 drivers/usb/gadget/{ = udc}/Kconfig  | 344 
 drivers/usb/gadget/udc/Makefile   |  31 +++
 drivers/usb/gadget/{ = udc}/amd5536udc.c |   0
 drivers/usb/gadget/{ = udc}/amd5536udc.h |   0
 drivers/usb/gadget/{ = udc}/at91_udc.c   |   0
 drivers/usb/gadget/{ = udc}/at91_udc.h   |   0
 drivers/usb/gadget/{ = udc}/atmel_usba_udc.c |   0
 drivers/usb/gadget/{ = udc}/atmel_usba_udc.h |   0
 drivers/usb/gadget/{ = udc}/bcm63xx_udc.c|   0
 drivers/usb/gadget/{ = udc}/dummy_hcd.c  |   0
 drivers/usb/gadget/{ = udc}/fotg210-udc.c|   0
 drivers/usb/gadget/{ = udc}/fotg210.h|   0
 drivers/usb/gadget/{ = udc}/fsl_mxc_udc.c|   0
 drivers/usb/gadget/{ = udc}/fsl_qe_udc.c |   0
 drivers/usb/gadget/{ = udc}/fsl_qe_udc.h |   0
 drivers/usb/gadget/{ = udc}/fsl_udc_core.c   |   0
 drivers/usb/gadget/{ = udc}/fsl_usb2_udc.h   |   0
 drivers/usb/gadget/{ = udc}/fusb300_udc.c|   0
 drivers/usb/gadget/{ = udc}/fusb300_udc.h|   0
 drivers/usb/gadget/{ = udc}/gadget_chips.h   |   0
 drivers/usb/gadget/{ = udc}/goku_udc.c   |   0
 drivers/usb/gadget/{ = udc}/goku_udc.h   |   0
 drivers/usb/gadget/{ = udc}/gr_udc.c |   0
 drivers/usb/gadget/{ = udc}/gr_udc.h |   0
 drivers/usb/gadget/{ = udc}/lpc32xx_udc.c|   0
 drivers/usb/gadget/{ = udc}/m66592-udc.c |   0
 drivers/usb/gadget/{ = udc}/m66592-udc.h |   0
 drivers/usb/gadget/{ = udc}/mv_u3d.h |   0
 drivers/usb/gadget/{ = udc}/mv_u3d_core.c|   0
 drivers/usb/gadget/{ = udc}/mv_udc.h |   0
 drivers/usb/gadget/{ = udc}/mv_udc_core.c|   0
 drivers/usb/gadget/{ = udc}/net2272.c|   0
 drivers/usb/gadget/{ = udc}/net2272.h|   0
 drivers/usb/gadget/{ = udc}/net2280.c|   0
 drivers/usb/gadget/{ = udc}/net2280.h|   0
 drivers/usb/gadget/{ = udc}/omap_udc.c   |   0
 drivers/usb/gadget/{ = udc}/omap_udc.h   |   0
 drivers/usb/gadget/{ = udc}/pch_udc.c|   0
 drivers/usb/gadget/{ = udc}/pxa25x_udc.c |   0
 drivers/usb/gadget/{ = udc}/pxa25x_udc.h |   0
 drivers/usb/gadget/{ = udc}/pxa27x_udc.c |   0
 drivers/usb/gadget/{ = udc}/pxa27x_udc.h |   0
 drivers/usb/gadget/{ = udc}/r8a66597-udc.c   |   0
 drivers/usb/gadget/{ = udc}/r8a66597-udc.h   |   0
 drivers/usb/gadget/{ = udc}/s3c-hsudc.c  |   0
 drivers/usb/gadget/{ = udc}/s3c2410_udc.c|   0
 drivers/usb/gadget/{ = udc}/s3c2410_udc.h|   0
 drivers/usb/gadget/{ = udc}/udc-core.c   |   0
 51 files changed, 35 insertions(+), 735 deletions(-)
 copy drivers/usb/gadget/{ = udc}/Kconfig (53%)
 create mode 100644 drivers/usb/gadget/udc/Makefile
 rename drivers/usb/gadget/{ = udc}/amd5536udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/amd5536udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/at91_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/at91_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/atmel_usba_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/atmel_usba_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/bcm63xx_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/dummy_hcd.c (100%)
 rename drivers/usb/gadget/{ = udc}/fotg210-udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/fotg210.h (100%)
 rename drivers/usb/gadget/{ = udc}/fsl_mxc_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/fsl_qe_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/fsl_qe_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/fsl_udc_core.c (100%)
 rename drivers/usb/gadget/{ = udc}/fsl_usb2_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/fusb300_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/fusb300_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/gadget_chips.h (100%)
 rename drivers/usb/gadget/{ = udc}/goku_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/goku_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/gr_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/gr_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/lpc32xx_udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/m66592-udc.c (100%)
 rename drivers/usb/gadget/{ = udc}/m66592-udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/mv_u3d.h (100%)
 rename drivers/usb/gadget/{ = udc}/mv_u3d_core.c (100%)
 rename drivers/usb/gadget/{ = udc}/mv_udc.h (100%)
 rename drivers/usb/gadget/{ = udc}/mv_udc_core.c (100%)
 rename drivers/usb/gadget/{ = udc}/net2272.c (100%)
 rename drivers/usb/gadget/{ = udc}/net2272.h (100%)
 rename drivers/usb/gadget/{ = udc}/net2280.c (100%)
 rename drivers/usb/gadget/{ = udc}/net2280.h (100%)
 rename drivers/usb/gadget/{ = udc}/omap_udc.c 

[PATCH v2][for 3.16 3/3] usb: gadget: Gadget directory cleanup - group usb functions

2014-06-17 Thread Andrzej Pietrasiewicz
The drivers/usb/gadget directory contains many files.
Files which are related can be distributed into separate directories.
This patch moves the USB functions implementations into a separate directory.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/Makefile| 30 +-
 drivers/usb/gadget/{ = function}/Makefile |  9 ++-
 drivers/usb/gadget/{ = function}/f_acm.c  |  0
 drivers/usb/gadget/{ = function}/f_ecm.c  |  0
 drivers/usb/gadget/{ = function}/f_eem.c  |  0
 drivers/usb/gadget/{ = function}/f_fs.c   |  0
 drivers/usb/gadget/{ = function}/f_hid.c  |  0
 drivers/usb/gadget/{ = function}/f_loopback.c |  0
 drivers/usb/gadget/{ = function}/f_mass_storage.c |  0
 drivers/usb/gadget/{ = function}/f_mass_storage.h |  0
 drivers/usb/gadget/{ = function}/f_midi.c |  0
 drivers/usb/gadget/{ = function}/f_ncm.c  |  0
 drivers/usb/gadget/{ = function}/f_obex.c |  0
 drivers/usb/gadget/{ = function}/f_phonet.c   |  0
 drivers/usb/gadget/{ = function}/f_rndis.c|  0
 drivers/usb/gadget/{ = function}/f_serial.c   |  0
 drivers/usb/gadget/{ = function}/f_sourcesink.c   |  0
 drivers/usb/gadget/{ = function}/f_subset.c   |  0
 drivers/usb/gadget/{ = function}/f_uac1.c |  0
 drivers/usb/gadget/{ = function}/f_uac2.c |  0
 drivers/usb/gadget/{ = function}/f_uvc.c  |  0
 drivers/usb/gadget/{ = function}/f_uvc.h  |  0
 drivers/usb/gadget/{ = function}/g_zero.h |  0
 drivers/usb/gadget/{ = function}/ndis.h   |  0
 drivers/usb/gadget/{ = function}/rndis.c  |  0
 drivers/usb/gadget/{ = function}/rndis.h  |  0
 drivers/usb/gadget/{ = function}/storage_common.c |  0
 drivers/usb/gadget/{ = function}/storage_common.h |  0
 drivers/usb/gadget/{ = function}/u_ecm.h  |  0
 drivers/usb/gadget/{ = function}/u_eem.h  |  0
 drivers/usb/gadget/{ = function}/u_ether.c|  0
 drivers/usb/gadget/{ = function}/u_ether.h|  0
 .../usb/gadget/{ = function}/u_ether_configfs.h   |  0
 drivers/usb/gadget/{ = function}/u_fs.h   |  0
 drivers/usb/gadget/{ = function}/u_gether.h   |  0
 drivers/usb/gadget/{ = function}/u_ncm.h  |  0
 drivers/usb/gadget/{ = function}/u_phonet.h   |  0
 drivers/usb/gadget/{ = function}/u_rndis.h|  0
 drivers/usb/gadget/{ = function}/u_serial.c   |  0
 drivers/usb/gadget/{ = function}/u_serial.h   |  0
 drivers/usb/gadget/{ = function}/u_uac1.c |  0
 drivers/usb/gadget/{ = function}/u_uac1.h |  0
 drivers/usb/gadget/{ = function}/uvc.h|  0
 drivers/usb/gadget/{ = function}/uvc_queue.c  |  0
 drivers/usb/gadget/{ = function}/uvc_queue.h  |  0
 drivers/usb/gadget/{ = function}/uvc_v4l2.c   |  0
 drivers/usb/gadget/{ = function}/uvc_video.c  |  0
 drivers/usb/gadget/legacy/Makefile |  1 +
 48 files changed, 4 insertions(+), 36 deletions(-)
 copy drivers/usb/gadget/{ = function}/Makefile (73%)
 rename drivers/usb/gadget/{ = function}/f_acm.c (100%)
 rename drivers/usb/gadget/{ = function}/f_ecm.c (100%)
 rename drivers/usb/gadget/{ = function}/f_eem.c (100%)
 rename drivers/usb/gadget/{ = function}/f_fs.c (100%)
 rename drivers/usb/gadget/{ = function}/f_hid.c (100%)
 rename drivers/usb/gadget/{ = function}/f_loopback.c (100%)
 rename drivers/usb/gadget/{ = function}/f_mass_storage.c (100%)
 rename drivers/usb/gadget/{ = function}/f_mass_storage.h (100%)
 rename drivers/usb/gadget/{ = function}/f_midi.c (100%)
 rename drivers/usb/gadget/{ = function}/f_ncm.c (100%)
 rename drivers/usb/gadget/{ = function}/f_obex.c (100%)
 rename drivers/usb/gadget/{ = function}/f_phonet.c (100%)
 rename drivers/usb/gadget/{ = function}/f_rndis.c (100%)
 rename drivers/usb/gadget/{ = function}/f_serial.c (100%)
 rename drivers/usb/gadget/{ = function}/f_sourcesink.c (100%)
 rename drivers/usb/gadget/{ = function}/f_subset.c (100%)
 rename drivers/usb/gadget/{ = function}/f_uac1.c (100%)
 rename drivers/usb/gadget/{ = function}/f_uac2.c (100%)
 rename drivers/usb/gadget/{ = function}/f_uvc.c (100%)
 rename drivers/usb/gadget/{ = function}/f_uvc.h (100%)
 rename drivers/usb/gadget/{ = function}/g_zero.h (100%)
 rename drivers/usb/gadget/{ = function}/ndis.h (100%)
 rename drivers/usb/gadget/{ = function}/rndis.c (100%)
 rename drivers/usb/gadget/{ = function}/rndis.h (100%)
 rename drivers/usb/gadget/{ = function}/storage_common.c (100%)
 rename drivers/usb/gadget/{ = function}/storage_common.h (100%)
 rename drivers/usb/gadget/{ = function}/u_ecm.h (100%)
 rename drivers/usb/gadget/{ = function}/u_eem.h (100%)
 rename drivers/usb/gadget/{ = function}/u_ether.c (100%)
 rename drivers/usb/gadget/{ = function}/u_ether.h (100%)
 rename drivers/usb/gadget/{ = function}/u_ether_configfs.h (100%)
 rename drivers/usb/gadget/{ = function}/u_fs.h (100%)
 rename drivers/usb/gadget/{ = 

[PATCH v2][for 3.16 0/3] Gadget directory cleanup

2014-06-17 Thread Andrzej Pietrasiewicz
This is a follow-up to this thread:

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

This refactoring has been accepted well, so I am sending it
once 3.16-rc1 is out in order to make it easy to apply it.

The cleanup rearranges the way source code files are located in the
drivers/usb/gadget directory. New subdirectories are introduced:

- udc for UDC chip drivers
- function for actual usb functions' implementations
- legacy for gadgets compiled as statically composed modules

while at the gadget's root level there are files related to the composite
framework.

These are the reasons for doing such a change:

- there are ~130 source code files already in a clean tree

- when all gadgets and some udc drivers are built as modules then,
including the by-products of the build (*.o, *.ko, *.mod.c, .*.cmd),
the number easily grows to ~500 files

- files serving different purpose (udc chip drivers, actual gadget functions'
implementations, legacy gadgets) are located side-by-side which might cause
confusion

- gadget's Kconfig and Makefile tend to be lengthy.

After the patches are applied the gadget subdirectory looks much cleaner.

Rebased onto Greg's usb-next.

Andrzej Pietrasiewicz (3):
  usb: gadget: Gadget directory cleanup - group legacy gadgets
  usb: gadget: Gadget directory cleanup - group UDC drivers
  usb: gadget: Gadget directory cleanup - group usb functions

 drivers/usb/gadget/Kconfig | 824 +
 drivers/usb/gadget/Makefile| 102 +--
 drivers/usb/gadget/function/Makefile   |  34 +
 drivers/usb/gadget/{ = function}/f_acm.c  |   0
 drivers/usb/gadget/{ = function}/f_ecm.c  |   0
 drivers/usb/gadget/{ = function}/f_eem.c  |   0
 drivers/usb/gadget/{ = function}/f_fs.c   |   0
 drivers/usb/gadget/{ = function}/f_hid.c  |   0
 drivers/usb/gadget/{ = function}/f_loopback.c |   0
 drivers/usb/gadget/{ = function}/f_mass_storage.c |   0
 drivers/usb/gadget/{ = function}/f_mass_storage.h |   0
 drivers/usb/gadget/{ = function}/f_midi.c |   0
 drivers/usb/gadget/{ = function}/f_ncm.c  |   0
 drivers/usb/gadget/{ = function}/f_obex.c |   0
 drivers/usb/gadget/{ = function}/f_phonet.c   |   0
 drivers/usb/gadget/{ = function}/f_rndis.c|   0
 drivers/usb/gadget/{ = function}/f_serial.c   |   0
 drivers/usb/gadget/{ = function}/f_sourcesink.c   |   0
 drivers/usb/gadget/{ = function}/f_subset.c   |   0
 drivers/usb/gadget/{ = function}/f_uac1.c |   0
 drivers/usb/gadget/{ = function}/f_uac2.c |   0
 drivers/usb/gadget/{ = function}/f_uvc.c  |   0
 drivers/usb/gadget/{ = function}/f_uvc.h  |   0
 drivers/usb/gadget/{ = function}/g_zero.h |   0
 drivers/usb/gadget/{ = function}/ndis.h   |   0
 drivers/usb/gadget/{ = function}/rndis.c  |   0
 drivers/usb/gadget/{ = function}/rndis.h  |   0
 drivers/usb/gadget/{ = function}/storage_common.c |   0
 drivers/usb/gadget/{ = function}/storage_common.h |   0
 drivers/usb/gadget/{ = function}/u_ecm.h  |   0
 drivers/usb/gadget/{ = function}/u_eem.h  |   0
 drivers/usb/gadget/{ = function}/u_ether.c|   0
 drivers/usb/gadget/{ = function}/u_ether.h|   0
 .../usb/gadget/{ = function}/u_ether_configfs.h   |   0
 drivers/usb/gadget/{ = function}/u_fs.h   |   0
 drivers/usb/gadget/{ = function}/u_gether.h   |   0
 drivers/usb/gadget/{ = function}/u_ncm.h  |   0
 drivers/usb/gadget/{ = function}/u_phonet.h   |   0
 drivers/usb/gadget/{ = function}/u_rndis.h|   0
 drivers/usb/gadget/{ = function}/u_serial.c   |   0
 drivers/usb/gadget/{ = function}/u_serial.h   |   0
 drivers/usb/gadget/{ = function}/u_uac1.c |   0
 drivers/usb/gadget/{ = function}/u_uac1.h |   0
 drivers/usb/gadget/{ = function}/uvc.h|   0
 drivers/usb/gadget/{ = function}/uvc_queue.c  |   0
 drivers/usb/gadget/{ = function}/uvc_queue.h  |   0
 drivers/usb/gadget/{ = function}/uvc_v4l2.c   |   0
 drivers/usb/gadget/{ = function}/uvc_video.c  |   0
 drivers/usb/gadget/legacy/Kconfig  | 475 
 drivers/usb/gadget/legacy/Makefile |  44 ++
 drivers/usb/gadget/{ = legacy}/acm_ms.c   |   0
 drivers/usb/gadget/{ = legacy}/audio.c|   0
 drivers/usb/gadget/{ = legacy}/cdc2.c |   0
 drivers/usb/gadget/{ = legacy}/dbgp.c |   0
 drivers/usb/gadget/{ = legacy}/ether.c|   0
 drivers/usb/gadget/{ = legacy}/g_ffs.c|   0
 drivers/usb/gadget/{ = legacy}/gmidi.c|   0
 drivers/usb/gadget/{ = legacy}/hid.c  |   0
 drivers/usb/gadget/{ = legacy}/inode.c|   0
 drivers/usb/gadget/{ = legacy}/mass_storage.c |   0
 drivers/usb/gadget/{ = legacy}/multi.c|   0
 drivers/usb/gadget/{ = legacy}/ncm.c  |   0
 drivers/usb/gadget/{ 

Re: [PATCH v6] leds: USB: HID: Add support for MSI GT683R led panels

2014-06-17 Thread Johan Hovold
On Tue, Jun 17, 2014 at 01:01:55AM +0300, Janne Kanniainen wrote:
 This driver adds support for USB controlled led panels that exists in
 MSI GT683R laptop
 
 Signed-off-by: Janne Kanniainen janne.kanniai...@gmail.com
 ---
 Changes in v2:
   - sorted headers to alphabetic order
   - using devm_kzalloc
   - using BIT(n)
   - using usb_control_msg instead of usb_submit_urb
   - removing unneeded code
 
 Changes in v3:
   - implemented as HID device
   - some cleanups and bug fixes
 
 Changes in v4:
   - more cleanups
   - support for selecting leds
   - suppport for selecting status
 
 Changes in v5:
   - mode attribute documented under Documentation/ABI
   - made array for led_classdev
   - led devices uses now recommended naming scheme
 
 Changes in v6:
   - flush_work added
   - using hid device name instead of hard coded gt683r
   - allocating name buffers with devm_kzalloc
 
 There was a bug with for, so I fixed it.

Then it really was a v7 and should have been marked as such, right?
 
  .../ABI/testing/sysfs-class-hid-driver-gt683r  |  14 +
  drivers/hid/Kconfig|  16 ++
  drivers/hid/Makefile   |   1 +
  drivers/hid/hid-core.c |   1 +
  drivers/hid/hid-gt683r.c   | 318 
 +
  drivers/hid/hid-ids.h  |   2 +-
  drivers/hid/usbhid/hid-quirks.c|   2 +-
  7 files changed, 352 insertions(+), 2 deletions(-)
  create mode 100644 Documentation/ABI/testing/sysfs-class-hid-driver-gt683r
  create mode 100644 drivers/hid/hid-gt683r.c
 
 diff --git a/Documentation/ABI/testing/sysfs-class-hid-driver-gt683r 
 b/Documentation/ABI/testing/sysfs-class-hid-driver-gt683r
 new file mode 100644
 index 000..6d0bd80
 --- /dev/null
 +++ b/Documentation/ABI/testing/sysfs-class-hid-driver-gt683r
 @@ -0,0 +1,14 @@
 +What:/sys/class/hidraw/hidraw/device/mode

Perhaps you should name this leds_mode or led_panel_mode, or similar
(only change the attribute name, code is fine otherwise). This is an
attribute of the parent HID device, but it's not really apparent what
just mode would mean for such a device.

 +Date:Jun 2014
 +KernelVersion:   3.17
 +Contact: Janne Kanniainen janne.kanniai...@gmail.com
 +Description:
 + Set the mode of LEDs
 +
 + 0 - normal
 + 1 - audio
 + 2 - breathing
 +
 + Normal: LEDs are on

Change this to LEDs are fully on when enabled, or similar?

 + Audio:  LEDs brightness depends on sound level
 + Breathing: LEDs brightness varies at human breathing rate
 \ No newline at end of file
 diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
 index 7af9d0b..b88cabd 100644
 --- a/drivers/hid/Kconfig
 +++ b/drivers/hid/Kconfig
 @@ -261,6 +261,22 @@ config HOLTEK_FF
 Say Y here if you have a Holtek On Line Grip based game controller
 and want to have force feedback support for it.
  
 +config HID_GT683R
 + tristate MSI GT68xR LED support
 + depends on LEDS_CLASS  USB_HID
 + ---help---
 + Say Y here if you want to enable support for the MSI GT68xR LEDS
 +
 + This driver support following modes:
 +   - Normal: LEDs are on
 +   - Audio:  LEDs brightness depends on sound level
 +   - Breathing: LEDs brightness varies at human breathing rate

This might need an update as well.

 +
 + You can also select which leds you want to enable.

You could drop this line, and just say enable support for the three
MSI LEDs above?

 +
 + Currently the following devices are know to be supported:
 +   - MSI GT683R
 +
  config HID_HUION
   tristate Huion tablets
   depends on USB_HID
 diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
 index fc712dd..7129311 100644
 --- a/drivers/hid/Makefile
 +++ b/drivers/hid/Makefile
 @@ -48,6 +48,7 @@ obj-$(CONFIG_HID_EMS_FF)+= hid-emsff.o
  obj-$(CONFIG_HID_ELECOM) += hid-elecom.o
  obj-$(CONFIG_HID_ELO)+= hid-elo.o
  obj-$(CONFIG_HID_EZKEY)  += hid-ezkey.o
 +obj-$(CONFIG_HID_GT683R) += hid-gt683r.o
  obj-$(CONFIG_HID_GYRATION)   += hid-gyration.o
  obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o
  obj-$(CONFIG_HID_HOLTEK) += hid-holtek-mouse.o
 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
 index da52279..ec88fdb 100644
 --- a/drivers/hid/hid-core.c
 +++ b/drivers/hid/hid-core.c
 @@ -1827,6 +1827,7 @@ static const struct hid_device_id 
 hid_have_special_driver[] = {
   { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 
 USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
   { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
   { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
 + { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) 
 },

xhci handling ring expansion

2014-06-17 Thread vichy
hi all:
I use kernel 3.8.0
And when I plug in webcam in my platform xhci host, I get below message:

platform-xhci platform-xhci.0: ERROR no room on ep ring, try ring expansion
 platform-xhci platform-xhci.0: ring expansion succeed, now has 4 segments
platform-xhci platform-xhci.0: ERROR Transfer event TRB DMA ptr not
part of current TD

under what circumstance the controller will return TRB DMA which is
not part of TD?
Is it possible to workaround this issue by modifying xhci-mem.c for
extending segments?

appreciate your help in advance,
--
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


[PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()

2014-06-17 Thread Tuomas Tynkkynen
The tegra_ehci_hcd structure is located in the private space allocated
by the core USB code so it must not be accessed after the HCD is
freed.

Signed-off-by: Tuomas Tynkkynen ttynkky...@nvidia.com
---
 drivers/usb/host/ehci-tegra.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6fdcb8a..5590567 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device *pdev)
 
usb_phy_shutdown(hcd-phy);
usb_remove_hcd(hcd);
-   usb_put_hcd(hcd);
 
clk_disable_unprepare(tegra-clk);
 
+   usb_put_hcd(hcd);
+
return 0;
 }
 
-- 
1.8.1.5

--
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


Re: [PATCH] USB:gadget: Fix a warning while loading g_mass_storage

2014-06-17 Thread Alan Stern
On Tue, 17 Jun 2014, Yang,Wei wrote:

 On 06/15/2014 10:42 AM, Yang,Wei wrote:
  Its v4, sorry for missing it in subject.
 
 Alan, How about this version?
 
 Cheers
 Wei

...

  Signed-off-by: Yang Wei wei.y...@windriver.com
  Acked-by: Alan Stern st...@rowland.harvard.edu

That is a strange question to ask.  If you did not know that I approved 
the patch, why did you insert my Acked-By:?

Alan Stern


--
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


Re: Probe function question

2014-06-17 Thread Alan Stern
On Tue, 17 Jun 2014, Vlad Ungureanu wrote:

 To go into ADK mode the host needs to send the Android device a series of usb
 control messages with different data. This yes can be done from userspace but
 when the device goes into the ADK mode I need to handle it into Kernel space.
 The end goal of the project is to simulate the displayLink driver using an
 Android device instead of a DisplayLink compatible screen. In ADK mode I will
 need just interface 1 which has 2 bulk EPs. No other interaction from 
 userspace
 will be with the device in ADK mode.

Have you considered what will happen if your driver is present but the
user wants the device to remain in its usual mode, rather than in ADK
mode?

Such problems are part of the reason why programs like usb-modeswitch
exist.

Alan Stern

--
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


Re: Probe function question

2014-06-17 Thread Oliver Neukum
On Tue, 2014-06-17 at 10:22 -0400, Alan Stern wrote:
 On Tue, 17 Jun 2014, Vlad Ungureanu wrote:
 
  To go into ADK mode the host needs to send the Android device a series of 
  usb
  control messages with different data. This yes can be done from userspace 
  but
  when the device goes into the ADK mode I need to handle it into Kernel 
  space.
  The end goal of the project is to simulate the displayLink driver using an
  Android device instead of a DisplayLink compatible screen. In ADK mode I 
  will
  need just interface 1 which has 2 bulk EPs. No other interaction from 
  userspace
  will be with the device in ADK mode.
 
 Have you considered what will happen if your driver is present but the
 user wants the device to remain in its usual mode, rather than in ADK
 mode?
 
 Such problems are part of the reason why programs like usb-modeswitch
 exist.

True, but as we have taken port power switching I think we may have
to revisit that decision.

Regards
Oliver



--
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


Re: xhci handling ring expansion

2014-06-17 Thread Greg KH
On Tue, Jun 17, 2014 at 10:07:38PM +0800, vichy wrote:
 hi all:
 I use kernel 3.8.0

That's a very old, and unsupported kernel version.  I suggest you update
to something more modern, especially for xhci issues as loads of them
have been fixed since 3.8 was released.  If you are stuck with 3.8 due
to a vendor requiring it, please get support from them.

Best of luck,

greg k-h
--
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


Re: [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()

2014-06-17 Thread Alan Stern
On Tue, 17 Jun 2014, Tuomas Tynkkynen wrote:

 The tegra_ehci_hcd structure is located in the private space allocated
 by the core USB code so it must not be accessed after the HCD is
 freed.
 
 Signed-off-by: Tuomas Tynkkynen ttynkky...@nvidia.com
 ---
  drivers/usb/host/ehci-tegra.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index 6fdcb8a..5590567 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device 
 *pdev)
  
   usb_phy_shutdown(hcd-phy);
   usb_remove_hcd(hcd);
 - usb_put_hcd(hcd);
  
   clk_disable_unprepare(tegra-clk);
  
 + usb_put_hcd(hcd);
 +
   return 0;
  }

Acked-by: Alan Stern st...@rowland.harvard.edu

--
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


Re: xhci handling ring expansion

2014-06-17 Thread vichy
hi Greg:


2014-06-17 22:25 GMT+08:00 Greg KH gre...@linuxfoundation.org:
 On Tue, Jun 17, 2014 at 10:07:38PM +0800, vichy wrote:
 hi all:
 I use kernel 3.8.0

 That's a very old, and unsupported kernel version.  I suggest you update
Yes. it is pretty old kernel.
But i have git diff the xhci-mem.c there is no log about  Transfer
event TRB DMA ptr not
part of current TD
I have no idea whether it is hardware issue.
I just want to know any one bump the same problem before?
appreciate your help,
--
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


RE: xhci handling ring expansion

2014-06-17 Thread David Laight
From: vichy
 hi all:
 I use kernel 3.8.0
 And when I plug in webcam in my platform xhci host, I get below message:
 
 platform-xhci platform-xhci.0: ERROR no room on ep ring, try ring expansion
  platform-xhci platform-xhci.0: ring expansion succeed, now has 4 segments
 platform-xhci platform-xhci.0: ERROR Transfer event TRB DMA ptr not
 part of current TD
 
 under what circumstance the controller will return TRB DMA which is
 not part of TD?

When the event TRB contains a pointer to something other than a data
buffer.
This is true for one of the error events.
Not that they should happen either.

David

 Is it possible to workaround this issue by modifying xhci-mem.c for
 extending segments?
 
 appreciate your help in advance,
 --
 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


r8a66597-udc: use devm functions

2014-06-17 Thread Ben Dooks
Change r8a66597-udc to use devm functions and cleanup the result.

--
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


[PATCH 3/8] r8a66597-udc: use devm_kzalloc() to allocate driver state

2014-06-17 Thread Ben Dooks
Update driver to use devm_kzalloc() to make tracking of resources
easier. Also remove the exit point via cleanup as there's no
cleanup necessary from this point now.

As a note, also removes the error print as the allocation calls
produce errors if they do not return memory.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 1721e44..48a9e0b 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1836,7 +1836,6 @@ static int __exit r8a66597_remove(struct platform_device 
*pdev)
clk_put(r8a66597-clk);
}
 
-   kfree(r8a66597);
return 0;
 }
 
@@ -1892,12 +1891,9 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
}
 
/* initialize ucd */
-   r8a66597 = kzalloc(sizeof(struct r8a66597), GFP_KERNEL);
-   if (r8a66597 == NULL) {
-   ret = -ENOMEM;
-   dev_err(dev, kzalloc error\n);
-   goto clean_up;
-   }
+   r8a66597 = devm_kzalloc(dev, sizeof(struct r8a66597), GFP_KERNEL);
+   if (r8a66597 == NULL)
+   return -ENOMEM;
 
spin_lock_init(r8a66597-lock);
platform_set_drvdata(pdev, r8a66597);
@@ -1996,7 +1992,6 @@ clean_up:
if (r8a66597-ep0_req)
r8a66597_free_request(r8a66597-ep[0].ep,
r8a66597-ep0_req);
-   kfree(r8a66597);
}
 
return ret;
-- 
2.0.0

--
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


[PATCH 5/8] r8a66597-udc: cleanup error path

2014-06-17 Thread Ben Dooks
With the updates for devm, the cleanup path no longer needs to
check for NULL device state, so remove it and return directly
if the irq resource missing

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 2662853..9ebe2c0 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1878,9 +1878,8 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
irq_trigger = ires-flags  IRQF_TRIGGER_MASK;
 
if (irq  0) {
-   ret = -ENODEV;
dev_err(dev, platform_get_irq error.\n);
-   goto clean_up;
+   return -ENODEV;
}
 
/* initialize ucd */
@@ -1979,11 +1978,8 @@ clean_up2:
clk_put(r8a66597-clk);
}
 clean_up:
-   if (r8a66597) {
-   if (r8a66597-ep0_req)
-   r8a66597_free_request(r8a66597-ep[0].ep,
-   r8a66597-ep0_req);
-   }
+   if (r8a66597-ep0_req)
+   r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
 
return ret;
 }
-- 
2.0.0

--
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


[PATCH 4/8] r8a66597-udc: handle sudmac registers with devm_ioremap_resource()

2014-06-17 Thread Ben Dooks
Change the sudmac register handling in the devm_ioremap_resource
to use the devm variant.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 48a9e0b..2662853 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1826,8 +1826,6 @@ static int __exit r8a66597_remove(struct platform_device 
*pdev)
 
usb_del_gadget_udc(r8a66597-gadget);
del_timer_sync(r8a66597-timer);
-   if (r8a66597-pdata-sudmac)
-   iounmap(r8a66597-sudmac_reg);
free_irq(platform_get_irq(pdev, 0), r8a66597);
r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
 
@@ -1849,15 +1847,10 @@ static int __init r8a66597_sudmac_ioremap(struct 
r8a66597 *r8a66597,
struct resource *res;
 
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, sudmac);
-   if (!res) {
-   dev_err(pdev-dev, platform_get_resource error(sudmac).\n);
-   return -ENODEV;
-   }
-
-   r8a66597-sudmac_reg = ioremap(res-start, resource_size(res));
-   if (r8a66597-sudmac_reg == NULL) {
+   r8a66597-sudmac_reg = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(r8a66597-sudmac_reg)) {
dev_err(pdev-dev, ioremap error(sudmac).\n);
-   return -ENOMEM;
+   return PTR_ERR(r8a66597-sudmac_reg);
}
 
return 0;
@@ -1987,8 +1980,6 @@ clean_up2:
}
 clean_up:
if (r8a66597) {
-   if (r8a66597-sudmac_reg)
-   iounmap(r8a66597-sudmac_reg);
if (r8a66597-ep0_req)
r8a66597_free_request(r8a66597-ep[0].ep,
r8a66597-ep0_req);
-- 
2.0.0

--
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


[PATCH 7/8] r8a66597-udc: use devm_request_irq() to get device irq

2014-06-17 Thread Ben Dooks
Use the devm_request_irq() call to get the interrupt for the
device and have it automatically free on exit.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 51eaedd..8414ba5 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1826,7 +1826,6 @@ static int __exit r8a66597_remove(struct platform_device 
*pdev)
 
usb_del_gadget_udc(r8a66597-gadget);
del_timer_sync(r8a66597-timer);
-   free_irq(platform_get_irq(pdev, 0), r8a66597);
r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
 
if (r8a66597-pdata-on_chip) {
@@ -1918,8 +1917,8 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
 
disable_controller(r8a66597); /* make sure controller is disabled */
 
-   ret = request_irq(irq, r8a66597_irq, IRQF_SHARED,
-   udc_name, r8a66597);
+   ret = devm_request_irq(dev, irq, r8a66597_irq, IRQF_SHARED,
+  udc_name, r8a66597);
if (ret  0) {
dev_err(dev, request_irq error (%d)\n, ret);
goto clean_up2;
@@ -1969,7 +1968,6 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
 err_add_udc:
r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
 clean_up3:
-   free_irq(irq, r8a66597);
 clean_up2:
if (r8a66597-pdata-on_chip)
clk_disable_unprepare(r8a66597-clk);
-- 
2.0.0

--
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


[PATCH 8/8] r8a66597-udc: remove now unused clean_up and clean_up3 label.

2014-06-17 Thread Ben Dooks
With the devm additions, the clean_up and clean_up3 are now
not needed or used. Change clean_up3 and make everything use
clean_up2 and just remove clean_up.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 8414ba5..6ad6028 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1954,7 +1954,7 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
GFP_KERNEL);
if (r8a66597-ep0_req == NULL) {
ret = -ENOMEM;
-   goto clean_up3;
+   goto clean_up2;
}
r8a66597-ep0_req-complete = nop_completion;
 
@@ -1967,11 +1967,10 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
 
 err_add_udc:
r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
-clean_up3:
 clean_up2:
if (r8a66597-pdata-on_chip)
clk_disable_unprepare(r8a66597-clk);
-clean_up:
+
if (r8a66597-ep0_req)
r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
 
-- 
2.0.0

--
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


[PATCH 6/8] r8a66597-udc: use devm_clk_get() to get clock

2014-06-17 Thread Ben Dooks
Change to using the devm_clk_get() to get the clock and
have it automatically freed on exit.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 9ebe2c0..51eaedd 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1831,7 +1831,6 @@ static int __exit r8a66597_remove(struct platform_device 
*pdev)
 
if (r8a66597-pdata-on_chip) {
clk_disable_unprepare(r8a66597-clk);
-   clk_put(r8a66597-clk);
}
 
return 0;
@@ -1903,11 +1902,10 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
 
if (r8a66597-pdata-on_chip) {
snprintf(clk_name, sizeof(clk_name), usb%d, pdev-id);
-   r8a66597-clk = clk_get(dev, clk_name);
+   r8a66597-clk = devm_clk_get(dev, clk_name);
if (IS_ERR(r8a66597-clk)) {
dev_err(dev, cannot get clock \%s\\n, clk_name);
-   ret = PTR_ERR(r8a66597-clk);
-   goto clean_up;
+   return PTR_ERR(r8a66597-clk);
}
clk_prepare_enable(r8a66597-clk);
}
@@ -1973,10 +1971,8 @@ err_add_udc:
 clean_up3:
free_irq(irq, r8a66597);
 clean_up2:
-   if (r8a66597-pdata-on_chip) {
+   if (r8a66597-pdata-on_chip)
clk_disable_unprepare(r8a66597-clk);
-   clk_put(r8a66597-clk);
-   }
 clean_up:
if (r8a66597-ep0_req)
r8a66597_free_request(r8a66597-ep[0].ep, r8a66597-ep0_req);
-- 
2.0.0

--
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


Re: [PATCH 2/8] r8a66597-udc: keep dev as reference to pdev-dev

2014-06-17 Thread Sergei Shtylyov

hello.

On 06/17/2014 07:14 PM, Ben Dooks wrote:


Remove usages of pdev-dev in the driver probe function


   s/Remove/Replace/?


with just dev to make the references to it easier to
write. Convert all the current users of it to use it.



Signed-off-by: Ben Dooks ben.do...@codethink.co.uk


WBR, Sergei


--
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


[PATCH 2/8] r8a66597-udc: keep dev as reference to pdev-dev

2014-06-17 Thread Ben Dooks
Remove usages of pdev-dev in the driver probe function
with just dev to make the references to it easier to
write. Convert all the current users of it to use it.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/usb/gadget/r8a66597-udc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 7f3af74..1721e44 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1866,6 +1866,7 @@ static int __init r8a66597_sudmac_ioremap(struct r8a66597 
*r8a66597,
 
 static int __init r8a66597_probe(struct platform_device *pdev)
 {
+   struct device *dev = pdev-dev;
char clk_name[8];
struct resource *res, *ires;
int irq;
@@ -1886,7 +1887,7 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
 
if (irq  0) {
ret = -ENODEV;
-   dev_err(pdev-dev, platform_get_irq error.\n);
+   dev_err(dev, platform_get_irq error.\n);
goto clean_up;
}
 
@@ -1894,13 +1895,13 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
r8a66597 = kzalloc(sizeof(struct r8a66597), GFP_KERNEL);
if (r8a66597 == NULL) {
ret = -ENOMEM;
-   dev_err(pdev-dev, kzalloc error\n);
+   dev_err(dev, kzalloc error\n);
goto clean_up;
}
 
spin_lock_init(r8a66597-lock);
platform_set_drvdata(pdev, r8a66597);
-   r8a66597-pdata = dev_get_platdata(pdev-dev);
+   r8a66597-pdata = dev_get_platdata(dev);
r8a66597-irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;
 
r8a66597-gadget.ops = r8a66597_gadget_ops;
@@ -1914,10 +1915,9 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
 
if (r8a66597-pdata-on_chip) {
snprintf(clk_name, sizeof(clk_name), usb%d, pdev-id);
-   r8a66597-clk = clk_get(pdev-dev, clk_name);
+   r8a66597-clk = clk_get(dev, clk_name);
if (IS_ERR(r8a66597-clk)) {
-   dev_err(pdev-dev, cannot get clock \%s\\n,
-   clk_name);
+   dev_err(dev, cannot get clock \%s\\n, clk_name);
ret = PTR_ERR(r8a66597-clk);
goto clean_up;
}
@@ -1935,7 +1935,7 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
ret = request_irq(irq, r8a66597_irq, IRQF_SHARED,
udc_name, r8a66597);
if (ret  0) {
-   dev_err(pdev-dev, request_irq error (%d)\n, ret);
+   dev_err(dev, request_irq error (%d)\n, ret);
goto clean_up2;
}
 
@@ -1973,11 +1973,11 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
}
r8a66597-ep0_req-complete = nop_completion;
 
-   ret = usb_add_gadget_udc(pdev-dev, r8a66597-gadget);
+   ret = usb_add_gadget_udc(dev, r8a66597-gadget);
if (ret)
goto err_add_udc;
 
-   dev_info(pdev-dev, version %s\n, DRIVER_VERSION);
+   dev_info(dev, version %s\n, DRIVER_VERSION);
return 0;
 
 err_add_udc:
-- 
2.0.0

--
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


[PATCH 1/8] r8a66597-udc: use devm_request_and_ioremap() for registers

2014-06-17 Thread Ben Dooks
---
 drivers/usb/gadget/r8a66597-udc.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index aff0a67..7f3af74 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1826,7 +1826,6 @@ static int __exit r8a66597_remove(struct platform_device 
*pdev)
 
usb_del_gadget_udc(r8a66597-gadget);
del_timer_sync(r8a66597-timer);
-   iounmap(r8a66597-reg);
if (r8a66597-pdata-sudmac)
iounmap(r8a66597-sudmac_reg);
free_irq(platform_get_irq(pdev, 0), r8a66597);
@@ -1877,11 +1876,9 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
unsigned long irq_trigger;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   ret = -ENODEV;
-   dev_err(pdev-dev, platform_get_resource error.\n);
-   goto clean_up;
-   }
+   reg = devm_ioremap_resource(pdev-dev, res);
+   if (!reg)
+   return -ENODEV;
 
ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
irq = ires-start;
@@ -1893,13 +1890,6 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
goto clean_up;
}
 
-   reg = ioremap(res-start, resource_size(res));
-   if (reg == NULL) {
-   ret = -ENOMEM;
-   dev_err(pdev-dev, ioremap error.\n);
-   goto clean_up;
-   }
-
/* initialize ucd */
r8a66597 = kzalloc(sizeof(struct r8a66597), GFP_KERNEL);
if (r8a66597 == NULL) {
@@ -2008,8 +1998,6 @@ clean_up:
r8a66597-ep0_req);
kfree(r8a66597);
}
-   if (reg)
-   iounmap(reg);
 
return ret;
 }
-- 
2.0.0

--
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


Re: xhci handling ring expansion

2014-06-17 Thread vichy
hi david:

 platform-xhci platform-xhci.0: ERROR no room on ep ring, try ring expansion
  platform-xhci platform-xhci.0: ring expansion succeed, now has 4 segments
 platform-xhci platform-xhci.0: ERROR Transfer event TRB DMA ptr not
 part of current TD

 under what circumstance the controller will return TRB DMA which is
 not part of TD?

 When the event TRB contains a pointer to something other than a data
 buffer.
after tracing the xhci driver, the message shows up because transfer
event TRB DMA is not located in current TD.

 This is true for one of the error events.
 Not that they should happen either.
do you mean this is one of error event trb we will get? But I cannot
find the error trb type in spec.
or it means something wrong in hardware?

Appreciate your help,
--
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


Re: [PATCH v2 1/1] xhci: clear root port wake on bits if controller isn't wake-up capable

2014-06-17 Thread Mathias Nyman
On 06/13/2014 03:06 AM, Lu Baolu wrote:
 When xHCI PCI host is suspended, if do_wakeup is false in xhci_pci_suspend,
 xhci_bus_suspend needs to clear all root port wake on bits. Otherwise some 
 Intel
 platforms may get a spurious wakeup, even if PCI PME# is disabled.
 
 This patch should be back-ported to kernels as old as 2.6.37, that
 contains the commit 9777e3ce907d4cb5a513902a87ecd03b52499569
 USB: xHCI: bus power management implementation. 
 
 Signed-off-by: Lu Baolu baolu...@linux.intel.com
 ---
  drivers/usb/host/xhci-hub.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
 index 6231ce6..fb771bd 100644
 --- a/drivers/usb/host/xhci-hub.c
 +++ b/drivers/usb/host/xhci-hub.c
 @@ -22,6 +22,7 @@
  
  
  #include linux/slab.h
 +#include linux/device.h
  #include asm/unaligned.h
  
  #include xhci.h
 @@ -1139,7 +1140,9 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
* including the USB 3.0 roothub, but only if CONFIG_PM_RUNTIME
* is enabled, so also enable remote wake here.
*/
 - if (hcd-self.root_hub-do_remote_wakeup) {
 + if (hcd-self.root_hub-do_remote_wakeup
 +  device_may_wakeup(hcd-self.controller)) {
 +
   if (t1  PORT_CONNECT) {
   t2 |= PORT_WKOC_E | PORT_WKDISC_E;
   t2 = ~PORT_WKCONN_E;
 

Looks good to me, thanks for fixing.
I can take it, add the cc: stable tag and send it forward to Greg once his 
trees get updated to 3.16 release candidates

-Mathias
--
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


[PATCH] usb: gadget: f_fs: fix NULL pointer dereference when there are no strings

2014-06-17 Thread Michal Nazarewicz
If the descriptors do not need any strings and user space sends empty
set of strings, the ffs-stringtabs field remains NULL.  Thus
*ffs-stringtabs in functionfs_bind leads to a NULL pointer
dereferenece.

The bug was introduced by commit [fd7c9a007f: “use usb_string_ids_n()”].

While at it, remove double initialisation of lang local variable in
that function.

ffs-strings_count does not need to be checked in any way since in
the above scenario it will remain zero and usb_string_ids_n() is
a no-operation when colled with 0 argument.

Cc: sta...@vger.kernel.org  # v2.6.36+
Signed-off-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 74202d6..8598c27 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -1483,11 +1483,13 @@ static int functionfs_bind(struct ffs_data *ffs, struct 
usb_composite_dev *cdev)
ffs-ep0req-context = ffs;
 
lang = ffs-stringtabs;
-   for (lang = ffs-stringtabs; *lang; ++lang) {
-   struct usb_string *str = (*lang)-strings;
-   int id = first_id;
-   for (; str-s; ++id, ++str)
-   str-id = id;
+   if (lang) {
+   for (; *lang; ++lang) {
+   struct usb_string *str = (*lang)-strings;
+   int id = first_id;
+   for (; str-s; ++id, ++str)
+   str-id = id;
+   }
}
 
ffs-gadget = cdev-gadget;
-- 
2.0.0.526.g5318336

--
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


RE: xhci handling ring expansion

2014-06-17 Thread David Laight
From: vichy 
 hi david:
 
  platform-xhci platform-xhci.0: ERROR no room on ep ring, try ring expansion
   platform-xhci platform-xhci.0: ring expansion succeed, now has 4 segments
  platform-xhci platform-xhci.0: ERROR Transfer event TRB DMA ptr not
  part of current TD
 
  under what circumstance the controller will return TRB DMA which is
  not part of TD?
 
  When the event TRB contains a pointer to something other than a data
  buffer.
 after tracing the xhci driver, the message shows up because transfer
 event TRB DMA is not located in current TD.
 
  This is true for one of the error events.
  Not that they should happen either.
 do you mean this is one of error event trb we will get? But I cannot
 find the error trb type in spec.
 or it means something wrong in hardware?

From one of the patches (not applied) I sent last November ...
Include the unknown address when the DMA pointer from an event isn't part
of the current TD. This will happen if the error code is TRB error.

David


Re: [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()

2014-06-17 Thread Stephen Warren
On 06/17/2014 08:17 AM, Tuomas Tynkkynen wrote:
 The tegra_ehci_hcd structure is located in the private space allocated
 by the core USB code so it must not be accessed after the HCD is
 freed.

 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c

This seems to be a persistent problem. Witness commit ecc8a0cdca18 usb:
host: tegra: fix warning messages in ehci_remove. So, I wonder if ...

 @@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device 
 *pdev)
  
   usb_phy_shutdown(hcd-phy);
   usb_remove_hcd(hcd);
 - usb_put_hcd(hcd);
  
   clk_disable_unprepare(tegra-clk);
  

It's worth putting a comment here:

/* This must be last, since *tegra is part of *hcd */
 + usb_put_hcd(hcd);
 +
   return 0;
  }

Of course, that could be a separate commit if you want.
--
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


Re: usb audio breaks ohci-pci

2014-06-17 Thread Dennis New
On Thu, 12 Jun 2014 10:20:54 -0400 (EDT), Alan Stern wrote:
 Dennis and Matteo:
 
 I promised to send both of you a patch changing the way ohci-hcd
 handles hardware bugs.  Well, it's finally ready for testing.  There's
 only a limited amount I can do on my own machine, so now it's up to
 you guys.
 
 The patch was made against an early -rc version of 3.15, but it will
 apply okay to 3.14 and maybe even earlier kernels.

So, it happened again, after a random few days, this time with dmesg a
bit different:

[210263.872368] ohci-pci :00:13.0: frame counter not updating;
disabled
[210263.872377] ohci-pci :00:13.0: HC died; cleaning up
[210263.872456] usb 2-4: USB disconnect, device number 4
[210264.872344] timeout: still 2 active urbs on EP #3

The frame counter indeed was not updating. I notice that this time, it
says there are still 2 active urbs, whereas before it always said 3.
I also noticed that before I would still get USB disconnect messages
when I unplugged my device, but not this time. It looks like there was
a more thorough disabling of the usb/ohci system this time.

--
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


[PATCH v8] leds: USB: HID: Add support for MSI GT683R led panels

2014-06-17 Thread Janne Kanniainen
This driver adds support for USB controlled led panels that exists in
MSI GT683R laptop

Changes in v2:
- sorted headers to alphabetic order
- using devm_kzalloc
- using BIT(n)
- using usb_control_msg instead of usb_submit_urb
- removing unneeded code
Changes in v3:
- implemented as HID device
- some cleanups and bug fixes

Changes in v4:
- more cleanups
- support for selecting leds
- suppport for selecting status

Changes in v5:
- mode attribute documented under Documentation/ABI
- made array for led_classdev
- led devices uses now recommended naming scheme

Changes in v6:
- flush_work added
- using hid device name instead of hard coded gt683r
- allocating name buffers with devm_kzalloc

Changes in v7:
- buf with for fixed

Changes in v8:
- some cleanups and bugs fixed

Signed-off-by: Janne Kanniainen janne.kanniai...@gmail.com
---
 .../ABI/testing/sysfs-class-hid-driver-gt683r  |  14 +
 drivers/hid/Kconfig|  14 +
 drivers/hid/Makefile   |   1 +
 drivers/hid/hid-core.c |   1 +
 drivers/hid/hid-gt683r.c   | 308 +
 drivers/hid/hid-ids.h  |   2 +-
 drivers/hid/usbhid/hid-quirks.c|   2 +-
 7 files changed, 340 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-hid-driver-gt683r
 create mode 100644 drivers/hid/hid-gt683r.c

diff --git a/Documentation/ABI/testing/sysfs-class-hid-driver-gt683r 
b/Documentation/ABI/testing/sysfs-class-hid-driver-gt683r
new file mode 100644
index 000..317e9d5
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-hid-driver-gt683r
@@ -0,0 +1,14 @@
+What:  /sys/class/hidraw/hidraw/device/leds_mode
+Date:  Jun 2014
+KernelVersion: 3.17
+Contact:   Janne Kanniainen janne.kanniai...@gmail.com
+Description:
+   Set the mode of LEDs
+
+   0 - normal
+   1 - audio
+   2 - breathing
+
+   Normal: LEDs are fully on when enabled
+   Audio:  LEDs brightness depends on sound level
+   Breathing: LEDs brightness varies at human breathing rate
\ No newline at end of file
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 7af9d0b..e2f4590 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -261,6 +261,20 @@ config HOLTEK_FF
  Say Y here if you have a Holtek On Line Grip based game controller
  and want to have force feedback support for it.
 
+config HID_GT683R
+   tristate MSI GT68xR LED support
+   depends on LEDS_CLASS  USB_HID
+   ---help---
+   Say Y here if you want to enable support for the three MSI GT68xR LEDs
+
+   This driver support following modes:
+ - Normal: LEDs are fully on when enabled
+ - Audio:  LEDs brightness depends on sound level
+ - Breathing: LEDs brightness varies at human breathing rate
+
+   Currently the following devices are know to be supported:
+ - MSI GT683R
+
 config HID_HUION
tristate Huion tablets
depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index fc712dd..7129311 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_HID_EMS_FF)  += hid-emsff.o
 obj-$(CONFIG_HID_ELECOM)   += hid-elecom.o
 obj-$(CONFIG_HID_ELO)  += hid-elo.o
 obj-$(CONFIG_HID_EZKEY)+= hid-ezkey.o
+obj-$(CONFIG_HID_GT683R)   += hid-gt683r.o
 obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
 obj-$(CONFIG_HID_HOLTEK)   += hid-holtek-kbd.o
 obj-$(CONFIG_HID_HOLTEK)   += hid-holtek-mouse.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index da52279..ec88fdb 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1827,6 +1827,7 @@ static const struct hid_device_id 
hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 
USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
+   { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) 
},
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) 
},
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, 
USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, 
USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) },
diff --git a/drivers/hid/hid-gt683r.c b/drivers/hid/hid-gt683r.c
new file mode 100644
index 000..19959ac
--- /dev/null
+++ b/drivers/hid/hid-gt683r.c
@@ -0,0 +1,308 @@
+/*
+ * MSI GT683R led driver
+ *
+ * Copyright (c) 2014 Janne Kanniainen janne.kanniai...@gmail.com
+ *
+ * This program is free software; 

Re: xhci handling ring expansion

2014-06-17 Thread vichy
hi david:

2014-06-17 23:50 GMT+08:00 David Laight david.lai...@aculab.com:
 From: vichy
 hi david:

  platform-xhci platform-xhci.0: ERROR no room on ep ring, try ring 
  expansion
   platform-xhci platform-xhci.0: ring expansion succeed, now has 4 segments
  platform-xhci platform-xhci.0: ERROR Transfer event TRB DMA ptr not
  part of current TD
 
  under what circumstance the controller will return TRB DMA which is
  not part of TD?
 
  When the event TRB contains a pointer to something other than a data
  buffer.
 after tracing the xhci driver, the message shows up because transfer
 event TRB DMA is not located in current TD.

  This is true for one of the error events.
  Not that they should happen either.
 do you mean this is one of error event trb we will get? But I cannot
 find the error trb type in spec.
 or it means something wrong in hardware?

 From one of the patches (not applied) I sent last November ...
 Include the unknown address when the DMA pointer from an event isn't part
 of the current TD. This will happen if the error code is TRB error.
do you mean below patch?
http://markmail.org/message/74qvwz7fhjxqeih3
it only add debug message instead of fixing it.

appreciate your help,
--
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


Re: [PATCH] USB:gadget: Fix a warning while loading g_mass_storage

2014-06-17 Thread Michal Nazarewicz
On Sun, Jun 15 2014, wei.y...@windriver.com wrote:
 From: Yang Wei wei.y...@windriver.com

 While loading g_mass_storage module, the following warning
 is triggered.

 WARNING: at drivers/usb/gadget/composite.c:
 usb_composite_setup_continue: Unexpected call
 Modules linked in: fat vfat minix nls_cp437 nls_iso8859_1 g_mass_storage
 [800179cc] (unwind_backtrace+0x0/0x104) from [80619608] 
 (dump_stack+0x20/0x24)
 [80619608] (dump_stack+0x20/0x24) from [80025100] 
 (warn_slowpath_common+0x64/0x74)
 [80025100] (warn_slowpath_common+0x64/0x74) from [800251cc] 
 (warn_slowpath_fmt+0x40/0x48)
 [800251cc] (warn_slowpath_fmt+0x40/0x48) from [7f047774] 
 (usb_composite_setup_continue+0xb4/0xbc [g_mass_storage])
 [7f047774] (usb_composite_setup_continue+0xb4/0xbc [g_mass_storage]) from 
 [7f047ad4] (handle_exception+0x358/0x3e4 [g_mass_storage])
 [7f047ad4] (handle_exception+0x358/0x3e4 [g_mass_storage]) from 
 [7f048080] (fsg_main_thread+0x520/0x157c [g_mass_storage])
 [7f048080] (fsg_main_thread+0x520/0x157c [g_mass_storage]) from 
 [8004bc90] (kthread+0x98/0x9c)
 [8004bc90] (kthread+0x98/0x9c) from [8000faec] 
 (kernel_thread_exit+0x0/0x8)

 The root cause is that the existing code fails to take into
 account the possibility that common-new_fsg can change while
 do_set_interface() is running, so the value of common-new_fsg
 that gets tested after do_set_interface returns needs to be
 the same as the value used by do_set_interface.

 Signed-off-by: Yang Wei wei.y...@windriver.com
 Acked-by: Alan Stern st...@rowland.harvard.edu

Acked-by: Michal Nazarewicz min...@mina86.com

 ---
  drivers/usb/gadget/f_mass_storage.c |6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

 Changes in v3  v4

 move new_fsg = common-new_fsg out of comm-lock protection, and refine the 
 commit log.

 Thanks
 Wei

 diff --git a/drivers/usb/gadget/f_mass_storage.c 
 b/drivers/usb/gadget/f_mass_storage.c
 index b963939..a7e24c8 100644
 --- a/drivers/usb/gadget/f_mass_storage.c
 +++ b/drivers/usb/gadget/f_mass_storage.c
 @@ -2342,6 +2342,7 @@ static void handle_exception(struct fsg_common *common)
   struct fsg_buffhd   *bh;
   enum fsg_state  old_state;
   struct fsg_lun  *curlun;
 + struct fsg_dev  *new_fsg;
   unsigned intexception_req_tag;
  
   /*
 @@ -2460,8 +2461,9 @@ static void handle_exception(struct fsg_common *common)
   break;
  
   case FSG_STATE_CONFIG_CHANGE:
 - do_set_interface(common, common-new_fsg);
 - if (common-new_fsg)
 + new_fsg = common-new_fsg;
 + do_set_interface(common, new_fsg);
 + if (new_fsg)
   usb_composite_setup_continue(common-cdev);
   break;

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--
--
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


Support for URB_ZERO_PACKET flag in XHCI

2014-06-17 Thread hemantk
Hi Sarah,

Looks like XHCI is not honoring URB_ZERO_PACKET flag set by class drivers.
I came across a patch from David Laight dated Nov 2013. But i couldn't
find it in latest kernel tree. Are you planning to add support using
David's patch (or any other patch) in near future? From current
implementation looks like driver does not add extra trb for zlp when
transfer_buffer_length is integral multiple of ep max packet size.

Please let me know.

Thanks,
Hemant

--
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


Re: [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()

2014-06-17 Thread Alan Stern
On Tue, 17 Jun 2014, Stephen Warren wrote:

 On 06/17/2014 08:17 AM, Tuomas Tynkkynen wrote:
  The tegra_ehci_hcd structure is located in the private space allocated
  by the core USB code so it must not be accessed after the HCD is
  freed.
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 
 This seems to be a persistent problem. Witness commit ecc8a0cdca18 usb:
 host: tegra: fix warning messages in ehci_remove. So, I wonder if ...
 
  @@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device 
  *pdev)
   
  usb_phy_shutdown(hcd-phy);
  usb_remove_hcd(hcd);
  -   usb_put_hcd(hcd);
   
  clk_disable_unprepare(tegra-clk);
   
 
 It's worth putting a comment here:
 
   /* This must be last, since *tegra is part of *hcd */
  +   usb_put_hcd(hcd);
  +
  return 0;
   }

Well, maybe.  At this stage it's not too likely that anything will be 
added after the usb_put_hcd().

 Of course, that could be a separate commit if you want.

This affects more than ehci-tegra.  The same concept applies to all the 
EHCI and OHCI platform drivers that use the platform-private area.

Alan Stern

--
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


usb/gadget/gr_udc.c:1528: possible bad test ?

2014-06-17 Thread David Binderman
Hello there,

[linux-3.16-rc1/drivers/usb/gadget/gr_udc.c:1528] - 
[linux-3.16-rc1/drivers/usb/gadget/gr_udc.c:1535]: 
(style) Mismatching assignment and comparison, comparison 'nt==17' is always 
false.

Source code is

nt = 0x3  (usb_endpoint_maxp(desc) 11);
buffer_size = GR_BUFFER_SIZE(epctrl);
if (nt  (mode == 0 || mode == 2)) {
dev_err(dev-dev,
%s mode: multiple trans./microframe not valid\n,
(mode == 2 ? Bulk : Control));
return -EINVAL;
} else if (nt == 0x11) {

If nt has been ANDed with 0x3, then it can't have a value of 0x11.
Suggest code rework.

Regards

David Binderman



  --
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


Re: [PATCH] staging: usbip: fixed a coding-style warning

2014-06-17 Thread Greg Kroah-Hartman
On Fri, Jun 13, 2014 at 11:35:13AM +0300, Alexey Tulia wrote:
 This fixes the following warning:
   - WARNING: __constant_cpu_to_le32 should be cpu_to_le32

What produces this warning?

 
 Signed-off-by: Alexey Tulia alexey.tu...@gmail.com
 ---
  drivers/staging/usbip/vhci_hcd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/usbip/vhci_hcd.c 
 b/drivers/staging/usbip/vhci_hcd.c
 index 0007d30..e21c1b4 100644
 --- a/drivers/staging/usbip/vhci_hcd.c
 +++ b/drivers/staging/usbip/vhci_hcd.c
 @@ -304,7 +304,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
 typeReq, u16 wValue,
   break;
   case GetHubStatus:
   usbip_dbg_vhci_rh( GetHubStatus\n);
 - *(__le32 *) buf = __constant_cpu_to_le32(0);
 + *(__le32 *) buf = cpu_to_le32(0);

How is this correct?  Why shouldn't __constant_cpu_to_le32() be used
here?  Heck, why can't we just use 0 given that it doesn't matter the
endianness of that specific value :)

thanks,

greg k-h
--
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


[bisected][regression] USB Ethernet Gadget Support - Freescale 8308

2014-06-17 Thread Barry G
Hi all,

We have a custom board that has been running on the v3.0 kernel
for a while.  Since that kernel version is deprecated we are working
on upgrading to the 3.10 kernel (some products are 3.10-ltsi so trying
to be common).

Everything is now working except the USB gadget support.  This is a
Freescale MPC8308 based board.  Our device tree entry is:
usb@23000 {
compatible = fsl-usb2-dr;
reg = 0x23000 0x1000;
#address-cells = 1;
#size-cells = 0;
interrupt-parent = ipic;
interrupts = 38 0x8;
dr_mode = peripheral;
phy_type = ulpi;
};

In 3.0, the dmesg shows:
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
Freescale High-Speed USB SOC Device Controller driver (Apr 20, 2007)
g_ether gadget: using random self ethernet address
g_ether gadget: using random host ethernet address
usb0: MAC fa:75:de:cd:cc:80
usb0: HOST MAC f6:64:f6:b4:6b:23
g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
g_ether gadget: g_ether ready
fsl-usb2-udc: bind to driver g_ether


But in 3.10 I was only getting the base ECHI driver line.

After some debugging I found fsl_udc_probe wasn't getting called.
I made the following change:
diff -Naurp linux_kernel.orig/drivers/usb/gadget/fsl_udc_core.c
linux_kernel/drivers/usb/gadget/fsl_udc_core.c
--- linux_kernel.orig/drivers/usb/gadget/fsl_udc_core.c 2014-06-17
11:23:57.008453643 -0700
+++ linux_kernel/drivers/usb/gadget/fsl_udc_core.c  2014-06-17
11:25:45.881727426 -0700
@@ -2661,7 +2661,7 @@ MODULE_DEVICE_TABLE(platform, fsl_udc_de
 static struct platform_driver udc_driver = {
.remove = __exit_p(fsl_udc_remove),
/* Just for FSL i.mx SoC currently */
-   .id_table   = fsl_udc_devtype,
+   /* .id_table= fsl_udc_devtype, */
/* these suspend and resume are not usb suspend and resume */
.suspend= fsl_udc_suspend,
.resume = fsl_udc_resume,


And now on boot I get:
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
usbcore: registered new interface driver usb-storage
g_ether gadget: using random self ethernet address
usb0: MAC c6:62:4c:03:81:9a
usb0: HOST MAC 00:11:22:33:44:55
g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
g_ether gadget: g_ether ready
i2c /dev entries driver

But plugging the cable in results in nothing.  The host computer
doesn't see anything via lsusb or dmesg, nor does the 8308 usb client
computer.  It is like the cable isn't connected.

In an effort to figure out what broke I bisected the kernel down
to:
eb65796ef161f1b2f959a6ab4b818976054b235d
[PATCH] usb: gadget: fsl_udc_core: convert to udc_start/udc_stop

Unfortunately this patch just switches us over to the new interface
and isn't really revertible as the old interface doesn't exist.

In a futile attempt to make it work, I grabbed the 3.15 fsl_udc_core.c,
remarked the calls to usb_ep-set_maxpacket_limit, and booted that. I got:
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
usbcore: registered new interface driver usb-storage
g_ether gadget: using random self ethernet address
usb0: MAC d6:bc:72:e8:87:a1
usb0: HOST MAC 00:11:22:33:44:55
g_ether gadget: rndis: can't bind, err -19
g_ether fsl-usb2-udc.0: failed to start g_ether: -19

I know crossing over kernel versions like that is dangerous so I am
not sure if I am getting to the garbage in/garbage out stage yet.

What can I do to get the USB Ethernet Gadget functionality working again?
Thoughts or directions would be appreciated.

Thanks,

Barry
--
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


[PATCH 0/3] port power control fixes for 3.16-rc2

2014-06-17 Thread Dan Williams
Fallout / regression fixes for the port power control rework that landed
in 3.16-rc1.

1/ Cosmetic fix to an error message

2/ Handle ACPI port-location-data conflicts by disabling port power off
   rather than spewing a backtrace and trying to continue.

3/ Handle hubs that do not support port power off by enforcing the
   PM_QOS_NO_POWER_OFF constraint from the kernel rather than disabling
   runtime power management.

---

Dan Williams (3):
  usb: improve not suspended yet message in hub_suspend()
  usb: quiet peer failure warning, disable poweroff
  usb: fix hub-port pm_runtime_enable() vs runtime pm transitions


 drivers/usb/core/hub.c  |9 -
 drivers/usb/core/hub.h  |2 +
 drivers/usb/core/port.c |   89 ++-
 3 files changed, 75 insertions(+), 25 deletions(-)
--
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


[PATCH 2/3] usb: quiet peer failure warning, disable poweroff

2014-06-17 Thread Dan Williams
In the case where platform firmware has specified conflicting values for
port locations it is confusing and otherwise not helpful to throw a
backtrace.  Instead, include enough information to determine that
firmware has done something wrong and globally disable port poweroff.

Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 drivers/usb/core/port.c |   24 +++-
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 62036faf56c0..9347ade7d5fe 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -21,6 +21,8 @@
 
 #include hub.h
 
+static int usb_port_block_power_off;
+
 static const struct attribute_group *port_dev_group[];
 
 static ssize_t connect_type_show(struct device *dev,
@@ -142,6 +144,9 @@ static int usb_port_runtime_suspend(struct device *dev)
== PM_QOS_FLAGS_ALL)
return -EAGAIN;
 
+   if (usb_port_block_power_off)
+   return -EBUSY;
+
usb_autopm_get_interface(intf);
retval = usb_hub_set_port_power(hdev, hub, port1, false);
usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION);
@@ -190,11 +195,19 @@ static int link_peers(struct usb_port *left, struct 
usb_port *right)
if (left-peer || right-peer) {
struct usb_port *lpeer = left-peer;
struct usb_port *rpeer = right-peer;
-
-   WARN(1, failed to peer %s and %s (%s - %p) (%s - %p)\n,
-   dev_name(left-dev), dev_name(right-dev),
-   dev_name(left-dev), lpeer,
-   dev_name(right-dev), rpeer);
+   char *method;
+
+   if (left-location  left-location == right-location)
+   method = location;
+   else
+   method = default;
+
+   pr_warn(usb: failed to peer %s and %s by %s (%s:%s) (%s:%s)\n,
+   dev_name(left-dev), dev_name(right-dev), method,
+   dev_name(left-dev),
+   lpeer ? dev_name(lpeer-dev) : none,
+   dev_name(right-dev),
+   rpeer ? dev_name(rpeer-dev) : none);
return -EBUSY;
}
 
@@ -251,6 +264,7 @@ static void link_peers_report(struct usb_port *left, struct 
usb_port *right)
dev_warn(left-dev, failed to peer to %s (%d)\n,
dev_name(right-dev), rc);
pr_warn_once(usb: port power management may be unreliable\n);
+   usb_port_block_power_off = 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


[PATCH 3/3] usb: fix hub-port pm_runtime_enable() vs runtime pm transitions

2014-06-17 Thread Dan Williams
Commit 9262c19d14c4 usb: disable port power control if not supported in
wHubCharacteristics gated enabling runtime pm for usb_port devices on
whether the parent hub supports power control, which causes a
regression.  The port must still be allowed to carry out runtime pm
callbacks and receive a -EAGAIN or -EBUSY result.  Otherwise the
usb_port device will transition to the pm error state and trigger the
same for the child usb_device.

Prior to the offending commit usb_hub_create_port_device() arranged for
runtime pm to be disabled is dev_pm_qos_expose_flags() failed.  Instead,
force the default state of PM_QOS_FLAG_NO_POWER_OFF flag to be set prior
to enabling runtime pm.  If that policy can not be set then fail
registration.

Report: http://marc.info/?l=linux-usbm=140290586301336w=2
Fixes: 9262c19d14c4 (usb: disable port power control if not supported in 
wHubCharacteristics)
Reported-by: Bjørn Mork bj...@mork.no
Reported-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 drivers/usb/core/hub.c  |6 
 drivers/usb/core/hub.h  |2 +
 drivers/usb/core/port.c |   65 +--
 3 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 6ac87cbf3af7..e476e767c8de 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1589,6 +1589,12 @@ static int hub_configure(struct usb_hub *hub,
}
}
hdev-maxchild = i;
+   for (i = 0; i  hdev-maxchild; i++) {
+   struct usb_port *port_dev = hub-ports[i];
+
+   pm_runtime_put(port_dev-dev);
+   }
+
mutex_unlock(usb_port_peer_mutex);
if (ret  0)
goto fail;
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 0a7cdc0ef0a9..326308e53961 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -84,6 +84,7 @@ struct usb_hub {
  * @dev: generic device interface
  * @port_owner: port's owner
  * @peer: related usb2 and usb3 ports (share the same connector)
+ * @req: default pm qos request for hubs without port power control
  * @connect_type: port's connect type
  * @location: opaque representation of platform connector location
  * @status_lock: synchronize port_event() vs usb_port_{suspend|resume}
@@ -95,6 +96,7 @@ struct usb_port {
struct device dev;
struct usb_dev_state *port_owner;
struct usb_port *peer;
+   struct dev_pm_qos_request *req;
enum usb_port_connect_type connect_type;
usb_port_location_t location;
struct mutex status_lock;
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 9347ade7d5fe..fe1b6d0967e3 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -68,6 +68,7 @@ static void usb_port_device_release(struct device *dev)
 {
struct usb_port *port_dev = to_usb_port(dev);
 
+   kfree(port_dev-req);
kfree(port_dev);
 }
 
@@ -400,9 +401,13 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
int retval;
 
port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL);
-   if (!port_dev) {
-   retval = -ENOMEM;
-   goto exit;
+   if (!port_dev)
+   return -ENOMEM;
+
+   port_dev-req = kzalloc(sizeof(*(port_dev-req)), GFP_KERNEL);
+   if (!port_dev-req) {
+   kfree(port_dev);
+   return -ENOMEM;
}
 
hub-ports[port1 - 1] = port_dev;
@@ -418,31 +423,53 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
port1);
mutex_init(port_dev-status_lock);
retval = device_register(port_dev-dev);
-   if (retval)
-   goto error_register;
+   if (retval) {
+   put_device(port_dev-dev);
+   return retval;
+   }
+
+   /* Set default policy of port-poweroff disabled. */
+   retval = dev_pm_qos_add_request(port_dev-dev, port_dev-req,
+   DEV_PM_QOS_FLAGS, PM_QOS_FLAG_NO_POWER_OFF);
+   if (retval  0) {
+   device_unregister(port_dev-dev);
+   return retval;
+   }
 
find_and_link_peer(hub, port1);
 
+   /*
+* Enable runtime pm and hold a refernce that hub_configure()
+* will drop once the PM_QOS_NO_POWER_OFF flag state has been set
+* and the hub has been fully registered (hdev-maxchild set).
+*/
pm_runtime_set_active(port_dev-dev);
+   pm_runtime_get_noresume(port_dev-dev);
+   pm_runtime_enable(port_dev-dev);
+   device_enable_async_suspend(port_dev-dev);
 
/*
-* Do not enable port runtime pm if the hub does not support
-* power switching.  Also, userspace must have final say of
-* whether a port is permitted to power-off.  Do not enable
-* runtime pm if we fail to expose pm_qos_no_power_off.
+* Keep hidden the ability to 

[PATCH 1/3] usb: improve not suspended yet message in hub_suspend()

2014-06-17 Thread Dan Williams
Reading through a recent bug report [1], Alan notes:

  Dan, the warning message in hub_suspend() should mention that the
   child device isn't suspended yet.

...update the warning from:

  usb usb3-port4: not suspended yet

...to:

   usb usb3-port4: device 3-4: not suspended yet

[1]: http://marc.info/?l=linux-usbm=140290586301336w=2

Reported-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 drivers/usb/core/hub.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 879b66e13370..6ac87cbf3af7 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3458,7 +3458,8 @@ static int hub_suspend(struct usb_interface *intf, 
pm_message_t msg)
struct usb_device *udev = port_dev-child;
 
if (udev  udev-can_submit) {
-   dev_warn(port_dev-dev, not suspended yet\n);
+   dev_warn(port_dev-dev, device %s not suspended 
yet\n,
+   dev_name(udev-dev));
if (PMSG_IS_AUTO(msg))
return -EBUSY;
}

--
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


Re: [PATCH 0/3] port power control fixes for 3.16-rc2

2014-06-17 Thread Greg KH
On Tue, Jun 17, 2014 at 04:16:16PM -0700, Dan Williams wrote:
 Fallout / regression fixes for the port power control rework that landed
 in 3.16-rc1.
 
 1/ Cosmetic fix to an error message
 
 2/ Handle ACPI port-location-data conflicts by disabling port power off
rather than spewing a backtrace and trying to continue.
 
 3/ Handle hubs that do not support port power off by enforcing the
PM_QOS_NO_POWER_OFF constraint from the kernel rather than disabling
runtime power management.

All now applied, along with your previously sent patch.  Have I missed
anything else pending from you for 3.16-final?

thanks,

greg k-h
--
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


Re: [PATCH v3 0/2] Fix subject line

2014-06-17 Thread Davidlohr Bueso
On Mon, 2014-06-16 at 00:28 +0400, Wahib wrote:
 Hi Davidlohr!
 
 Don't worry. I am not discouraged. :)
 
 I understand your concern that the patch feels superficial. It's what the task
 asked us to do. I suspect the author(s) of the Eudyptula Challenge designed
 this task to get us involved with the Linux kernel community.

If you feel you actually learn something by doing the Eudyptula
Challenge, then good for you, and by all means continue doing so. As I
mentioned, I know almost zero about it, but can say for sure that
cleanups alone won't get you very far in the community and you will
probably get bored sooner or later -- which is unfortunate as kernel
hacking fascinating.

 
 I have been looking for a bug in 'usbip' to bundle with my patch. The only bug
 that I could find (as of 16-Jun-2014) on bugzilla.kernel.org related
 to 'usbip' is Bug 77191.
 
 Bug 77191 - ftdi-sio (usbserial) over usbip hung after disconnect while in use
 (https://bugzilla.kernel.org/show_bug.cgi?id=77191)
 
 Sadly the bug doesn't seem to be newbie friendly as it requires special setup
 to reproduce and requires the developer to know about the intricacies of the
 'usbip' subsystem. I understand that people commiting their specialized
 knowledge is how the kernel development actually works. But USB is not my
 speciality (yet).
 
 Could you point me to more beginner friendly bugs which aren't superficial 
 code
 cleanups?

There are plenty of bugs out there, and not so hard to find -- just push
some module/filesystem/subsystem/testcase hard enough to make it do
things it shouldn't. Run linux-next on trinity and fix/report the bugs,
etc.

imho testing and reading other people's patches is perhaps the best way
to do useful things, get acquainted with the code and get experience
with lkml and the process behind kernel development.

 Can I bundle fixes to subsystems other than 'usbip' with the code cleanup 
 patch
 for 'usbip'?

Probably not, unless it's a tree-wide change.

Hope this helps,
Davidlohr

--
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


Re: [PATCH 0/3] port power control fixes for 3.16-rc2

2014-06-17 Thread Dan Williams
On Tue, Jun 17, 2014 at 5:06 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Tue, Jun 17, 2014 at 04:16:16PM -0700, Dan Williams wrote:
 Fallout / regression fixes for the port power control rework that landed
 in 3.16-rc1.

 1/ Cosmetic fix to an error message

 2/ Handle ACPI port-location-data conflicts by disabling port power off
rather than spewing a backtrace and trying to continue.

 3/ Handle hubs that do not support port power off by enforcing the
PM_QOS_NO_POWER_OFF constraint from the kernel rather than disabling
runtime power management.

 All now applied, along with your previously sent patch.  Have I missed
 anything else pending from you for 3.16-final?

This is all I had pending.

I put patch 3 usb: fix hub-port pm_runtime_enable() vs runtime pm
transitions through it's paces, but I'd still like to see a positive
test report from Bjørn... even if it's too late to add a Tested-by.
--
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


Re: [PATCH] USB:gadget: Fix a warning while loading g_mass_storage

2014-06-17 Thread Yang,Wei

On 06/17/2014 10:18 PM, Alan Stern wrote:

That is a strange question to ask.  If you did not know that I approved
the patch, why did you insert my Acked-By:?


I added your Acked-By, as when you reviewed V3, you mentioned that I 
*may* add your Acked-by in this patch. If I misunderstood your point, I 
am so sorry for that.


Best Regards
Wei


With that change, you may add

Acked-by: Alan Sternst...@rowland.harvard.edu

Alan Stern


--
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


Re: [bisected][regression] USB Ethernet Gadget Support - Freescale 8308

2014-06-17 Thread Felipe Balbi
Hi,

On Tue, Jun 17, 2014 at 04:04:04PM -0700, Barry G wrote:
 Hi all,
 
 We have a custom board that has been running on the v3.0 kernel
 for a while.  Since that kernel version is deprecated we are working
 on upgrading to the 3.10 kernel (some products are 3.10-ltsi so trying

3.10 is a pretty old kernel, you need to ask support from whoever gave
you that kernel, unless you can try v3.16-rc1 on your board.

Good luck.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 1/4] USB: ehci-msm: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/host/ehci-msm.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 982c09b..934b39d 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -190,7 +190,7 @@ static const struct dev_pm_ops ehci_msm_dev_pm_ops = {
.resume  = ehci_msm_pm_resume,
 };
 
-static struct of_device_id msm_ehci_dt_match[] = {
+static const struct of_device_id msm_ehci_dt_match[] = {
{ .compatible = qcom,ehci-host, },
{}
 };
-- 
1.7.10.4


--
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


[PATCH 2/4] USB: ehci-spear: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/host/ehci-spear.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 1d59958..1355ff0 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -150,7 +150,7 @@ static int spear_ehci_hcd_drv_remove(struct platform_device 
*pdev)
return 0;
 }
 
-static struct of_device_id spear_ehci_id_table[] = {
+static const struct of_device_id spear_ehci_id_table[] = {
{ .compatible = st,spear600-ehci, },
{ },
 };
-- 
1.7.10.4


--
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


[PATCH 3/4] USB: ehci-tegra: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/host/ehci-tegra.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6fdcb8a..c303371 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -326,7 +326,7 @@ static const struct tegra_ehci_soc_config 
tegra20_soc_config = {
.has_hostpc = false,
 };
 
-static struct of_device_id tegra_ehci_of_match[] = {
+static const struct of_device_id tegra_ehci_of_match[] = {
{ .compatible = nvidia,tegra30-ehci, .data = tegra30_soc_config },
{ .compatible = nvidia,tegra20-ehci, .data = tegra20_soc_config },
{ },
-- 
1.7.10.4


--
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


[PATCH 4/4] USB: ohci-spear: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/host/ohci-spear.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 8b29a0c..8d58766 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -162,7 +162,7 @@ static int spear_ohci_hcd_drv_resume(struct platform_device 
*dev)
 }
 #endif
 
-static struct of_device_id spear_ohci_id_table[] = {
+static const struct of_device_id spear_ohci_id_table[] = {
{ .compatible = st,spear600-ohci, },
{ },
 };
-- 
1.7.10.4


--
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


[PATCH 1/2] usb: gadget: gr_udc: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/gadget/gr_udc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 99a37ed..5d93f2b 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2212,7 +2212,7 @@ out:
return retval;
 }
 
-static struct of_device_id gr_match[] = {
+static const struct of_device_id gr_match[] = {
{.name = GAISLER_USBDC},
{.name = 01_021},
{},
-- 
1.7.10.4


--
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


[PATCH 2/2] usb: gadget: lpc32xx_udc: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/gadget/lpc32xx_udc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index e471580..c77c687 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -3397,7 +3397,7 @@ static int lpc32xx_udc_resume(struct platform_device 
*pdev)
 #endif
 
 #ifdef CONFIG_OF
-static struct of_device_id lpc32xx_udc_of_match[] = {
+static const struct of_device_id lpc32xx_udc_of_match[] = {
{ .compatible = nxp,lpc3220-udc, },
{ },
 };
-- 
1.7.10.4


--
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


[PATCH 1/2] usb: phy: msm: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/phy/phy-msm-usb.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index ced34f3..625c144 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1427,7 +1427,7 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_remove(msm_otg_dbg_root);
 }
 
-static struct of_device_id msm_otg_dt_match[] = {
+static const struct of_device_id msm_otg_dt_match[] = {
{
.compatible = qcom,usb-otg-ci,
.data = (void *) CI_45NM_INTEGRATED_PHY
-- 
1.7.10.4


--
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


[PATCH 2/2] usb: phy: tegra: Make of_device_id array const

2014-06-17 Thread Jingoo Han
Make of_device_id array const, because all OF functions handle
it as const.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/phy/phy-tegra-usb.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index bbe4f8e..cd36cb4 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -965,7 +965,7 @@ static const struct tegra_phy_soc_config tegra30_soc_config 
= {
.requires_extra_tuning_parameters = true,
 };
 
-static struct of_device_id tegra_usb_phy_id_table[] = {
+static const struct of_device_id tegra_usb_phy_id_table[] = {
{ .compatible = nvidia,tegra30-usb-phy, .data = tegra30_soc_config },
{ .compatible = nvidia,tegra20-usb-phy, .data = tegra20_soc_config },
{ },
-- 
1.7.10.4


--
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


Re: [PATCH v6 1/1] usb: host: xhci-plat: add support for the R-Car H2 and M2 xHCI controllers

2014-06-17 Thread Magnus Damm
Hi Felipe,

On Fri, Jun 13, 2014 at 11:25 PM, Felipe Balbi ba...@ti.com wrote:
 Hi,

 On Fri, Jun 13, 2014 at 09:20:31PM +0900, Yoshihiro Shimoda wrote:
 The R-Car H2 and M2 SoCs come with an xHCI controller that requires
 some specific initializations related to the firmware downloading and
 some specific registers. This patch adds the support for this special
 configuration as an xHCI quirk executed during probe and start.

 Signed-off-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
 ---

 diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
 new file mode 100644
 index 000..ff0d1b4
 --- /dev/null
 +++ b/drivers/usb/host/xhci-rcar.c
 @@ -0,0 +1,148 @@
 +/*
 + * xHCI host controller driver for R-Car SoCs
 + *
 + * Copyright (C) 2014 Renesas Electronics Corporation
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * version 2 as published by the Free Software Foundation.
 + */
 +
 +#include linux/firmware.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/usb/phy.h
 +
 +#include xhci.h
 +#include xhci-rcar.h
 +
 +#define FIRMWARE_NAMEr8a779x_usb3_v1.dlmem
 +MODULE_FIRMWARE(FIRMWARE_NAME);
 +
 +/*** Register Offset ***/
 +#define RCAR_USB3_INT_ENA0x224   /* Interrupt Enable */
 +#define RCAR_USB3_DL_CTRL0x250   /* FW Download Control  Status */
 +#define RCAR_USB3_FW_DATA0   0x258   /* FW Data0 */
 +
 +#define RCAR_USB3_LCLK   0xa44   /* LCLK Select */
 +#define RCAR_USB3_CONF1  0xa48   /* USB3.0 Configuration1 */
 +#define RCAR_USB3_CONF2  0xa5c   /* USB3.0 Configuration2 */
 +#define RCAR_USB3_CONF3  0xaa8   /* USB3.0 Configuration3 */
 +#define RCAR_USB3_RX_POL 0xab0   /* USB3.0 RX Polarity */
 +#define RCAR_USB3_TX_POL 0xab8   /* USB3.0 TX Polarity */
 +
 +/*** Register Settings ***/
 +/* Interrupt Enable */
 +#define RCAR_USB3_INT_XHC_ENA0x0001
 +#define RCAR_USB3_INT_PME_ENA0x0002
 +#define RCAR_USB3_INT_HSE_ENA0x0004
 +#define RCAR_USB3_INT_ENA_VAL(RCAR_USB3_INT_XHC_ENA | \
 + RCAR_USB3_INT_PME_ENA | RCAR_USB3_INT_HSE_ENA)
 +
 +/* FW Download Control  Status */
 +#define RCAR_USB3_DL_CTRL_ENABLE 0x0001
 +#define RCAR_USB3_DL_CTRL_FW_SUCCESS 0x0010
 +#define RCAR_USB3_DL_CTRL_FW_SET_DATA0   0x0100
 +
 +/* LCLK Select */
 +#define RCAR_USB3_LCLK_ENA_VAL   0x01030001
 +
 +/* USB3.0 Configuration */
 +#define RCAR_USB3_CONF1_VAL  0x00030204
 +#define RCAR_USB3_CONF2_VAL  0x00030300
 +#define RCAR_USB3_CONF3_VAL  0x13802007
 +
 +/* USB3.0 Polarity */
 +#define RCAR_USB3_RX_POL_VAL BIT(21)
 +#define RCAR_USB3_TX_POL_VAL BIT(4)
 +
 +void xhci_rcar_start(struct usb_hcd *hcd)
 +{
 + u32 temp;
 +
 + if (hcd-regs != NULL) {
 + /* Interrupt Enable */
 + temp = readl(hcd-regs + RCAR_USB3_INT_ENA);
 + temp |= RCAR_USB3_INT_ENA_VAL;
 + writel(temp, hcd-regs + RCAR_USB3_INT_ENA);
 + /* LCLK Select */
 + writel(RCAR_USB3_LCLK_ENA_VAL, hcd-regs + RCAR_USB3_LCLK);
 + /* USB3.0 Configuration */
 + writel(RCAR_USB3_CONF1_VAL, hcd-regs + RCAR_USB3_CONF1);
 + writel(RCAR_USB3_CONF2_VAL, hcd-regs + RCAR_USB3_CONF2);
 + writel(RCAR_USB3_CONF3_VAL, hcd-regs + RCAR_USB3_CONF3);
 + /* USB3.0 Polarity */
 + writel(RCAR_USB3_RX_POL_VAL, hcd-regs + RCAR_USB3_RX_POL);
 + writel(RCAR_USB3_TX_POL_VAL, hcd-regs + RCAR_USB3_TX_POL);
 + }
 +}
 +
 +static int xhci_rcar_download_firmware(struct device *dev, void __iomem 
 *regs)
 +{
 + const struct firmware *fw;
 + int retval, index, j, time;
 + int timeout = 1;
 + u32 data, val, temp;
 +
 + /* request R-Car USB3.0 firmware */
 + retval = request_firmware(fw, FIRMWARE_NAME, dev);
 + if (retval)
 + return retval;
 +
 + /* download R-Car USB3.0 firmware */
 + temp = readl(regs + RCAR_USB3_DL_CTRL);
 + temp |= RCAR_USB3_DL_CTRL_ENABLE;
 + writel(temp, regs + RCAR_USB3_DL_CTRL);
 +
 + for (index = 0; index  fw-size; index += 4) {
 + /* to avoid reading beyond the end of the buffer */
 + for (data = 0, j = 3; j = 0; j--) {
 + if ((j + index)  fw-size)
 + data |= fw-data[index + j]  (8 * j);
 + }
 + writel(data, regs + RCAR_USB3_FW_DATA0);
 + temp = readl(regs + RCAR_USB3_DL_CTRL);
 + temp |= RCAR_USB3_DL_CTRL_FW_SET_DATA0;
 + writel(temp, regs + RCAR_USB3_DL_CTRL);
 +
 + for (time = 0; time  timeout; time++) {
 + val = readl(regs + RCAR_USB3_DL_CTRL);
 + if ((val  RCAR_USB3_DL_CTRL_FW_SET_DATA0) == 0)
 + break;
 +