Re: [PATCH v8 3/4] USB: io_ti: Add firmware image sanity checks

2015-07-30 Thread Johan Hovold
On Thu, Jul 23, 2015 at 01:39:06PM +0300, Sergei Shtylyov wrote:
 Hello.
 
 On 7/22/2015 9:56 PM, Peter E. Berger wrote:

  @@ -928,6 +928,41 @@ static int ti_cpu_rev(struct edge_ti_manuf_descriptor 
  *desc)
  return TI_GET_CPU_REVISION(desc-CpuRev_BoardRev);
}
 
  +static int check_fw_sanity(struct edgeport_serial *serial,
  +   const struct firmware *fw)
  +{
  +   u16 length_total;
  +   int checksum = 0;
  +   int pos;
  +   struct device *dev = serial-serial-interface-dev;
  +   struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data;
  +
  +   if (fw-size  sizeof(struct edgeport_fw_hdr)) {
  +   dev_err(dev, Incomplete fw header\n);
  +   return -EINVAL;
  +   }
  +
  +   length_total = le16_to_cpu(fw_hdr-length) +
  +   sizeof(struct edgeport_fw_hdr);
  +
  +   if (fw-size != length_total) {
  +   dev_err(dev, Bad fw size (Expected: %u, Got: %zu)\n,
 
 I would not capitalize the latter 2 words.

I wouldn't either; just use lower case for the whole message.

  +   length_total, fw-size);
  +   return -EINVAL;
  +   }
  +
  +   for (pos = sizeof(struct edgeport_fw_hdr); pos  fw-size; ++pos)
  +   checksum = (checksum + fw-data[pos])  0xFF;
 
 Why not make 'checksum' 's8' or 'u8' instead of *int*?

I'd prefer that as well.

  +
  +   if (checksum != fw_hdr-checksum) {
  +   dev_err(dev, Bad fw checksum (Expected: 0x%x, Got: 0x%x)\n,
  +   fw_hdr-checksum, checksum);
 
 I would not capitalize the latter 2 words.

Please use all lower case.

Thanks,
Johan
--
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 v8 00/23] usb gadget update for OTG 2.0

2015-07-30 Thread Felipe Balbi
On Thu, Jul 30, 2015 at 09:46:58AM +0800, Li Jun wrote:
 On Wed, Jul 29, 2015 at 09:11:41PM -0500, Felipe Balbi wrote:
  On Thu, Jul 30, 2015 at 07:24:03AM +0800, Li Jun wrote:
   On Wed, Jul 29, 2015 at 10:04:27AM -0500, Felipe Balbi wrote:
On Mon, Jul 27, 2015 at 03:21:59PM +0800, Peter Chen wrote:
 On Thu, Jul 23, 2015 at 11:37:24AM +0800, Li Jun wrote:
  Change for v8:
  - Add Peter's ACk for chipidea driver; and Roger's Reviewed-by for 
  patch
07, 21~23.
  - Add ci-is_otg condition before enable ci-gadget.is_otg for 
  chipidea
driver in patch 8.
  
 
 Hi Felipe,
 
 For chipidea patches in this series, help to queue them in your tree 
 please, thanks.

all there, please make sure they're correct. There were so many versions
of this series that I might have picked up the wrong one :-p

   
   Patch [8/23]: usb: chipidea: set usb otg capabilities, you picked up 
   the V7,
   I have a small change for V8, others are correct.
  
  Can you send an incremental diff, please ?
  
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index 61fde89..c6d1595 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1838,8 +1838,8 @@ static int udc_start(struct ci_hdrc *ci)
   ci-gadget.name = ci-platdata-name;
   ci-gadget.otg_caps = otg_caps;
  
 - if (otg_caps-hnp_support || otg_caps-srp_support ||
 - otg_caps-adp_support)
 + if (ci-is_otg  (otg_caps-hnp_support || otg_caps-srp_support ||
 + otg_caps-adp_support))
   ci-gadget.is_otg = 1;
  
   INIT_LIST_HEAD(ci-gadget.ep_list);

I need it as a real patch with Signed-off-by and all, so I can apply :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] Bluetooth: btusb: match generic class code in interface descriptor

2015-07-30 Thread Marcel Holtmann
Hi Daniel,

 btusb currently has a generic match on USB device descriptors:
{ USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
 
 However, http://www.usb.org/developers/defined_class states:
 
  Base Class E0h (Wireless Controller)
  This base class is defined for devices that are Wireless controllers.
  Values not shown in the table below are reserved. These class codes are
  to be used in Interface Descriptors, with the exception of the Bluetooth
  class code which can also be used in a Device Descriptor.
 
 Add a match on the interface descriptors accordingly.
 
 This fixes compatibility with the RTL8723AU device shown below.
 This device conforms to the USB Interface Association Descriptor
 specification, which requires the device to have class ef/02/01.
 The extra IAD descriptor then specifies that interfaces 0 and 1
 belong to the same function/driver, which is true. Provided that
 the Bluetooth device class spec accepts use of the IAD, I imagine that
 technically, all btusb devices should be configured like this.
 
 T:  Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
 D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
 P:  Vendor=0bda ProdID=0724 Rev= 2.00
 S:  Manufacturer=Realtek
 S:  Product=802.11n WLAN Adapter
 S:  SerialNumber=00e04c01
 C:* #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=500mA
 A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
 I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
 E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
 E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
 I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
 E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
 I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
 E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
 I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
 E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
 I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
 E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
 I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
 E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
 I:* If#= 2 Alt= 0 #EPs= 4 Cls=ff(vend.) Sub=ff Prot=ff Driver=rtl8723au
 E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=87(I) Atr=03(Int.) MxPS=  64 Ivl=500us
 
 Signed-off-by: Daniel Drake dr...@endlessm.com
 ---
 drivers/bluetooth/btusb.c | 1 +
 1 file changed, 1 insertion(+)
 
 This replaces/obsoletes:
  [PATCH] Bluetooth: btusb: Recognize Realtek shared wifi/bluetooth devices
  [PATCH] Bluetooth: btusb: Add Realtek devices into module device table
 
 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
 index 93339a4..9874aac 100644
 --- a/drivers/bluetooth/btusb.c
 +++ b/drivers/bluetooth/btusb.c
 @@ -64,6 +64,7 @@ static struct usb_driver btusb_driver;
 static const struct usb_device_id btusb_table[] = {
   /* Generic Bluetooth USB device */
   { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
 + { USB_INTERFACE_INFO(0xe0, 0x01, 0x01) },

I moved this into its own line with its own comment before applying your patch.

Regards

Marcel

--
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] drivers/usb/: Simplify return statements

2015-07-30 Thread Karajgaonkar, Saurabh (S.)
From: Saurabh Karajgaonkar skara...@visteon.com

This patch is created using simple_return.cocci coccinelle script.
It replaces the redundant instances where variables are assigned
return value from functions and then used in return statements.

Signed-off-by: Saurabh Karajgaonkar skara...@visteon.com
---
 drivers/usb/host/ehci-st.c  |  7 +--
 drivers/usb/host/oxu210hp-hcd.c |  7 +--
 drivers/usb/host/u132-hcd.c | 27 +--
 drivers/usb/host/xhci.c |  6 +-
 drivers/usb/misc/ftdi-elan.c| 10 ++
 drivers/usb/musb/musb_dsps.c|  6 +-
 drivers/usb/phy/phy-keystone.c  |  6 +-
 drivers/usb/phy/phy-mxs-usb.c   |  6 +-
 drivers/usb/serial/mxuport.c|  6 +-
 9 files changed, 14 insertions(+), 67 deletions(-)

diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index 7e4bd39..b7c5cfa 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -54,7 +54,6 @@ static int st_ehci_platform_reset(struct usb_hcd *hcd)
struct platform_device *pdev = to_platform_device(hcd-self.controller);
struct usb_ehci_pdata *pdata = dev_get_platdata(pdev-dev);
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-   int retval;
u32 threshold;
 
/* Set EHCI packet buffer IN/OUT threshold to 128 bytes */
@@ -62,11 +61,7 @@ static int st_ehci_platform_reset(struct usb_hcd *hcd)
writel(threshold, hcd-regs + AHB2STBUS_INSREG01);
 
ehci-caps = hcd-regs + pdata-caps_offset;
-   retval = ehci_setup(hcd);
-   if (retval)
-   return retval;
-
-   return 0;
+   return ehci_setup(hcd);
 }
 
 static int st_ehci_platform_power_on(struct platform_device *dev)
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 6352f54..fe3bd1c 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -2670,7 +2670,6 @@ static int oxu_hcd_init(struct usb_hcd *hcd)
 static int oxu_reset(struct usb_hcd *hcd)
 {
struct oxu_hcd *oxu = hcd_to_oxu(hcd);
-   int ret;
 
spin_lock_init(oxu-mem_lock);
INIT_LIST_HEAD(oxu-urb_list);
@@ -2696,11 +2695,7 @@ static int oxu_reset(struct usb_hcd *hcd)
oxu-hcs_params = readl(oxu-caps-hcs_params);
oxu-sbrn = 0x20;
 
-   ret = oxu_hcd_init(hcd);
-   if (ret)
-   return ret;
-
-   return 0;
+   return oxu_hcd_init(hcd);
 }
 
 static int oxu_run(struct usb_hcd *hcd)
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index d516877..1cfb811 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -1542,11 +1542,8 @@ static int u132_periodic_reinit(struct u132 *u132)
(fit ^ FIT) | u132-hc_fminterval);
if (retval)
return retval;
-   retval = u132_write_pcimem(u132, periodicstart,
+   return u132_write_pcimem(u132, periodicstart,
((9 * fi) / 10)  0x3fff);
-   if (retval)
-   return retval;
-   return 0;
 }
 
 static char *hcfs2string(int state)
@@ -2701,28 +2698,18 @@ static int u132_roothub_setportfeature(struct u132 
*u132, u16 wValue,
if (wIndex == 0 || wIndex  u132-num_ports) {
return -EINVAL;
} else {
-   int retval;
int port_index = wIndex - 1;
struct u132_port *port = u132-port[port_index];
port-Status = ~(1  wValue);
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
-   retval = u132_write_pcimem(u132,
+   return u132_write_pcimem(u132,
roothub.portstatus[port_index], RH_PS_PSS);
-   if (retval)
-   return retval;
-   return 0;
case USB_PORT_FEAT_POWER:
-   retval = u132_write_pcimem(u132,
+   return u132_write_pcimem(u132,
roothub.portstatus[port_index], RH_PS_PPS);
-   if (retval)
-   return retval;
-   return 0;
case USB_PORT_FEAT_RESET:
-   retval = u132_roothub_portreset(u132, port_index);
-   if (retval)
-   return retval;
-   return 0;
+   return u132_roothub_portreset(u132, port_index);
default:
return -EPIPE;
}
@@ -2737,7 +2724,6 @@ static int u132_roothub_clearportfeature(struct u132 
*u132, u16 wValue,
} else {
int port_index = wIndex - 1;
u32 temp;
-   int retval;
struct u132_port *port = u132-port[port_index];
port-Status = ~(1  wValue);
switch (wValue) {
@@ -2773,11 +2759,8 @@ static int 

Re: [PATCH v8 2/4] USB: io_ti: Fix firmware version handling

2015-07-30 Thread Johan Hovold
On Wed, Jul 22, 2015 at 01:56:14PM -0500, Peter E. Berger wrote:
 From: Peter E. Berger pber...@brimson.com
 
 The io_ti driver fails to download firmware to Edgeport
 devices such as the EP/416, even when the on-disk firmware image
 (/lib/firmware/edgeport/down3.bin) is more current than the version
 on the EP/416.  The current download code is broken in a few ways.
 Notably it mis-uses global variables OperationalMajorVersion and
 OperationalMinorVersion (reading their values before they've been
 properly initialized and subsequently initializing them multiple times
 without synchronization).  This patch drops the global variables and
 replaces the redundant calls to request_firmware()/release_firmware()
 in download_fw() with a single call pair in edge_startup(); the firmware
 image pointer is then passed to download_fw() and build_i2c_fw_hdr().
 
 Signed-off-by: Peter E. Berger pber...@brimson.com
 ---
  drivers/usb/serial/io_ti.c | 115 
 ++---
  1 file changed, 66 insertions(+), 49 deletions(-)
 
 diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
 index 69378a7..6cff12c 100644
 --- a/drivers/usb/serial/io_ti.c
 +++ b/drivers/usb/serial/io_ti.c
 @@ -71,6 +71,25 @@ struct product_info {
   __u8hardware_type;  /* Type of hardware */
  } __attribute__((packed));
  
 +/*
 + * Edgeport firmware header
 + *
 + * build_number has been set to 0 in all three of the images I have
 + * seen, and Digi Tech Support suggests that it is safe to ignore it.
 + *
 + * length is the number of bytes of actual data following the header.
 + *
 + * checksum is the low order byte resulting from adding the values of
 + * all the data bytes.
 + */
 +struct edgeport_fw_hdr {
 + u8 major_version;
 + u8 minor_version;
 + u16 build_number;
 + u16 length;

These should be __le16.

 + u8 checksum;
 +} __packed;
 +
  struct edgeport_port {
   __u16 uart_base;
   __u16 dma_address;

 @@ -934,7 +934,8 @@ static int ti_cpu_rev(struct edge_ti_manuf_descriptor 
 *desc)
   * This routine downloads the main operating code into the TI5052, using the
   * boot code already burned into E2PROM or ROM.
   */
 -static int download_fw(struct edgeport_serial *serial)
 +static int download_fw(struct edgeport_serial *serial,
 + const struct firmware *fw)
  {
   struct device *dev = serial-serial-dev-dev;
   int status = 0;
 @@ -943,6 +944,17 @@ static int download_fw(struct edgeport_serial *serial)
   struct usb_interface_descriptor *interface;
   int download_cur_ver;
   int download_new_ver;
 + struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data;
 +
 + if (fw-size  sizeof(struct edgeport_fw_hdr)) {

Missing le16_to_cpu on fw-size.

 + dev_err(serial-serial-interface-dev,
 + %s - Incomplete firmware header.\n, __func__);

No need to include the function name here.

 + return -EINVAL;
 + }
 +
 + /* If on-board version is newer, fw_version will be updated below. */
 + serial-fw_version = (fw_hdr-major_version  8) +
 + fw_hdr-minor_version;
  
   /* This routine is entered by both the BOOT mode and the Download mode
* We can determine which code is running by the reading the config

 @@ -2383,6 +2387,9 @@ static int edge_startup(struct usb_serial *serial)
  {
   struct edgeport_serial *edge_serial;
   int status;
 + const struct firmware *fw;
 + const char *fw_name = edgeport/down3.bin;
 + struct device *dev = serial-interface-dev;
  
   /* create our private serial structure */
   edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
 @@ -2393,7 +2400,17 @@ static int edge_startup(struct usb_serial *serial)
   edge_serial-serial = serial;
   usb_set_serial_data(serial, edge_serial);
  
 - status = download_fw(edge_serial);
 + status = request_firmware(fw, fw_name, dev);
 + if (status) {
 + dev_err(serial-interface-dev,

Why not use dev here as well?

 + %s - Failed to load image \%s\ err %d\n,
 + __func__, fw_name, status);

You can drop the function name here as well.

 + kfree(edge_serial);
 + return status;
 + }
 +
 + status = download_fw(edge_serial, fw);
 + release_firmware(fw);
   if (status) {
   kfree(edge_serial);
   return status;

Thanks,
Johan
--
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 v8 4/4] USB: io_ti: Add heartbeat to keep idle EP/416 ports from disconnecting

2015-07-30 Thread Johan Hovold
On Wed, Jul 22, 2015 at 01:56:16PM -0500, Peter E. Berger wrote:
 
 +static inline void edge_heartbeat_schedule(struct edgeport_serial 
 *edge_serial)
 +{
 + u16 product_id = le16_to_cpu(
 + edge_serial-serial-dev-descriptor.idProduct);
 +
 + /* Currently only the EP/416 models require heartbeat support */
 + if (product_id != ION_DEVICE_ID_TI_EDGEPORT_416 
 + product_id != ION_DEVICE_ID_TI_EDGEPORT_416B)
 + return;
 +
 + if (edge_serial-fw_version = FW_HEARTBEAT_VERSION_CUTOFF)
 + return;

Please do both these checks (product id and fw_version) once in
edge_startup and just set a flag in struct edgeport_serial (e.g. bool
use_heartbeat) that you check here.

 +
 + schedule_delayed_work(edge_serial-heartbeat_work,
 + FW_HEARTBEAT_SECS * HZ);
 +}

This series looks really good now. Care to fix these last few issues up
and I'll apply it for 4.3 in the next couple of days?

Thanks,
Johan
--
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 v4] usb: gadget: f_mass_storage: stop thread in bind failure case

2015-07-30 Thread Michal Nazarewicz
On Wed, Jul 22 2015, Sanjay Singh Rawat wrote:
 After the worker thread is launched, bind function is doing further
 configuration. In case of failure stop the thread.

 Signed-off-by: Sanjay Singh Rawat snjs...@gmail.com

Sorry for the delay.

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

 ---

 history:

 v3: - handled Michal's comment; used existing function to change state and
   exit thread.
 - tested for f_mass_storage.c only; dropped patches for legacy.

 v2: - Handled review comment from Michal.
   - Merged v2 patch-2/3/4 to make patch-2.
 - Added acked-by from Michal to patch-1.

 v1: - Handled review comments from Michal.
   - updated patch-2 : added thread wake in legacy client of function 
 (patch-2).
   - added patch-4 : freeing file-storage thread in configuration error 
 case.
 - added patch-3 (needed by patch-4) : moved fsg_common structure to 
 header
   file, as code is dereferencing common-thread_task.
 ---
  drivers/usb/gadget/function/f_mass_storage.c | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index f936268..c5b3db5 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3080,7 +3080,7 @@ static int fsg_bind(struct usb_configuration *c, struct 
 usb_function *f)
   /* New interface */
   i = usb_interface_id(c, f);
   if (i  0)
 - return i;
 + goto fail;
   fsg_intf_desc.bInterfaceNumber = i;
   fsg-interface_number = i;
  
 @@ -3123,7 +3123,14 @@ static int fsg_bind(struct usb_configuration *c, 
 struct usb_function *f)
  
  autoconf_fail:
   ERROR(fsg, unable to autoconfigure all endpoints\n);
 - return -ENOTSUPP;
 + i = -ENOTSUPP;
 +fail:
 + /* terminate the thread */
 + if (fsg-common-state != FSG_STATE_TERMINATED) {
 + raise_exception(fsg-common, FSG_STATE_EXIT);
 + wait_for_completion(fsg-common-thread_notifier);
 + }
 + return i;
  }
  
  /** ALLOCATE FUNCTION */
 -- 
 1.9.1


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


Inquiry

2015-07-30 Thread Khalid Grupo
Inquiry

Dear we are ATLANTIC TRADING DISTRIBUTING CO.LTD based in
Qatar,We are in need of your products, Urgently
please send to us your complete catalog / website ?in our email
address(khaledgr...@yahoo.com
Best regards,

Mr,khaled grupo

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


[GIT PULL] USB-serial fixes for v4.2-rc5

2015-07-30 Thread Johan Hovold
Hi Greg,

Here's a fix and some device ids for v4.2-rc5. All have been in
linux-next.

Thanks,
Johan

The following changes since commit 52721d9d3334c1cb1f76219a161084094ec634dc:

  Linux 4.2-rc3 (2015-07-19 14:45:02 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
tags/usb-serial-4.2-rc5

for you to fetch changes up to 74472233233f577eaa0ca6d6e17d9017b6e53150:

  USB: sierra: add 1199:68AB device ID (2015-07-28 09:27:50 +0200)


USB-serial fixes for v4.2-rc5

Here's a fix for some Sierra Wireless modems and a couple of new device
ids.

Signed-off-by: Johan Hovold jo...@kernel.org


Dirk Behme (1):
  USB: sierra: add 1199:68AB device ID

Pieter Hollants (1):
  USB: qcserial: Add support for Dell Wireless 5809e 4G Modem

Reinhard Speyerer (1):
  USB: qcserial/option: make AT URCs work for Sierra Wireless MC7305/MC7355

 drivers/usb/serial/option.c   | 2 ++
 drivers/usb/serial/qcserial.c | 2 +-
 drivers/usb/serial/sierra.c   | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)
--
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 v8 2/4] USB: io_ti: Fix firmware version handling

2015-07-30 Thread Peter Berger
On Thu, 2015-07-30 at 15:44 +0200, Johan Hovold wrote:
 On Wed, Jul 22, 2015 at 01:56:14PM -0500, Peter E. Berger wrote:
  From: Peter E. Berger pber...@brimson.com
  
  The io_ti driver fails to download firmware to Edgeport
  devices such as the EP/416, even when the on-disk firmware image
  (/lib/firmware/edgeport/down3.bin) is more current than the version
  on the EP/416.  The current download code is broken in a few ways.
  Notably it mis-uses global variables OperationalMajorVersion and
  OperationalMinorVersion (reading their values before they've been
  properly initialized and subsequently initializing them multiple times
  without synchronization).  This patch drops the global variables and
  replaces the redundant calls to request_firmware()/release_firmware()
  in download_fw() with a single call pair in edge_startup(); the firmware
  image pointer is then passed to download_fw() and build_i2c_fw_hdr().
  
  Signed-off-by: Peter E. Berger pber...@brimson.com
  ---
   drivers/usb/serial/io_ti.c | 115 
  ++---
   1 file changed, 66 insertions(+), 49 deletions(-)
  
  diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
  index 69378a7..6cff12c 100644
  --- a/drivers/usb/serial/io_ti.c
  +++ b/drivers/usb/serial/io_ti.c
  @@ -71,6 +71,25 @@ struct product_info {
  __u8hardware_type;  /* Type of hardware */
   } __attribute__((packed));
   
  +/*
  + * Edgeport firmware header
  + *
  + * build_number has been set to 0 in all three of the images I have
  + * seen, and Digi Tech Support suggests that it is safe to ignore it.
  + *
  + * length is the number of bytes of actual data following the header.
  + *
  + * checksum is the low order byte resulting from adding the values of
  + * all the data bytes.
  + */
  +struct edgeport_fw_hdr {
  +   u8 major_version;
  +   u8 minor_version;
  +   u16 build_number;
  +   u16 length;
 
 These should be __le16.

I'm on the road today, but I'll plan to make this and the other changes
that you and Sergei suggest when I get back tonight, so I hope to have a
v9 patchset to you by tomorrow.  At first glance all look easy for me to
implement, but I have a question about one below.

 
  +   u8 checksum;
  +} __packed;
  +
   struct edgeport_port {
  __u16 uart_base;
  __u16 dma_address;
 
  @@ -934,7 +934,8 @@ static int ti_cpu_rev(struct edge_ti_manuf_descriptor 
  *desc)
* This routine downloads the main operating code into the TI5052, using 
  the
* boot code already burned into E2PROM or ROM.
*/
  -static int download_fw(struct edgeport_serial *serial)
  +static int download_fw(struct edgeport_serial *serial,
  +   const struct firmware *fw)
   {
  struct device *dev = serial-serial-dev-dev;
  int status = 0;
  @@ -943,6 +944,17 @@ static int download_fw(struct edgeport_serial *serial)
  struct usb_interface_descriptor *interface;
  int download_cur_ver;
  int download_new_ver;
  +   struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data;
  +
  +   if (fw-size  sizeof(struct edgeport_fw_hdr)) {
 
 Missing le16_to_cpu on fw-size.

Hmmm... The fw-size refers to the size_t size element of struct
firmware (not to an element of edgeport_fw_hdr).  Are you saying that I
should change this to if (le16_to_cpu(fw-size)  sizeof... or did I
mistake your meaning?

I'll work on this and the other changes when I get back tonight and hope
to have a new patchset for you by tomorrow.

Thanks.
 --Peter

 
  +   dev_err(serial-serial-interface-dev,
  +   %s - Incomplete firmware header.\n, __func__);
 
 No need to include the function name here.
 
  +   return -EINVAL;
  +   }
  +
  +   /* If on-board version is newer, fw_version will be updated below. */
  +   serial-fw_version = (fw_hdr-major_version  8) +
  +   fw_hdr-minor_version;
   
  /* This routine is entered by both the BOOT mode and the Download mode
   * We can determine which code is running by the reading the config
 
  @@ -2383,6 +2387,9 @@ static int edge_startup(struct usb_serial *serial)
   {
  struct edgeport_serial *edge_serial;
  int status;
  +   const struct firmware *fw;
  +   const char *fw_name = edgeport/down3.bin;
  +   struct device *dev = serial-interface-dev;
   
  /* create our private serial structure */
  edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
  @@ -2393,7 +2400,17 @@ static int edge_startup(struct usb_serial *serial)
  edge_serial-serial = serial;
  usb_set_serial_data(serial, edge_serial);
   
  -   status = download_fw(edge_serial);
  +   status = request_firmware(fw, fw_name, dev);
  +   if (status) {
  +   dev_err(serial-interface-dev,
 
 Why not use dev here as well?
 
  +   %s - Failed to load image \%s\ err %d\n,
  +   __func__, fw_name, status);
 
 You can drop the function name 

Re: [PATCH v8 2/4] USB: io_ti: Fix firmware version handling

2015-07-30 Thread Johan Hovold
On Thu, Jul 30, 2015 at 10:28:05AM -0500, Peter Berger wrote:
 On Thu, 2015-07-30 at 15:44 +0200, Johan Hovold wrote:
  On Wed, Jul 22, 2015 at 01:56:14PM -0500, Peter E. Berger wrote:
   From: Peter E. Berger pber...@brimson.com

   @@ -943,6 +944,17 @@ static int download_fw(struct edgeport_serial 
   *serial)
 struct usb_interface_descriptor *interface;
 int download_cur_ver;
 int download_new_ver;
   + struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data;
   +
   + if (fw-size  sizeof(struct edgeport_fw_hdr)) {
  
  Missing le16_to_cpu on fw-size.
 
 Hmmm... The fw-size refers to the size_t size element of struct
 firmware (not to an element of edgeport_fw_hdr).  Are you saying that I
 should change this to if (le16_to_cpu(fw-size)  sizeof... or did I
 mistake your meaning?

My bad, I read it as fw_hdr-length. Sorry about that.

 I'll work on this and the other changes when I get back tonight and hope
 to have a new patchset for you by tomorrow.

Much appreciated.

Thanks,
Johan
--
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: I have run scripts/checkpatch.pl on my patch.The new patch attachment is at the bottom.//Re: We want to add commit device's PID,the following is the content of the patch.Patch attachment is at the

2015-07-30 Thread Johan Hovold
On Tue, Jul 28, 2015 at 06:55:57PM +0800, hu.bin...@zte.com.cn wrote:
 Dear Johan:
  Thank you for your reply me so quickly. 
As you say, I have done the following test and verify:
 1.I have run scripts/checkpatch.pl on my patch,and test result is OK.
 2. I have installed this patch,and test result is OK.
3.I have compiled the kernel code contains patch, and verified the 
 patch is correct.
 4.I have uninstall this patch,and test result is OK.
 
 The following is the new file attachment.If there anything is incorrect, 
 please let me know immediately,thank you.

Yes, please address the review comments below before resending in a
format that can be applied (send the patch as an inline mail, not as a
mime-attachment). And fix up the patch summary.

 On Sat, Jul 25, 2015 at 10:53:22AM +0800, hu.bin...@zte.com.cn wrote:
  Dear all:
  We want to add commit device's PID,we have been verified,the 
  following is the content of the patch,If there anything is incorrect, 
  please let me know immediately, thank you.
 
 Please read Documentation/SubmittingPatches for information on how to
 format and submit a patch. 
 
 Try sending the patch to yourself first and make sure to run
 scripts/checkpatch.pl on it afterwards.
 
 For an example what such a patch may look like, see:
 
  
 https://lkml.kernel.org/r/1413276457-19486-1-git-send-email-dnl...@gmail.com
 
 
  diff -urN ./linux-4.1.2/drivers/usb/serial/option.c 
  ./linux-4.1.2_plus/drivers/usb/serial/option.c
  --- ./linux-4.1.2/drivers/usb/serial/option.c   2015-07-10 
  12:50:06.0 -0400
  +++ ./linux-4.1.2_plus/drivers/usb/serial/option.c  2015-07-24 
  21:10:02.075090212 -0400
  @@ -285,6 +285,10 @@
   #define ZTE_PRODUCT_MC2718 0xffe8
   #define ZTE_PRODUCT_AD3812 0xffeb
   #define ZTE_PRODUCT_MC2716 0xffed
  +#define ZTE_PRODUCT_ZM8620_X   0x0396
  +#define ZTE_PRODUCT_ME3620_X   0x1432
  +#define ZTE_PRODUCT_ME3620_L   0x1433
  +#define ZTE_PRODUCT_ME3620_MBIM0x0426
 
 Try to keep the entries ordered by PID.
 
   #define BENQ_VENDOR_ID 0x04a5
   #define BENQ_PRODUCT_H10   0x4068
  @@ -544,6 +548,23 @@
  .sendsetup = BIT(1) | BIT(2) | BIT(3),
   };
  
  +static const struct option_blacklist_info zte_zm8620_x_blacklist = {
  +   .reserved = BIT(3) | BIT(4) | BIT(5),
  +};
  +
  +static const struct option_blacklist_info zte_me3620_x_blacklist = {
  +   .reserved = BIT(3) | BIT(4) | BIT(5),
  +};
  +
  +static const struct option_blacklist_info zte_me3620_l_blacklist = {
  +   .reserved = BIT(3) | BIT(4) | BIT(5),
  +};
 
 Could you reuse the same blacklist for related devices perhaps?
 
  +static const struct option_blacklist_info zte_me3620_mbim_blacklist = {
  +   .reserved = BIT(2) | BIT(3) | BIT(4),
  +};
 
 And try to keep blacklist entries you add sorted by symbol name.
 
  +
  +
   static const struct option_blacklist_info huawei_cdc12_blacklist = {
  .reserved = BIT(1) | BIT(2),
   };
  @@ -1592,6 +1613,14 @@
  { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) 
 
  },
  { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) 
 
  },
  { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) 
 
  },
  +   { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ZM8620_X),
  +   .driver_info = (kernel_ulong_t)zte_zm8620_x_blacklist 
 },
  +   { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ME3620_X),
  +   .driver_info = (kernel_ulong_t)zte_me3620_x_blacklist 
 },
  +   { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ME3620_L),
  +   .driver_info = (kernel_ulong_t)zte_me3620_l_blacklist 
 },
  +   { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ME3620_MBIM),
  +   .driver_info = 
 (kernel_ulong_t)zte_me3620_mbim_blacklist 
  },
 
 Should be sorted by PID symbol whenever possible.
 
  { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
  { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
  
  
  
  
  一一一
  胡滨 Hu Bin
  产品研发一部 Product RD Dept Ⅰ.
  
  Tel: +86-029-83636981
  MP: +86-17792055220
  Email: hu.bin...@zte.com.cn
  Website: www.ztewelink.com
  Add: 西安市长安区西沣路五星段9号 1A3-56
  
  ZTE Information Security Notice: The information contained in this mail 
 (and any attachment transmitted herewith) is privileged and confidential 
 and is intended for the exclusive use of the addressee(s).  If you are not 
 an intended recipient, any disclosure, reproduction, distribution or other 
 dissemination or use of the information contained is strictly prohibited. 
 If you have received this mail in error, please delete it and notify us 
 immediately.
 
 Please make sure not to include such headers when posting to public
 mailing 

Inquiry

2015-07-30 Thread Khalid Grupo
Inquiry

Dear we are ATLANTIC TRADING DISTRIBUTING CO.LTD based in
Qatar,We are in need of your products, Urgently
please send to us your complete catalog / website ?in our email
address(khaledgr...@yahoo.com
Best regards,

Mr,khaled grupo

Purchase Manager
--
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 net v3 0/2] r8152: device reset

2015-07-30 Thread David Miller
From: Hayes Wang hayesw...@realtek.com
Date: Wed, 29 Jul 2015 20:39:07 +0800

 v3:
 For patch #2, remove cancel_delayed_work().
 
 v2:
 For patch #1, remove usb_autopm_get_interface(), usb_autopm_put_interface(), 
 and
 the checking of intf-condition.
 
 For patch #2, replace the original method with usb_queue_reset_device() to 
 reset
 the device. 
 
 v1:
 Although the driver works normally, we find the device may get all 0xff data 
 when
 transmitting packets on certain platforms. It would break the device and no 
 packet
 could be transmitted. The reset is necessary to recover the hw for this 
 situation.

Series applied, thanks.
--
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: Multiple drives on JMS56x-based sata-usb docking station.

2015-07-30 Thread Giulio Bernardi

On 31/07/2015 00:12, Giulio Bernardi wrote:

On 30/07/2015 23:42, Giulio Bernardi wrote:

On 27/07/2015 16:28, Alan Stern wrote:

On Mon, 27 Jul 2015, Giulio Bernardi wrote:


Sorry for the late reply, but it took me a little bit to recompile the kernel
(my laptop is slow) and I was not able to obtain any meaningful results (please
note I know nothing about kernel internals).

However, i filled scsi_sequential_lun_scan() with printk's but none of them
appeared (yes, I did echo 7  /proc/sys/kernel/printk).
So I enabled logging for SCSI scan bus (echo 448 
/proc/sys/dev/scsi/logging_level) and I did not see message scsi scan:
Sequential scan\n appearing. So I thought scsi_sequential_lun_scan() was not
being called.


That's strange.  If you look at __scsi_scan_target(), you'll see that
the code calls scsi_probe_and_add_lun() for LUN 0, then it calls
scsi_report_lun_scan() (which should return 1), and then it calls
scsi_sequential_lun_scan().

You should check that scsi_report_lun_scan() really does return 1.  If
it returns 0 instead (because BLIST_NOLUN is set in bflags or for any
other reason), that would cause the behavior you see.



I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed.
It is a bug in scsi_get_device_flags_keyed():
In fact, my device reports these strings for model and vendor:
vendor = Inateck 0101
model = 0101
and this matches with this entry in the global scsi device list:
{, Scanner, 1.80, BLIST_NOLUN}
In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so
memcmp always passes, and the check on model passes because the code assumes
that max length of model is 16: when trimming the string (which is exactly 16
spaces followed by 0101) it ends up with an empty string, which then matches
whatever string for the same reason of the previous check.
I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it
works, but I don't know if other devices do exist with a longer model string.
Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not
for USB devices?

However, who should I notify about the issue? linux-scsi mailing list? bugzilla?

Thank you again for the support, I wouldn't have been able to discover this
alone.



It looks like I talked too soon. Now it scans for lun1 also, but then I have 
this:

kernel: scsi 6:0:0:1: scsi scan: INQUIRY pass 1 length 36
kernel: scsi 6:0:0:1: scsi scan: INQUIRY failed with code 0x4

Giulio


Sorry, forget this last message, one of the two drives got undocked. I 
reattached it and it works properly.

--
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: Multiple drives on JMS56x-based sata-usb docking station.

2015-07-30 Thread Giulio Bernardi

On 27/07/2015 16:28, Alan Stern wrote:

On Mon, 27 Jul 2015, Giulio Bernardi wrote:


Sorry for the late reply, but it took me a little bit to recompile the kernel
(my laptop is slow) and I was not able to obtain any meaningful results (please
note I know nothing about kernel internals).

However, i filled scsi_sequential_lun_scan() with printk's but none of them
appeared (yes, I did echo 7  /proc/sys/kernel/printk).
So I enabled logging for SCSI scan bus (echo 448 
/proc/sys/dev/scsi/logging_level) and I did not see message scsi scan:
Sequential scan\n appearing. So I thought scsi_sequential_lun_scan() was not
being called.


That's strange.  If you look at __scsi_scan_target(), you'll see that
the code calls scsi_probe_and_add_lun() for LUN 0, then it calls
scsi_report_lun_scan() (which should return 1), and then it calls
scsi_sequential_lun_scan().

You should check that scsi_report_lun_scan() really does return 1.  If
it returns 0 instead (because BLIST_NOLUN is set in bflags or for any
other reason), that would cause the behavior you see.



I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed.
It is a bug in scsi_get_device_flags_keyed():
In fact, my device reports these strings for model and vendor:
vendor = Inateck 0101
model = 0101
and this matches with this entry in the global scsi device list:
{, Scanner, 1.80, BLIST_NOLUN}
In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so 
memcmp always passes, and the check on model passes because the code assumes 
that max length of model is 16: when trimming the string (which is exactly 16 
spaces followed by 0101) it ends up with an empty string, which then matches 
whatever string for the same reason of the previous check.
I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it 
works, but I don't know if other devices do exist with a longer model string. 
Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not 
for USB devices?


However, who should I notify about the issue? linux-scsi mailing list? bugzilla?

Thank you again for the support, I wouldn't have been able to discover this 
alone.

--
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: chipidea: add ci-is_otg condition for otg judgement

2015-07-30 Thread Li Jun
Since some chipidea based controller is not otg capable, add ci-is_otg
condition when setting is_otg flag for gadget.

Signed-off-by: Li Jun jun...@freescale.com
Reviewed-by: Roger Quadros rog...@ti.com
Acked-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 61fde89..c6d1595 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1838,8 +1838,8 @@ static int udc_start(struct ci_hdrc *ci)
ci-gadget.name = ci-platdata-name;
ci-gadget.otg_caps = otg_caps;
 
-   if (otg_caps-hnp_support || otg_caps-srp_support ||
-   otg_caps-adp_support)
+   if (ci-is_otg  (otg_caps-hnp_support || otg_caps-srp_support ||
+   otg_caps-adp_support))
ci-gadget.is_otg = 1;
 
INIT_LIST_HEAD(ci-gadget.ep_list);
-- 
1.9.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 net-next] r8152: disable the capability of zero length

2015-07-30 Thread Hayes Wang
The UEFI driver would enable zero length, and the Linux driver doesn't
need it. Zero length let the hw complete the transfer with length 0,
when there is no received packet. It would add the load of USB host
controller and reduce the performance.

Signed-off-by: Hayes Wang hayesw...@realtek.com
---
 drivers/net/usb/r8152.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 57b72ec..348652a 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -339,6 +339,7 @@
 
 /* USB_USB_CTRL */
 #define RX_AGG_DISABLE 0x0010
+#define RX_ZERO_EN 0x0080
 
 /* USB_U2P3_CTRL */
 #define U2P3_ENABLE0x0001
@@ -2705,7 +2706,7 @@ static void r8153_first_init(struct r8152 *tp)
 
/* rx aggregation */
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
-   ocp_data = ~RX_AGG_DISABLE;
+   ocp_data = ~(RX_AGG_DISABLE | RX_ZERO_EN);
ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 }
 
@@ -3227,7 +3228,7 @@ static void r8152b_init(struct r8152 *tp)
 
/* enable rx aggregation */
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
-   ocp_data = ~RX_AGG_DISABLE;
+   ocp_data = ~(RX_AGG_DISABLE | RX_ZERO_EN);
ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 }
 
-- 
2.4.2

--
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: Bug with USB 3.0 in Modul xhci_hcd

2015-07-30 Thread Greg KH
On Fri, Jul 31, 2015 at 03:49:02AM +0200, schorsch wrote:
 https://bugzilla.kernel.org/show_bug.cgi?id=89471#c2

Please send the full information here so that we don't have to try to
track down some random web link...
--
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] drivers/usb/: Simplify return statements

2015-07-30 Thread Karajgaonkar, Saurabh (S.)
Sure, I'll do that. Just wanted to know whether I should split the patches and
send them in this same mail thread (may be something like [PATCH 01/04 V2])
or should I start new threads and send them separately to the respective 
maintainers.

Thanks and Regards,
Saurabh Karajgaonkar

On Thu, Jul 30, 2015 at 11:25:27AM -0500, Felipe Balbi wrote:
 On Thu, Jul 30, 2015 at 01:13:42PM +, Karajgaonkar, Saurabh (S.) wrote:
  From: Saurabh Karajgaonkar skara...@visteon.com
  
  This patch is created using simple_return.cocci coccinelle script.
  It replaces the redundant instances where variables are assigned
  return value from functions and then used in return statements.
  
  Signed-off-by: Saurabh Karajgaonkar skara...@visteon.com
 
 do you mind splitting this per-driver ? That makes it a lot easier for
 different maintainers to take their part. For example, I would take
 drivers/usb/phy/* and drivers/usb/musb/*
 
 Alan Stern would handle drivers/usb/host/[uoe]hci*.[ch]
 
 Mathias Nyman, driver/usb/host/xhci*.[ch]
 
 and so on. Thanks
 
 -- 
 balbi

--
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/1] lsusb: Fix issue with lengthy string descriptors

2015-07-30 Thread Muthu M
Fixed the issue in displaying lengthy string descriptor (more than 128 bytes)

Signed-off-by: Muthu M muthu@gmail.com
---
 usbmisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usbmisc.c b/usbmisc.c
index f3577ea..71a702c 100644
--- a/usbmisc.c
+++ b/usbmisc.c
@@ -229,7 +229,7 @@ char *get_dev_string(libusb_device_handle *dev, u_int8_t id)
   sizeof unicode_buf);
if (ret  2) return strdup((error));
 
-   if (unicode_buf[0]  2 || unicode_buf[1] != LIBUSB_DT_STRING)
+   if ((unsigned char)unicode_buf[0]  2 || unicode_buf[1] != 
LIBUSB_DT_STRING)
return strdup((error));
 
buf = usb_string_to_native(unicode_buf + 2,
-- 
1.8.3.2

--
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] USB: pl2303: Rewrite pl2303_encode_baud_rate_divisor

2015-07-30 Thread Johan Hovold
On Sun, Jul 26, 2015 at 11:14:34AM +0200, Michał Pecio wrote:
 
 This commit fixes the following issues:
 
 1. The 9th bit of buf was believed to be the LSB of divisor's
 exponent, but the hardware interprets it as MSB (9th bit) of the
 mantissa. The exponent is actually one bit shorter and applies
 to base 4, not 2 as previously believed.
 
 2. Loop iterations doubled the exponent instead of incrementing.
 
 3. The exponent wasn't checked for overflow.
 
 4. The function returned requested rate instead of actual rate.
 
 Due to issue #2, the old code deviated from the wrong formula
 described in #1 and actually yielded correct rates when divisor
 was lower than 4096 by using exponents of 0, 2 or 4 base-2,
 interpreted as 0, 1, 2 base-4 with the 9th mantissa bit clear.
 However, at 93.75 kbaud or less the rate turned out too slow
 due to #2 or too fast due to #2 and #3.
 
 I tested this patch by sending and validating 0x00,0x01,..,0xff
 to an FTDI dongle at 234, 987, 2401, 9601, 31415, 115199, 250k,
 500k, 750k, 1M, 1.5M, 3M+1 baud. All rates passed.
 
 I also used pv to check speed at some rates unsupported by FTDI:
 45 (the lowest possible), 2M, 4M, 5M and 6M-1. Looked sane.
 
 Signed-off-by: Michal Pecio michal.pe...@gmail.com

Now applied for 4.3 with stable tag for 3.18+. [ Low, non-standard
baudrates were first enabled by 399aa9a75ad3 (USB: pl2303: use divisors
for unsupported baud rates ].

Again, thanks for fixing this.

Johan
--
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: [GIT PULL] USB-serial fixes for v4.2-rc5

2015-07-30 Thread Greg Kroah-Hartman
On Thu, Jul 30, 2015 at 04:46:12PM +0200, Johan Hovold wrote:
 Hi Greg,
 
 Here's a fix and some device ids for v4.2-rc5. All have been in
 linux-next.
 
 Thanks,
 Johan
 
 The following changes since commit 52721d9d3334c1cb1f76219a161084094ec634dc:
 
   Linux 4.2-rc3 (2015-07-19 14:45:02 -0700)
 
 are available in the git repository at:
 
   git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
 tags/usb-serial-4.2-rc5

Pulled and pushed out, 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] usb: gadget: mass_storage: Use static array for luns

2015-07-30 Thread Felipe Balbi
Hi,

On Thu, Jul 23, 2015 at 07:57:49PM +0200, Krzysztof Opasiak wrote:
 This patch replace dynamicly allocated luns array with static one.
 This simplifies the code of mass storage function and modules.
 
 Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com
 Acked-by: Michal Nazarewicz min...@mina86.com

this actually regresses g_mass_storage:

# modprobe g_mass_storage removable=1
[   40.115294] Mass Storage Function, version: 2009/09/11
[   40.120680] LUN: removable file: (no medium)
[   40.125374] Unable to handle kernel NULL pointer dereference at virtual 
address 0054
[   40.133863] pgd = ed574000
[   40.136689] [0054] *pgd=
[   40.140429] Internal error: Oops: 5 [#1] SMP ARM
[   40.145238] Modules linked in: g_mass_storage(+) usb_f_mass_storage 
libcomposite xhci_plat_hcd xhci_hcd usbcore joydev dwc3 udc_core usb_common 
evdev cpufreq_dt omapfb snd_soc_evm thermal_sys cfbfillrect cfbimgblt 
cfbcopyarea matrix_keypad hwmon leds_gpio led_class matrix_keymap pwm_bl 
panel_dpi snd_soc_tlv320aic3x snd_soc_davinci_mcasp snd_soc_edma snd_soc_omap 
snd_soc_core omapdss snd_compress snd_pcm_dmaengine snd_pcm dwc3_omap snd_timer 
lis3lv02d_i2c extcon pwm_tiecap snd lis3lv02d input_polldev soundcore rtc_omap 
spi_ti_qspi omap_wdt tps65218_pwrbutton phy_omap_usb2 ipv6 autofs4
[   40.199522] CPU: 0 PID: 244 Comm: modprobe Not tainted 
4.2.0-rc4-00060-g691ddfcf5846 #755
[   40.208039] Hardware name: Generic AM43 (Flattened Device Tree)
[   40.214210] task: ed01e240 ti: ee7be000 task.ti: ee7be000
[   40.219843] PC is at kernfs_find_ns+0xc/0x138
[   40.224381] LR is at kernfs_find_and_get_ns+0x30/0x4c
[   40.229649] pc : [c01de508]lr : [c01de664]psr: 200f0013
[   40.229649] sp : ee7bfc68  ip : 0002  fp : bf0aa740
[   40.241609] r10: bf0aa788  r9 : ed3353c0  r8 : 
[   40.247055] r7 :   r6 : c06466a4  r5 :   r4 : c0917840
[   40.253851] r3 : c093c5d4  r2 :   r1 : c06466a4  r0 : 
[   40.260651] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[   40.268085] Control: 10c5387d  Table: ad574059  DAC: 0015
[   40.274069] Process modprobe (pid: 244, stack limit = 0xee7be218)
[   40.280415] Stack: (0xee7bfc68 to 0xee7c)
[   40.284959] fc60:   c0917840  c06466a4  
ed214400 c01de664
[   40.293478] fc80:  c09474d0 ee56f438 ee56f430  c01e13d4 
 c09474a0
[   40.301996] fca0: ee56f438 c03f6384 ee56f430 ee56f430 ed214598 c03ec6d0 
bf0aa788 c008e820
[   40.310519] fcc0: c015a7d4 ed01e240 ee56f430 ed2144d0 ed214598 ed21450c 
ed214400 c03ec8b8
[   40.319048] fce0: ee56f400 bf10f304 ee533e00 ee533e04 bf0aa980 bf0aa54c 
0001 bf10f374
[   40.327572] fd00: bf115840 bf07ec18 fff0 bf0aa0a0 c05fe878 0001 
 0100
[   40.336089] fd20: ed506098    bf2f8528 c0979e80 
600f0093 c0091548
[   40.344612] fd40: 0001 0080  bf2f8528  ed01e768 
ed01e240 0004
[   40.353137] fd60: 0006 12d341e8 bf0aa788 c008e820 c06008b8 ed01e240 
0001 bf0aa694
[   40.361654] fd80:  c008e984 a00f0013 ed506088 ed506088 c06008b8 
 
[   40.370172] fda0:   ed335301 0002  ed3353c0 
bf0aa6bc 
[   40.378690] fdc0: ed506170  12d341e8 bf07ea84 bf2e7d08 ee53b000 
bf0aa6bc ee53b000
[   40.387207] fde0: bf0aa6bc ed2cbd00 ee53b008  12d341e8 bf0aa788 
bf0aa740 bf2e7b90
[   40.395724] fe00:  bf2e8308 bf0aa6bc ed2cbd00 bf0b bf2e7d44 
 c08c9ea0
[   40.404241] fe20: c08c9ea0 c00097a4 0001   c0150fe4 
 eeef9000
[   40.412766] fe40: ef7c8460 4000 001e c008ec68 ee5e1e40 00d0 
00d0 c015ba10
[   40.421283] fe60: ee7bff58 c008ec68 c08c63a8 600f0013 a00f0013 bf0aa740 
bf0aa740 c0979fd4
[   40.429811] fe80: ee5e1e40 ed2cbe40 0001 bf0aa788 bf0aa740 c05f7d28 
c0979fd4 0001
[   40.438334] fea0: ee7bff58 c0979fd4 0001 c00c88c4 bf0aa74c 7fff 
 c00c606c
[   40.446857] fec0: c1153024 0124 bf0aa74c bf0aa95c ee7bff60 f03a29a4 
bf0aa74c 
[   40.455381] fee0: 02e401dd  000f 000181a4 0001  
 
[   40.463900] ff00:       
 
[   40.472424] ff20:     7f643410  
0005 7f643410
[   40.480941] ff40: 017b c000f724 ee7be000  7f6431c8 c00c91c0 
f0385000 0001d9f4
[   40.489471] ff60: f03a2314 f039a942 f039b5e0 09a8 0e38  
 
[   40.497993] ff80: 002a 002b 0012 0016 000b  
 000b
[   40.506537] ffa0: 000b c000f540  000b 0005 7f643410 
 7f6431b0
[   40.515062] ffc0:  000b 000b 017b 0004 000b 
000b 7f6431c8
[   40.523579] ffe0: bea6a9a0 bea6a990 7f62643f b6f52812 600f0030 0005 
0001bccc 0098b800
[   40.532117] [c01de508] 

Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Javier Martinez Canillas
Hello Dmitry,

Thanks a lot for your feedback.

On 07/30/2015 06:37 PM, Dmitry Torokhov wrote:
 On Thu, Jul 30, 2015 at 09:35:17AM -0700, Dmitry Torokhov wrote:
 Hi Javier,

 On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
 Hello,

 Short version:

 This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
 to export that information so modules have the correct aliases built-in
 and autoloading works correctly.

 Longer version:

 Currently it's mandatory for I2C drivers to have an I2C device ID table
 regardless if the device was registered using platform data or OF. This
 is because the I2C core needs an I2C device ID table for two reasons:

 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
is passed to the I2C driver probe() function.

 2) Export the module aliases from the I2C device ID table so userspace
can auto-load the correct module. This is because i2c_device_uevent
always reports a MODALIAS of the form i2c:client-name.

 Why are we not fixing this? We emit specially carved uevent for
 ACPI-based devices, why not the same for OF? Platform bus does this...
 
 Ah, now I see the 27/27 patch. I think it is exactly what we need. And

Yes, patch 27/27 is needed but the problem is as I explained before that
there are drivers relying on the current behavior. The item c) in the list
of issues that I mentioned. So those drivers need to be fixed before that
patch is merged...

 probably for SPI bus as well.


Yes, I didn't mention SPI because the cover letter became too long
already but it does indeed have the same issue and I discussed this
with  Mark already some time ago [0].

Once I2C uevent report is fixed, I plan to do the same for SPI.

 Thanks.
 

[0]: https://lkml.org/lkml/2014/9/11/458

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
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 4/7] usb: interface authorization: Introduces the USB interface authorization

2015-07-30 Thread Stefan Koch
The kernel supports the device authorization because of wireless USB.
These is usable for wired USB devices, too.
These new interface authorization allows to enable or disable
individual interfaces instead a whole device.

If a deauthorized interface will be authorized so the driver probing must
be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe

Signed-off-by: Stefan Koch sk...@suse.de
---
 drivers/usb/core/message.c | 38 ++
 drivers/usb/core/usb.h |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 3d25d89..c090f50 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1555,6 +1555,44 @@ static void usb_release_interface(struct device *dev)
kfree(intf);
 }
 
+/*
+ * usb_deauthorize_interface - deauthorize an USB interface
+ *
+ * @intf: USB interface structure
+ */
+void usb_deauthorize_interface(struct usb_interface *intf)
+{
+   struct device *dev = intf-dev;
+
+   device_lock(dev-parent);
+
+   if (intf-authorized) {
+   device_lock(dev);
+   intf-authorized = 0;
+   device_unlock(dev);
+
+   usb_forced_unbind_intf(intf);
+   }
+
+   device_unlock(dev-parent);
+}
+
+/*
+ * usb_authorize_interface - authorize an USB interface
+ *
+ * @intf: USB interface structure
+ */
+void usb_authorize_interface(struct usb_interface *intf)
+{
+   struct device *dev = intf-dev;
+
+   if (!intf-authorized) {
+   device_lock(dev);
+   intf-authorized = 1; /* authorize interface */
+   device_unlock(dev);
+   }
+}
+
 static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
struct usb_device *usb_dev;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 457255a..05b5e17 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -27,6 +27,8 @@ extern void usb_release_interface_cache(struct kref *ref);
 extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
 extern int usb_deauthorize_device(struct usb_device *);
 extern int usb_authorize_device(struct usb_device *);
+extern void usb_deauthorize_interface(struct usb_interface *);
+extern void usb_authorize_interface(struct usb_interface *);
 extern void usb_detect_quirks(struct usb_device *udev);
 extern void usb_detect_interface_quirks(struct usb_device *udev);
 extern int usb_remove_device(struct usb_device *udev);
-- 
2.1.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 v8 5/7] usb: interface authorization: SysFS part of USB interface authorization

2015-07-30 Thread Stefan Koch
This introduces an attribute for each interface to
authorize (1) or deauthorize (0) it:
/sys/bus/usb/devices/INTERFACE/authorized

Signed-off-by: Stefan Koch sk...@suse.de
---
 drivers/usb/core/sysfs.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index d269738..3ddaada 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -926,6 +926,41 @@ static ssize_t supports_autosuspend_show(struct device 
*dev,
 }
 static DEVICE_ATTR_RO(supports_autosuspend);
 
+/*
+ * interface_authorized_show - show authorization status of an USB interface
+ * 1 is authorized, 0 is deauthorized
+ */
+static ssize_t interface_authorized_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_interface *intf = to_usb_interface(dev);
+
+   return sprintf(buf, %u\n, intf-authorized);
+}
+
+/*
+ * interface_authorized_store - authorize or deauthorize an USB interface
+ */
+static ssize_t interface_authorized_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct usb_interface *intf = to_usb_interface(dev);
+   bool val;
+
+   if (strtobool(buf, val) != 0)
+   return -EINVAL;
+
+   if (val)
+   usb_authorize_interface(intf);
+   else
+   usb_deauthorize_interface(intf);
+
+   return count;
+}
+static struct device_attribute dev_attr_interface_authorized =
+   __ATTR(authorized, S_IRUGO | S_IWUSR,
+   interface_authorized_show, interface_authorized_store);
+
 static struct attribute *intf_attrs[] = {
dev_attr_bInterfaceNumber.attr,
dev_attr_bAlternateSetting.attr,
@@ -935,6 +970,7 @@ static struct attribute *intf_attrs[] = {
dev_attr_bInterfaceProtocol.attr,
dev_attr_modalias.attr,
dev_attr_supports_autosuspend.attr,
+   dev_attr_interface_authorized.attr,
NULL,
 };
 static struct attribute_group intf_attr_grp = {
-- 
2.1.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 v8 2/7] usb: interface authorization: Introduces the default interface authorization

2015-07-30 Thread Stefan Koch
Interfaces are allowed per default.
This can disabled or enabled (again) by writing 0 or 1 to
/sys/bus/usb/devices/usbX/interface_authorized_default

Signed-off-by: Stefan Koch sk...@suse.de
---
 drivers/usb/core/hcd.c | 47 ++
 drivers/usb/core/message.c |  1 +
 include/linux/usb/hcd.h|  3 +++
 3 files changed, 51 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index cbcd092..84b5923 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -882,9 +882,53 @@ static ssize_t authorized_default_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(authorized_default);
 
+/*
+ * interface_authorized_default_show - show default authorization status
+ * for USB interfaces
+ *
+ * note: interface_authorized_default is the default value
+ *   for initializing the authorized attribute of interfaces
+ */
+static ssize_t interface_authorized_default_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_device *usb_dev = to_usb_device(dev);
+   struct usb_hcd *hcd = bus_to_hcd(usb_dev-bus);
+
+   return sprintf(buf, %u\n, !!HCD_INTF_AUTHORIZED(hcd));
+}
+
+/*
+ * interface_authorized_default_store - store default authorization status
+ * for USB interfaces
+ *
+ * note: interface_authorized_default is the default value
+ *   for initializing the authorized attribute of interfaces
+ */
+static ssize_t interface_authorized_default_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct usb_device *usb_dev = to_usb_device(dev);
+   struct usb_hcd *hcd = bus_to_hcd(usb_dev-bus);
+   int rc = count;
+   bool val;
+
+   if (strtobool(buf, val) != 0)
+   return -EINVAL;
+
+   if (val)
+   set_bit(HCD_FLAG_INTF_AUTHORIZED, hcd-flags);
+   else
+   clear_bit(HCD_FLAG_INTF_AUTHORIZED, hcd-flags);
+
+   return rc;
+}
+static DEVICE_ATTR_RW(interface_authorized_default);
+
 /* Group all the USB bus attributes */
 static struct attribute *usb_bus_attrs[] = {
dev_attr_authorized_default.attr,
+   dev_attr_interface_authorized_default.attr,
NULL,
 };
 
@@ -2682,6 +2726,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
hcd-authorized_default = authorized_default;
set_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags);
 
+   /* per default all interfaces are authorized */
+   set_bit(HCD_FLAG_INTF_AUTHORIZED, hcd-flags);
+
/* HC is in reset state, but accessible.  Now do the one-time init,
 * bottom up so that hcds can customize the root hubs before hub_wq
 * starts talking to them.  (Note, bus id is assigned early too.)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f368d20..3d25d89 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1807,6 +1807,7 @@ free_interfaces:
intfc = cp-intf_cache[i];
intf-altsetting = intfc-altsetting;
intf-num_altsetting = intfc-num_altsetting;
+   intf-authorized = !!HCD_INTF_AUTHORIZED(hcd);
kref_get(intfc-ref);
 
alt = usb_altnum_to_altsetting(intf, 0);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index c9aa779..7b8ddae 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -120,6 +120,7 @@ struct usb_hcd {
 #define HCD_FLAG_WAKEUP_PENDING4   /* root hub is 
resuming? */
 #define HCD_FLAG_RH_RUNNING5   /* root hub is running? */
 #define HCD_FLAG_DEAD  6   /* controller has died? */
+#define HCD_FLAG_INTF_AUTHORIZED   8   /* authorize interfaces? */
 
/* The flags can be tested using these macros; they are likely to
 * be slightly faster than test_bit().
@@ -130,6 +131,8 @@ struct usb_hcd {
 #define HCD_WAKEUP_PENDING(hcd)((hcd)-flags  (1U  
HCD_FLAG_WAKEUP_PENDING))
 #define HCD_RH_RUNNING(hcd)((hcd)-flags  (1U  HCD_FLAG_RH_RUNNING))
 #define HCD_DEAD(hcd)  ((hcd)-flags  (1U  HCD_FLAG_DEAD))
+#define HCD_INTF_AUTHORIZED(hcd) \
+   ((hcd)-flags  (1U  HCD_FLAG_INTF_AUTHORIZED))
 
/* Flags that get set only during HCD registration or removal. */
unsignedrh_registered:1;/* is root hub registered? */
-- 
2.1.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 v8 3/7] usb: interface authorization: Control interface probing and claiming

2015-07-30 Thread Stefan Koch
Driver probings and interface claims get rejected
if an interface is not authorized.

Signed-off-by: Stefan Koch sk...@suse.de
---
 drivers/usb/core/driver.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 818369a..d542d43 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -295,6 +295,10 @@ static int usb_probe_interface(struct device *dev)
if (udev-authorized == 0) {
dev_err(intf-dev, Device is not authorized for usage\n);
return error;
+   } else if (intf-authorized == 0) {
+   dev_err(intf-dev, Interface %d is not authorized for 
usage\n,
+   intf-altsetting-desc.bInterfaceNumber);
+   return error;
}
 
id = usb_match_dynamic_id(intf, driver);
@@ -507,6 +511,10 @@ int usb_driver_claim_interface(struct usb_driver *driver,
if (dev-driver)
return -EBUSY;
 
+   /* reject claim if not iterface is not authorized */
+   if (!iface-authorized)
+   return -ENODEV;
+
udev = interface_to_usbdev(iface);
 
dev-driver = driver-drvwrap.driver;
-- 
2.1.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 v3] usb: chipidea: Use extcon framework for VBUS and ID detect

2015-07-30 Thread Ivan T. Ivanov

On Wed, 2015-07-29 at 12:10 -0700, Tim Bird wrote:
 On Tue, Jun 2, 2015 at 6:14 AM, Ivan T. Ivanov iva...@linaro.org wrote:
  On recent Qualcomm platforms VBUS and ID lines are not routed to
  USB PHY LINK controller. Use extcon framework to receive connect
  and disconnect ID and VBUS notification.
  
  Signed-off-by: Ivan T. Ivanov iva...@linaro.org
  ---
  Changes sice v2 [1].
  
  * Simulate IRQ on extcon event - used to trigger OTG state machine.
  
  I have to admit that I couldn't test complete Chipidea OTG state machine,
  because my setup is little weird. I am using qcom,usb-otg-ci as PHY/OTG
  provider, qcom,ehci-host as host controller driver and qcom,ci-hdrc for
  device role.
 
 Ivan,
 
 Do you have patches for the code (presumably pmic code) where the vbus and id
 lines are signaled?  Presumably you've added some extcon_set_cable_state() 
 calls
 somewhere in your source tree, for this to work.  I'm wondering if you
 can share your
 work in progress, or let me know when you plan to push that upstream?
 

Well, not exactly. Maybe change description is badly worded. 
I have DB410c where VBUS and ID lines are not routed to USB controller, 
but to GPIO. So from the chipidea core driver point of view ID and VBUS
changes/IRQs are triggered from extcon driver linux,extcon-usb-gpio

 I'm interested in testing the msm usb code (specifically host mode support)
 on my dragonboard here.
 

Since yesterday, Felipe kindly merged simple usb-phy driver for 8x16[1].
Which allow just using qcom,ci-hdrc and qcom,usb-8x16-phy to have
DRD support on 8x16 chipsets. I have tried to use chipidea,usb2, but 
unfortunately quirks in qcom,ci-hdrc are required.

Once we have similar usb-phy drivers for 8x60, 8064, 8074 and 8084,
I believe the we can remove qcom,usb-otg-xxx monster. 

usb-phy driver for 8074 should be very similar to 8x16 one.

Regards,
Ivan

[1] http://bit.ly/1U6IjK4


--
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 v4 04/46] staging: emxx_udc: add ep capabilities support

2015-07-30 Thread Robert Baldyga
On 07/29/2015 05:20 PM, Felipe Balbi wrote:
 On Mon, Jul 27, 2015 at 11:16:14AM +0200, Robert Baldyga wrote:
 Convert endpoint configuration to new capabilities model.

 Fixed typo in epc-nulk to epc-bulk.

 Signed-off-by: Robert Baldyga r.bald...@samsung.com
 ---
  drivers/staging/emxx_udc/emxx_udc.c | 60 
 ++---
  1 file changed, 29 insertions(+), 31 deletions(-)

 diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
 b/drivers/staging/emxx_udc/emxx_udc.c
 index 3b7aa36..0d64bee 100644
 --- a/drivers/staging/emxx_udc/emxx_udc.c
 +++ b/drivers/staging/emxx_udc/emxx_udc.c
 @@ -3153,36 +3153,33 @@ static const struct usb_gadget_ops nbu2ss_gadget_ops 
 = {
  .ioctl  = nbu2ss_gad_ioctl,
  };
  
 -static const char g_ep0_name[] = ep0;
 -static const char g_ep1_name[] = ep1-bulk;
 -static const char g_ep2_name[] = ep2-bulk;
 -static const char g_ep3_name[] = ep3in-int;
 -static const char g_ep4_name[] = ep4-iso;
 -static const char g_ep5_name[] = ep5-iso;
 -static const char g_ep6_name[] = ep6-bulk;
 -static const char g_ep7_name[] = ep7-bulk;
 -static const char g_ep8_name[] = ep8in-int;
 -static const char g_ep9_name[] = ep9-iso;
 -static const char g_epa_name[] = epa-iso;
 -static const char g_epb_name[] = epb-bulk;
 -static const char g_epc_name[] = epc-nulk;
 -static const char g_epd_name[] = epdin-int;
 -
 -static const char *gp_ep_name[NUM_ENDPOINTS] = {
 -g_ep0_name,
 -g_ep1_name,
 -g_ep2_name,
 -g_ep3_name,
 -g_ep4_name,
 -g_ep5_name,
 -g_ep6_name,
 -g_ep7_name,
 -g_ep8_name,
 -g_ep9_name,
 -g_epa_name,
 -g_epb_name,
 -g_epc_name,
 -g_epd_name,
 +static const struct {
 +const char *name;
 +const struct usb_ep_caps caps;
 +} ep_info[NUM_ENDPOINTS] = {
 +#define EP_INFO(_name, _type, _dir) \
 +{ \
 +.name = _name, \
 +.caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
 +USB_EP_CAPS_DIR_ ## _dir), \
 +}
 +
 +EP_INFO(ep0,  CONTROL, ALL),
 +EP_INFO(ep1-bulk, BULK,   ALL),
 +EP_INFO(ep2-bulk, BULK,   ALL),
 +EP_INFO(ep3in-int,INT,IN),
 +EP_INFO(ep4-iso,  INT,ALL),
 +EP_INFO(ep5-iso,  ISO,ALL),
 +EP_INFO(ep6-bulk, ISO,ALL),
 +EP_INFO(ep7-bulk, BULK,   ALL),
 +EP_INFO(ep8in-int,INT,IN),
 +EP_INFO(ep9-iso,  ISO,ALL),
 +EP_INFO(epa-iso,  ISO,ALL),
 +EP_INFO(epb-bulk, BULK,   ALL),
 +EP_INFO(epc-bulk, BULK,   ALL),
 +EP_INFO(epdin-int,INT,IN),
 
 IMO, this is pointless obfuscation. It just makes it a pain to grep
 source around. Why don't you have UDC drivers initialize the 1-bit flags
 directly ?
 

Do you mean something like this? It just makes it a pain to scroll this
source ;)

static const struct {
const char *name;
const struct usb_ep_caps caps;
} ep_info[NUM_ENDPOINTS] = {
{
.name = ep0,
.caps = {
.type_control = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep1-bulk,
.caps = {
.type_bulk = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep2-bulk,
.caps = {
.type_bulk = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep3in-int,
.caps = {
.type_int = true,
.dir_in = true,
},
},
{
.name = ep4-iso,
.caps = {
.type_iso = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep5-iso,
.caps = {
.type_iso = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep6-bulk,
.caps = {
.type_bulk = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep7-bulk,
.caps = {
.type_bulk = true,
.dir_in = true,
.dir_out = true,
},
},
{
.name = ep8in-int,
.caps = {
.type_int = true,
.dir_in = true,
},
},
{
.name = ep9-iso,
.caps = {
.type_iso = true,

[PATCH v8 6/7] usb: interface authorization: Documentation part

2015-07-30 Thread Stefan Koch
This part adds the documentation for the interface authorization.

Signed-off-by: Stefan Koch sk...@suse.de
---
 Documentation/ABI/testing/sysfs-bus-usb | 22 +
 Documentation/usb/authorization.txt | 34 +
 2 files changed, 56 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index e5cc763..ca8c8d3 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -1,3 +1,25 @@
+What:  /sys/bus/usb/devices/INTERFACE/authorized
+Date:  June 2015
+KernelVersion: 4.2
+Description:
+   This allows to authorize (1) or deauthorize (0)
+   individual interfaces instead a whole device
+   in contrast to the device authorization.
+   If a deauthorized interface will be authorized
+   so the driver probing must be triggered manually
+   by writing INTERFACE to /sys/bus/usb/drivers_probe
+   This allows to avoid side-effects with drivers
+   that need multiple interfaces.
+   A deauthorized interface cannot be probed or claimed.
+
+What:  /sys/bus/usb/devices/usbX/interface_authorized_default
+Date:  June 2015
+KernelVersion: 4.2
+Description:
+   This is used as default value that determines
+   if interfaces would authorized per default.
+   The value can be 1 or 0. It is per default 1.
+
 What:  /sys/bus/usb/device/.../authorized
 Date:  July 2008
 KernelVersion: 2.6.26
diff --git a/Documentation/usb/authorization.txt 
b/Documentation/usb/authorization.txt
index c069b68..020cec5 100644
--- a/Documentation/usb/authorization.txt
+++ b/Documentation/usb/authorization.txt
@@ -3,6 +3,9 @@ Authorizing (or not) your USB devices to connect to the system
 
 (C) 2007 Inaky Perez-Gonzalez in...@linux.intel.com Intel Corporation
 
+Interface authorization part:
+   (C) 2015 Stefan Koch sk...@suse.de SUSE LLC
+
 This feature allows you to control if a USB device can be used (or
 not) in a system. This feature will allow you to implement a lock-down
 of USB devices, fully controlled by user space.
@@ -90,3 +93,34 @@ etc, but you get the idea. Anybody with access to a device 
gadget kit
 can fake descriptors and device info. Don't trust that. You are
 welcome.
 
+
+Interface authorization
+---
+There is a similar approach to allow or deny specific USB interfaces.
+That allows to block only a subset of an USB device.
+
+Authorize an interface:
+$ echo 1  /sys/bus/usb/devices/INTERFACE/authorized
+
+Deauthorize an interface:
+$ echo 0  /sys/bus/usb/devices/INTERFACE/authorized
+
+The default value for new interfaces
+on a particular USB bus can be changed, too.
+
+Allow interfaces per default:
+$ echo 1  /sys/bus/usb/devices/usbX/interface_authorized_default
+
+Deny interfaces per default:
+$ echo 0  /sys/bus/usb/devices/usbX/interface_authorized_default
+
+Per default the interface_authorized_default bit is 1.
+So all interfaces would authorized per default.
+
+Note:
+If a deauthorized interface will be authorized so the driver probing must
+be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe
+
+For drivers that need multiple interfaces all needed interfaces should be
+authroized first. After that the drivers should be probed.
+This avoids side effects.
-- 
2.1.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 v8 1/7] usb: interface authorization: Declare authorized attribute

2015-07-30 Thread Stefan Koch
The attribute authorized shows the authorization state for an interface.

Signed-off-by: Stefan Koch sk...@suse.de
---
 include/linux/usb.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 447fe29..3deccab 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -178,6 +178,7 @@ struct usb_interface {
unsigned needs_altsetting0:1;   /* switch to altsetting 0 is pending */
unsigned needs_binding:1;   /* needs delayed unbind/rebind */
unsigned resetting_device:1;/* true: bandwidth alloc after reset */
+   unsigned authorized:1;  /* used for interface authorization */
 
struct device dev;  /* interface specific device info */
struct device *usb_dev;
-- 
2.1.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 v8 7/7] usb: interface authorization: Use a flag for the default device authorization

2015-07-30 Thread Stefan Koch
With this patch a flag instead of a variable
is used for the default device authorization.

Signed-off-by: Stefan Koch sk...@suse.de
---
 drivers/usb/core/hcd.c  | 31 +--
 drivers/usb/core/usb.c  |  2 +-
 include/linux/usb/hcd.h |  6 --
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 84b5923..a567647 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -854,10 +854,10 @@ static ssize_t authorized_default_show(struct device *dev,
 {
struct usb_device *rh_usb_dev = to_usb_device(dev);
struct usb_bus *usb_bus = rh_usb_dev-bus;
-   struct usb_hcd *usb_hcd;
+   struct usb_hcd *hcd;
 
-   usb_hcd = bus_to_hcd(usb_bus);
-   return snprintf(buf, PAGE_SIZE, %u\n, usb_hcd-authorized_default);
+   hcd = bus_to_hcd(usb_bus);
+   return snprintf(buf, PAGE_SIZE, %u\n, !!HCD_DEV_AUTHORIZED(hcd));
 }
 
 static ssize_t authorized_default_store(struct device *dev,
@@ -868,12 +868,16 @@ static ssize_t authorized_default_store(struct device 
*dev,
unsigned val;
struct usb_device *rh_usb_dev = to_usb_device(dev);
struct usb_bus *usb_bus = rh_usb_dev-bus;
-   struct usb_hcd *usb_hcd;
+   struct usb_hcd *hcd;
 
-   usb_hcd = bus_to_hcd(usb_bus);
+   hcd = bus_to_hcd(usb_bus);
result = sscanf(buf, %u\n, val);
if (result == 1) {
-   usb_hcd-authorized_default = val ? 1 : 0;
+   if (val)
+   set_bit(HCD_FLAG_DEV_AUTHORIZED, hcd-flags);
+   else
+   clear_bit(HCD_FLAG_DEV_AUTHORIZED, hcd-flags);
+
result = size;
} else {
result = -EINVAL;
@@ -2720,10 +2724,17 @@ int usb_add_hcd(struct usb_hcd *hcd,
dev_info(hcd-self.controller, %s\n, hcd-product_desc);
 
/* Keep old behaviour if authorized_default is not in [0, 1]. */
-   if (authorized_default  0 || authorized_default  1)
-   hcd-authorized_default = hcd-wireless ? 0 : 1;
-   else
-   hcd-authorized_default = authorized_default;
+   if (authorized_default  0 || authorized_default  1) {
+   if (hcd-wireless)
+   clear_bit(HCD_FLAG_DEV_AUTHORIZED, hcd-flags);
+   else
+   set_bit(HCD_FLAG_DEV_AUTHORIZED, hcd-flags);
+   } else {
+   if (authorized_default)
+   set_bit(HCD_FLAG_DEV_AUTHORIZED, hcd-flags);
+   else
+   clear_bit(HCD_FLAG_DEV_AUTHORIZED, hcd-flags);
+   }
set_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags);
 
/* per default all interfaces are authorized */
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 8d5b2f4..f8bbd0b 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -510,7 +510,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
if (root_hub)   /* Root hub always ok [and always wired] */
dev-authorized = 1;
else {
-   dev-authorized = usb_hcd-authorized_default;
+   dev-authorized = !!HCD_DEV_AUTHORIZED(usb_hcd);
dev-wusb = usb_bus_is_wusb(bus) ? 1 : 0;
}
return dev;
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 7b8ddae..f7c6dd1 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -59,7 +59,7 @@
  * Since struct usb_bus is so thin, you can't share much code in it.
  * This framework is a layer over that, and should be more sharable.
  *
- * @authorized_default: Specifies if new devices are authorized to
+ * @HCD_DEV_AUTHORIZED: Specifies if new devices are authorized to
  *  connect by default or they require explicit
  *  user space authorization; this bit is settable
  *  through /sys/class/usb_host/X/authorized_default.
@@ -120,6 +120,7 @@ struct usb_hcd {
 #define HCD_FLAG_WAKEUP_PENDING4   /* root hub is 
resuming? */
 #define HCD_FLAG_RH_RUNNING5   /* root hub is running? */
 #define HCD_FLAG_DEAD  6   /* controller has died? */
+#define HCD_FLAG_DEV_AUTHORIZED7   /* authorize devices? */
 #define HCD_FLAG_INTF_AUTHORIZED   8   /* authorize interfaces? */
 
/* The flags can be tested using these macros; they are likely to
@@ -131,6 +132,8 @@ struct usb_hcd {
 #define HCD_WAKEUP_PENDING(hcd)((hcd)-flags  (1U  
HCD_FLAG_WAKEUP_PENDING))
 #define HCD_RH_RUNNING(hcd)((hcd)-flags  (1U  HCD_FLAG_RH_RUNNING))
 #define HCD_DEAD(hcd)  ((hcd)-flags  (1U  HCD_FLAG_DEAD))
+#define HCD_DEV_AUTHORIZED(hcd) \
+   ((hcd)-flags  (1U  HCD_FLAG_DEV_AUTHORIZED))
 #define HCD_INTF_AUTHORIZED(hcd) \
((hcd)-flags  (1U  HCD_FLAG_INTF_AUTHORIZED))
 
@@ -144,7 +147,6 @@ struct usb_hcd {
 * support the new 

[PATCH v8 0/7] usb: interface authorization

2015-07-30 Thread Stefan Koch
This patch introduces an interface authorization for USB devices.
The kernel supports a device authorization because of wireless USB.

But the new interface authorization allows to authorize or deauthorize
individual interfaces instead authorization or deauthorize a whole device.

Therefore the authorized attribute is introduced for each interface.

Each patch depends on all patches with a lesser number.

v5 was acked-by Alan Stern:
http://comments.gmane.org/gmane.linux.usb.general/127144
http://permalink.gmane.org/gmane.linux.usb.general/127151

Changes since v7:
- Implemented suggestions from Alan Stern and Sergei Shtylyov

Changes since v6:
- Implemented suggestions from Alan Stern and Sergei Shtylyov

Changes since v5:
- Implemented suggestions from Greg K-H
- Changed device authorization to save the default bit in the same flag as the 
interface authorization does this
  (recommended by Alan Stern 
http://permalink.gmane.org/gmane.linux.usb.general/127086)


Stefan Koch (7):
  usb: interface authorization: Declare authorized attribute
  usb: interface authorization: Introduces the default interface
authorization
  usb: interface authorization: Control interface probing and claiming
  usb: interface authorization: Introduces the USB interface
authorization
  usb: interface authorization: SysFS part of USB interface
authorization
  usb: interface authorization: Documentation part
  usb: interface authorization: Use a flag for the default device
authorization

 Documentation/ABI/testing/sysfs-bus-usb | 22 ++
 Documentation/usb/authorization.txt | 34 ++
 drivers/usb/core/driver.c   |  8 
 drivers/usb/core/hcd.c  | 78 -
 drivers/usb/core/message.c  | 39 +
 drivers/usb/core/sysfs.c| 36 +++
 drivers/usb/core/usb.c  |  2 +-
 drivers/usb/core/usb.h  |  2 +
 include/linux/usb.h |  1 +
 include/linux/usb/hcd.h |  9 +++-
 10 files changed, 218 insertions(+), 13 deletions(-)

-- 
2.1.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 v6 1/1] usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth

2015-07-30 Thread Peter Chen
According to USB Audio Device 2.0 Spec, Ch4.10.1.1:
wMaxPacketSize is defined as follows:
Maximum packet size this endpoint is capable of sending or receiving
when this configuration is selected.
This is determined by the audio bandwidth constraints of the endpoint.

In current code, the wMaxPacketSize is defined as the maximum packet size
for ISO endpoint, and it will let the host reserve much more space than
it really needs, so that we can't let more endpoints work together at
one frame.

We find this issue when we try to let 4 f_uac2 gadgets work together [1]
at FS connection.

[1]http://www.spinics.net/lists/linux-usb/msg123478.html

Acked-by: Daniel Mack zon...@gmail.com
Cc: andrze...@samsung.com
Cc: Daniel Mack zon...@gmail.com
Cc: ti...@suse.de
Cc: sta...@vger.kernel.org #v3.18+
Cc: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Peter Chen peter.c...@freescale.com
---

Changes for v6:
- Fix below sparse warning
drivers/usb/gadget/function/f_uac2.c:997:35: sparse:
restricted __le16 degrades to integer
- Add Acked-by: Daniel Mack zon...@gmail.com

Changes for v5:
- Add additional parameters 'is_playback' for helper
- Add const for parameter 'struct f_uac2_opts *uac2_opts'
- Put all three int variables at one line 
- Fix the CodeStyle problem

Changes for v4:
- Add helper set_ep_max_packet_size to calculate max packet size

Changes for v3:
- Consider 'bInterval' to calculate wMaxPacketSize
- playback endpoint is IN ep, and capture endpoint is OUT ep

Changes for v2:
- Using DIV_ROUND_UP to calculate max packet size
 drivers/usb/gadget/function/f_uac2.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c 
b/drivers/usb/gadget/function/f_uac2.c
index 5318615..96d935b 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -975,6 +975,29 @@ free_ep(struct uac2_rtd_params *prm, struct usb_ep *ep)
%s:%d Error!\n, __func__, __LINE__);
 }
 
+static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
+   struct usb_endpoint_descriptor *ep_desc,
+   unsigned int factor, bool is_playback)
+{
+   int chmask, srate, ssize;
+   u16 max_packet_size;
+
+   if (is_playback) {
+   chmask = uac2_opts-p_chmask;
+   srate = uac2_opts-p_srate;
+   ssize = uac2_opts-p_ssize;
+   } else {
+   chmask = uac2_opts-c_chmask;
+   srate = uac2_opts-c_srate;
+   ssize = uac2_opts-c_ssize;
+   }
+
+   max_packet_size = num_channels(chmask) * ssize *
+   DIV_ROUND_UP(srate, factor / (1  (ep_desc-bInterval - 1)));
+   ep_desc-wMaxPacketSize = cpu_to_le16(min(max_packet_size,
+   le16_to_cpu(ep_desc-wMaxPacketSize)));
+}
+
 static int
 afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
 {
@@ -1070,10 +1093,14 @@ afunc_bind(struct usb_configuration *cfg, struct 
usb_function *fn)
uac2-p_prm.uac2 = uac2;
uac2-c_prm.uac2 = uac2;
 
+   /* Calculate wMaxPacketSize according to audio bandwidth */
+   set_ep_max_packet_size(uac2_opts, fs_epin_desc, 1000, true);
+   set_ep_max_packet_size(uac2_opts, fs_epout_desc, 1000, false);
+   set_ep_max_packet_size(uac2_opts, hs_epin_desc, 8000, true);
+   set_ep_max_packet_size(uac2_opts, hs_epout_desc, 8000, false);
+
hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
-   hs_epout_desc.wMaxPacketSize = fs_epout_desc.wMaxPacketSize;
hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;
-   hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize;
 
ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL);
if (ret)
-- 
1.9.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


Re: [PATCH] Input: xpad - Fix double URB submission races

2015-07-30 Thread Dmitry Torokhov
Hi Laura,

On Wed, Jul 29, 2015 at 02:27:23PM -0700, Laura Abbott wrote:
@@ -791,6 +796,9 @@ static int xpad_play_effect(struct input_dev *dev, void 
*data, struct ff_effect
  {
   struct usb_xpad *xpad = input_get_drvdata(dev);
  
 + if (test_and_set_bit(OUT_IRQ_SUBMITTED, xpad-odata_flags))
 + return 0;
 +

So this results in basically ignoring the request if urb is busy which
is not the best way of handling this. You need to note that there is
pending effect to be played and submit it after currently executing
request completes.

The same needs to be done for led toggling request.

Thanks.

-- 
Dmitry
--
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 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Javier Martinez Canillas
Hello,

Short version:

This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
to export that information so modules have the correct aliases built-in
and autoloading works correctly.

Longer version:

Currently it's mandatory for I2C drivers to have an I2C device ID table
regardless if the device was registered using platform data or OF. This
is because the I2C core needs an I2C device ID table for two reasons:

1) Match the I2C client with a I2C device ID so a struct i2c_device_id
   is passed to the I2C driver probe() function.

2) Export the module aliases from the I2C device ID table so userspace
   can auto-load the correct module. This is because i2c_device_uevent
   always reports a MODALIAS of the form i2c:client-name.

Lee Jones posted a patch series [0] to solve 1) by allowing the I2C
drivers to have a probe() function that does not get a i2c_device_id.

The problem is that his series didn't take into account 2) so if that
was merged and the I2C ID table is removed from all the drivers that
don't needed it, module auto-loading will break for those.

But even now there are many I2C drivers were module auto-loading is
not working because of the fact that the I2C core always reports the
MODALIAS as i2c:client-name and many developers didn't expect this.

I've identified I2C drivers with 3 types of different issues:

a) Those that have an i2c_table but are not exported. The match works
   and the correct i2c_device_id is passed on probe but since the ID
   table is not exported, module auto-load won't work.

b) Those that have a of_table but are not exported. This is currently
   not an issue since even when the of_table is used to match the dev
   with the driver, an OF modalias is not reported by the I2C core.
   But if the I2C core is changed to report the MODALIAS of the form
   of:N*T*C as it's made by other subsystems, then module auto-load
   will break for these drivers.

c) Those that don't have a of_table but should since are OF drivers
   with DT bindings doc for them. Since the I2C core does not report
   a OF modalias and since i2c_device_match() fallbacks to match the
   device part of the compatible string with the I2C device ID table,
   many OF drivers don't have an of_table to match. After all having
   a I2C device ID table is mandatory so it works without a of_table.

So, in order to not make mandatory to have a I2C device ID table, at
least a) and b) needs to be addressed, this series does that.

c) should be fixed too since it seems wrong that a driver with a DT
binding document, does not have a OF table and export it to modules.

Also stripping the vendor part from the compatible string to match
with the I2C devices ID table and reporting only the device name to
user-space doesn't seem to be correct. I've identified at least two
drivers that have the same name on their I2C device ID table so the
manufacturer prefix is important. But I've not tried to fix c) yet
since that is not so easy to automate due drivers not having all the
information (i.e: the device name can match a documented compatible
string device part but without the vendor prefix is hard to tell).

I split the changes so the patches in this series are independent and
can be picked individually by subsystem maintainers. Patch #27 changes
the logic of i2c_device_uevent() to report an OF modalias if the device
was registered using OF. But this patch is included in the series only
as an RFC for illustration purposes since changing that without fixing
c) will break module auto-loading for the drivers of devices registered
with OF but that don't have a of_match_table.

Although arguably, those drivers were relying on the assumption that a
MODALIAS=i2c:foo would always be reported even for the OF case which
is not the true on other subsystems.

[0]: https://lkml.org/lkml/2014/8/28/283

Best regards,
Javier


Javier Martinez Canillas (27):
  mfd: stw481x: Export I2C module alias information
  spi: xcomm: Export I2C module alias information
  iio: Export I2C module alias information in missing drivers
  [media] Export I2C module alias information in missing drivers
  macintosh: therm_windtunnel: Export I2C module alias information
  misc: eeprom: Export I2C module alias information in missing drivers
  Input: Export I2C module alias information in missing drivers
  power: Export I2C module alias information in missing drivers
  i2c: core: Export I2C module alias information in dummy driver
  backlight: tosa: Export I2C module alias information
  [media] staging: media: lirc: Export I2C module alias information
  usb: phy: isp1301: Export I2C module alias information
  ALSA: ppc: keywest: Export I2C module alias information
  hwmon: (nct7904) Export I2C module alias information
  regulator: fan53555: Export I2C module alias information
  mfd: Export OF module alias information in missing drivers
  iio: Export OF module alias information in missing drivers
  hwmon: (g762) Export OF module alias information

[PATCH 27/27] i2c: (RFC, don't apply) report OF style modalias when probing using DT

2015-07-30 Thread Javier Martinez Canillas
An I2C driver that supports both OF and legacy platforms, will have
both a OF and I2C ID table. This means that when built as a module,
the aliases will be filled from both tables but currently always an
alias of the form i2c:deviceId is reported, e.g:

$ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
i2c:maxtouch

So if a device is probed by matching its compatible string, udev can
get a MODALIAS uevent env var that doesn't match with one of the valid
aliases so the module won't be auto-loaded.

This patch changes the I2C core to report a OF related MODALIAS uevent
(of:N*T*C) env var instead so the module can be auto-loaded and also
report the correct alias using sysfs:

$ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
of:NtrackpadTNULLCatmel,maxtouch

Signed-off-by: Javier Martinez Canillas jav...@osg.samsung.com



---

 drivers/i2c/i2c-core.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 92dddfeb3f39..c0668c2ed9da 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -489,6 +489,10 @@ static int i2c_device_uevent(struct device *dev, struct 
kobj_uevent_env *env)
struct i2c_client   *client = to_i2c_client(dev);
int rc;
 
+   rc = of_device_uevent_modalias(dev, env);
+   if (rc != -ENODEV)
+   return rc;
+
rc = acpi_device_uevent_modalias(dev, env);
if (rc != -ENODEV)
return rc;
@@ -726,6 +730,10 @@ show_modalias(struct device *dev, struct device_attribute 
*attr, char *buf)
struct i2c_client *client = to_i2c_client(dev);
int len;
 
+   len = of_device_get_modalias(dev, buf, PAGE_SIZE - 1);
+   if (len != -ENODEV)
+   return len;
+
len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
if (len != -ENODEV)
return len;
-- 
2.4.3

--
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 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Dmitry Torokhov
On Thu, Jul 30, 2015 at 09:35:17AM -0700, Dmitry Torokhov wrote:
 Hi Javier,
 
 On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
  Hello,
  
  Short version:
  
  This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
  to export that information so modules have the correct aliases built-in
  and autoloading works correctly.
  
  Longer version:
  
  Currently it's mandatory for I2C drivers to have an I2C device ID table
  regardless if the device was registered using platform data or OF. This
  is because the I2C core needs an I2C device ID table for two reasons:
  
  1) Match the I2C client with a I2C device ID so a struct i2c_device_id
 is passed to the I2C driver probe() function.
  
  2) Export the module aliases from the I2C device ID table so userspace
 can auto-load the correct module. This is because i2c_device_uevent
 always reports a MODALIAS of the form i2c:client-name.
 
 Why are we not fixing this? We emit specially carved uevent for
 ACPI-based devices, why not the same for OF? Platform bus does this...

Ah, now I see the 27/27 patch. I think it is exactly what we need. And
probably for SPI bus as well.

Thanks.

-- 
Dmitry
--
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/4] cp210x: Unify code for set/get config control messages

2015-07-30 Thread Johan Hovold
On Fri, Jul 24, 2015 at 08:48:09AM +0200, Petr Tesarik wrote:
 From: Petr Tesarik ptesa...@suse.cz
 
 There is a lot of overlap between the two functions (e.g. calculation
 of the buffer size), so this removes a bit of code duplication, but
 most importantly, a more generic function can be easily reused for
 other message types.

I'm not sure I consider this is an improvement yet.

 Signed-off-by: Petr Tesarik ptesa...@suse.com
 ---
  drivers/usb/serial/cp210x.c | 109 
 
  1 file changed, 49 insertions(+), 60 deletions(-)
 
 diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
 index 1bae015..69f03b6 100644
 --- a/drivers/usb/serial/cp210x.c
 +++ b/drivers/usb/serial/cp210x.c
 @@ -307,14 +307,17 @@ enum cp210x_request_type {
  #define CONTROL_WRITE_RTS0x0200
  
  /*
 - * cp210x_get_config
 - * Reads from the CP210x configuration registers
 + * cp210x_control_msg
 + * Sends a generic control message, taking care of endianness
 + * and error messages.
   * 'size' is specified in bytes.
 - * 'data' is a pointer to a pre-allocated array of integers large
 - * enough to hold 'size' bytes (with 4 bytes to each integer)
 + * 'data' is a pointer to the input/output buffer. For output, it holds
 + * the data (in host order) to be sent. For input, it receives data from
 + * the device and must be big enough to hold 'size' bytes.
   */
 -static int cp210x_get_config(struct usb_serial_port *port, u8 request,
 - unsigned int *data, int size)
 +static int cp210x_control_msg(struct usb_serial_port *port, u8 request,
 +   u8 requesttype, u16 value, u32 *data, int size,
 +   int timeout)

Should you not use your new request type enum here?

  {
   struct usb_serial *serial = port-serial;
   struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
 @@ -328,20 +331,22 @@ static int cp210x_get_config(struct usb_serial_port 
 *port, u8 request,
   if (!buf)
   return -ENOMEM;
  
 - /* Issue the request, attempting to read 'size' bytes */
 - result = usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0),
 - request, REQTYPE_INTERFACE_TO_HOST, 0x,
 - spriv-bInterfaceNumber, buf, size,
 - USB_CTRL_GET_TIMEOUT);
 + if (!(requesttype  USB_DIR_IN)) {
 + for (i = 0; i  length; i++)
 + buf[i] = cpu_to_le32(data[i]);
 + }
  
 - /* Convert data into an array of integers */
 - for (i = 0; i  length; i++)
 - data[i] = le32_to_cpu(buf[i]);
 + result = usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0),

And this should be usb_sndctrlpipe for outgoing messages.

 +  request, requesttype, value,
 +  spriv-bInterfaceNumber, buf, size, timeout);

Please resend this when you start using your generalised function (for
the gpio work?).

I'll drop all four for now.

Thanks,
Johan
--
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 12/27] usb: phy: isp1301: Export I2C module alias information

2015-07-30 Thread Javier Martinez Canillas
The I2C core always reports the MODALIAS uevent as i2c:client name
regardless if the driver was matched using the I2C id_table or the
of_match_table. So the driver needs to export the I2C table and this
be built into the module or udev won't have the necessary information
to auto load the correct module when the device is added.

Signed-off-by: Javier Martinez Canillas jav...@osg.samsung.com

---

 drivers/usb/phy/phy-isp1301.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
index 8a55b37d1a02..db68156568e6 100644
--- a/drivers/usb/phy/phy-isp1301.c
+++ b/drivers/usb/phy/phy-isp1301.c
@@ -31,6 +31,7 @@ static const struct i2c_device_id isp1301_id[] = {
{ isp1301, 0 },
{ }
 };
+MODULE_DEVICE_TABLE(i2c, isp1301_id);
 
 static struct i2c_client *isp1301_i2c_client;
 
-- 
2.4.3

--
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] drivers/usb/: Simplify return statements

2015-07-30 Thread Felipe Balbi
On Thu, Jul 30, 2015 at 01:13:42PM +, Karajgaonkar, Saurabh (S.) wrote:
 From: Saurabh Karajgaonkar skara...@visteon.com
 
 This patch is created using simple_return.cocci coccinelle script.
 It replaces the redundant instances where variables are assigned
 return value from functions and then used in return statements.
 
 Signed-off-by: Saurabh Karajgaonkar skara...@visteon.com

do you mind splitting this per-driver ? That makes it a lot easier for
different maintainers to take their part. For example, I would take
drivers/usb/phy/* and drivers/usb/musb/*

Alan Stern would handle drivers/usb/host/[uoe]hci*.[ch]

Mathias Nyman, driver/usb/host/xhci*.[ch]

and so on. Thanks

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Dmitry Torokhov
Hi Javier,

On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
 Hello,
 
 Short version:
 
 This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
 to export that information so modules have the correct aliases built-in
 and autoloading works correctly.
 
 Longer version:
 
 Currently it's mandatory for I2C drivers to have an I2C device ID table
 regardless if the device was registered using platform data or OF. This
 is because the I2C core needs an I2C device ID table for two reasons:
 
 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
is passed to the I2C driver probe() function.
 
 2) Export the module aliases from the I2C device ID table so userspace
can auto-load the correct module. This is because i2c_device_uevent
always reports a MODALIAS of the form i2c:client-name.

Why are we not fixing this? We emit specially carved uevent for
ACPI-based devices, why not the same for OF? Platform bus does this...

Thanks.

-- 
Dmitry
--
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: Multiple drives on JMS56x-based sata-usb docking station.

2015-07-30 Thread Giulio Bernardi

On 30/07/2015 23:42, Giulio Bernardi wrote:

On 27/07/2015 16:28, Alan Stern wrote:

On Mon, 27 Jul 2015, Giulio Bernardi wrote:


Sorry for the late reply, but it took me a little bit to recompile the kernel
(my laptop is slow) and I was not able to obtain any meaningful results (please
note I know nothing about kernel internals).

However, i filled scsi_sequential_lun_scan() with printk's but none of them
appeared (yes, I did echo 7  /proc/sys/kernel/printk).
So I enabled logging for SCSI scan bus (echo 448 
/proc/sys/dev/scsi/logging_level) and I did not see message scsi scan:
Sequential scan\n appearing. So I thought scsi_sequential_lun_scan() was not
being called.


That's strange.  If you look at __scsi_scan_target(), you'll see that
the code calls scsi_probe_and_add_lun() for LUN 0, then it calls
scsi_report_lun_scan() (which should return 1), and then it calls
scsi_sequential_lun_scan().

You should check that scsi_report_lun_scan() really does return 1.  If
it returns 0 instead (because BLIST_NOLUN is set in bflags or for any
other reason), that would cause the behavior you see.



I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed.
It is a bug in scsi_get_device_flags_keyed():
In fact, my device reports these strings for model and vendor:
vendor = Inateck 0101
model = 0101
and this matches with this entry in the global scsi device list:
{, Scanner, 1.80, BLIST_NOLUN}
In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so
memcmp always passes, and the check on model passes because the code assumes
that max length of model is 16: when trimming the string (which is exactly 16
spaces followed by 0101) it ends up with an empty string, which then matches
whatever string for the same reason of the previous check.
I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it
works, but I don't know if other devices do exist with a longer model string.
Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not
for USB devices?

However, who should I notify about the issue? linux-scsi mailing list? bugzilla?

Thank you again for the support, I wouldn't have been able to discover this 
alone.



It looks like I talked too soon. Now it scans for lun1 also, but then I have 
this:

kernel: scsi 6:0:0:1: scsi scan: INQUIRY pass 1 length 36
kernel: scsi 6:0:0:1: scsi scan: INQUIRY failed with code 0x4

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


Bug with USB 3.0 in Modul xhci_hcd

2015-07-30 Thread schorsch
https://bugzilla.kernel.org/show_bug.cgi?id=89471#c2

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