[PATCH v2 00/17] Equivalent of g_ether.ko with configfs

2013-05-28 Thread Andrzej Pietrasiewicz
Here I present the conversion of everything that is required to provide
the equivalent of g_ether.ko with configfs.

A branch will be available here (from 28th May 2013, afternoon UTC):
git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs

v1..v2:

- fixed compilation error if RNDIS is not selected
- made f_eem build conditionally only if selected in .config
- used ERR_CAST instead of ERR_PTR(PTR_ERR(x))
  [reported by Fengguag Wu, thank you]
- made geth_alloc and rndis_alloc static
  [reported by Fengguag Wu, thank you]
- used memcpy instead of copying individual bytes
  [reported by Sergei Shtylov, thank you]

This series requires the following series to be applied:

http://comments.gmane.org/gmane.linux.usb.general/86773
http://comments.gmane.org/gmane.linux.usb.general/86783
http://www.spinics.net/lists/linux-usb/msg85307.html
http://comments.gmane.org/gmane.linux.usb.general/86790

The g_ether consists of 4 USB functions, and 3 of them needed to be converted
to the new interface and equipped with configfs support (a few patches per
function), so this patch series is a bit lengthy (17 patches), but I tried
to do the conversion in small, readable steps.

BACKWARD COMPATIBILITY
==

Please note that the old g_ether.ko is still available and works.


USING THE NEW "GADGET"
==

Please refer to this post:

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

for general information from Sebastian on how to use configfs-based
gadgets (*).

Here is the description specific to using g_ether.ko equivalent.

Original g_ether


The original g_ether can contain CDC EEM, CDC ECM (or CDC ECM subset for devices
which do not support full ECM) and RNDIS, depending on what is set in .config.
Even if all of them are selected in .config, only one of them can be used at
runtime. The above functions are assigned to two configurations: either EEM
or ECM or ECM subset is the only function in one configuration, and RNDIS
is the only function in the other.

If the EEM/ECM/ECM subset configuration is selected by the host, then
depending on the use_eem module parameter either EEM or ECM/ECM subset
is used. The decision to use either ECM or ECM subset is made based
on the can_support_ecm() static inline function found in u_ether.h.

If no idVendor, idProduct module parameters are specified, the gadget
uses different default values depending on which function will
actually be used.

No matter which function is actually used, only one network interface
is created and registered.

Configfs-based
--

It is possible to create a gadget which is pretty close to the original
g_ether with three exceptions: (1) for each function a new network interface
is created, (2) a configuration's composition of a number of functions
is done by user creating appropriate symbolic links and (3) idVendor/idProduct
must be explicitly specified.

What does that mean?

As far as (1) is concerned, a gadget which has two configurations,
one containing RNDIS and the other containing EEM, will cause two network
interfaces to appear on the device(after bind): usb0 and usb1, while in the
old gadget only one would be used (which, on the other hand, means that with
the old gadget it is impossible to have e.g. EEM and RNDIS at the same time
in the same configuration).
The two interfaces created here could be an issue, but on the other hand
on many (most?) systems udev will handle interfaces naming anyway.

As for the (2), configurations in a configfs-based gadget can be composed
at will of any available functions, but once a gadget is bound, the composition
is fixed. The old gadget created the configuration programmaticaly at gadget's
bind and included only one of EEM/ECM/ECM subset depending on the use_eem
parameter and can_support_ecm() function's result. In other words, with configfs
it is not possible to say "this configuration will contain either this function
or that", but rather it is possible to say "this configuration will contain
this set of functions".
This could be an issue as well, but with configfs the gadgets are composed
AT RUNTIME. This makes a huge difference compared to the old approach.
The old approach was: if you want a USB gadget which contains this number
of configurations and in each configuration it contains these functions,
go create a new .c and compile it. Plus, if you want that
in mainline, persuade Felipe and Greg to take it. But with configfs
you have your building blocks in mainline (hopefully; Felipe?), and out of those
you compose the gadget you want, and if you want a gadget which consists of
different configurations/functions depending on some circumstances, everything
can be achieved at runtime. No need to write C code at all.

As far as g_ether.ko's equivalent is concerned, the equivalent of use_eem=1
module parameter boils down to instantiating the EEM function, while
the equivalent of use_eem=0 module parameter boils down to having some users

[PATCH v2 01/17] usb/gadget: u_ether: allow getting binary-form host address

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/u_ether.c |9 +
 drivers/usb/gadget/u_ether.h |   10 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 6d3ccdc..2aae0d6 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -963,6 +963,15 @@ int gether_get_host_addr_cdc(struct net_device *net, char 
*host_addr, int len)
 }
 EXPORT_SYMBOL(gether_get_host_addr_cdc);
 
+void gether_get_host_addr_u8(struct net_device *net, u8 host_mac[ETH_ALEN])
+{
+   struct eth_dev *dev;
+
+   dev = netdev_priv(net);
+   memcpy(host_mac, dev->host_mac, ETH_ALEN);
+}
+EXPORT_SYMBOL(gether_get_host_addr_u8);
+
 void gether_set_qmult(struct net_device *net, unsigned qmult)
 {
struct eth_dev *dev;
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 1671a79..5efa657 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -210,6 +210,16 @@ int gether_get_host_addr(struct net_device *net, char 
*host_addr, int len);
 int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len);
 
 /**
+ * gether_get_host_addr_u8 - get an ethernet-over-usb link host address
+ * @net: device representing this link
+ * @host_mac: place to store the eth address of the host
+ *
+ * This gets the binary formatted host-side Ethernet address of this
+ * ethernet-over-usb link.
+ */
+void gether_get_host_addr_u8(struct net_device *net, u8 host_mac[ETH_ALEN]);
+
+/**
  * gether_set_qmult - initialize an ethernet-over-usb link with a multiplier
  * @net: device representing this link
  * @qmult: queue multiplier
-- 
1.7.0.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 v2 06/17] usb/gadget: f_eem: use usb_gstrings_attach

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_eem.c |   17 ++---
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 9d54d68..31a2cb7 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -248,6 +248,7 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_eem*eem = func_to_eem(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
@@ -269,16 +270,11 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
eem_opts->bound = true;
}
 
-   /* maybe allocate device-global string IDs */
-   if (eem_string_defs[0].id == 0) {
-
-   /* control interface label */
-   status = usb_string_id(c->cdev);
-   if (status < 0)
-   return status;
-   eem_string_defs[0].id = status;
-   eem_intf.iInterface = status;
-   }
+   us = usb_gstrings_attach(cdev, eem_strings,
+ARRAY_SIZE(eem_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   eem_intf.iInterface = us[0].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -595,7 +591,6 @@ struct usb_function *eem_alloc(struct usb_function_instance 
*fi)
eem->port.cdc_filter = DEFAULT_FILTER;
 
eem->port.func.name = "cdc_eem";
-   eem->port.func.strings = eem_strings;
/* descriptors are per-instance copies */
eem->port.func.bind = eem_bind;
eem->port.func.unbind = eem_unbind;
-- 
1.7.0.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 v2 03/17] usb/gadget: f_eem: convert to new function interface with backward compatibility

2013-05-28 Thread Andrzej Pietrasiewicz
Converting eem to the new function interface requires converting
the USB eem's function code and its users.
This patch converts the f_eem.c to the new function interface.
The file is now compiled into a separate usb_f_eem.ko module.
The old function interface is provided by means of a preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig  |3 +
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/ether.c  |2 +
 drivers/usb/gadget/f_eem.c  |  174 ++-
 drivers/usb/gadget/u_eem.h  |   27 +++
 5 files changed, 172 insertions(+), 36 deletions(-)
 create mode 100644 drivers/usb/gadget/u_eem.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index ae0ac04..5f68ad3 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -572,6 +572,9 @@ config USB_F_ECM
 config USB_F_PHONET
tristate
 
+config USB_F_EEM
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f065e67..a8f6655 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -55,6 +55,8 @@ usb_f_ecm-y   := f_ecm.o
 obj-$(CONFIG_USB_F_ECM)+= usb_f_ecm.o
 usb_f_phonet-y := f_phonet.o
 obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o
+usb_f_eem-y:= f_eem.o
+obj-$(CONFIG_USB_F_EEM)+= usb_f_eem.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index f4d46d7..397609d 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -108,6 +108,8 @@ static inline bool has_rndis(void)
 #include "f_rndis.c"
 #include "rndis.h"
 #endif
+
+#define USB_FEEM_INCLUDED
 #include "f_eem.c"
 
 /*-*/
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index f4e0bbe..471acc8 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -12,12 +12,14 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
 #include "u_ether.h"
+#include "u_eem.h"
 
 #define EEM_HLEN 2
 
@@ -40,7 +42,7 @@ static inline struct f_eem *func_to_eem(struct usb_function 
*f)
 
 /* interface descriptor: */
 
-static struct usb_interface_descriptor eem_intf __initdata = {
+static struct usb_interface_descriptor eem_intf = {
.bLength =  sizeof eem_intf,
.bDescriptorType =  USB_DT_INTERFACE,
 
@@ -54,7 +56,7 @@ static struct usb_interface_descriptor eem_intf __initdata = {
 
 /* full speed support: */
 
-static struct usb_endpoint_descriptor eem_fs_in_desc __initdata = {
+static struct usb_endpoint_descriptor eem_fs_in_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
.bDescriptorType =  USB_DT_ENDPOINT,
 
@@ -62,7 +64,7 @@ static struct usb_endpoint_descriptor eem_fs_in_desc 
__initdata = {
.bmAttributes = USB_ENDPOINT_XFER_BULK,
 };
 
-static struct usb_endpoint_descriptor eem_fs_out_desc __initdata = {
+static struct usb_endpoint_descriptor eem_fs_out_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
.bDescriptorType =  USB_DT_ENDPOINT,
 
@@ -70,7 +72,7 @@ static struct usb_endpoint_descriptor eem_fs_out_desc 
__initdata = {
.bmAttributes = USB_ENDPOINT_XFER_BULK,
 };
 
-static struct usb_descriptor_header *eem_fs_function[] __initdata = {
+static struct usb_descriptor_header *eem_fs_function[] = {
/* CDC EEM control descriptors */
(struct usb_descriptor_header *) &eem_intf,
(struct usb_descriptor_header *) &eem_fs_in_desc,
@@ -80,7 +82,7 @@ static struct usb_descriptor_header *eem_fs_function[] 
__initdata = {
 
 /* high speed support: */
 
-static struct usb_endpoint_descriptor eem_hs_in_desc __initdata = {
+static struct usb_endpoint_descriptor eem_hs_in_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
.bDescriptorType =  USB_DT_ENDPOINT,
 
@@ -89,7 +91,7 @@ static struct usb_endpoint_descriptor eem_hs_in_desc 
__initdata = {
.wMaxPacketSize =   cpu_to_le16(512),
 };
 
-static struct usb_endpoint_descriptor eem_hs_out_desc __initdata = {
+static struct usb_endpoint_descriptor eem_hs_out_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
.bDescriptorType =  USB_DT_ENDPOINT,
 
@@ -98,7 +100,7 @@ static struct usb_endpoint_descriptor eem_hs_out_desc 
__initdata = {
.wMaxPacketSize =   cpu_to_le16(512),
 };
 
-static struct usb_descriptor_header *eem_hs_function[] __initdata = {
+static struct usb_descriptor_header *eem_hs_function[] = {
/* CDC EEM control descriptors */
(struct usb_descriptor_header *) &eem_intf,
(struct usb_descrip

[PATCH v2 02/17] usb/gadget: ether: convert to new interface of f_ecm

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ether.c |   73 
 2 files changed, 61 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 6dd2192..ae0ac04 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -739,6 +739,7 @@ config USB_ETH
select USB_LIBCOMPOSITE
select USB_U_ETHER
select USB_U_RNDIS
+   select USB_F_ECM
select CRC32
help
  This driver implements Ethernet style communication, in one of
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 862ef65..f4d46d7 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -102,8 +102,7 @@ static inline bool has_rndis(void)
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
-#define USBF_ECM_INCLUDED
-#include "f_ecm.c"
+#include "u_ecm.h"
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
@@ -212,6 +211,10 @@ static struct usb_gadget_strings *dev_strings[] = {
 
 static u8 host_mac[ETH_ALEN];
 static struct eth_dev *the_dev;
+
+static struct usb_function_instance *fi_ecm;
+static struct usb_function *f_ecm;
+
 /*-*/
 
 /*
@@ -253,6 +256,8 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
  */
 static int __init eth_do_config(struct usb_configuration *c)
 {
+   int status = 0;
+
/* FIXME alloc iConfiguration string, set it in c->strings */
 
if (gadget_is_otg(c->cdev->gadget)) {
@@ -262,10 +267,19 @@ static int __init eth_do_config(struct usb_configuration 
*c)
 
if (use_eem)
return eem_bind_config(c, the_dev);
-   else if (can_support_ecm(c->cdev->gadget))
-   return ecm_bind_config(c, host_mac, the_dev);
-   else
+   else if (can_support_ecm(c->cdev->gadget)) {
+   f_ecm = usb_get_function(fi_ecm);
+   if (IS_ERR(f_ecm))
+   return PTR_ERR(f_ecm);
+
+   status = usb_add_function(c, f_ecm);
+   if (status < 0)
+   usb_put_function(f_ecm);
+
+   return status;
+   } else
return geth_bind_config(c, host_mac, the_dev);
+
 }
 
 static struct usb_configuration eth_config_driver = {
@@ -280,13 +294,16 @@ static struct usb_configuration eth_config_driver = {
 static int __init eth_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev->gadget;
+   struct f_ecm_opts   *ecm_opts = NULL;
int status;
 
-   /* set up network link layer */
-   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
-  qmult);
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
+   if (use_eem || !can_support_ecm(gadget)) {
+   /* set up network link layer */
+   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr,
+   host_mac, qmult);
+   if (IS_ERR(the_dev))
+   return PTR_ERR(the_dev);
+   }
 
/* set up main config label and device descriptor */
if (use_eem) {
@@ -294,8 +311,23 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
eth_config_driver.label = "CDC Ethernet (EEM)";
device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
device_desc.idProduct = cpu_to_le16(EEM_PRODUCT_NUM);
-   } else if (can_support_ecm(cdev->gadget)) {
+   } else if (can_support_ecm(gadget)) {
/* ECM */
+
+   fi_ecm = usb_get_function_instance("ecm");
+   if (IS_ERR(fi_ecm))
+   return PTR_ERR(fi_ecm);
+
+   ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
+
+   gether_set_qmult(ecm_opts->net, qmult);
+   if (!gether_set_host_addr(ecm_opts->net, host_addr))
+   pr_info("using host ethernet address: %s", host_addr);
+   if (!gether_set_dev_addr(ecm_opts->net, dev_addr))
+   pr_info("using self ethernet address: %s", dev_addr);
+
+   the_dev = netdev_priv(ecm_opts->net);
+
eth_config_driver.label = "CDC Ethernet (ECM)";
} else {
/* CDC Subset */
@@ -309,6 +341,15 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
 
if (has_rndis()) {
/* RNDIS plus ECM-or-Subset */
+   if (!use_eem && can_support_ecm(gadget)) {
+   gether_set_gadget(ecm_opts->net, cdev->gadget);
+   status = gether_register_netdev(ecm_opts->net);
+   if (status)
+ 

[PATCH v2 05/17] usb/gadget: f_eem: remove compatibility layer

2013-05-28 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_eem.c   |   59 --
 drivers/usb/gadget/u_ether.h |1 -
 2 files changed, 0 insertions(+), 60 deletions(-)

diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 471acc8..9d54d68 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -251,7 +251,6 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
int status;
struct usb_ep   *ep;
 
-#ifndef USB_FEEM_INCLUDED
struct f_eem_opts   *eem_opts;
 
eem_opts = container_of(f->fi, struct f_eem_opts, func_inst);
@@ -269,7 +268,6 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
return status;
eem_opts->bound = true;
}
-#endif
 
/* maybe allocate device-global string IDs */
if (eem_string_defs[0].id == 0) {
@@ -539,61 +537,6 @@ error:
return status;
 }
 
-#ifdef USB_FEEM_INCLUDED
-
-static void eem_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_eem*eem = func_to_eem(f);
-
-   DBG(c->cdev, "eem unbind\n");
-
-   usb_free_all_descriptors(f);
-   kfree(eem);
-}
-
-/**
- * eem_bind_config - add CDC Ethernet (EEM) network link to a configuration
- * @c: the configuration to support the network link
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int __init eem_bind_config(struct usb_configuration *c, struct eth_dev *dev)
-{
-   struct f_eem*eem;
-   int status;
-
-   /* allocate and initialize one new instance */
-   eem = kzalloc(sizeof *eem, GFP_KERNEL);
-   if (!eem)
-   return -ENOMEM;
-
-   eem->port.ioport = dev;
-   eem->port.cdc_filter = DEFAULT_FILTER;
-
-   eem->port.func.name = "cdc_eem";
-   eem->port.func.strings = eem_strings;
-   /* descriptors are per-instance copies */
-   eem->port.func.bind = eem_bind;
-   eem->port.func.unbind = eem_old_unbind;
-   eem->port.func.set_alt = eem_set_alt;
-   eem->port.func.setup = eem_setup;
-   eem->port.func.disable = eem_disable;
-   eem->port.wrap = eem_wrap;
-   eem->port.unwrap = eem_unwrap;
-   eem->port.header_len = EEM_HLEN;
-
-   status = usb_add_function(c, &eem->port.func);
-   if (status)
-   kfree(eem);
-   return status;
-}
-
-#else
-
 static void eem_free_inst(struct usb_function_instance *f)
 {
struct f_eem_opts *opts;
@@ -670,5 +613,3 @@ struct usb_function *eem_alloc(struct usb_function_instance 
*fi)
 DECLARE_USB_FUNCTION_INIT(eem, eem_alloc_inst, eem_alloc);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("David Brownell");
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 5efa657..fb23d1f 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -272,7 +272,6 @@ int geth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
struct eth_dev *dev);
 int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
struct eth_dev *dev);
-int eem_bind_config(struct usb_configuration *c, struct eth_dev *dev);
 
 #ifdef USB_ETH_RNDIS
 
-- 
1.7.0.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 v2 08/17] usb/gadget: multi: Remove unused include

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/multi.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index f9e07c0..66f756f 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -45,7 +45,6 @@ MODULE_LICENSE("GPL");
 
 #define USBF_ECM_INCLUDED
 #include "f_ecm.c"
-#include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #  include "f_rndis.c"
 #  include "rndis.h"
-- 
1.7.0.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 v2 07/17] usb/gadget: f_eem: add configfs support

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 Documentation/ABI/testing/configfs-usb-gadget-eem |   14 ++
 drivers/usb/gadget/Kconfig|   15 ++
 drivers/usb/gadget/f_eem.c|   49 +
 drivers/usb/gadget/u_eem.h|9 
 4 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-eem

diff --git a/Documentation/ABI/testing/configfs-usb-gadget-eem 
b/Documentation/ABI/testing/configfs-usb-gadget-eem
new file mode 100644
index 000..10e87d6
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-eem
@@ -0,0 +1,14 @@
+What:  /config/usb-gadget/gadget/functions/eem.name
+Date:  May 2013
+KenelVersion:  3.11
+Description:
+   The attributes:
+
+   ifname  - network device interface name associated with
+   this function instance
+   qmult   - queue length multiplier for high and
+   super speed
+   host_addr   - MAC address of host's end of this
+   Ethernet over USB link
+   dev_addr- MAC address of device's end of this
+   Ethernet over USB link
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 90c15d3..96d2661 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -660,6 +660,21 @@ config USB_CONFIGFS_ECM
  favor of simpler vendor-specific hardware, but is widely
  supported by firmware for smart network devices.
 
+config USB_CONFIGFS_EEM
+   bool "Ethernet Emulation Model (EEM)"
+   depends on USB_CONFIGFS
+   depends on NET
+   select USB_U_ETHER
+   select USB_F_EEM
+   help
+ CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM
+ and therefore can be supported by more hardware.  Technically ECM and
+ EEM are designed for different applications.  The ECM model extends
+ the network interface to the target (e.g. a USB cable modem), and the
+ EEM model is for mobile devices to communicate with hosts using
+ ethernet over USB.  For Linux gadgets, however, the interface with
+ the host is the same (a usbX device), so the differences are minimal.
+
 config USB_CONFIGFS_PHONET
boolean "Phonet protocol"
depends on USB_CONFIGFS
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 31a2cb7..90ee802 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -19,6 +19,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_eem.h"
 
 #define EEM_HLEN 2
@@ -263,8 +264,10 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
 * with regard to eem_opts->bound access
 */
if (!eem_opts->bound) {
+   mutex_lock(&eem_opts->lock);
gether_set_gadget(eem_opts->net, cdev->gadget);
status = gether_register_netdev(eem_opts->net);
+   mutex_unlock(&eem_opts->lock);
if (status)
return status;
eem_opts->bound = true;
@@ -533,6 +536,41 @@ error:
return status;
 }
 
+static inline struct f_eem_opts *to_f_eem_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_eem_opts,
+   func_inst.group);
+}
+
+/* f_eem_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(eem);
+
+/* f_eem_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(eem);
+
+/* f_eem_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(eem);
+
+/* f_eem_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
+
+/* f_eem_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
+
+static struct configfs_attribute *eem_attrs[] = {
+   &f_eem_opts_dev_addr.attr,
+   &f_eem_opts_host_addr.attr,
+   &f_eem_opts_qmult.attr,
+   &f_eem_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type eem_func_type = {
+   .ct_item_ops= &eem_item_ops,
+   .ct_attrs   = eem_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void eem_free_inst(struct usb_function_instance *f)
 {
struct f_eem_opts *opts;
@@ -552,20 +590,28 @@ static struct usb_function_instance *eem_alloc_inst(void)
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
+   mutex_init(&opts->lock);
opts->func_inst.free_func_inst = eem_free_inst;
opts->net = gether_setup_default();
if (IS_ERR(opts->net))
return ERR_CAST(opts->net);
 
+   config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
+
return &opts->func_inst;
 }
 
 static void eem_free(struct usb_function 

[PATCH v2 11/17] usb/gadget: f_subset: use usb_gstrings_attach

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_subset.c |   18 --
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index 4a0eb68..d340317 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -296,6 +296,7 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_gether *geth = func_to_geth(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
@@ -319,14 +320,13 @@ geth_bind(struct usb_configuration *c, struct 
usb_function *f)
gether_opts->bound = true;
}
 #endif
-   /* maybe allocate device-global string IDs */
-   if (geth_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, geth_string_defs);
-   if (status < 0)
-   return status;
-   subset_data_intf.iInterface = geth_string_defs[0].id;
-   ether_desc.iMACAddress = geth_string_defs[1].id;
-   }
+   us = usb_gstrings_attach(cdev, geth_strings,
+ARRAY_SIZE(geth_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+
+   subset_data_intf.iInterface = us[0].id;
+   ether_desc.iMACAddress = us[1].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -431,7 +431,6 @@ int geth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
geth->port.cdc_filter = DEFAULT_FILTER;
 
geth->port.func.name = "cdc_subset";
-   geth->port.func.strings = geth_strings;
geth->port.func.bind = geth_bind;
geth->port.func.unbind = geth_old_unbind;
geth->port.func.set_alt = geth_set_alt;
@@ -513,7 +512,6 @@ static struct usb_function *geth_alloc(struct 
usb_function_instance *fi)
geth->port.cdc_filter = DEFAULT_FILTER;
 
geth->port.func.name = "cdc_subset";
-   geth->port.func.strings = geth_strings;
geth->port.func.bind = geth_bind;
geth->port.func.unbind = geth_unbind;
geth->port.func.set_alt = geth_set_alt;
-- 
1.7.0.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 v2 10/17] usb/gadget: ether: convert to new interface of f_subset

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ether.c |  104 
 2 files changed, 58 insertions(+), 47 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index adbcde4..74a0a98 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -761,6 +761,7 @@ config USB_ETH
select USB_U_ETHER
select USB_U_RNDIS
select USB_F_ECM
+   select USB_F_SUBSET
select CRC32
help
  This driver implements Ethernet style communication, in one of
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3173966..9e96d55 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -14,6 +14,7 @@
 /* #define VERBOSE_DEBUG */
 
 #include 
+#include 
 
 #if defined USB_ETH_RNDIS
 #  undef USB_ETH_RNDIS
@@ -103,8 +104,7 @@ static inline bool has_rndis(void)
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "u_ecm.h"
-#define USB_FSUBSET_INCLUDED
-#include "f_subset.c"
+#include "u_gether.h"
 #ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
 #include "rndis.h"
@@ -220,6 +220,9 @@ static struct usb_function *f_ecm;
 static struct usb_function_instance *fi_eem;
 static struct usb_function *f_eem;
 
+static struct usb_function_instance *fi_geth;
+static struct usb_function *f_geth;
+
 /*-*/
 
 /*
@@ -290,8 +293,17 @@ static int __init eth_do_config(struct usb_configuration 
*c)
usb_put_function(f_ecm);
 
return status;
-   } else
-   return geth_bind_config(c, host_mac, the_dev);
+   } else {
+   f_geth = usb_get_function(fi_geth);
+   if (IS_ERR(f_geth))
+   return PTR_ERR(f_geth);
+
+   status = usb_add_function(c, f_geth);
+   if (status < 0)
+   usb_put_function(f_geth);
+
+   return status;
+   }
 
 }
 
@@ -309,16 +321,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
struct usb_gadget   *gadget = cdev->gadget;
struct f_eem_opts   *eem_opts = NULL;
struct f_ecm_opts   *ecm_opts = NULL;
+   struct f_gether_opts*geth_opts = NULL;
+   struct net_device   *net;
int status;
 
-   if (!use_eem && !can_support_ecm(gadget)) {
-   /* set up network link layer */
-   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr,
-   host_mac, qmult);
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
-   }
-
/* set up main config label and device descriptor */
if (use_eem) {
/* EEM */
@@ -328,13 +334,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
 
eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst);
 
-   gether_set_qmult(eem_opts->net, qmult);
-   if (!gether_set_host_addr(eem_opts->net, host_addr))
-   pr_info("using host ethernet address: %s", host_addr);
-   if (!gether_set_dev_addr(eem_opts->net, dev_addr))
-   pr_info("using self ethernet address: %s", dev_addr);
-
-   the_dev = netdev_priv(eem_opts->net);
+   net = eem_opts->net;
+   the_dev = netdev_priv(net);
 
eth_config_driver.label = "CDC Ethernet (EEM)";
device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
@@ -348,17 +349,23 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
 
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
 
-   gether_set_qmult(ecm_opts->net, qmult);
-   if (!gether_set_host_addr(ecm_opts->net, host_addr))
-   pr_info("using host ethernet address: %s", host_addr);
-   if (!gether_set_dev_addr(ecm_opts->net, dev_addr))
-   pr_info("using self ethernet address: %s", dev_addr);
-
-   the_dev = netdev_priv(ecm_opts->net);
+   net = ecm_opts->net;
+   the_dev = netdev_priv(net);
 
eth_config_driver.label = "CDC Ethernet (ECM)";
} else {
/* CDC Subset */
+
+   fi_geth = usb_get_function_instance("geth");
+   if (IS_ERR(fi_geth))
+   return PTR_ERR(fi_geth);
+
+   geth_opts = container_of(fi_geth, struct f_gether_opts,
+func_inst);
+
+   net = geth_opts->net;
+   the_dev = netdev_priv(net);
+
eth_config_driver.label = "CDC Subset/SAFE";
 
device_desc.idVendor = cpu_to_le16(SIMPLE_VENDOR_NUM);
@@ -367,23 +374,26 @@ stati

[PATCH v2 12/17] usb/gadget: f_subset: add configfs support

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 .../ABI/testing/configfs-usb-gadget-subset |   14 ++
 drivers/usb/gadget/Kconfig |   10 
 drivers/usb/gadget/f_subset.c  |   46 +++-
 drivers/usb/gadget/u_gether.h  |9 
 4 files changed, 78 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-subset

diff --git a/Documentation/ABI/testing/configfs-usb-gadget-subset 
b/Documentation/ABI/testing/configfs-usb-gadget-subset
new file mode 100644
index 000..f47170a
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-subset
@@ -0,0 +1,14 @@
+What:  /config/usb-gadget/gadget/functions/geth.name
+Date:  May 2013
+KenelVersion:  3.11
+Description:
+   The attributes:
+
+   ifname  - network device interface name associated with
+   this function instance
+   qmult   - queue length multiplier for high and
+   super speed
+   host_addr   - MAC address of host's end of this
+   Ethernet over USB link
+   dev_addr- MAC address of device's end of this
+   Ethernet over USB link
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 74a0a98..ca21750 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -663,6 +663,16 @@ config USB_CONFIGFS_ECM
  favor of simpler vendor-specific hardware, but is widely
  supported by firmware for smart network devices.
 
+config USB_CONFIGFS_ECM_SUBSET
+   boolean "Ethernet Control Model (CDC ECM) subset"
+   depends on USB_CONFIGFS
+   depends on NET
+   select USB_U_ETHER
+   select USB_F_SUBSET
+   help
+ On hardware that can't implement the full protocol,
+ a simple CDC subset is used, placing fewer demands on USB.
+
 config USB_CONFIGFS_EEM
bool "Ethernet Emulation Model (EEM)"
depends on USB_CONFIGFS
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index d340317..0cd47d6 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -17,6 +17,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_gether.h"
 
 /*
@@ -313,8 +314,10 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
 * with regard to gether_opts->bound access
 */
if (!gether_opts->bound) {
+   mutex_lock(&gether_opts->lock);
gether_set_gadget(gether_opts->net, cdev->gadget);
status = gether_register_netdev(gether_opts->net);
+   mutex_unlock(&gether_opts->lock);
if (status)
return status;
gether_opts->bound = true;
@@ -444,6 +447,41 @@ int geth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
 
 #else
 
+static inline struct f_gether_opts *to_f_gether_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_gether_opts,
+   func_inst.group);
+}
+
+/* f_gether_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(gether);
+
+/* f_gether_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(gether);
+
+/* f_gether_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(gether);
+
+/* f_gether_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether);
+
+/* f_gether_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether);
+
+static struct configfs_attribute *gether_attrs[] = {
+   &f_gether_opts_dev_addr.attr,
+   &f_gether_opts_host_addr.attr,
+   &f_gether_opts_qmult.attr,
+   &f_gether_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type gether_func_type = {
+   .ct_item_ops= &gether_item_ops,
+   .ct_attrs   = gether_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void geth_free_inst(struct usb_function_instance *f)
 {
struct f_gether_opts *opts;
@@ -463,12 +501,15 @@ static struct usb_function_instance *geth_alloc_inst(void)
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
-
+   mutex_init(&opts->lock);
opts->func_inst.free_func_inst = geth_free_inst;
opts->net = gether_setup_default();
if (IS_ERR(opts->net))
return ERR_CAST(opts->net);
 
+   config_group_init_type_name(&opts->func_inst.group, "",
+   &gether_func_type);
+
return &opts->func_inst;
 }
 
@@ -499,6 +540,8 @@ static struct usb_function *geth_alloc(struct 
usb_function_instance *fi)
 
opts = container_of(fi, struct f_gether_opts, func_inst);
 
+   mutex_lock(&opts->lock);
+   opts->refcnt++;
/* export host's 

[PATCH v2 14/17] usb/gadget: ether: convert to new interface of f_rndis

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ether.c |   56 ++--
 2 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index fc56db1..a4131af 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -811,6 +811,7 @@ config USB_ETH_RNDIS
bool "RNDIS support"
depends on USB_ETH
select USB_LIBCOMPOSITE
+   select USB_F_RNDIS
default y
help
   Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 4d7290a..f48712f 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -94,23 +94,14 @@ static inline bool has_rndis(void)
 
 #include 
 
-/*-*/
-
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
 #include "u_ecm.h"
 #include "u_gether.h"
 #ifdef USB_ETH_RNDIS
-#define USB_FRNDIS_INCLUDED
-#include "f_rndis.c"
+#include "u_rndis.h"
 #include "rndis.h"
+#else
+#define rndis_borrow_net(...) do {} while (0)
 #endif
-
 #include "u_eem.h"
 
 /*-*/
@@ -212,9 +203,6 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-static u8 host_mac[ETH_ALEN];
-static struct eth_dev *the_dev;
-
 static struct usb_function_instance *fi_ecm;
 static struct usb_function *f_ecm;
 
@@ -224,6 +212,9 @@ static struct usb_function *f_eem;
 static struct usb_function_instance *fi_geth;
 static struct usb_function *f_geth;
 
+static struct usb_function_instance *fi_rndis;
+static struct usb_function *f_rndis;
+
 /*-*/
 
 /*
@@ -233,6 +224,8 @@ static struct usb_function *f_geth;
  */
 static int __init rndis_do_config(struct usb_configuration *c)
 {
+   int status;
+
/* FIXME alloc iConfiguration string, set it in c->strings */
 
if (gadget_is_otg(c->cdev->gadget)) {
@@ -240,7 +233,15 @@ static int __init rndis_do_config(struct usb_configuration 
*c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   return rndis_bind_config(c, host_mac, the_dev);
+   f_rndis = usb_get_function(fi_rndis);
+   if (IS_ERR(f_rndis))
+   return PTR_ERR(f_rndis);
+
+   status = usb_add_function(c, f_rndis);
+   if (status < 0)
+   usb_put_function(f_rndis);
+
+   return status;
 }
 
 static struct usb_configuration rndis_config_driver = {
@@ -336,7 +337,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst);
 
net = eem_opts->net;
-   the_dev = netdev_priv(net);
 
eth_config_driver.label = "CDC Ethernet (EEM)";
device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
@@ -351,7 +351,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
 
net = ecm_opts->net;
-   the_dev = netdev_priv(net);
 
eth_config_driver.label = "CDC Ethernet (ECM)";
} else {
@@ -365,7 +364,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
 func_inst);
 
net = geth_opts->net;
-   the_dev = netdev_priv(net);
 
eth_config_driver.label = "CDC Subset/SAFE";
 
@@ -387,7 +385,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
status = gether_register_netdev(net);
if (status)
goto fail;
-   gether_get_host_addr_u8(net, host_mac);
 
if (use_eem)
eem_opts->bound = true;
@@ -396,6 +393,14 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
else
geth_opts->bound = true;
 
+   fi_rndis = usb_get_function_instance("rndis");
+   if (IS_ERR(fi_rndis)) {
+   status = PTR_ERR(fi_rndis);
+   goto fail;
+   }
+
+   rndis_borrow_net(fi_rndis, net);
+
device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM);
device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM);
device_desc.bNumConfigurations = 2;
@@ -407,7 +412,7 @@ static int __init eth_bind(struct usb_c

[PATCH v2 15/17] usb/gadget: rndis: init & exit rndis at module load/unload

2013-05-28 Thread Andrzej Pietrasiewicz
This is required in preparation for using usb_gstrings_attach.
The rndis initialization so far has been performed on the first
occurence of rndis_bind(), but the condition to check it (first
or not first) was "borrowed" from strings handling.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_rndis.c |   15 ++-
 drivers/usb/gadget/rndis.c   |4 ++--
 drivers/usb/gadget/rndis.h   |3 ---
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 437198b..e5c6aee 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -698,11 +698,6 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
 #endif
 
if (rndis_string_defs[0].id == 0) {
-   /* ... and setup RNDIS itself */
-   status = rndis_init();
-   if (status < 0)
-   return status;
-
status = usb_string_ids_tab(c->cdev, rndis_string_defs);
if (status)
return status;
@@ -844,7 +839,6 @@ rndis_old_unbind(struct usb_configuration *c, struct 
usb_function *f)
struct f_rndis  *rndis = func_to_rndis(f);
 
rndis_deregister(rndis->config);
-   rndis_exit();
 
rndis_string_defs[0].id = 0;
usb_free_all_descriptors(f);
@@ -891,11 +885,9 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
rndis->port.func.disable = rndis_disable;
 
status = usb_add_function(c, &rndis->port.func);
-   if (status) {
+   if (status)
kfree(rndis);
 fail:
-   rndis_exit();
-   }
return status;
 }
 
@@ -958,7 +950,6 @@ static void rndis_unbind(struct usb_configuration *c, 
struct usb_function *f)
 {
struct f_rndis  *rndis = func_to_rndis(f);
 
-   rndis_exit();
rndis_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
@@ -974,10 +965,8 @@ static struct usb_function *rndis_alloc(struct 
usb_function_instance *fi)
 
/* allocate and initialize one new instance */
rndis = kzalloc(sizeof(*rndis), GFP_KERNEL);
-   if (!rndis) {
-   rndis_exit();
+   if (!rndis)
return ERR_PTR(-ENOMEM);
-   }
 
opts = container_of(fi, struct f_rndis_opts, func_inst);
 
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 4e84964..45f1114 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1174,7 +1174,7 @@ int rndis_init(void)
 
return 0;
 }
-EXPORT_SYMBOL(rndis_init);
+module_init(rndis_init);
 
 void rndis_exit(void)
 {
@@ -1188,6 +1188,6 @@ void rndis_exit(void)
}
 #endif
 }
-EXPORT_SYMBOL(rndis_exit);
+module_exit(rndis_exit);
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/rndis.h b/drivers/usb/gadget/rndis.h
index 6e79615..0f4abb4 100644
--- a/drivers/usb/gadget/rndis.h
+++ b/drivers/usb/gadget/rndis.h
@@ -217,7 +217,4 @@ int  rndis_signal_disconnect (int configNr);
 int  rndis_state (int configNr);
 extern void rndis_set_host_mac (int configNr, const u8 *addr);
 
-int rndis_init(void);
-void rndis_exit (void);
-
 #endif  /* _LINUX_RNDIS_H */
-- 
1.7.0.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 v2 17/17] usb/gadget: f_rndis: add configfs support

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 .../ABI/testing/configfs-usb-gadget-rndis  |   14 ++
 drivers/usb/gadget/Kconfig |   16 ++
 drivers/usb/gadget/f_rndis.c   |   49 +++-
 drivers/usb/gadget/u_rndis.h   |9 
 4 files changed, 87 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-rndis

diff --git a/Documentation/ABI/testing/configfs-usb-gadget-rndis 
b/Documentation/ABI/testing/configfs-usb-gadget-rndis
new file mode 100644
index 000..ff127dd
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-rndis
@@ -0,0 +1,14 @@
+What:  /config/usb-gadget/gadget/functions/rndis.name
+Date:  May 2013
+KenelVersion:  3.11
+Description:
+   The attributes:
+
+   ifname  - network device interface name associated with
+   this function instance
+   qmult   - queue length multiplier for high and
+   super speed
+   host_addr   - MAC address of host's end of this
+   Ethernet over USB link
+   dev_addr- MAC address of device's end of this
+   Ethernet over USB link
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a4131af..882f854 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -676,6 +676,22 @@ config USB_CONFIGFS_ECM_SUBSET
  On hardware that can't implement the full protocol,
  a simple CDC subset is used, placing fewer demands on USB.
 
+config USB_CONFIGFS_RNDIS
+   bool "RNDIS"
+   depends on USB_CONFIGFS
+   depends on NET
+   select USB_U_ETHER
+   select USB_F_RNDIS
+   help
+  Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
+  and Microsoft provides redistributable binary RNDIS drivers for
+  older versions of Windows.
+
+  To make MS-Windows work with this, use Documentation/usb/linux.inf
+  as the "driver info file".  For versions of MS-Windows older than
+  XP, you'll need to download drivers from Microsoft's website; a URL
+  is given in comments found in that info file.
+
 config USB_CONFIGFS_EEM
bool "Ethernet Emulation Model (EEM)"
depends on USB_CONFIGFS
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 4045ca2..191df35 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_rndis.h"
 #include "rndis.h"
 
@@ -903,6 +904,41 @@ void rndis_borrow_net(struct usb_function_instance *f, 
struct net_device *net)
 }
 EXPORT_SYMBOL(rndis_borrow_net);
 
+static inline struct f_rndis_opts *to_f_rndis_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_rndis_opts,
+   func_inst.group);
+}
+
+/* f_rndis_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(rndis);
+
+/* f_rndis_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(rndis);
+
+/* f_rndis_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(rndis);
+
+/* f_rndis_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
+
+/* f_rndis_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
+
+static struct configfs_attribute *rndis_attrs[] = {
+   &f_rndis_opts_dev_addr.attr,
+   &f_rndis_opts_host_addr.attr,
+   &f_rndis_opts_qmult.attr,
+   &f_rndis_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type rndis_func_type = {
+   .ct_item_ops= &rndis_item_ops,
+   .ct_attrs   = rndis_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void rndis_free_inst(struct usb_function_instance *f)
 {
struct f_rndis_opts *opts;
@@ -924,22 +960,30 @@ static struct usb_function_instance 
*rndis_alloc_inst(void)
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
-
+   mutex_init(&opts->lock);
opts->func_inst.free_func_inst = rndis_free_inst;
opts->net = gether_setup_default();
if (IS_ERR(opts->net))
return ERR_CAST(opts->net);
 
+   config_group_init_type_name(&opts->func_inst.group, "",
+   &rndis_func_type);
+
return &opts->func_inst;
 }
 
 static void rndis_free(struct usb_function *f)
 {
struct f_rndis *rndis;
+   struct f_rndis_opts *opts;
 
rndis = func_to_rndis(f);
rndis_deregister(rndis->config);
+   opts = container_of(f->fi, struct f_rndis_opts, func_inst);
kfree(rndis);
+   mutex_lock(&opts->lock);
+   opts->refcnt--;
+   mutex_unlock(&opts->lock);
 }
 
 static void rndis_unbind(struct usb_configur

[PATCH v2 04/17] usb/gadget: ether: convert to new interface of f_eem

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ether.c |   54 ---
 2 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 5f68ad3..90c15d3 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -798,6 +798,7 @@ config USB_ETH_EEM
bool "Ethernet Emulation Model (EEM) support"
depends on USB_ETH
select USB_LIBCOMPOSITE
+   select USB_F_EEM
default n
help
  CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 397609d..2078e6c 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -109,8 +109,7 @@ static inline bool has_rndis(void)
 #include "rndis.h"
 #endif
 
-#define USB_FEEM_INCLUDED
-#include "f_eem.c"
+#include "u_eem.h"
 
 /*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
@@ -217,6 +216,9 @@ static struct eth_dev *the_dev;
 static struct usb_function_instance *fi_ecm;
 static struct usb_function *f_ecm;
 
+static struct usb_function_instance *fi_eem;
+static struct usb_function *f_eem;
+
 /*-*/
 
 /*
@@ -267,9 +269,17 @@ static int __init eth_do_config(struct usb_configuration 
*c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   if (use_eem)
-   return eem_bind_config(c, the_dev);
-   else if (can_support_ecm(c->cdev->gadget)) {
+   if (use_eem) {
+   f_eem = usb_get_function(fi_eem);
+   if (IS_ERR(f_eem))
+   return PTR_ERR(f_eem);
+
+   status = usb_add_function(c, f_eem);
+   if (status < 0)
+   usb_put_function(f_eem);
+
+   return status;
+   } else if (can_support_ecm(c->cdev->gadget)) {
f_ecm = usb_get_function(fi_ecm);
if (IS_ERR(f_ecm))
return PTR_ERR(f_ecm);
@@ -296,10 +306,11 @@ static struct usb_configuration eth_config_driver = {
 static int __init eth_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev->gadget;
+   struct f_eem_opts   *eem_opts = NULL;
struct f_ecm_opts   *ecm_opts = NULL;
int status;
 
-   if (use_eem || !can_support_ecm(gadget)) {
+   if (!use_eem && !can_support_ecm(gadget)) {
/* set up network link layer */
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr,
host_mac, qmult);
@@ -310,6 +321,20 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
/* set up main config label and device descriptor */
if (use_eem) {
/* EEM */
+   fi_eem = usb_get_function_instance("eem");
+   if (IS_ERR(fi_eem))
+   return PTR_ERR(fi_eem);
+
+   eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst);
+
+   gether_set_qmult(eem_opts->net, qmult);
+   if (!gether_set_host_addr(eem_opts->net, host_addr))
+   pr_info("using host ethernet address: %s", host_addr);
+   if (!gether_set_dev_addr(eem_opts->net, dev_addr))
+   pr_info("using self ethernet address: %s", dev_addr);
+
+   the_dev = netdev_priv(eem_opts->net);
+
eth_config_driver.label = "CDC Ethernet (EEM)";
device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
device_desc.idProduct = cpu_to_le16(EEM_PRODUCT_NUM);
@@ -343,7 +368,14 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
 
if (has_rndis()) {
/* RNDIS plus ECM-or-Subset */
-   if (!use_eem && can_support_ecm(gadget)) {
+   if (use_eem) {
+   gether_set_gadget(eem_opts->net, cdev->gadget);
+   status = gether_register_netdev(eem_opts->net);
+   if (status)
+   goto fail;
+   eem_opts->bound = true;
+   gether_get_host_addr_u8(eem_opts->net, host_mac);
+   } else if (can_support_ecm(gadget)) {
gether_set_gadget(ecm_opts->net, cdev->gadget);
status = gether_register_netdev(ecm_opts->net);
if (status)
@@ -386,8 +418,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
return 0;
 
 fail:
-   if (use_eem || !can_support_ecm(gadget))
+   if (!use_eem && !can_support_ecm(gadget))
gether_cleanup(the_dev);
+   else if (use_eem)
+   usb_put_function_instance(fi_

[PATCH v2 09/17] usb/gadget: f_subset: convert to new function interface with backward compatibility

2013-05-28 Thread Andrzej Pietrasiewicz
Converting ecm subset to the new function interface requires converting
the USB subset's function code and its users.
This patch converts the f_subset.c to the new function interface.
The file is now compiled into a separate usb_f_subset.ko module.
The old function interface is provided by means of a preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig|3 +
 drivers/usb/gadget/Makefile   |2 +
 drivers/usb/gadget/ether.c|1 +
 drivers/usb/gadget/f_subset.c |  136 -
 drivers/usb/gadget/g_ffs.c|1 +
 drivers/usb/gadget/u_gether.h |   27 
 6 files changed, 155 insertions(+), 15 deletions(-)
 create mode 100644 drivers/usb/gadget/u_gether.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 96d2661..adbcde4 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -575,6 +575,9 @@ config USB_F_PHONET
 config USB_F_EEM
tristate
 
+config USB_F_SUBSET
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index a8f6655..99655e5 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -57,6 +57,8 @@ usb_f_phonet-y:= f_phonet.o
 obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o
 usb_f_eem-y:= f_eem.o
 obj-$(CONFIG_USB_F_EEM)+= usb_f_eem.o
+usb_f_ecm_subset-y := f_subset.o
+obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 2078e6c..3173966 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -103,6 +103,7 @@ static inline bool has_rndis(void)
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "u_ecm.h"
+#define USB_FSUBSET_INCLUDED
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index 185d6f5..4a0eb68 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -12,11 +12,12 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include "u_ether.h"
-
+#include "u_gether.h"
 
 /*
  * This function packages a simple "CDC Subset" Ethernet port with no real
@@ -298,6 +299,35 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
+#ifndef USB_FSUBSET_INCLUDED
+   struct f_gether_opts*gether_opts;
+
+   gether_opts = container_of(f->fi, struct f_gether_opts, func_inst);
+
+   /*
+* in drivers/usb/gadget/configfs.c:configfs_composite_bind()
+* configurations are bound in sequence with list_for_each_entry,
+* in each configuration its functions are bound in sequence
+* with list_for_each_entry, so we assume no race condition
+* with regard to gether_opts->bound access
+*/
+   if (!gether_opts->bound) {
+   gether_set_gadget(gether_opts->net, cdev->gadget);
+   status = gether_register_netdev(gether_opts->net);
+   if (status)
+   return status;
+   gether_opts->bound = true;
+   }
+#endif
+   /* maybe allocate device-global string IDs */
+   if (geth_string_defs[0].id == 0) {
+   status = usb_string_ids_tab(c->cdev, geth_string_defs);
+   if (status < 0)
+   return status;
+   subset_data_intf.iInterface = geth_string_defs[0].id;
+   ether_desc.iMACAddress = geth_string_defs[1].id;
+   }
+
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
@@ -360,8 +390,10 @@ fail:
return status;
 }
 
+#ifdef USB_FSUBSET_INCLUDED
+
 static void
-geth_unbind(struct usb_configuration *c, struct usb_function *f)
+geth_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
geth_string_defs[0].id = 0;
usb_free_all_descriptors(f);
@@ -386,18 +418,6 @@ int geth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
struct f_gether *geth;
int status;
 
-   if (!ethaddr)
-   return -EINVAL;
-
-   /* maybe allocate device-global string IDs */
-   if (geth_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, geth_string_defs);
-   if (status < 0)
-   return status;
-   subset_data_intf.iInterface = geth_string_defs[0].id;
-   ether_desc.iMACAddress = geth_string_defs[1].id;
-   }
-
/* allocate and initialize one new instance */
geth = kzalloc

[PATCH v2 13/17] usb/gadget: f_rndis: convert to new function interface with backward compatibility

2013-05-28 Thread Andrzej Pietrasiewicz
Converting rndis to the new function interface requires converting
the USB rndis' function code and its users.
This patch converts the f_rndis.c to the new function interface.
The file is now compiled into a separate usb_f_rndis.ko module.
The old function interface is provided by means of a preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig   |3 +
 drivers/usb/gadget/Makefile  |2 +
 drivers/usb/gadget/ether.c   |1 +
 drivers/usb/gadget/f_rndis.c |  203 --
 drivers/usb/gadget/g_ffs.c   |1 +
 drivers/usb/gadget/multi.c   |1 +
 drivers/usb/gadget/u_rndis.h |   32 +++
 7 files changed, 215 insertions(+), 28 deletions(-)
 create mode 100644 drivers/usb/gadget/u_rndis.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index ca21750..fc56db1 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -578,6 +578,9 @@ config USB_F_EEM
 config USB_F_SUBSET
tristate
 
+config USB_F_RNDIS
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 99655e5..8cd7770 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -59,6 +59,8 @@ usb_f_eem-y   := f_eem.o
 obj-$(CONFIG_USB_F_EEM)+= usb_f_eem.o
 usb_f_ecm_subset-y := f_subset.o
 obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o
+usb_f_rndis-y  := f_rndis.o
+obj-$(CONFIG_USB_F_RNDIS)  += usb_f_rndis.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 9e96d55..4d7290a 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -106,6 +106,7 @@ static inline bool has_rndis(void)
 #include "u_ecm.h"
 #include "u_gether.h"
 #ifdef USB_ETH_RNDIS
+#define USB_FRNDIS_INCLUDED
 #include "f_rndis.c"
 #include "rndis.h"
 #endif
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 36e8c44..437198b 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -17,15 +17,16 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
 
 #include "u_ether.h"
+#include "u_rndis.h"
 #include "rndis.h"
 
-
 /*
  * This function is an RNDIS Ethernet port -- a Microsoft protocol that's
  * been promoted instead of the standard CDC Ethernet.  The published RNDIS
@@ -655,6 +656,13 @@ static void rndis_close(struct gether *geth)
 
 /*-*/
 
+/* Some controllers can't support RNDIS ... */
+static inline bool can_support_rndis(struct usb_configuration *c)
+{
+   /* everything else is *presumably* fine */
+   return true;
+}
+
 /* ethernet function driver setup/binding */
 
 static int
@@ -665,6 +673,45 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
int status;
struct usb_ep   *ep;
 
+#ifndef USB_FRNDIS_INCLUDED
+   struct f_rndis_opts *rndis_opts;
+
+   if (!can_support_rndis(c))
+   return -EINVAL;
+
+   rndis_opts = container_of(f->fi, struct f_rndis_opts, func_inst);
+
+   /*
+* in drivers/usb/gadget/configfs.c:configfs_composite_bind()
+* configurations are bound in sequence with list_for_each_entry,
+* in each configuration its functions are bound in sequence
+* with list_for_each_entry, so we assume no race condition
+* with regard to rndis_opts->bound access
+*/
+   if (!rndis_opts->bound) {
+   gether_set_gadget(rndis_opts->net, cdev->gadget);
+   status = gether_register_netdev(rndis_opts->net);
+   if (status)
+   return status;
+   rndis_opts->bound = true;
+   }
+#endif
+
+   if (rndis_string_defs[0].id == 0) {
+   /* ... and setup RNDIS itself */
+   status = rndis_init();
+   if (status < 0)
+   return status;
+
+   status = usb_string_ids_tab(c->cdev, rndis_string_defs);
+   if (status)
+   return status;
+
+   rndis_control_intf.iInterface = rndis_string_defs[0].id;
+   rndis_data_intf.iInterface = rndis_string_defs[1].id;
+   rndis_iad_descriptor.iFunction = rndis_string_defs[2].id;
+   }
+
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
@@ -741,10 +788,12 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
rndis->port.open = rndis_open;
rndis->port.close = rndis_close;
 
+#ifdef USB_FRNDIS_INCLUDED
status = rndis_register(rndis_response_available, rndis);
 

[PATCH v2 16/17] usb/gadget: f_rndis: use usb_gstrings_attach

2013-05-28 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_rndis.c |   22 --
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index e5c6aee..4045ca2 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -670,6 +670,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function 
*f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_rndis  *rndis = func_to_rndis(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
@@ -696,16 +697,13 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
rndis_opts->bound = true;
}
 #endif
-
-   if (rndis_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, rndis_string_defs);
-   if (status)
-   return status;
-
-   rndis_control_intf.iInterface = rndis_string_defs[0].id;
-   rndis_data_intf.iInterface = rndis_string_defs[1].id;
-   rndis_iad_descriptor.iFunction = rndis_string_defs[2].id;
-   }
+   us = usb_gstrings_attach(cdev, rndis_strings,
+ARRAY_SIZE(rndis_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   rndis_control_intf.iInterface = us[0].id;
+   rndis_data_intf.iInterface = us[1].id;
+   rndis_iad_descriptor.iFunction = us[2].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -840,7 +838,6 @@ rndis_old_unbind(struct usb_configuration *c, struct 
usb_function *f)
 
rndis_deregister(rndis->config);
 
-   rndis_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(rndis->notify_req->buf);
@@ -876,7 +873,6 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
rndis->port.unwrap = rndis_rm_hdr;
 
rndis->port.func.name = "rndis";
-   rndis->port.func.strings = rndis_strings;
/* descriptors are per-instance copies */
rndis->port.func.bind = rndis_bind;
rndis->port.func.unbind = rndis_old_unbind;
@@ -950,7 +946,6 @@ static void rndis_unbind(struct usb_configuration *c, 
struct usb_function *f)
 {
struct f_rndis  *rndis = func_to_rndis(f);
 
-   rndis_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(rndis->notify_req->buf);
@@ -984,7 +979,6 @@ static struct usb_function *rndis_alloc(struct 
usb_function_instance *fi)
rndis->port.unwrap = rndis_rm_hdr;
 
rndis->port.func.name = "rndis";
-   rndis->port.func.strings = rndis_strings;
/* descriptors are per-instance copies */
rndis->port.func.bind = rndis_bind;
rndis->port.func.unbind = rndis_unbind;
-- 
1.7.0.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] usb: dwc3: cleanup DWC3_DCTL_LSFTRST bit

2013-05-28 Thread Huang Rui
This bit is removed and set as reserved in 2.50a spec.

Signed-off-by: Huang Rui 
---
 drivers/usb/dwc3/core.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index b69d322..4e6e0f9 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -223,7 +223,6 @@
 /* Device Control Register */
 #define DWC3_DCTL_RUN_STOP (1 << 31)
 #define DWC3_DCTL_CSFTRST  (1 << 30)
-#define DWC3_DCTL_LSFTRST  (1 << 29)
 
 #define DWC3_DCTL_HIRD_THRES_MASK  (0x1f << 24)
 #define DWC3_DCTL_HIRD_THRES(n)((n) << 24)
-- 
1.7.10.4


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


Re: [PATCH] xhci: Add BayTrail to list of Intel switchable hosts

2013-05-28 Thread Heikki Krogerus
Hi Sarah,

On Fri, May 24, 2013 at 09:55:25AM -0700, Sarah Sharp wrote:
> At this point the port switchover quirk is getting unwieldy.  I know of
> at least two more platforms that will need the switchover quirk, and
> it's silly to keep adding them to the list.
> 
> Heikki, can you change the code to always try to switchover the ports
> from EHCI to xHCI if an Intel xHCI host is found, and fail gracefully if
> there isn't an EHCI host controller on board?
> 
> I suspect Intel will include the port switchover mechanism until they
> decide to only include xHCI hosts and no EHCI hosts.  In the meantime,
> we can avoid breaking USB 3.0 new platforms by always attempting to do
> the switchover.

OK, makes sense. I or Mathias will make the patch for you.

Thanks,

-- 
heikki
--
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 v2] usb: musb: fix clock naming

2013-05-28 Thread yegorslists
From: Yegor Yefremov 

'ick' was changed to 'hsotgusb_ick'
'fck' was changed to 'hsotgusb_fck'

Signed-off-by: Jan Luebbe 
Signed-off-by: Yegor Yefremov 
---
v2: CC linux-usb mailing list

 drivers/usb/musb/am35x.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 2231850..92b5b23 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -477,14 +477,14 @@ static int am35x_probe(struct platform_device *pdev)
goto err1;
}
 
-   phy_clk = clk_get(&pdev->dev, "fck");
+   phy_clk = clk_get(&pdev->dev, "hsotgusb_ick");
if (IS_ERR(phy_clk)) {
dev_err(&pdev->dev, "failed to get PHY clock\n");
ret = PTR_ERR(phy_clk);
goto err3;
}
 
-   clk = clk_get(&pdev->dev, "ick");
+   clk = clk_get(&pdev->dev, "hsotgusb_fck");
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
-- 
1.7.7

--
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] ARM: OMAP4: USB_EHCI_HCD needs USB_PHY and NOP_USB_XCEIV

2013-05-28 Thread Roger Quadros
On 05/27/2013 09:23 PM, Arnd Bergmann wrote:
> On Saturday 25 May 2013, Adrien Vergé wrote:
>> On OMAP4 platforms, EHCI HCD needs the physical layer signalling
>> activated, along with the NOP USB Transceiver driver. Otherwise, the
>> kernel boots without registering any USB device.
> 
> This does not actually sound like a critical error: If a user forgets
> to enable a driver, that driver will not be loaded. Of course the
> kernel should not just crash when a non-essential driver is missing,
> and it should not fail to build, but your description sounds harmless.
> 
> Am I missing something?

Right, there is no crash or anything if the PHY drivers are not selected,
just that OMAP USB host will not work.

> 
>> This patch applies to Linux 3.10-rc2.
>>
>> Signed-off-by: Adrien Vergé 
>> ---
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index de94f26..47959d7 100644
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
>> @@ -44,6 +44,8 @@ endif # USB_XHCI_HCD
>>  config USB_EHCI_HCD
>> tristate "EHCI HCD (USB 2.0) support"
> 
> This is the wrong place: it should be in USB_EHCI_HCD_OMAP
> if any.

Right.
> 
>> depends on USB_ARCH_HAS_EHCI
>> +   select USB_PHY if ARCH_OMAP4
>> +   select NOP_USB_XCEIV if ARCH_OMAP4
>> ---help---
>>   The Enhanced Host Controller Interface (EHCI) is standard for USB 
>> 2.0
>>   "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
> 
> 'select'ing USB_PHY sounds wrong too, I think you mean 'depends on'.
> 
> Also note that Roger Quadros has just removed the 'select NOP_USB_XCEIV'
> there, I think you should coordinate with him.

Selecting NOP_USB_XCEIV is wrong as it in turn depends on USB_PHY.

I'm not for depends as it would hide USB_EHCI_HCD_OMAP in menuconfig.
I'm for explicitly selecting both, as it makes the user's life much easier.
But I'm afraid maintainers might object to that.

The other option is to enable the required drivers in omap2plus_defconfig.
http://comments.gmane.org/gmane.linux.ports.arm.omap/97899

Maybe you could just resend that patch after addressing Kevin's comments?

cheers,
-roger
--
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] ARM: OMAP4: USB_EHCI_HCD needs USB_PHY and NOP_USB_XCEIV

2013-05-28 Thread Arnd Bergmann
On Tuesday 28 May 2013 11:14:37 Roger Quadros wrote:
> >> depends on USB_ARCH_HAS_EHCI
> >> +   select USB_PHY if ARCH_OMAP4
> >> +   select NOP_USB_XCEIV if ARCH_OMAP4
> >> ---help---
> >>   The Enhanced Host Controller Interface (EHCI) is standard for 
> >> USB 2.0
> >>   "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller 
> >> hardware.
> > 
> > 'select'ing USB_PHY sounds wrong too, I think you mean 'depends on'.
> > 
> > Also note that Roger Quadros has just removed the 'select NOP_USB_XCEIV'
> > there, I think you should coordinate with him.
> 
> Selecting NOP_USB_XCEIV is wrong as it in turn depends on USB_PHY.
> 
> I'm not for depends as it would hide USB_EHCI_HCD_OMAP in menuconfig.
> I'm for explicitly selecting both, as it makes the user's life much easier.
> But I'm afraid maintainers might object to that.

My preferred option would be to turn the 'menuconfig PHY' into 'menu',
which is what we did to solve a similar problem in drivers/mfd: It lets
us 'select' specific PHY drivers without turning on the entire
menu. Using 'select PHY' has the nasty side-effect of creating an
incorrect dependency between the OMAP EHCI driver and all the
non-OMAP phy drivers that become visible once the usb-phy directory
gets enabled.

Arnd
--
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: Linux USB file storage gadget with new UDC

2013-05-28 Thread victor yeo
Hi,

>> Yes, it is silly. The hardware interrupt is not being generated for
>> every SCSI command received, so the driver has to poll. I put the
>> polling code in a thread, and this dilemma is fixed.
>
> Are you sure about this?  If it is correct, you should _fix_ the
> interrupt problem.  Don't try to work around it by creating a new
> thread.
>
> Figure out why there isn't an interrupt.  Does your driver forget to
> set an interrupt-enable bit?
>
>> I still observe the SCSI_WRITE_10 command time out sometimes. When
>> time out happens, the gadget log shows:
>>
>> g_file_storage gadget: invalid CBW: len 512 sig 0x6f007442
>> g_file_storage gadget: bulk-in set wedge
>>
>> Is it because the gadget expects 31 byte command, but 512 byte data is
>> received instead?
>
> No.  It is because kagen2_ep_queue returned _before_ a new command was
> received, probably as a result of your polling thread.  Since there was
> no new command, the data in the buffer was wrong.
>
>> The full UDC/gadget log is attached. Hope it is useful. If not, i will
>> add in more printk statements.
>
> You can see the problem in the log:
>
>> g_file_storage gadget: bulk-in, length 13:
>> : 55 53 42 53 50 00 00 00 00 00 00 00 00
>> [start_transfer] 53425355 50
>> ept1 in queue len 0xd, buffer 0xc0c3c000
>> 0: 0x53425355
>> 4: 0x50
>> 8: 0x0
>> bulk_in_complete --> 0, 13/13
>
> That was the end of the previous command.  Now the gadget waits for a
> new command to arrive.
>
>> [start_transfer] 6f007442 7000
>> ept1 out queue len 0x200, buffer 0xc1338000
>> before kagen2_ep_queue
>> after kagen2_ep_queue
>> kagen2_ep_queue 512 512 512
>> [kagen2_ep_queue] 6f007442 7000
>
> kagen2_ep_queue returned but there was no interrupt.  This means no new
> data was received, so the old data is still in the buffer.
>
>> g_file_storage gadget: bulk_out_complete --> 0, 512/31
>> g_file_storage gadget: invalid CBW: len 512 sig 0x6f007442
>> g_file_storage gadget: bulk-in set wedge
>
> That 0x6f007442 is the old data from the previous command, as you can
> see from the log messages (it is the same data that was present when
> kagen2_ep_queue was called).
>

Now the UDC driver is working on both Linux and Windows host, meaning
the read/write operation is ok. I still use the polling method,
because waiting for interrupt is not reliable. Is it possible to
contribute the code to Linux community?

On the other hand, i run the USB 2.0 command verifier to test the
gadget, the gadget crashes at BOS descriptor test. I think the gadget
is not able to handle BOS descriptor, is the gadget driver setup
function returning negative error code for BOS descriptor?

Thanks,
victor
g_file_storage gadget: high-speed config #1
Unable to handle kernel NULL pointer dereference at virtual address 
pgd = c0204000
[] *pgd=
Internal error: Oops - BUG: 817 [#1] PREEMPT ARM
Modules linked in: g_file_storage kagen2_udc ath6kl_sdio ath6kl_core 
ka2000_sdio ka2000_sdhc
CPU: 0Not tainted  (3.4.4+ #43)
PC is at kagen2_irq+0x290/0x3bc [kagen2_udc]
LR is at handle_irq_event_percpu+0x30/0x178
pc : []lr : []psr: 6093
sp : c132de98  ip : 0002  fp : c132debc
r10:   r9 :   r8 : 
r7 : 0020  r6 : 0002  r5 : 0201  r4 : c12a8c00
r3 :   r2 : 0001  r1 : c12a8d1c  r0 : 
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0005717f  Table: 0130c000  DAC: 0017
Process chkbusy_t (pid: 121, stack limit = 0xc132c270)
Stack: (0xc132de98 to 0xc132e000)
de80:   0080 0002
dea0: c12b9840 c049cf70  0020 c132dee4 c132dec0 c02496d0 bf02f484
dec0: c049cf70 c132c000 c12b9840 c132df94   c132df04 c132dee8
dee0: c0249878 c02496b0 f5006000 c049cf70  f5006000 c132df1c c132df08
df00: c024bd38 c0249828 c024bc24 0020 c132df34 c132df20 c02490e0 c024bc34
df20: 0040 0020 c132df4c c132df38 c0209c2c c02490c8 bf02f8c0 0013
df40: c132df5c c132df50 c0208410 c0209bd4 c132dfbc c132df60 c0208f14 c0208410
df60:  4000 0288001f c2886000 c12a8c00 c12a8c00 bf02f894 0013
df80:    c132dfbc c132c000 c132dfa8 4001 bf02f8c0
dfa0: 0013   c128dd58 c132dff4 c132dfc0 c022f8f4 bf02f8a4
dfc0: c128dd58  c12a8c00  c132dfd0 c132dfd0  c128dd58
dfe0: c022f860 c02191c8  c132dff8 c02191c8 c022f870 08f0 0402
Backtrace: 
[] (kagen2_irq+0x0/0x3bc [kagen2_udc]) from [] 
(handle_irq_event_percpu+0x30/0x178)
 r7:0020 r6: r5:c049cf70 r4:c12b9840
[] (handle_irq_event_percpu+0x0/0x178) from [] 
(handle_irq_event+0x60/0x7c)
[] (handle_irq_event+0x0/0x7c) from [] 
(handle_edge_irq+0x114/0x16c)
 r6:f5006000 r5: r4:c049cf70 r3:f5006000
[] (handle_edge_irq+0x0/0x16c) from [] 
(generic_handle_irq+0x28/0x38)
 r4:0020 r3:c024bc24
[] (generic_handle_irq+0x0/0x38) from [] 
(handle_IRQ+0x68/0x8c)
 r4:0020

[PATCH] usb: phy: samsung: Add support for EXYNOS4210

2013-05-28 Thread Jingoo Han
Add support for EXYNOS4210 that includes USB EHCI/OHCI.
Previous PHY initialization code is not correct; thus, it is modifed
to support EXYNOS4210 PHY. Also, after common clock framework for
Samsung is added, clock name is defined as 'usb_device'.

Signed-off-by: Jingoo Han 
---
Tested on Exynos4210.

 drivers/usb/phy/phy-samsung-usb.h  |   35 ++---
 drivers/usb/phy/phy-samsung-usb2.c |   74 +---
 2 files changed, 98 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.h 
b/drivers/usb/phy/phy-samsung-usb.h
index 70a9cae..34c35e8 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -22,13 +22,22 @@
 
 #define SAMSUNG_PHYPWR (0x00)
 
+#define PHYPWR_PHY1_HSIC_NORMAL_MASK   (0xf << 9)
+#define PHYPWR_PHY1_HSIC1_SLEEP(1 << 12)
+#define PHYPWR_PHY1_HSIC1_FORCE_SUSPEND(1 << 11)
+#define PHYPWR_PHY1_HSIC0_SLEEP(1 << 10)
+#define PHYPWR_PHY1_HSIC0_FORCE_SUSPEND(1 << 9)
+#define PHYPWR_PHY1_STD_NORMAL_MASK(0x7 << 6)
+#define PHYPWR_PHY1_STD_SLEEP  (1 << 8)
+#define PHYPWR_PHY1_STD_ANALOG_POWERDOWN   (1 << 7)
+#define PHYPWR_PHY1_STD_FORCE_SUSPEND  (1 << 6)
 #define PHYPWR_NORMAL_MASK (0x19 << 0)
 #define PHYPWR_OTG_DISABLE (0x1 << 4)
 #define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
 #define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
 /* For Exynos4 */
-#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
-#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
+#define PHYPWR_PHY0_NORMAL_MASK(0x39 << 0)
+#define PHYPWR_PHY0_SLEEP  (0x1 << 5)
 
 #define SAMSUNG_PHYCLK (0x04)
 
@@ -43,9 +52,25 @@
 
 #define SAMSUNG_RSTCON (0x08)
 
-#define RSTCON_PHYLINK_SWRST   (0x1 << 2)
-#define RSTCON_HLINK_SWRST (0x1 << 1)
-#define RSTCON_SWRST   (0x1 << 0)
+#define RSTCON_HOST_LINK_PORT_SWRST_MASK   (0xf << 6)
+#define RSTCON_HOST_LINK_PORT2_SWRST   (0x1 << 9)
+#define RSTCON_HOST_LINK_PORT1_SWRST   (0x1 << 8)
+#define RSTCON_HOST_LINK_PORT0_SWRST   (0x1 << 7)
+#define RSTCON_HOST_LINK_ALL_SWRST (0x1 << 6)
+#define RSTCON_PHY1_SWRST_MASK (0x7 << 3)
+#define RSTCON_PHY1_HSIC_SWRST (0x1 << 5)
+#define RSTCON_PHY1_STD_SWRST  (0x1 << 4)
+#define RSTCON_PHY1_ALL_SWRST  (0x1 << 3)
+#define RSTCON_PHY0_SWRST_MASK (0x7 << 0)
+#define RSTCON_PHY0_PHYLINK_SWRST  (0x1 << 2)
+#define RSTCON_PHY0_HLINK_SWRST(0x1 << 1)
+#define RSTCON_PHY0_SWRST  (0x1 << 0)
+
+/* EXYNOS4 */
+#define EXYNOS4_PHY1CON(0x34)
+
+#define PHY1CON_FPENABLEN  (0x1 << 0)
+
 
 /* EXYNOS5 */
 #define EXYNOS5_PHY_HOST_CTRL0 (0x00)
diff --git a/drivers/usb/phy/phy-samsung-usb2.c 
b/drivers/usb/phy/phy-samsung-usb2.c
index 9d5e273..4f93d84 100644
--- a/drivers/usb/phy/phy-samsung-usb2.c
+++ b/drivers/usb/phy/phy-samsung-usb2.c
@@ -158,6 +158,15 @@ static void samsung_exynos5_usb2phy_enable(struct 
samsung_usbphy *sphy)
writel(ohcictrl, regs + EXYNOS5_PHY_HOST_OHCICTRL);
 }
 
+static bool exynos4_phyhost_is_on(void __iomem *regs)
+{
+   u32 reg;
+
+   reg = readl(regs + SAMSUNG_PHYPWR);
+
+   return !(reg & PHYPWR_PHY1_STD_ANALOG_POWERDOWN);
+}
+
 static void samsung_usb2phy_enable(struct samsung_usbphy *sphy)
 {
void __iomem *regs = sphy->regs;
@@ -165,6 +174,18 @@ static void samsung_usb2phy_enable(struct samsung_usbphy 
*sphy)
u32 phyclk;
u32 rstcon;
 
+   switch (sphy->drv_data->cpu_type) {
+   case TYPE_EXYNOS4210:
+   atomic_inc(&sphy->phy_usage);
+
+   if (exynos4_phyhost_is_on(regs)) {
+   dev_info(sphy->dev, "Already power on PHY\n");
+   return;
+   }
+   default:
+   break;
+   }
+
/* set clock frequency for PLL */
phyclk = sphy->ref_clk_freq;
phypwr = readl(regs + SAMSUNG_PHYPWR);
@@ -174,22 +195,48 @@ static void samsung_usb2phy_enable(struct samsung_usbphy 
*sphy)
case TYPE_S3C64XX:
phyclk &= ~PHYCLK_COMMON_ON_N;
phypwr &= ~PHYPWR_NORMAL_MASK;
-   rstcon |= RSTCON_SWRST;
+   rstcon |= RSTCON_PHY0_SWRST;
break;
case TYPE_EXYNOS4210:
-   phypwr &= ~PHYPWR_NORMAL_MASK_PHY0;
-   rstcon |= RSTCON_SWRST;
+   phypwr &= ~(PHYPWR_PHY0_NORMAL_MASK |
+   PHYPWR_PHY1_STD_NORMAL_MASK |
+   PHYPWR_PHY1_HSIC_

Re: [PATCH] ARM: OMAP4: USB_EHCI_HCD needs USB_PHY and NOP_USB_XCEIV

2013-05-28 Thread Roger Quadros
On 05/28/2013 11:40 AM, Arnd Bergmann wrote:
> On Tuesday 28 May 2013 11:14:37 Roger Quadros wrote:
 depends on USB_ARCH_HAS_EHCI
 +   select USB_PHY if ARCH_OMAP4
 +   select NOP_USB_XCEIV if ARCH_OMAP4
 ---help---
   The Enhanced Host Controller Interface (EHCI) is standard for 
 USB 2.0
   "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller 
 hardware.
>>>
>>> 'select'ing USB_PHY sounds wrong too, I think you mean 'depends on'.
>>>
>>> Also note that Roger Quadros has just removed the 'select NOP_USB_XCEIV'
>>> there, I think you should coordinate with him.
>>
>> Selecting NOP_USB_XCEIV is wrong as it in turn depends on USB_PHY.
>>
>> I'm not for depends as it would hide USB_EHCI_HCD_OMAP in menuconfig.
>> I'm for explicitly selecting both, as it makes the user's life much easier.
>> But I'm afraid maintainers might object to that.
> 
> My preferred option would be to turn the 'menuconfig PHY' into 'menu',
> which is what we did to solve a similar problem in drivers/mfd: It lets
> us 'select' specific PHY drivers without turning on the entire
> menu. Using 'select PHY' has the nasty side-effect of creating an
> incorrect dependency between the OMAP EHCI driver and all the
> non-OMAP phy drivers that become visible once the usb-phy directory
> gets enabled.
>

Good idea, thanks. I will give this a try.

cheers,
-roger
--
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: serial: dump small buffers with help of %*ph

2013-05-28 Thread Andy Shevchenko
There is a specifier we may use to dump small buffers.

Signed-off-by: Andy Shevchenko 
---
 drivers/usb/serial/keyspan.c | 13 ++---
 drivers/usb/serial/pl2303.c  |  6 ++
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index eb30d7b..546fa90 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -520,12 +520,7 @@ static voidusa28_instat_callback(struct urb *urb)
goto exit;
}
 
-   /*
-   dev_dbg(&urb->dev->dev,
-   "%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__,
-   data[0], data[1], data[2], data[3], data[4], data[5],
-   data[6], data[7], data[8], data[9], data[10], data[11]);
-   */
+   /*dev_dbg(&urb->dev->dev, "%s %12ph", __func__, data);*/
 
/* Now do something useful with the data */
msg = (struct keyspan_usa28_portStatusMessage *)data;
@@ -607,11 +602,7 @@ static voidusa49_instat_callback(struct urb *urb)
goto exit;
}
 
-   /*
-   dev_dbg(&urb->dev->dev, "%s: %x %x %x %x %x %x %x %x %x %x %x",
-   __func__, data[0], data[1], data[2], data[3], data[4],
-   data[5], data[6], data[7], data[8], data[9], data[10]);
-   */
+   /*dev_dbg(&urb->dev->dev, "%s: %11ph", __func__, data);*/
 
/* Now do something useful with the data */
msg = (struct keyspan_usa49_portStatusMessage *)data;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 7151659..dc74c25 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -300,8 +300,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
0, 0, buf, 7, 100);
-   dev_dbg(&port->dev, "0xa1:0x21:0:0  %d - %x %x %x %x %x %x %x\n", i,
-   buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
+   dev_dbg(&port->dev, "0xa1:0x21:0:0  %d - %7ph\n", i, buf);
 
if (cflag & CSIZE) {
switch (cflag & CSIZE) {
@@ -448,8 +447,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
0, 0, buf, 7, 100);
-   dev_dbg(&port->dev, "0xa1:0x21:0:0  %d - %x %x %x %x %x %x %x\n", i,
-buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
+   dev_dbg(&port->dev, "0xa1:0x21:0:0  %d - %7ph\n", i, buf);
 
if (cflag & CRTSCTS) {
if (spriv->type == HX)
-- 
1.8.2.rc0.22.gb3600c3

--
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] uwb: use %*ph specifier to dump buffer

2013-05-28 Thread Andy Shevchenko
In kernel we have nice specifier %*ph to dump small buffers. Let's use it.

Signed-off-by: Andy Shevchenko 
---
 drivers/uwb/est.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/uwb/est.c b/drivers/uwb/est.c
index 86ed7e6..457f31d 100644
--- a/drivers/uwb/est.c
+++ b/drivers/uwb/est.c
@@ -436,7 +436,6 @@ ssize_t uwb_est_find_size(struct uwb_rc *rc, const struct 
uwb_rceb *rceb,
unsigned long flags;
unsigned itr;
u16 type_event_high, event;
-   u8 *ptr = (u8 *) rceb;
 
read_lock_irqsave(&uwb_est_lock, flags);
size = -ENOSPC;
@@ -453,12 +452,12 @@ ssize_t uwb_est_find_size(struct uwb_rc *rc, const struct 
uwb_rceb *rceb,
if (size != -ENOENT)
goto out;
}
-   dev_dbg(dev, "event 0x%02x/%04x/%02x: no handlers available; "
-   "RCEB %02x %02x %02x %02x\n",
+   dev_dbg(dev,
+   "event 0x%02x/%04x/%02x: no handlers available; RCEB %4ph\n",
(unsigned) rceb->bEventType,
(unsigned) le16_to_cpu(rceb->wEvent),
(unsigned) rceb->bEventContext,
-   ptr[0], ptr[1], ptr[2], ptr[3]);
+   rceb);
size = -ENOENT;
 out:
read_unlock_irqrestore(&uwb_est_lock, flags);
-- 
1.8.2.rc0.22.gb3600c3

--
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/usb/kalmia: use %*phC to dump small buffers

2013-05-28 Thread Andy Shevchenko
Instead of dereferencing pointer and put values on stack we could use nice
%*phC specifier.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/usb/kalmia.c | 46 --
 1 file changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c
index 0192073..13ecfc5 100644
--- a/drivers/net/usb/kalmia.c
+++ b/drivers/net/usb/kalmia.c
@@ -221,12 +221,9 @@ done:
memset(skb_put(skb, padlen), 0, padlen);
}
 
-   netdev_dbg(
-   dev->net,
-   "Sending package with length %i and padding %i. Header: 
%02x:%02x:%02x:%02x:%02x:%02x.",
-   content_len, padlen, header_start[0], header_start[1],
-   header_start[2], header_start[3], header_start[4],
-   header_start[5]);
+   netdev_dbg(dev->net,
+   "Sending package with length %i and padding %i. Header: %6phC.",
+   content_len, padlen, header_start);
 
return skb;
 }
@@ -263,32 +260,24 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp(
header_start, EXPECTED_UNKNOWN_HEADER_2,
sizeof(EXPECTED_UNKNOWN_HEADER_2))) {
-   netdev_dbg(
-   dev->net,
-   "Received expected unknown frame 
header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
-   header_start[0], header_start[1],
-   header_start[2], header_start[3],
-   header_start[4], header_start[5],
+   netdev_dbg(dev->net,
+   "Received expected unknown frame "
+   "header: %6phC. Package length: %i\n",
+   header_start,
skb->len - KALMIA_HEADER_LENGTH);
}
else {
-   netdev_err(
-   dev->net,
-   "Received unknown frame header: 
%02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
-   header_start[0], header_start[1],
-   header_start[2], header_start[3],
-   header_start[4], header_start[5],
+   netdev_err(dev->net,
+   "Received unknown frame header: %6phC. "
+   "Package length: %i\n", header_start,
skb->len - KALMIA_HEADER_LENGTH);
return 0;
}
}
else
-   netdev_dbg(
-   dev->net,
-   "Received header: 
%02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
-   header_start[0], header_start[1], 
header_start[2],
-   header_start[3], header_start[4], 
header_start[5],
-   skb->len - KALMIA_HEADER_LENGTH);
+   netdev_dbg(dev->net,
+   "Received header: %6phC. Package length: %i\n",
+   header_start, skb->len - KALMIA_HEADER_LENGTH);
 
/* subtract start header and end header */
usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH);
@@ -310,12 +299,9 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
sizeof(HEADER_END_OF_USB_PACKET)) == 0);
if (!is_last) {
header_start = skb->data + ether_packet_length;
-   netdev_dbg(
-   dev->net,
-   "End header: 
%02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
-   header_start[0], header_start[1],
-   header_start[2], header_start[3],
-   header_start[4], header_start[5],
+   netdev_dbg(dev->net,
+   "End header: %6phC. Package length: %i"
+   "\n", header_start,
skb->len - KALMIA_HEADER_LENGTH);
}
}
-- 
1.8.2.rc0.22.gb3600c3

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


Re: [PATCH v2] usb: omap2430: fix memleak in err case

2013-05-28 Thread Libo Chen
ping...

On 2013/5/22 11:30, Libo Chen wrote:
> 
> when omap_get_control_dev faild, we should release related platform_device
> 
> * Changelog from v1:
>   * fix spell: s/fail/fails/, s/relational/related/ , thank Sergei 
> 
> 
> Signed-off-by: Libo Chen 
> ---
>  drivers/usb/musb/omap2430.c |3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 3551f1a..b626f19 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -549,7 +549,8 @@ static int omap2430_probe(struct platform_device *pdev)
>   glue->control_otghs = omap_get_control_dev();
>   if (IS_ERR(glue->control_otghs)) {
>   dev_vdbg(&pdev->dev, "Failed to get control device\n");
> - return -ENODEV;
> + ret = -ENODEV;
> + goto err2;
>   }
>   } else {
>   glue->control_otghs = ERR_PTR(-ENODEV);
> 


--
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 0/3] USB: OHCI: Start splitting up the driver

2013-05-28 Thread Manjunath Goudar
This series of patches begins the process of splitting ohci-hcd up into
a core library module and independent pci driver modules.

Patch 1/3 prepares the way by exporting a few functions from ohci-hcd
and adding a new mechanism for platform-specific drivers to initialize
their hc_driver structures.  This deserves to be done in the core
because almost all of the entries in these structures are pure
boilerplate -- practically none of the drivers need to override more
than three of the standard core values.

Change from V7 to V8
ohci_hcd_init() is called by ohci_setup() to make generic ohci 
initialization in all ohci drivers.

Patch 2/3 is part of separating the ohci pci host controller
driver from ohci-hcd host code.
Moved sb800_prefetch() function from ohci-pci.c to pci-quirks.c file
and EXPORTed, this is part of the effort to move the ohci pci related
code to generic pci code.

Change from V7 to V8
no change.

Patch 3/3  separate out ohci-pci into independent driver modules.

Change from V7 to V8
USB_OHCI_HCD_PCI symbol no longer dependence on STB03xxx, PPC_MPC52xx and   
  
USB_OHCI_HCD_PPC_OF that's what removed.

Manjunath Goudar (3):
  USB: OHCI: prepare to make ohci-hcd a library module
  USB: OHCI: Generic changes to make ohci-pci a separate driver
  USB: OHCI: make ohci-pci a separate driver

 drivers/usb/host/Kconfig  |6 +-
 drivers/usb/host/Makefile |3 +
 drivers/usb/host/ohci-hcd.c   |  134 ++--
 drivers/usb/host/ohci-hub.c   |1 -
 drivers/usb/host/ohci-pci.c   |  151 -
 drivers/usb/host/ohci-q.c |6 +-
 drivers/usb/host/ohci.h   |   17 +
 drivers/usb/host/pci-quirks.c |   13 
 drivers/usb/host/pci-quirks.h |2 +
 9 files changed, 184 insertions(+), 149 deletions(-)

-- 
1.7.9.5

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


[PATCH V8 1/3] USB: OHCI: prepare to make ohci-hcd a library module

2013-05-28 Thread Manjunath Goudar
This patch prepares ohci-hcd for being split up into a core
library and separate platform driver modules.  A generic
ohci_hc_driver structure is created, containing all the "standard"
values, and a new mechanism is added whereby a driver module can
specify a set of overrides to those values.  In addition the
ohci_restart(),ohci_suspend() and ohci_resume() routines need
to be EXPORTed for use by the drivers.

Added ohci_setip(() and ohci_start() routine for to start the generic
controller rather than each having its own idiosyncratic approach.
This allow to clean duplicated code in most of SOC driver

In V2:
 -ohci_hcd_init() ohci_run() and ohci_stop() are not made non-static.
 -Adds the ohci_setup() and ohci_start() routine.

In V3:
 -purpose of ohci_setup() and ohci_start() function description written in the 
patch
  description.
 -ohci_init() are not made non-static but now called beginning of the 
ohci_restart().
 -ohci_run() signature change reverted back.
 -unrelated changes removed.
 -duplicate comment line removed.
 -inline ohci_suspend() and ohci_resume() is not needed so removed from ohci.h 
file.

In V4:
 -ohci-init() EXPORTed because it is called by all bus glue modules.
 -ohci-setup() removed from 1/2 added into 2/2 patch.

In V5:
 -Again ohci_setup() is added and EXPORTed because to replace the ohci_init() 
from
  all bus glues.
 -ohci_init() is not made non-static function.

In V6:
  -ohci_init() call is removed from ohci_quirk_nec_worker(), because it is 
already called in ohci_restart().

In V8:
  -ohci_hcd_init() is called by ohci_setup() to make generic ohci 
initialization in all ohci drivers.

Signed-off-by: Manjunath Goudar 
Acked-by: Alan Stern 
Cc: Arnd Bergmann 
Cc: Greg KH 
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/host/ohci-hcd.c |  105 +++
 drivers/usb/host/ohci-hub.c |1 -
 drivers/usb/host/ohci-pci.c |7 ---
 drivers/usb/host/ohci.h |   17 +++
 4 files changed, 113 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9e6de95..2815359 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -79,13 +79,7 @@ static const charhcd_name [] = "ohci_hcd";
 #include "pci-quirks.h"
 
 static void ohci_dump (struct ohci_hcd *ohci, int verbose);
-static int ohci_init (struct ohci_hcd *ohci);
 static void ohci_stop (struct usb_hcd *hcd);
-
-#if defined(CONFIG_PM) || defined(CONFIG_PCI)
-static int ohci_restart (struct ohci_hcd *ohci);
-#endif
-
 #ifdef CONFIG_PCI
 static void sb800_prefetch(struct ohci_hcd *ohci, int on);
 #else
@@ -768,6 +762,32 @@ retry:
return 0;
 }
 
+/* ohci_setup routine for generic controller initialization */
+
+int ohci_setup(struct usb_hcd *hcd)
+{
+   struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+
+   ohci_hcd_init(ohci);
+   
+   return ohci_init(ohci);
+}
+EXPORT_SYMBOL_GPL(ohci_setup);
+
+/* ohci_start routine for generic controller start of all OHCI bus glue */
+static int ohci_start(struct usb_hcd *hcd)
+{
+   struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+   int ret;
+
+   ret = ohci_run(ohci);
+   if (ret < 0) {
+   ohci_err(ohci, "can't start\n");
+   ohci_stop(hcd);
+   }
+   return ret;
+}
+
 /*-*/
 
 /* an interrupt happens */
@@ -949,12 +969,13 @@ static void ohci_stop (struct usb_hcd *hcd)
 #if defined(CONFIG_PM) || defined(CONFIG_PCI)
 
 /* must not be called from interrupt context */
-static int ohci_restart (struct ohci_hcd *ohci)
+int ohci_restart(struct ohci_hcd *ohci)
 {
int temp;
int i;
struct urb_priv *priv;
 
+   ohci_init(ohci);
spin_lock_irq(&ohci->lock);
ohci->rh_state = OHCI_RH_HALTED;
 
@@ -1008,12 +1029,13 @@ static int ohci_restart (struct ohci_hcd *ohci)
ohci_dbg(ohci, "restart complete\n");
return 0;
 }
+EXPORT_SYMBOL_GPL(ohci_restart);
 
 #endif
 
 #ifdef CONFIG_PM
 
-static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup)
+int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup)
 {
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
unsigned long   flags;
@@ -1031,9 +1053,10 @@ static int __maybe_unused ohci_suspend(struct usb_hcd 
*hcd, bool do_wakeup)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(ohci_suspend);
 
 
-static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated)
+int ohci_resume(struct usb_hcd *hcd, bool hibernated)
 {
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
int port;
@@ -1081,8 +1104,72 @@ static int __maybe_unused ohci_resume(struct usb_hcd 
*hcd, bool hibernated)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(ohci_resume);
+
+#endif
+
+/*-*/
+
+/*
+ * Generic structure: This gets copied for platform drivers so that

[PATCH V8 2/3] USB: OHCI: Generic changes to make ohci-pci a separate driver

2013-05-28 Thread Manjunath Goudar
Note that this changes is part of separating the ohci pci host controller
driver from ohci-hcd host code.
This contains :
 -Moved sb800_prefetch() function from ohci-pci.c to pci-quirks.c file
  and EXPORTed, this is part of the effort to move the ohci pci related
  code to generic pci code.
 -Passed "device" argument instead  of "ohci_hcd" in sb800_prefetch()
  function to avoid extra include file in pci-quirks.c.

V2:
 -Passed "device" argment instead of "pci_dev", then we use to_pci_dev()
  to get the "pci_dev" structure.

Signed-off-by: Manjunath Goudar 
Acked-by: Alan Stern 
Cc: Arnd Bergmann 
Cc: Greg KH 
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/host/ohci-hcd.c   |9 -
 drivers/usb/host/ohci-pci.c   |   13 -
 drivers/usb/host/ohci-q.c |6 --
 drivers/usb/host/pci-quirks.c |   13 +
 drivers/usb/host/pci-quirks.h |2 ++
 5 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 2815359..194ae4a 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -80,15 +80,6 @@ static const charhcd_name [] = "ohci_hcd";
 
 static void ohci_dump (struct ohci_hcd *ohci, int verbose);
 static void ohci_stop (struct usb_hcd *hcd);
-#ifdef CONFIG_PCI
-static void sb800_prefetch(struct ohci_hcd *ohci, int on);
-#else
-static inline void sb800_prefetch(struct ohci_hcd *ohci, int on)
-{
-   return;
-}
-#endif
-
 
 #include "ohci-hub.c"
 #include "ohci-dbg.c"
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 2c27a5f..c3fa936 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -168,19 +168,6 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
return 0;
 }
 
-static void sb800_prefetch(struct ohci_hcd *ohci, int on)
-{
-   struct pci_dev *pdev;
-   u16 misc;
-
-   pdev = to_pci_dev(ohci_to_hcd(ohci)->self.controller);
-   pci_read_config_word(pdev, 0x50, &misc);
-   if (on == 0)
-   pci_write_config_word(pdev, 0x50, misc & 0xfcff);
-   else
-   pci_write_config_word(pdev, 0x50, misc | 0x0300);
-}
-
 /* List of quirks for OHCI */
 static const struct pci_device_id ohci_pci_quirks[] = {
{
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 88731b7..df4a670 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -41,6 +41,7 @@ finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status)
 __releases(ohci->lock)
 __acquires(ohci->lock)
 {
+struct device *dev = ohci_to_hcd(ohci)->self.controller;
// ASSERT (urb->hcpriv != 0);
 
urb_free_priv (ohci, urb->hcpriv);
@@ -55,7 +56,7 @@ __acquires(ohci->lock)
if (quirk_amdiso(ohci))
usb_amd_quirk_pll_enable();
if (quirk_amdprefetch(ohci))
-   sb800_prefetch(ohci, 0);
+   sb800_prefetch(dev, 0);
}
break;
case PIPE_INTERRUPT:
@@ -580,6 +581,7 @@ static void td_submit_urb (
struct urb  *urb
 ) {
struct urb_priv *urb_priv = urb->hcpriv;
+   struct device *dev = ohci_to_hcd(ohci)->self.controller;
dma_addr_t  data;
int data_len = urb->transfer_buffer_length;
int cnt = 0;
@@ -689,7 +691,7 @@ static void td_submit_urb (
if (quirk_amdiso(ohci))
usb_amd_quirk_pll_disable();
if (quirk_amdprefetch(ohci))
-   sb800_prefetch(ohci, 1);
+   sb800_prefetch(dev, 1);
}
periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0
&& ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0;
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 4c338ec..b9848e4 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -91,6 +91,19 @@ static struct amd_chipset_info {
 
 static DEFINE_SPINLOCK(amd_lock);
 
+void sb800_prefetch(struct device *dev, int on)
+{
+   u16 misc;
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   pci_read_config_word(pdev, 0x50, &misc);
+   if (on == 0)
+   pci_write_config_word(pdev, 0x50, misc & 0xfcff);
+   else
+   pci_write_config_word(pdev, 0x50, misc | 0x0300);
+}
+EXPORT_SYMBOL_GPL(sb800_prefetch);
+
 int usb_amd_find_chipset_info(void)
 {
u8 rev = 0;
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h
index 7f69a39..4b8a209 100644
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quirks.h
@@ -11,11 +11,13 @@ void usb_amd_quirk_pll_enable(void);
 bool usb_is_intel_switchable_xhci(struct pci_dev *pdev);
 void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)

[PATCH V8 3/3] USB: OHCI: make ohci-pci a separate driver

2013-05-28 Thread Manjunath Goudar
This patch splits the PCI portion of ohci-hcd out into its
own separate driver module, called ohci-pci.

The major point of difficulty lies in ohci-pci's many vendor- and
device-specific workarounds.  Some of them have to be applied before
calling ohci_start() some after, which necessitates a fair amount of
code motion.  The other platform drivers require much smaller changes.

The complete sb800_prefetch() function moved to ohci-q.c,because its
only related to ohci-pci driver.

USB_OHCI_HCD_PCI symbol no longer dependence on STB03xxx, PPC_MPC52xx and
USB_OHCI_HCD_PPC_OF that's what removed.

V2:
  - few specific content of pci related code in ohci_pci_start function has 
been moved to ohci_pci_reset
and rest of the generic code is written in ohci_start of ohci-hcd.c file.
V3:
 - ohci_restart() has been called in ohci_pci_reset() function for to reset the 
ohci pci.

V4:
 -sb800_prefetch() moved to ohci-q.c,because its only related to ohci-pci.
 -no longer _creating_ CONFIG_USB_OHCI_PCI,creating CONFIG_USB_OHCI_HCD_PCI.
 -overrides renamed with pci_override,its giving proper meaning.

V5:
 -sb800_prefetch() moved to pci-quirks.c,because its only related to pci.

V6:
 -sb800_prefetch() function has been moved to pci-quirks.c made as separate 
patch in 2/3.
 -Most of the generic ohci pci changes moved in 2/3 patch,now this is complete  
ohci-pci separation patch.

V7:
 -Unrelated include file has been removed from ohci.h file.

V8:
 -USB_OHCI_HCD_PCI symbol does not dependence on STB03xxx, PPC_MPC52xx and 
USB_OHCI_HCD_PPC_OF.

Signed-off-by: Manjunath Goudar 
Cc: Arnd Bergmann 
Cc: Greg KH 
Cc: Alan Stern 
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/host/Kconfig|6 +-
 drivers/usb/host/Makefile   |3 +
 drivers/usb/host/ohci-hcd.c |   20 +--
 drivers/usb/host/ohci-pci.c |  131 +++
 4 files changed, 52 insertions(+), 108 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 64d7209..a0a2f3a 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -377,7 +377,7 @@ config USB_FUSBH200_HCD
module will be called fusbh200-hcd.
 
 config USB_OHCI_HCD
-   tristate "OHCI HCD support"
+   tristate "OHCI HCD (USB 1.1) support"
depends on USB_ARCH_HAS_OHCI
select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
depends on USB_ISP1301 || !ARCH_LPC32XX
@@ -446,8 +446,8 @@ config USB_OHCI_HCD_PPC_OF
default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE
 
 config USB_OHCI_HCD_PCI
-   bool "OHCI support for PCI-bus USB controllers"
-   depends on PCI && (STB03xxx || PPC_MPC52xx || USB_OHCI_HCD_PPC_OF)
+   tristate "OHCI support for PCI-bus USB controllers"
+   depends on PCI
default y
select USB_OHCI_LITTLE_ENDIAN
---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 661c558..2214ded 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -42,7 +42,10 @@ obj-$(CONFIG_USB_EHCI_TEGRA)+=ehci-tegra.o
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
 obj-$(CONFIG_USB_ISP1362_HCD)  += isp1362-hcd.o
+
 obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
+obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o
+
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
 obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 194ae4a..237be7c 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1168,11 +1168,6 @@ MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE ("GPL");
 
-#ifdef CONFIG_PCI
-#include "ohci-pci.c"
-#define PCI_DRIVER ohci_pci_driver
-#endif
-
 #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA)
 #include "ohci-sa.c"
 #define SA_DRIVER  ohci_hcd_sa_driver
@@ -1268,7 +1263,7 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVERohci_platform_driver
 #endif
 
-#if!defined(PCI_DRIVER) && \
+#if!IS_ENABLED(CONFIG_USB_OHCI_HCD_PCI) && \
!defined(PLATFORM_DRIVER) &&\
!defined(OMAP1_PLATFORM_DRIVER) &&  \
!defined(OMAP3_PLATFORM_DRIVER) &&  \
@@ -1343,12 +1338,6 @@ static int __init ohci_hcd_mod_init(void)
goto error_sa;
 #endif
 
-#ifdef PCI_DRIVER
-   retval = pci_register_driver(&PCI_DRIVER);
-   if (retval < 0)
-   goto error_pci;
-#endif
-
 #ifdef SM501_OHCI_DRIVER
retval = platform_driver_register(&SM501_OHCI_DRIVER);
if (retval < 0)
@@ -1442,10 +1431,6 @@ static int __init ohci_hcd_mod_init(void)
platform_driver_unregister(&SM501_OHCI_DRIVER);
  error_sm501:
 #endif
-#ifdef PCI_DRIVER
-   pci_unregister_driver(&PCI_DRIVER);
- error_pci:
-#endif
 #ifdef SA_DRIVER
sa_driver_unregister(&SA_DRIVER);
  error_sa1

Re: [PATCH] ARM: OMAP4: USB_EHCI_HCD needs USB_PHY and NOP_USB_XCEIV

2013-05-28 Thread Adrien Vergé
Dear Arnd and Roger, thank you for your answers.

2013/5/28 Roger Quadros 
> Selecting NOP_USB_XCEIV is wrong as it in turn depends on USB_PHY.
>
> I'm not for depends as it would hide USB_EHCI_HCD_OMAP in menuconfig.
> I'm for explicitly selecting both, as it makes the user's life much
> easier.
> But I'm afraid maintainers might object to that.
>
> The other option is to enable the required drivers in omap2plus_defconfig.
> http://comments.gmane.org/gmane.linux.ports.arm.omap/97899

This seems a good idea to me, since many OMAP users boot with NFS and
need USB directly working (Ethernet over USB).

> Maybe you could just resend that patch after addressing Kevin's comments?

It's sad that USB_EHCI_HCD is too instable to be added in omap2plus_defconfig.
Still, USB_PHY and NOP_USB_XCEIV are needed since v3.10 for USB
support (and harmless): should I send a patch adding those two in
omap2plus_defconfig?

Cheers,
Adrien
--
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: [regression] USB: EHCI: changes related to qh_refresh()

2013-05-28 Thread Alan Stern
On Mon, 27 May 2013, Oleksij Rempel wrote:

> > Hmmm.  Maybe we can narrow this down.  What happens if you apply only
> > parts of the commit?
> >
> > For example, on top of c97041a, try applying only the hunks that change
> > ehci-sched.c.  If that works, try applying also only the last hunk
> > affecting ehci-q.c. If that works, try applying also the two previous
> > hunks.
> >
> 
> after ehci-sched.c hank i have this problem again:
> 
> +++ b/drivers/usb/host/ehci-sched.c
> @@ -792,7 +792,6 @@ static int qh_schedule(struct ehci_hcd *ehci, struct 
> ehci_qh
>  unsignedframe;  /* 0..(qh->period - 1), or 
> NO_FRAME */
>  struct ehci_qh_hw   *hw = qh->hw;
> 
> -   qh_refresh(ehci, qh);
>  hw->hw_next = EHCI_LIST_END(ehci);
>  frame = qh->start;
> 
> @@ -844,8 +843,6 @@ static int qh_schedule(struct ehci_hcd *ehci, struct 
> ehci_qh
>  } else
>  ehci_dbg (ehci, "reused qh %p schedule\n", qh);
> 
> -   /* stuff into the periodic schedule */
> -   qh_link_periodic(ehci, qh);
>   done:
>  return status;
>   }
> @@ -891,6 +888,12 @@ static int intr_submit (
>  qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv);
>  BUG_ON (qh == NULL);
> 
> +   /* stuff into the periodic schedule */
> +   if (qh->qh_state == QH_STATE_IDLE) {
> +   qh_refresh(ehci, qh);
> +   qh_link_periodic(ehci, qh);
> +   }
> +
>  /* ... update usbfs periodic stats */
>  ehci_to_hcd(ehci)->self.bandwidth_int_reqs++;

Good grief, I can't believe I forgot to include this material in the
original commit.  I really am getting careless...

Anyway, this should fix the problem.

Alan Stern



Index: usb-3.9/drivers/usb/host/ehci-sched.c
===
--- usb-3.9.orig/drivers/usb/host/ehci-sched.c
+++ usb-3.9/drivers/usb/host/ehci-sched.c
@@ -646,6 +646,10 @@ static void end_unlink_intr(struct ehci_
/* reschedule QH iff another request is queued */
if (!list_empty(&qh->qtd_list) && ehci->rh_state == EHCI_RH_RUNNING) {
rc = qh_schedule(ehci, qh);
+   if (rc == 0) {
+   qh_refresh(ehci, qh);
+   qh_link_periodic(ehci, qh);
+   }
 
/* An error here likely indicates handshake failure
 * or no space left in the schedule.  Neither fault
@@ -653,9 +657,10 @@ static void end_unlink_intr(struct ehci_
 *
 * FIXME kill the now-dysfunctional queued urbs
 */
-   if (rc != 0)
+   else {
ehci_err(ehci, "can't reschedule qh %p, err %d\n",
qh, rc);
+   }
}
 
/* maybe turn off periodic schedule */

--
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] ARM: OMAP4: USB_EHCI_HCD needs USB_PHY and NOP_USB_XCEIV

2013-05-28 Thread Roger Quadros
Adrien,

On 05/28/2013 04:30 PM, Adrien Vergé wrote:
> Dear Arnd and Roger, thank you for your answers.
> 
> 2013/5/28 Roger Quadros 
>> Selecting NOP_USB_XCEIV is wrong as it in turn depends on USB_PHY.
>>
>> I'm not for depends as it would hide USB_EHCI_HCD_OMAP in menuconfig.
>> I'm for explicitly selecting both, as it makes the user's life much
>> easier.
>> But I'm afraid maintainers might object to that.
>>
>> The other option is to enable the required drivers in omap2plus_defconfig.
>> http://comments.gmane.org/gmane.linux.ports.arm.omap/97899
> 
> This seems a good idea to me, since many OMAP users boot with NFS and
> need USB directly working (Ethernet over USB).
> 
>> Maybe you could just resend that patch after addressing Kevin's comments?
> 
> It's sad that USB_EHCI_HCD is too instable to be added in omap2plus_defconfig.

This is not true as of today. A lot has changed since 2012 and most of the 
issues that Kevin
had pointed out then have been fixed. The only piece that is missing is 
allowing the system
to hit lower power states (e.g. RETention) when USB host is suspended. This 
feature
will eventually be supported when we have IO daisy chaining working with device 
tree.

> Still, USB_PHY and NOP_USB_XCEIV are needed since v3.10 for USB
> support (and harmless): should I send a patch adding those two in
> omap2plus_defconfig?

Yes please. Thanks :). I'm working on the approach Arnd suggested as well.

cheers,
-roger
--
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 3/3] USB: OHCI: make ohci-pci a separate driver

2013-05-28 Thread Alan Stern
On Tue, 28 May 2013, Manjunath Goudar wrote:

> This patch splits the PCI portion of ohci-hcd out into its
> own separate driver module, called ohci-pci.
> 
> The major point of difficulty lies in ohci-pci's many vendor- and
> device-specific workarounds.  Some of them have to be applied before
> calling ohci_start() some after, which necessitates a fair amount of
> code motion.  The other platform drivers require much smaller changes.
> 
> The complete sb800_prefetch() function moved to ohci-q.c,because its
> only related to ohci-pci driver.
> 
> USB_OHCI_HCD_PCI symbol no longer dependence on STB03xxx, PPC_MPC52xx and
> USB_OHCI_HCD_PPC_OF that's what removed.
> 
> V2:
>   - few specific content of pci related code in ohci_pci_start function has 
> been moved to ohci_pci_reset
> and rest of the generic code is written in ohci_start of ohci-hcd.c file.
> V3:
>  - ohci_restart() has been called in ohci_pci_reset() function for to reset 
> the ohci pci.
> 
> V4:
>  -sb800_prefetch() moved to ohci-q.c,because its only related to ohci-pci.
>  -no longer _creating_ CONFIG_USB_OHCI_PCI,creating CONFIG_USB_OHCI_HCD_PCI.
>  -overrides renamed with pci_override,its giving proper meaning.
> 
> V5:
>  -sb800_prefetch() moved to pci-quirks.c,because its only related to pci.
> 
> V6:
>  -sb800_prefetch() function has been moved to pci-quirks.c made as separate 
> patch in 2/3.
>  -Most of the generic ohci pci changes moved in 2/3 patch,now this is 
> complete  ohci-pci separation patch.
> 
> V7:
>  -Unrelated include file has been removed from ohci.h file.
> 
> V8:
>  -USB_OHCI_HCD_PCI symbol does not dependence on STB03xxx, PPC_MPC52xx and 
> USB_OHCI_HCD_PPC_OF.

Acked-by: Alan Stern 

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


Re: Linux USB file storage gadget with new UDC

2013-05-28 Thread Alan Stern
On Tue, 28 May 2013, victor yeo wrote:

> Now the UDC driver is working on both Linux and Windows host, meaning
> the read/write operation is ok. I still use the polling method,
> because waiting for interrupt is not reliable.

Why aren't the interrupts reliable?  Is this a known erratum for your 
hardware?

> Is it possible to
> contribute the code to Linux community?

Yes.  But first you should test it with other gadget drivers, not just
g_file_storage.

> On the other hand, i run the USB 2.0 command verifier to test the
> gadget, the gadget crashes at BOS descriptor test. I think the gadget
> is not able to handle BOS descriptor, is the gadget driver setup
> function returning negative error code for BOS descriptor?

The crash dump you attached contained this line:

PC is at kagen2_irq+0x290/0x3bc [kagen2_udc]

This means the crash occurred inside the UDC driver, not the gadget 
driver.

Alan Stern

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


Re: [PATCH v2] usb: omap2430: fix memleak in err case

2013-05-28 Thread Andy Shevchenko
No go.

Check the 4b7e450fb5cefb5865c77999a675330206ab3b8a
And update you tree, please.

--
With Best Regards,
Andy Shevchenko
--
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 V10 04/12] usb: ehci: ehci-mv: use PHY driver for ehci

2013-05-28 Thread Felipe Balbi
Hi,

On Mon, May 13, 2013 at 10:13:44AM -0400, Alan Stern wrote:
> On Mon, 13 May 2013, Chao Xie wrote:
> 
> > Originaly, ehci driver will call the callbacks in platform data
> > for PHY initialization and shut down.
> > With PHY driver, it will call the APIs provided by PHY driver
> > for PHY initialization and shutdown. It removes the callbacks
> > in platform data, and at same time it removes one block in the
> > way of enabling device tree for ehci driver.
> 
> I wonder if this is the sort of thing that should be handled in 
> ehci-hcd.c rather than in all the different platform glue drivers.
> 
> Felipe, what do you think?  Are the required actions now sufficiently 
> generic that a single source file can take care of them?

Sorry for the delay, was on business trip and now on vacations. Anyway,
I agree with you. Our PHY layer should be generic enough that it should
be usable by ehci-hcd itself. If we have any missing method, let's add
it generically.

cheers

ps: dropping this from my queue for now.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 20/39] usb: musb: ux500: move channel number knowledge into the driver

2013-05-28 Thread Felipe Balbi
Hi,

On Wed, May 15, 2013 at 07:18:01PM +0200, Linus Walleij wrote:
> On Wed, May 15, 2013 at 11:51 AM, Lee Jones  wrote:
> 
> > For all ux500 based platforms the maximum number of end-points are used.
> > Move this knowledge into the driver so we can relinquish the burden from
> > platform data. This also removes quite a bit of complexity from the driver
> > and will aid us when we come to enable the driver for Device Tree.
> >
> > Cc: Felipe Balbi 
> > Cc: linux-usb@vger.kernel.org
> > Acked-by: Linus Walleij 
> > Acked-by: Fabio Baltieri 
> > Signed-off-by: Lee Jones 
> 
> I guess this stuff is dependent on the stuff Fabio has recently sent to
> Felipe for the ux500 musb DMA so these musb patches should
> primarily go through his tree.
> 
> It seems like the later changes to the platform code
> (arch/arm/mach-ux500) may be sufficiently orthogonal
> so it can be done out-of-order?
> 
> I can't merge any of this without Felipes ACKs in any
> case.

Do you want to take this yourself ? I haven't fully read the series yet,
but seems like this depends on the rest of the series. If you want to
take it, let me know I can ack the patches as soon as I'm done
reviewing.

-- 
balbi


signature.asc
Description: Digital signature


Re: MUSB multiplatform work?

2013-05-28 Thread Felipe Balbi
Hi,

On Mon, May 27, 2013 at 05:02:09PM +0200, Arnd Bergmann wrote:
> Hi Felipe,
> 
> We've gone through remaining work items for getting the ARM kernel
> to full multiplatform support again, and MUSB came up. I'm sure you
> have your own thoughts on this, but I'd like to know if there is
> already a plan in place.
> 
> From what I can see, the driver in PIO mode should almost work
> on multiple platforms, but there are a couple of compile-time
> dependencies in it that need to be turned into run-time conditionals.
> In particular the TUSB version seem sufficiently different that
> it needs some extra work to be a true run-time option.

yeah, TUSB layer is quite messy, all the others should be doable though.

> The DMA support as far as I can tell has never been intended to
> be usable in a multiplatform setup, but that also seems doable.

we're looking into dmaengine for that but will take a lot of work to
have something usable.

> Looking just at the #ifdef statements in the driver, I found
> that the following things need to be addressed:
> 
> * abstract musb_write_fifo and musb_read_fifo into callbacks
> * move fifo_mode setting into glue driver for runtime selection

for the fifo mode, I'd rather detect the size of the internal fifo and
configure it dynamically based on that plus number of endpoints
configured in the IP.

> * turn TUSB compile-time switches into run-time conditionals
> * turn musb_ep_select into run-time switch
> * make is_dma_capable/is_cppi_enabled/tusb_dma_omap run-time conditionals

those can be remove, actually. Back at Nokia we did a huge cleanup on
the DMA programming part, it can be very simple with no ifdefs at all,
just needs someone to put the work and test on all platforms.

> * abtract dma_controller_create/destroy interface
> 
> Aside from this, a recent discussion with Maxime has brought up
> that the Allwinner A1x platform (mach-sunxi) contains an MUSB variant
> that is currently used with an independently implemented device driver,
> see 
> https://github.com/linux-sunxi/linux-sunxi/tree/sunxi-3.0/drivers/usb/sun5i_usb
> I wonder if you have any insight on how that can be integrated into
> musb, or whether it is likely to be a compatible version to start with.

just write a glue layer, should be as easy as that :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 20/39] usb: musb: ux500: move channel number knowledge into the driver

2013-05-28 Thread Lee Jones
Hi Felipe

> > > For all ux500 based platforms the maximum number of end-points are used.
> > > Move this knowledge into the driver so we can relinquish the burden from
> > > platform data. This also removes quite a bit of complexity from the driver
> > > and will aid us when we come to enable the driver for Device Tree.
> > >
> > > Cc: Felipe Balbi 
> > > Cc: linux-usb@vger.kernel.org
> > > Acked-by: Linus Walleij 
> > > Acked-by: Fabio Baltieri 
> > > Signed-off-by: Lee Jones 
> > 
> > I guess this stuff is dependent on the stuff Fabio has recently sent to
> > Felipe for the ux500 musb DMA so these musb patches should
> > primarily go through his tree.
> > 
> > It seems like the later changes to the platform code
> > (arch/arm/mach-ux500) may be sufficiently orthogonal
> > so it can be done out-of-order?
> > 
> > I can't merge any of this without Felipes ACKs in any
> > case.
> 
> Do you want to take this yourself ? I haven't fully read the series yet,
> but seems like this depends on the rest of the series. If you want to
> take it, let me know I can ack the patches as soon as I'm done
> reviewing.

Yes that would be ideal, if you wouldn't mind.

Kind regards,
Lee

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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] ARM: tegra: DT-related fixes needed by the USB tree

2013-05-28 Thread Stephen Warren
On 05/17/2013 04:50 PM, Stephen Warren wrote:
> Felipe, (and Alan, Greg),
> 
> These are the changes from the Tegra tree that need to be merged
> before the Tegra USB driver patches 4-8 from Venu can be applied. Recall
> that we had previously agreed on this approach for v3.9, but Venu's
> patches didn't end up being ready until now, unfortunately. I note
> that Venu's patches affect both the Tegra USB and PHY drivers.

Felipe, do you know when you plan to pull this into the USB tree, and
apply Venu's patches? 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


[PATCH v2] usb: dwc3: gadget: free trb pool only from epnum 2

2013-05-28 Thread Felipe Balbi
From: George Cherian 

we never allocate a TRB pool for physical endpoints
0 and 1 so trying to free it (a invalid TRB pool pointer)
will lead us in a warning while removing dwc3.ko module.

In order to fix the situation, all we have to do is skip
dwc3_free_trb_pool() for physical endpoints 0 and 1 just
as we while deleting endpoints from the endpoints list.

Cc: sta...@vger.kernel.org # v3.2+
Signed-off-by: George Cherian 
Signed-off-by: Felipe Balbi 
---

Improved the comment in the driver a little bit.

Also, Ccing stable. This should be backported as far back
as possible. This bug exists since first version of the
driver back in v3.2.

 drivers/usb/dwc3/gadget.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 2b6e7e0..b5e5b35 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1706,11 +1706,19 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
dep = dwc->eps[epnum];
if (!dep)
continue;
-
-   dwc3_free_trb_pool(dep);
-
-   if (epnum != 0 && epnum != 1)
+   /*
+* Physical endpoints 0 and 1 are special; they form the
+* bi-directional USB endpoint 0.
+*
+* For those two physical endpoints, we don't allocate a TRB
+* pool nor do we add them the endpoints list. Due to that, we
+* shouldn't do these two operations otherwise we would end up
+* with all sorts of bugs when removing dwc3.ko.
+*/
+   if (epnum != 0 && epnum != 1) {
+   dwc3_free_trb_pool(dep);
list_del(&dep->endpoint.ep_list);
+   }
 
kfree(dep);
}
-- 
1.8.2.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] usb: dwc3: cleanup DWC3_DCTL_LSFTRST bit

2013-05-28 Thread Felipe Balbi
On Tue, May 28, 2013 at 03:42:50PM +0800, Huang Rui wrote:
> This bit is removed and set as reserved in 2.50a spec.
> 
> Signed-off-by: Huang Rui 

so ? This driver also works on older versions of the core. What you
should do is, perhaps, add a comment saying that this bit shouldn't be
used in v2.50a+, then we need to keep an eye for any future users of
that bit and make sure that there is proper revision detection around
it.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/3] usb: dwc3: omap Modify dwc3_omap_readl/writel with offsets

2013-05-28 Thread Felipe Balbi
Hi,

On Mon, May 27, 2013 at 01:32:57PM +0530, George Cherian wrote:
> This patch modifies dwc3_omap_readl/writel calls to accomodate
> both OMAP5 and AM437x reg maps (It uses the cached register offsets).
> Also renames OMAP5 IRQ1 as IRQMISC, IRQ1 bits as IRQMISC bits.
> 
> Signed-off-by: George Cherian 

can you change this patch a bit so that it adds wrappers around
dwc3_omap_*() ? The idea is the have the code look like:

static u32 dwc3_omap_read_utmi_status(struct dwc3_omap *omap)
{
return dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS +
omap->utmi_otg_offset);
}

(likewise for write and for all other offsets, of course)

that way, reading/writing to registers which need the offset will be
less error-prone and th driver will look a little nicer.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: phy: samsung: Add support for EXYNOS4210

2013-05-28 Thread Felipe Balbi
On Tue, May 28, 2013 at 06:04:07PM +0900, Jingoo Han wrote:
> @@ -165,6 +174,18 @@ static void samsung_usb2phy_enable(struct samsung_usbphy 
> *sphy)
>   u32 phyclk;
>   u32 rstcon;
>  
> + switch (sphy->drv_data->cpu_type) {
> + case TYPE_EXYNOS4210:
> + atomic_inc(&sphy->phy_usage);

please switch over to the generic reference counting which I have
pending in my testing branch. It'll be available for v3.11 merge window.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 0/3] palmas usb driver

2013-05-28 Thread Felipe Balbi
On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> This patch series adds driver for palmas usb which is used to detect
> attach/detach events of usb device and usb host.
> 
> [PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> is added in this patch series itself. The revision history is added
> in the patch comments section.
> 
> A checkpatch warning "WARNING: static const char * array should
> probably be static const char * const"is ignored since it introduces a
> compilation warning.
> 
> Graeme Gregory (2):
>   drivers: regulator: palmas: add an API to set/clear the switch bit on
> SMPS10
>   extcon: Palmas Extcon Driver
> 
> Kishon Vijay Abraham I (1):
>   usb: dwc3: use extcon fwrk to receive connect/disconnect notification


There were some comments to this series, what will happen with it ? Any
new versions coming ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] usb: musb: fix clock naming

2013-05-28 Thread Felipe Balbi
On Tue, May 28, 2013 at 09:21:01AM +0200, yegorsli...@googlemail.com wrote:
> From: Yegor Yefremov 
> 
> 'ick' was changed to 'hsotgusb_ick'
> 'fck' was changed to 'hsotgusb_fck'
> 
> Signed-off-by: Jan Luebbe 
> Signed-off-by: Yegor Yefremov 

NAK. Fix your clock data.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] usb: omap2430: fix memleak in err case

2013-05-28 Thread Sergei Shtylyov

Hello.

On 22-05-2013 7:30, Libo Chen wrote:


when omap_get_control_dev faild, we should release related platform_device



* Changelog from v1:
* fix spell: s/fail/fails/, s/relational/related/ , thank Sergei 



   It seems you've actually replaced "fail" with "faild", not "fails".


Signed-off-by: Libo Chen 
---
  drivers/usb/musb/omap2430.c |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)


WBR, Sergei

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


Re: [PATCH v1 0/9] adding dual instance and usb-phy support for am335x platform

2013-05-28 Thread Felipe Balbi
Hi,

On Thu, May 23, 2013 at 11:31:19AM +0530, Ravi Babu wrote:
> This patch set series
> - adds dual musb instances support for am335x platform
> - adds phy-dsps-usb driver based on TI's gs70 driver
> - adds DT bindings for am33xx usb-phy
>   - removed references to usb-nop-xceiv from musb

as Sergei pointed out, this would break some DaVinci/DA8xx platforms, so
I'm dropping from it from my queue.

-- 
balbi


signature.asc
Description: Digital signature


Re: [GIT PULL] ARM: tegra: DT-related fixes needed by the USB tree

2013-05-28 Thread Felipe Balbi
On Tue, May 28, 2013 at 11:15:25AM -0600, Stephen Warren wrote:
> On 05/17/2013 04:50 PM, Stephen Warren wrote:
> > Felipe, (and Alan, Greg),
> > 
> > These are the changes from the Tegra tree that need to be merged
> > before the Tegra USB driver patches 4-8 from Venu can be applied. Recall
> > that we had previously agreed on this approach for v3.9, but Venu's
> > patches didn't end up being ready until now, unfortunately. I note
> > that Venu's patches affect both the Tegra USB and PHY drivers.
> 
> Felipe, do you know when you plan to pull this into the USB tree, and
> apply Venu's patches? Thanks.

got 35 commits testing right now. This pull is in my list for tomorrow.

sorry for the delay, have been on a trip for the last 3 weeks and now
I'm catching up with emails during my vacations (next 2 weeks).

-- 
balbi


signature.asc
Description: Digital signature


Re: xhci_hcd and Canon Lide 110 not playing well together

2013-05-28 Thread Holger Hans Peter Freyther
On Mon, Oct 22, 2012 at 10:01:04AM -0700, Sarah Sharp wrote:

Good Evening,

> > Maybe Sarah can give you some pointers on where to look next.
> 
> I've asked for a physical bus trace from one of our QA folks with the
> same scanner.  I think that will shed some light on whether this is a
> host-side bug or a software bug.  I do know that a certain set of
> scanners don't work under Ivy Bridge/Panther Point xHCI hosts, I just
> haven't had time to look at the bus trace to figure out why.

Debian/Sid has a 3.8 kernel now and I wanted to check if the scanner
can be used for my daily scanning routines. In terms of symptoms it
is still the same (the first page can be scanned, on the next scan
it just doesn't work).

Is there a timeline when you think this could be fixed?

holger
--
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: revert periodic scheduling bugfix

2013-05-28 Thread Alan Stern
This patch reverts commit 3e619d04159be54b3daa0b7036b0ce9e067f4b5d
(USB: EHCI: fix bug in scheduling periodic split transfers).  The
commit was valid -- it fixed a real bug -- but the periodic scheduler
in ehci-hcd is in such bad shape (especially the part that handles
split transactions) that fixing one bug is very likely to cause
another to surface.  That's what happened in this case; the result was
choppy and noisy playback on certain 24-bit audio devices.

The only real fix will be to rewrite this entire section of code.  My
next project...

This fixes https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1136110.

Thanks to Tim Richardson for extra testing and feedback, and to Joseph
Salisbury and Tyson Tan for tracking down the original source of the
problem.

Signed-off-by: Alan Stern 
CC: Joseph Salisbury 
CC: Tim Richardson 
CC: 

---

[as1683]


 drivers/usb/host/ehci-sched.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: usb-3.9/drivers/usb/host/ehci-sched.c
===
--- usb-3.9.orig/drivers/usb/host/ehci-sched.c
+++ usb-3.9/drivers/usb/host/ehci-sched.c
@@ -213,7 +213,7 @@ static inline unsigned char tt_start_ufr
 }
 
 static const unsigned char
-max_tt_usecs[] = { 125, 125, 125, 125, 125, 125, 125, 25 };
+max_tt_usecs[] = { 125, 125, 125, 125, 125, 125, 30, 0 };
 
 /* carryover low/fullspeed bandwidth that crosses uframe boundries */
 static inline void carryover_tt_bandwidth(unsigned short tt_usecs[8])

--
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/usb/kalmia: use %*phC to dump small buffers

2013-05-28 Thread Sergei Shtylyov

Hello.

On 28-05-2013 13:56, Andy Shevchenko wrote:


Instead of dereferencing pointer and put values on stack we could use nice
%*phC specifier.



Signed-off-by: Andy Shevchenko 
---
  drivers/net/usb/kalmia.c | 46 --
  1 file changed, 16 insertions(+), 30 deletions(-)



diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c
index 0192073..13ecfc5 100644
--- a/drivers/net/usb/kalmia.c
+++ b/drivers/net/usb/kalmia.c

[...]

@@ -263,32 +260,24 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp(
header_start, EXPECTED_UNKNOWN_HEADER_2,
sizeof(EXPECTED_UNKNOWN_HEADER_2))) {
-   netdev_dbg(
-   dev->net,
-   "Received expected unknown frame header: 
%02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
-   header_start[0], header_start[1],
-   header_start[2], header_start[3],
-   header_start[4], header_start[5],
+   netdev_dbg(dev->net,
+   "Received expected unknown frame "
+   "header: %6phC. Package length: %i\n",


   Message strings shouldn't be broken, despite 80 chars limit (there's an
exception for them in checkpatch.pl).


+   header_start,
skb->len - KALMIA_HEADER_LENGTH);
}
else {
-   netdev_err(
-   dev->net,
-   "Received unknown frame header: 
%02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
-   header_start[0], header_start[1],
-   header_start[2], header_start[3],
-   header_start[4], header_start[5],
+   netdev_err(dev->net,
+   "Received unknown frame header: %6phC. "
+   "Package length: %i\n", header_start,


   Same here...


skb->len - KALMIA_HEADER_LENGTH);
return 0;
}
}

[...]

@@ -310,12 +299,9 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
sizeof(HEADER_END_OF_USB_PACKET)) == 0);
if (!is_last) {
header_start = skb->data + ether_packet_length;
-   netdev_dbg(
-   dev->net,
-   "End header: %02x:%02x:%02x:%02x:%02x:%02x. 
Package length: %i\n",
-   header_start[0], header_start[1],
-   header_start[2], header_start[3],
-   header_start[4], header_start[5],
+   netdev_dbg(dev->net,
+   "End header: %6phC. Package length: %i"
+   "\n", header_start,


   ... and here.

WBR, Sergei

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


Re: [PATCH] net/usb/kalmia: use %*phC to dump small buffers

2013-05-28 Thread Andy Shevchenko
On Tue, May 28, 2013 at 9:14 PM, Sergei Shtylyov
 wrote:
> On 28-05-2013 13:56, Andy Shevchenko wrote:

>> @@ -263,32 +260,24 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff
>> *skb)
>> sizeof(EXPECTED_UNKNOWN_HEADER_1)) ||
>> !memcmp(
>> header_start, EXPECTED_UNKNOWN_HEADER_2,
>> sizeof(EXPECTED_UNKNOWN_HEADER_2))) {
>> -   netdev_dbg(
>> -   dev->net,
>> -   "Received expected unknown frame
>> header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
>> -   header_start[0], header_start[1],
>> -   header_start[2], header_start[3],
>> -   header_start[4], header_start[5],
>> +   netdev_dbg(dev->net,
>> +   "Received expected unknown frame "
>> +   "header: %6phC. Package length:
>> %i\n",
>
>Message strings shouldn't be broken, despite 80 chars limit (there's an
> exception for them in checkpatch.pl).

I'm glad to hear that checkpatch.pl is eventually fixed.
Will send patch v2 tomorrow.

--
With Best Regards,
Andy Shevchenko
--
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 v2 1/2] usb: dwc3: pci: PHY should be deleted later than dwc3 core

2013-05-28 Thread Felipe Balbi
From: Peter Chen 

If the glue layer is removed first (core layer later),
it deletes the phy device first, then the core device.
But at core's removal, it still uses PHY's resources, it may
cause kernel's oops. It is much like the problem
Paul Zimmerman reported at:
http://marc.info/?l=linux-usb&m=136547502011472&w=2.

Besides, it is reasonable the PHY is deleted at last as
the controller is the PHY's user.

Signed-off-by: Peter Chen 
Cc: 
Signed-off-by: Felipe Balbi 
---

fixed stable address

 drivers/usb/dwc3/dwc3-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 227d4a7..eba9e2b 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -196,9 +196,9 @@ static void dwc3_pci_remove(struct pci_dev *pci)
 {
struct dwc3_pci *glue = pci_get_drvdata(pci);
 
+   platform_device_unregister(glue->dwc3);
platform_device_unregister(glue->usb2_phy);
platform_device_unregister(glue->usb3_phy);
-   platform_device_unregister(glue->dwc3);
pci_set_drvdata(pci, NULL);
pci_disable_device(pci);
 }
-- 
1.8.2.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 v2 2/2] usb: dwc3: exynos: PHY should be deleted later than dwc3 core

2013-05-28 Thread Felipe Balbi
From: Peter Chen 

If the glue layer is removed first (core layer later),
it deletes the phy device first, then the core device.
But at core's removal, it still uses PHY's resources, it may
cause kernel's oops. It is much like the problem
Paul Zimmerman reported at:
http://marc.info/?l=linux-usb&m=136547502011472&w=2.

Besides, it is reasonable the PHY is deleted at last as
the controller is the PHY's user.

Signed-off-by: Peter Chen 
Cc: 
Signed-off-by: Felipe Balbi 
---

fixed stable address

 drivers/usb/dwc3/dwc3-exynos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 929e7dd..8ce9d7f 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -164,9 +164,9 @@ static int dwc3_exynos_remove(struct platform_device *pdev)
 {
struct dwc3_exynos  *exynos = platform_get_drvdata(pdev);
 
+   device_for_each_child(&pdev->dev, NULL, dwc3_exynos_remove_child);
platform_device_unregister(exynos->usb2_phy);
platform_device_unregister(exynos->usb3_phy);
-   device_for_each_child(&pdev->dev, NULL, dwc3_exynos_remove_child);
 
clk_disable_unprepare(exynos->clk);
 
-- 
1.8.2.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 2/2] usb-serial: Moxa UPORT 12XX/14XX/16XX driver

2013-05-28 Thread Andrew Lunn
On Sun, May 26, 2013 at 06:04:24PM +0200, Johan Hovold wrote:
> On Sun, May 26, 2013 at 01:00:51PM +0200, Andrew Lunn wrote:
> > +/*
> > + * mxuport_write_room
> > + *
> > + * Return how much space is available in the buffer.
> > + */
> > +static int mxuport_write_room(struct tty_struct *tty)
> > +{
> > +   struct usb_serial_port *port = tty->driver_data;
> > +   unsigned long flags;
> > +   int room;
> > +
> > +   spin_lock_irqsave(&port->lock, flags);
> > +   room = kfifo_avail(&port->write_fifo);
> > +   spin_unlock_irqrestore(&port->lock, flags);
> > +
> > +   dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
> > +   return room;
> > +}


 
> It seems it could be possible to reuse the generic write implementations
> of all functions but prepare_write_buffer above rather than the modified
> copies.

Hi Johan

If there a reason why usb_serial_generic_write_room() is not exported
as a GPL symbol. It looks like i should be able to use it once i sort
my 'fake' ports/endpoints out.

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


RE: [PATCH] staging: dwc2: fix value of dma_mask

2013-05-28 Thread Paul Zimmerman
> From: Matthijs Kooijman [mailto:matth...@stdin.nl]
> Sent: Friday, May 24, 2013 11:47 PM
> 
> On Fri, May 24, 2013 at 04:27:56PM -0700, Paul Zimmerman wrote:
> > Passing the value DMA_BIT_MASK(31) to dma_set_mask() causes the
> > dwc2-pci driver to sometimes fail (cannot enumerate the connected
> > device). Change it to DMA_BIT_MASK(32) instead, which is a more
> > sensible value anyway.
> 
> Isn't 32 the default value usually? Not sure a about PCI devices,
> though. It also made sense to set it to 31, since the comment talks
> about a workaround for > 2GB ram (and 2GB ~~ 31 bits).
> 
> Or, is the workaround really only needed in the coherent mask and is
> that the reason why you didn't change the coherent dma mask to 32?
> 
> If this is so, wouldn't it make sense to only set the coherent dma mask
> and leave the dma mask at whatever default (just guessing here...).

Hi Matthijs,

About the comment for the workaround, I was the one who added the
comment and the workaround, because I was seeing a kernel crash
when there was an Isoc transfer with an unaligned data buffer. That
was with the 3.9 rc- series. Since then, I haven't been able to
cause an unaligned Isoc transfer to occur, so I cannot verify if
the workaround is still needed. But since with later kernels it
sometimes completely fails to work with the 31-bit DMA mask, I see
no choice but to set the mask to 32 bits.

About removing the call to dma_set_mask(), according to
Documentation/DMA-API-HOWTO.txt:

   For correct operation, you must interrogate the kernel in your device
   probe routine to see if the DMA controller on the machine can properly
   support the DMA addressing limitation your device has.  It is good
   style to do this even if your device holds the default setting,
   because this shows that you did think about these issues wrt. your
   device.

   The query is performed via a call to dma_set_mask():
   int dma_set_mask(struct device *dev, u64 mask);

So I think having the call to dma_set_mask() is the recommended way to
do it.

-- 
Paul

--
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 0/3] USB: OHCI: Start splitting up the driver

2013-05-28 Thread Arnd Bergmann
On Tuesday 28 May 2013, Manjunath Goudar wrote:
> This series of patches begins the process of splitting ohci-hcd up into
> a core library module and independent pci driver modules.
> 

Seems to basically work now, but I'm getting run-time errors after
loading the driver, with patch 1/3 applied:

[15916.438452] input: Logitech USB-PS/2 Optical Mouse as 
/devices/pci:00/:00:12.0/usb3/3-1/3-1:1.0/input/input26
[15916.438584] hid-generic 0003:046D:C050.0017: input,hidraw0: USB HID v1.10 
Mouse [Logitech USB-PS/2 Optical Mouse] on usb-:00:12.0-1/input0
[15917.465597] usb 3-3: new full-speed USB device number 3 using ohci-pci
[15917.636712] usb 3-3: New USB device found, idVendor=0ccd, idProduct=0077
[15917.636717] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[15917.636721] usb 3-3: Product: USB PnP Sound Device
[15917.636724] usb 3-3: Manufacturer: C-Media Electronics Inc.  
[15917.812827] input: C-Media Electronics Inc.   USB PnP Sound Device as 
/devices/pci:00/:00:12.0/usb3/3-3/3-3:1.3/input/input27
[15917.812919] hid-generic 0003:0CCD:0077.0018: input,hidraw1: USB HID v1.00 
Device [C-Media Electronics Inc.   USB PnP Sound Device] on 
usb-:00:12.0-3/input3
[15918.789906] cannot submit urb (err = -18)
[15918.790163] cannot submit urb (err = -18)
[15918.842095] usb 7-1: new full-speed USB device number 2 using ohci-pci
[15919.883135] cannot submit urb (err = -18)
[15919.883604] cannot submit urb (err = -18)
[15919.883613] cannot submit urb (err = -18)
[15919.883616] cannot submit urb (err = -18)
[15919.883619] cannot submit urb (err = -18)
[15919.883623] cannot submit urb (err = -18)
[15919.883626] cannot submit urb (err = -18)
[15919.883629] cannot submit urb (err = -18)
[15919.883632] cannot submit urb (err = -18)
[15919.883639] delay: estimated 354, actual 1
[15919.883644] cannot submit urb (err = -18)
[15919.883647] delay: estimated 353, actual 0
[15919.883651] cannot submit urb (err = -18)

Arnd
--
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: xhci: Disable runtime PM suspend for quirky controllers.

2013-05-28 Thread Sarah Sharp
On Sat, May 25, 2013 at 09:57:57AM -0700, Shawn Nematbakhsh wrote:
> Hi Sarah and Alan,
> 
> Thanks for the comments. I will make the following revisions:
> 
> 1. Call pm_runtime_get_noresume only when the first device is connected,
> and call pm_runtime_put when the last device is disconnected.
> 2. Wrap the calls in an ifdef CONFIG_USB_DEFAULT_PERSIST.
> 3. Make sure that all pm_runtime_get_noresume calls have a corresponding
> pm_runtime_put somewhere (originally the intent was to disable runtime
> suspend "forever", but no longer).
> 
> In principle, would the patch be acceptable with these revisions?

Maybe, but I still don't like this approach, because it's too
heavy-handed.

I was considering whether userspace could do something similar to this
approach, but with udev rules instead of within the kernel.   You could
add a udev rule to trigger on USB device insertion, that would disable
runtime PM for the host, and a corresponding rule that re-enabled
runtime PM when the last USB device was disconnected.

I think it could be possible if userspace can get to the DMI information
for the system.  However, then we open the other can of worms by needing
to keep the userspace quirks list in sync with the kernel quirks list.

What if we exposed the xHCI quirks through a new quirks file in
/sys/bus/usb/devices/usbN/?  That would mean userspace doesn't need to
keep the quirks list separately.

Sarah Sharp
--
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/2] usb-serial: Moxa UPORT 12XX/14XX/16XX driver

2013-05-28 Thread Johan Hovold
On Tue, May 28, 2013 at 09:41:08PM +0200, Andrew Lunn wrote:
> On Sun, May 26, 2013 at 06:04:24PM +0200, Johan Hovold wrote:
> > On Sun, May 26, 2013 at 01:00:51PM +0200, Andrew Lunn wrote:
> > > +/*
> > > + * mxuport_write_room
> > > + *
> > > + * Return how much space is available in the buffer.
> > > + */
> > > +static int mxuport_write_room(struct tty_struct *tty)
> > > +{
> > > + struct usb_serial_port *port = tty->driver_data;
> > > + unsigned long flags;
> > > + int room;
> > > +
> > > + spin_lock_irqsave(&port->lock, flags);
> > > + room = kfifo_avail(&port->write_fifo);
> > > + spin_unlock_irqrestore(&port->lock, flags);
> > > +
> > > + dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
> > > + return room;
> > > +}
> 
> 
>  
> > It seems it could be possible to reuse the generic write implementations
> > of all functions but prepare_write_buffer above rather than the modified
> > copies.
> 
> Hi Johan
> 
> If there a reason why usb_serial_generic_write_room() is not exported
> as a GPL symbol. It looks like i should be able to use it once i sort
> my 'fake' ports/endpoints out.

No, I don't think so, but perhaps it should be. Most usb-serial drivers
still use it. Simply leave the operation unset and usb-serial core will
set it for you.

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


[GIT PULL] USB patches

2013-05-28 Thread Felipe Balbi
Hi Greg,

Here's a new set of 4 fixes for v3.10-rc. Let me know if you want anything to
be changed.

cheers

The following changes since commit e4aa937ec75df0eea0bee03bffa3303ad36c986b:

  Linux 3.10-rc3 (2013-05-26 16:00:47 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
tags/fixes-for-v3.10-rc4

for you to fetch changes up to ed74df12dc3e07a37d99aab60211496e871488a0:

  usb: musb: make use_sg flag URB specific (2013-05-28 22:17:21 +0300)


usb: fixes for v3.10-rc4

Fix for a long standing bug where we would try to free
resources which we never allocated for DWC3's physical
endpoints 0 and 1.

DWC3 also learned that when calling glue layer's ->remove()
method, ordering of the teardown logic matters. This fixes
a bug where we would try to act on bogus PHY resources.

Lastly, MUSB learns about proper URB handling when the URB's
buffer sits in highmen. In order to fix the bug, use_sg flag
is moved down to the URB.


George Cherian (1):
  usb: dwc3: gadget: free trb pool only from epnum 2

Peter Chen (2):
  usb: dwc3: pci: PHY should be deleted later than dwc3 core
  usb: dwc3: exynos: PHY should be deleted later than dwc3 core

Virupax Sadashivpetimath (1):
  usb: musb: make use_sg flag URB specific

 drivers/usb/dwc3/dwc3-exynos.c |  2 +-
 drivers/usb/dwc3/dwc3-pci.c|  2 +-
 drivers/usb/dwc3/gadget.c  | 16 
 drivers/usb/musb/musb_host.c   | 18 --
 drivers/usb/musb/musb_host.h   |  1 +
 5 files changed, 23 insertions(+), 16 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] usb-serial: Moxa UPORT 12XX/14XX/16XX driver

2013-05-28 Thread Andrew Lunn
On Tue, May 28, 2013 at 11:08:54PM +0200, Johan Hovold wrote:
> On Tue, May 28, 2013 at 09:41:08PM +0200, Andrew Lunn wrote:
> > On Sun, May 26, 2013 at 06:04:24PM +0200, Johan Hovold wrote:
> > > On Sun, May 26, 2013 at 01:00:51PM +0200, Andrew Lunn wrote:
> > > > +/*
> > > > + * mxuport_write_room
> > > > + *
> > > > + * Return how much space is available in the buffer.
> > > > + */
> > > > +static int mxuport_write_room(struct tty_struct *tty)
> > > > +{
> > > > +   struct usb_serial_port *port = tty->driver_data;
> > > > +   unsigned long flags;
> > > > +   int room;
> > > > +
> > > > +   spin_lock_irqsave(&port->lock, flags);
> > > > +   room = kfifo_avail(&port->write_fifo);
> > > > +   spin_unlock_irqrestore(&port->lock, flags);
> > > > +
> > > > +   dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
> > > > +   return room;
> > > > +}
> > 
> > 
> >  
> > > It seems it could be possible to reuse the generic write implementations
> > > of all functions but prepare_write_buffer above rather than the modified
> > > copies.
> > 
> > Hi Johan
> > 
> > If there a reason why usb_serial_generic_write_room() is not exported
> > as a GPL symbol. It looks like i should be able to use it once i sort
> > my 'fake' ports/endpoints out.
> 
> No, I don't think so, but perhaps it should be. Most usb-serial drivers
> still use it. Simply leave the operation unset and usb-serial core will
> set it for you.

Hi Johan

Ah, i fell into the trap. I grep'd for usb_serial_generic_write_room
and did not get any hits. The code is obfusticated/grep unfriendly:

set_to_generic_if_null(device, write_room);

I will leave it unset.

  Andrew

--
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: xhci: Disable runtime PM suspend for quirky controllers.

2013-05-28 Thread Julius Werner
The policy we want to achieve is to disable runtime PM iff there is a
device connected that doesn't have persist_enabled or a reset_resume()
handler and whose parent/root hub resets on resume, right? So couldn't
we remove the HCD-specific XHCI_RESET_ON_RESUME and set the (existing)
generic USB_QUIRK_RESET_RESUME on the root hub instead? Then we could
handle all of this in the USB core (during device initialization and
when changing persist_enabled through sysfs) by just checking for
udev->reset_resume on all parent hubs of the device in question (and
use pm_runtime_get/put() on said device to prevent its parents from
suspending as appropriate).
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 1/9] drivers: phy: add generic PHY framework

2013-05-28 Thread Sylwester Nawrocki

Hi Kishon,

On 04/29/2013 12:03 PM, Kishon Vijay Abraham I wrote:

The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I


Thanks for working on this. For the record, I plan to give this a try
in the end of this week, with my simple MIPI CSI/DSI PHY driver. I might
have some more comments then. For now just couple of remarks after
reading the documentation.


---
  .../devicetree/bindings/phy/phy-bindings.txt   |   66 +++
  Documentation/phy.txt  |  123 +
  MAINTAINERS|7 +
  drivers/Kconfig|2 +
  drivers/Makefile   |2 +
  drivers/phy/Kconfig|   13 +
  drivers/phy/Makefile   |5 +
  drivers/phy/phy-core.c |  539 
  include/linux/phy/phy.h|  248 +
  9 files changed, 1005 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
  create mode 100644 Documentation/phy.txt
  create mode 100644 drivers/phy/Kconfig
  create mode 100644 drivers/phy/Makefile
  create mode 100644 drivers/phy/phy-core.c
  create mode 100644 include/linux/phy/phy.h

diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
b/Documentation/devicetree/bindings/phy/phy-bindings.txt
new file mode 100644
index 000..8ae844f
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
@@ -0,0 +1,66 @@
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
+
+PHY device node
+===
+
+Required Properties:
+#phy-cells:Number of cells in a PHY specifier;  The meaning of all those
+   cells is defined by the binding for the phy node. The PHY
+   provider can use the values in cells to find the appropriate
+   PHY.
+
+For example:
+
+phys: phy {
+compatible = "xxx";
+reg =<...>;
+.
+.
+#phy-cells =<1>;
+.
+.
+};
+
+That node describes an IP block (PHY provider) that implements 2 different 
PHYs.
+In order to differentiate between these 2 PHYs, an additonal specifier should 
be
+given while trying to get a reference to it.
+
+PHY user node
+=
+
+Required Properties:
+phys : the phandle for the PHY device (used by the PHY subsystem)
+phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phys* phandle
+
+Example 1:
+usb1: usb_otg_ss@xxx {
+compatible = "xxx";
+reg =;
+.
+.
+phys =<&usb2_phy>,<&usb3_phy>;
+phy-names = "usb2phy", "usb3phy";
+.
+.
+};
+
+This node represents a controller that uses two PHYs, one for usb2 and one for
+usb3.
+
+Example 2:
+usb2: usb_otg_ss@xxx {
+compatible = "xxx";
+reg =;
+.
+.
+phys =<&phys 1>;
+phy-names = "usbphy";
+.
+.
+};
+
+This node represents a controller that uses one of the PHYs of the PHY provider
+device defined previously. Note that the phy handle has an additional specifier
+"1" to differentiate between the two PHYs.
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
new file mode 100644
index 000..408d25f
--- /dev/null
+++ b/Documentation/phy.txt
@@ -0,0 +1,123 @@
+   PHY SUBSYSTEM
+ Kishon Vijay Abraham I
+
+This document explains the Generic PHY Framework along with the APIs provided,
+and how-to-use.
+
+1. Introduction
+
+*PHY* is the abbreviation for physical layer. It is used to connect a device
+to the physical medium e.g., the USB controller has a PHY to provide functions
+such as serialization, de-serialization, encoding, decoding and is responsible
+for obtaining the required data transmission rate. Note that some USB
+controller has PHY functionality embedded into it and others use an external


"Note that some USB
controllers have PHY functionality embedded into them..." ?


+PHY. Other peripherals that uses a PHY include Wireless LAN, Ethernet,


s/uses/use ?


+SATA etc.
+
+The intention of creating this framework is to bring the phy drivers spread


s/phy/PHY ?


+all over the Linux kernel to drivers/phy to increase code re-use and for
+better code maintainability.
+
+This framework will be of use only to devices that uses external PHY (PHY


s/that use

USB3 SSD/HD device file disappears after "eject"

2013-05-28 Thread Grant
I just got one of these:

http://www.newegg.com/Product/Product.aspx?Item=N82E16820208913

It seems to work fine except I get the following after ejecting it in Thunar:

sd 8:0:0:0: [sdb] Synchronizing SCSI cache
sd 8:0:0:0: Device offlined - not ready after error recovery

The only way I've found to get the /dev/sdb device file back right
away is to 'modprobe -r xhci_hcd && modprobe xhci_hcd'.  It comes back
on its own after about 30 minutes (rough estimate) or so.  I've tried
two different USB3 cables.  I have a 1TB USB3 HD that also requires
modprobe after ejecting but it doesn't print anything interesting to
dmesg.  My laptop is a Dell XPS13 and I'm on the latest BIOS:

# lspci -v
...
02:00.0 USB controller: Fresco Logic FL1009 USB 3.0 Host Controller
(rev 02) (prog-if 30 [XHCI])
Subsystem: Dell Device 052e
Flags: bus master, fast devsel, latency 0, IRQ 19
Memory at f040 (64-bit, non-prefetchable) [size=64K]
Memory at f041 (64-bit, non-prefetchable) [size=4K]
Memory at f0411000 (64-bit, non-prefetchable) [size=4K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/8 Maskable- 64bit+
Capabilities: [70] Express Endpoint, MSI 00
Capabilities: [b0] MSI-X: Enable+ Count=8 Masked-
Capabilities: [100] Advanced Error Reporting
Kernel driver in use: xhci_hcd
Kernel modules: xhci_hcd

Should I file a bug?

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


Re: [PATCH v2] usb: omap2430: fix memleak in err case

2013-05-28 Thread Libo Chen
On 2013/5/28 23:34, Andy Shevchenko wrote:
> No go.
> 
> Check the 4b7e450fb5cefb5865c77999a675330206ab3b8a
> And update you tree, please.
> 
> --
> With Best Regards,
> Andy Shevchenko
> 
> 

It had been changed :(

Thanks,

Libo

--
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: USB3 SSD/HD device file disappears after "eject"

2013-05-28 Thread Greg KH
On Tue, May 28, 2013 at 05:27:22PM -0700, Grant wrote:
> I just got one of these:
> 
> http://www.newegg.com/Product/Product.aspx?Item=N82E16820208913
> 
> It seems to work fine except I get the following after ejecting it in Thunar:
> 
> sd 8:0:0:0: [sdb] Synchronizing SCSI cache
> sd 8:0:0:0: Device offlined - not ready after error recovery

That's to be expected.  Lots of devices will shut down after userspace
told it to power down.  It was a feature request that Thunar and
Nautilus added a year or so ago.

Not all devices will do this, as their firmware does not support the
powerdown command, which is why older devices do not act like this.

If you don't like this, don't eject the device :)

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: [GIT PULL] USB patches

2013-05-28 Thread Greg KH
On Wed, May 29, 2013 at 12:08:56AM +0300, Felipe Balbi wrote:
> Hi Greg,
> 
> Here's a new set of 4 fixes for v3.10-rc. Let me know if you want anything to
> be changed.
> 
> cheers
> 
> The following changes since commit e4aa937ec75df0eea0bee03bffa3303ad36c986b:
> 
>   Linux 3.10-rc3 (2013-05-26 16:00:47 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v3.10-rc4

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: [Pull Request] xhci: Misc bug fixes for 3.10

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 04:07:51PM -0700, Sarah Sharp wrote:
> The following changes since commit 2a0ebf80aa95cc758d4725f74a7016e992606a39:
> 
>   USB: cxacru: potential underflow in cxacru_cm_get_array() (2013-05-20 
> 11:35:47 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
> for-usb-linus-2013-05-24

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: [RFC 0/6] xHCI and USB security bug fixes

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 05:42:52PM -0700, Sarah Sharp wrote:
> This patchset address some (but not all) of the security issues found
> with the Klockwork static analysis tool.  I have not reviewed these in
> detail to see if these could be used by attackers, so someone with more
> security experience may want to look these over.

A lot of these changes are just to add checks to functions that you are
calling yourself.  How can those pointers be "not valid" when you
control what you pass to them?

Those seems over-eager, and not really needed.  Or am I missing
somewhere that could change the pointer without the driver knowing it?

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: [RFC 1/6] xhci: Remove BUG_ON() in xhci_alloc_container_ctx.

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 05:42:54PM -0700, Sarah Sharp wrote:
> It's horrible coding style to panic the kernel when someone passes you
> an argument value you didn't expect.

I agree, but why is this a stable issue?  Who can pass in a bad pointer?
Can't we just drop the check entirely?

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: [RFC 2/6] xhci: Remove BUG_ON in xhci_get_input_control_ctx.

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 05:42:56PM -0700, Sarah Sharp wrote:
> Fail gracefully, instead of causing the kernel to panic, if the input
> control context doesn't have the right type (XHCI_CTX_TYPE_INPUT).  Push
> finding the pointer to the input control context up into functions that
> can fail.
> 
> This patch should be backported to kernels as old as 2.6.31, that
> contain the commit d115b04818e57bdbc7ccde4d0660b15e33013dc8 "USB: xhci:
> Support for 64-byte contexts".
> 
> Signed-off-by: Sarah Sharp 
> Cc: John Youn 
> Cc: sta...@vger.kernel.org
> ---
>  drivers/usb/host/xhci-dbg.c  |5 ++
>  drivers/usb/host/xhci-mem.c  |4 +-
>  drivers/usb/host/xhci-ring.c |4 +
>  drivers/usb/host/xhci.c  |  148 
> --
>  4 files changed, 126 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
> index 5f3a7c7..8e0be37 100644
> --- a/drivers/usb/host/xhci-dbg.c
> +++ b/drivers/usb/host/xhci-dbg.c
> @@ -550,6 +550,11 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci,
>   if (ctx->type == XHCI_CTX_TYPE_INPUT) {
>   struct xhci_input_control_ctx *ctrl_ctx =
>   xhci_get_input_control_ctx(xhci, ctx);
> + if (!ctrl_ctx) {
> + xhci_warn(xhci, "Could not get input context, bad 
> type.\n");
> + return;
> + }
> +
>   xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - drop flags\n",
>&ctrl_ctx->drop_flags, (unsigned long long)dma,
>ctrl_ctx->drop_flags);
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 1a2052d..e68aafe 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -389,7 +389,9 @@ static void xhci_free_container_ctx(struct xhci_hcd *xhci,
>  struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd 
> *xhci,
> struct xhci_container_ctx *ctx)
>  {
> - BUG_ON(ctx->type != XHCI_CTX_TYPE_INPUT);
> + if (ctx->type != XHCI_CTX_TYPE_INPUT)
> + return NULL;

How can a non-input pointer be passed here?

> +
>   return (struct xhci_input_control_ctx *)ctx->bytes;

What?  Why isn't "bytes" this structure already?  How about an anonymous
union if you want to, but void * aren't nice to have.

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: [RFC 2/6] xhci: Remove BUG_ON in xhci_get_input_control_ctx.

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 05:42:56PM -0700, Sarah Sharp wrote:
> Fail gracefully, instead of causing the kernel to panic, if the input
> control context doesn't have the right type (XHCI_CTX_TYPE_INPUT).  Push
> finding the pointer to the input control context up into functions that
> can fail.

I fail to see how this is a stable fix, what am I missing?

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: [RFC 3/6] xhci: Remove BUG in xhci_setup_addressable_virt_dev

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 05:42:59PM -0700, Sarah Sharp wrote:
> From: Mathias Nyman 
> 
> We may have more speed types in the future, so fail gracefully, rather
> than causing the kernel to panic.
> 
> BUG() was called if the device speed was unknown when setting max packet
> size.  Set the max packet size at the same time as the slot speed and
> get rid of one switch statement with BUG() option completely.
> 
> [Note: Sarah merged a patch that she wrote that touched the
> xhci_setup_addressable_virt_dev function with this patch from Mathias
> for clarity.]
> 
> This patch should be backported to kernels as old as 2.6.31, that
> contain the commit 3ffbba9511b4148cbe1f6b6238686adaeaca8feb "USB: xhci:
> Allocate and address USB devices"

How is this a stable issue?  Do you have devices out there that will
panic on this existing code, or are devices coming, that will panic the
current code because of the BUG_ON()?  If so, that's a good reason for
this, otherwise I need to be convinced.

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: [RFC 4/6] xhci: remove BUG() in xhci_get_endpoint_type()

2013-05-28 Thread Greg Kroah-Hartman
On Fri, May 24, 2013 at 05:43:01PM -0700, Sarah Sharp wrote:
> From: Mathias Nyman 
> 
> If the endpoint type is unknown, set it to 0 and fail gracefully
> instead of causing a kernel panic.

How can the endpoint type be unknown?

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 2/4] chipidea: ci13xxx_imx: Remove reg_vbus

2013-05-28 Thread Shawn Guo
On Mon, May 27, 2013 at 09:51:28AM -0300, Fabio Estevam wrote:
> There is no need to keep a 'reg_vbus' indirection, so get rid of it.
> 
> The motivation for doing this change is that in the case of error, the current
> code only sets the local reg_vbus to NULL instead of updating the private 
> structure 'data->reg_vbus'.
> 
> Updating only the local reg_vbus is wrong, since we currently check for
> data->reg_vbus in the ci13xxx_imx_remove() function.
> 
> In order to avoid such issue, just use 'data->reg_vbus' directly.
> 
Do you actually see the issue in real?  While I'm fine with the change,
I do not think the current code will cause the issue you are describing
here, since the devm_kzalloc() of data ensures that data->reg_vbus is NULL
initially.

Shawn

> Signed-off-by: Fabio Estevam 
> ---
>  drivers/usb/chipidea/ci13xxx_imx.c | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
> b/drivers/usb/chipidea/ci13xxx_imx.c
> index a9afd06..1661cac 100644
> --- a/drivers/usb/chipidea/ci13xxx_imx.c
> +++ b/drivers/usb/chipidea/ci13xxx_imx.c
> @@ -102,7 +102,6 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
>   struct platform_device *phy_pdev;
>   struct device_node *phy_np;
>   struct resource *res;
> - struct regulator *reg_vbus;
>   struct pinctrl *pinctrl;
>   int ret;
>  
> @@ -157,18 +156,17 @@ static int ci13xxx_imx_probe(struct platform_device 
> *pdev)
>   }
>  
>   /* we only support host now, so enable vbus here */
> - reg_vbus = devm_regulator_get(&pdev->dev, "vbus");
> - if (!IS_ERR(reg_vbus)) {
> - ret = regulator_enable(reg_vbus);
> + data->reg_vbus = devm_regulator_get(&pdev->dev, "vbus");
> + if (!IS_ERR(data->reg_vbus)) {
> + ret = regulator_enable(data->reg_vbus);
>   if (ret) {
>   dev_err(&pdev->dev,
>   "Failed to enable vbus regulator, err=%d\n",
>   ret);
>   goto put_np;
>   }
> - data->reg_vbus = reg_vbus;
>   } else {
> - reg_vbus = NULL;
> + data->reg_vbus = NULL;
>   }
>  
>   ci13xxx_imx_platdata.phy = data->phy;
> @@ -217,8 +215,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
>  disable_device:
>   ci13xxx_remove_device(data->ci_pdev);
>  err:
> - if (reg_vbus)
> - regulator_disable(reg_vbus);
> + if (data->reg_vbus)
> + regulator_disable(data->reg_vbus);
>  put_np:
>   if (phy_np)
>   of_node_put(phy_np);
> -- 
> 1.8.1.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 v2] usb: omap2430: fix memleak in err case

2013-05-28 Thread Libo Chen
On 2013/5/29 1:40, Sergei Shtylyov wrote:
> Hello.
> 
> On 22-05-2013 7:30, Libo Chen wrote:
> 
>> when omap_get_control_dev faild, we should release related platform_device
> 
>> * Changelog from v1:
>> * fix spell: s/fail/fails/, s/relational/related/ , thank Sergei 
>> 
> 
>It seems you've actually replaced "fail" with "faild", not "fails".

sorry for my weak spell.


thanks again,

Libo


> 
>> Signed-off-by: Libo Chen 
>> ---
>>   drivers/usb/musb/omap2430.c |3 ++-
>>   1 files changed, 2 insertions(+), 1 deletions(-)
> 
> WBR, Sergei
> 
> 
> 


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


Re: USB3 SSD/HD device file disappears after "eject"

2013-05-28 Thread Grant
>> I just got one of these:
>>
>> http://www.newegg.com/Product/Product.aspx?Item=N82E16820208913
>>
>> It seems to work fine except I get the following after ejecting it in Thunar:
>>
>> sd 8:0:0:0: [sdb] Synchronizing SCSI cache
>> sd 8:0:0:0: Device offlined - not ready after error recovery
>
> That's to be expected.  Lots of devices will shut down after userspace
> told it to power down.  It was a feature request that Thunar and
> Nautilus added a year or so ago.
>
> Not all devices will do this, as their firmware does not support the
> powerdown command, which is why older devices do not act like this.
>
> If you don't like this, don't eject the device :)

OK good point.  In light of this, here's the real problem.  Ejecting
the SSD results in the "Writing data to device" desktop notification
persisting on the desktop instead of disappearing after a few seconds
like it does with my other external drives.  The following messages
appears in dmesg which does not appear when ejecting my other external
drives:

sd 8:0:0:0: [sdb] Synchronizing SCSI cache
sd 8:0:0:0: Device offlined - not ready after error recovery

Unplugging and replugging the device does not result in the
reappearance of the /dev/sdb device file like it does with my other
external drives.  The only way to bring the /dev/sdb device file back
is to 'modprobe -r xhci_hcd && modprobe xhci_hcd'.

I originally wrote a problem report like this but then I convinced
myself that the *real* problem was the one I described in my previous
message which Greg proved it is not.

- Grant
--
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 v1 0/9] adding dual instance and usb-phy support for am335x platform

2013-05-28 Thread B, Ravi
Felipe

> Subject: Re: [PATCH v1 0/9] adding dual instance and usb-phy support for 
> am335x platform

> Hi,

>On Thu, May 23, 2013 at 11:31:19AM +0530, Ravi Babu wrote:
>> This patch set series
>> - adds dual musb instances support for am335x platform
>> - adds phy-dsps-usb driver based on TI's gs70 driver
>> - adds DT bindings for am33xx usb-phy
>>  - removed references to usb-nop-xceiv from musb

>as Sergei pointed out, this would break some DaVinci/DA8xx platforms, so I'm 
>dropping from it from my queue.

As I understand, already all musb glue platform drivers(dsps/davinci/da8xx) are 
changed to new usb_get_phy() API set.  
Currently the mainline code snippet as shown.

dsps/davinci/da8xx/xxx_musb_init() {
...
usb_nop_xceiv_register() 
..
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (IS_ERR_OR_NULL(musb->xceiv)) {
ret = -EPROBE_DEFER;
goto fail;
}
..
}
Because of this all glue xxx_musb_init() will fail to get the phy without the 
phy-bindings for each controller. 
Without this patch series am335x musb will fail to get usb_phy(). Similarly phy 
support to be added for all davinci/da8xx
platform also. The usb_nop_xciev_xx() is dummy unused API here and hence 
removed from all glue in this patch series.

1) dsps platforms (am335x/dm81xx) series uses TI gs70 based phy 
This patch adds support for ths dsps phy driver at 
drivers/usb/phy/usb-dsps-phy.c 
2) omapl13x/da8xx series of soc uses different phy
Separate phy driver need to be added at drivers/usb/phy/usb-da8xx-phy.c
3) similarly all davinci series of soc uses separate TI-phy 
Separate phy driver need to added at drivers/usb/phy/usb-davinci-phy.c

The bindings of the respective usb-phy and controller need to done in DT or 
non-DT way.  
I can add usb-phy support for davinci/da8xx platform in similar way.

---
Ravi B
--
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 V10 04/12] usb: ehci: ehci-mv: use PHY driver for ehci

2013-05-28 Thread Chao Xie
On Wed, May 29, 2013 at 12:24 AM, Felipe Balbi  wrote:
> Hi,
>
> On Mon, May 13, 2013 at 10:13:44AM -0400, Alan Stern wrote:
>> On Mon, 13 May 2013, Chao Xie wrote:
>>
>> > Originaly, ehci driver will call the callbacks in platform data
>> > for PHY initialization and shut down.
>> > With PHY driver, it will call the APIs provided by PHY driver
>> > for PHY initialization and shutdown. It removes the callbacks
>> > in platform data, and at same time it removes one block in the
>> > way of enabling device tree for ehci driver.
>>
>> I wonder if this is the sort of thing that should be handled in
>> ehci-hcd.c rather than in all the different platform glue drivers.
>>
>> Felipe, what do you think?  Are the required actions now sufficiently
>> generic that a single source file can take care of them?
>
> Sorry for the delay, was on business trip and now on vacations. Anyway,
> I agree with you. Our PHY layer should be generic enough that it should
> be usable by ehci-hcd itself. If we have any missing method, let's add
> it generically.
>
So what are your idea about making the PHY layer more generic? How
ehci-hcd will make use of PHY layer?

> cheers
>
> ps: dropping this from my queue for now.
>
> --
> 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


Re: [PATCH v6 1/9] drivers: phy: add generic PHY framework

2013-05-28 Thread Kishon Vijay Abraham I

Hi,

On Wednesday 29 May 2013 04:07 AM, Sylwester Nawrocki wrote:

Hi Kishon,

On 04/29/2013 12:03 PM, Kishon Vijay Abraham I wrote:

The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference
to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be
found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I


Thanks for working on this. For the record, I plan to give this a try
in the end of this week, with my simple MIPI CSI/DSI PHY driver. I might
have some more comments then. For now just couple of remarks after
reading the documentation.


Thanks for reviewing. I'll wait for your comments before posting the 
next version.


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


Re: [PATCH 0/3] palmas usb driver

2013-05-28 Thread Kishon Vijay Abraham I

Hi Felipe,

On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:

On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:

This patch series adds driver for palmas usb which is used to detect
attach/detach events of usb device and usb host.

[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
is added in this patch series itself. The revision history is added
in the patch comments section.

A checkpatch warning "WARNING: static const char * array should
probably be static const char * const"is ignored since it introduces a
compilation warning.

Graeme Gregory (2):
   drivers: regulator: palmas: add an API to set/clear the switch bit on
 SMPS10
   extcon: Palmas Extcon Driver

Kishon Vijay Abraham I (1):
   usb: dwc3: use extcon fwrk to receive connect/disconnect notification



There were some comments to this series, what will happen with it ? Any
new versions coming ?


I've already sent new versions. Palmas Extcon Driver is already queued 
in extcon-next.
Chanwoo can take this patch in his tree after your ACK. [PATCH v2] usb: 
dwc3: use extcon fwrk to receive connect/disconnect notification.


Thanks
Kishon
--
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: dwc3: cleanup DWC3_DCTL_LSFTRST bit

2013-05-28 Thread Huang Rui
Hi Felipe,

On Wed, May 29, 2013 at 01:25:59AM +0800, Felipe Balbi wrote:
> On Tue, May 28, 2013 at 03:42:50PM +0800, Huang Rui wrote:
> > This bit is removed and set as reserved in 2.50a spec.
> > 
> > Signed-off-by: Huang Rui 
> 
> so ? This driver also works on older versions of the core. What you
> should do is, perhaps, add a comment saying that this bit shouldn't be
> used in v2.50a+, then we need to keep an eye for any future users of
> that bit and make sure that there is proper revision detection around
> it.

Thanks to your reply. I greped codes, in current driver didn't use
this bit, and I saw that the bit is marked as reserved in 2.50a spec.
I don't confirm this bit should use in v2.50a+, if it will be used or
I was wrong, please correct me. 
I just looked at register mapping, and compared with spec and found
this bit is reserved, so I send this patch to remove this define to
prevent to confuse. :)

Best Regards,
Rui

--
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 3/3] usb: dwc3: omap Modify dwc3_omap_readl/writel with offsets

2013-05-28 Thread Cherian, George


> -Original Message-
> From: Balbi, Felipe
> Sent: Tuesday, May 28, 2013 11:02 PM
> To: Cherian, George
> Cc: Balbi, Felipe; linux-usb@vger.kernel.org; linux-o...@vger.kernel.org;
> linux-ker...@vger.kernel.org; gre...@linuxfoundation.org
> Subject: Re: [PATCH 3/3] usb: dwc3: omap Modify dwc3_omap_readl/writel
> with offsets
> 
> Hi,
> 
> On Mon, May 27, 2013 at 01:32:57PM +0530, George Cherian wrote:
> > This patch modifies dwc3_omap_readl/writel calls to accomodate
> > both OMAP5 and AM437x reg maps (It uses the cached register offsets).
> > Also renames OMAP5 IRQ1 as IRQMISC, IRQ1 bits as IRQMISC bits.
> >
> > Signed-off-by: George Cherian 
> 
> can you change this patch a bit so that it adds wrappers around
> dwc3_omap_*() ? The idea is the have the code look like:
> 
> static u32 dwc3_omap_read_utmi_status(struct dwc3_omap *omap)
> {
>   return dwc3_omap_readl(omap->base,
> USBOTGSS_UTMI_OTG_STATUS +
>   omap->utmi_otg_offset);
> }
> 
> (likewise for write and for all other offsets, of course)
> 
> that way, reading/writing to registers which need the offset will be
> less error-prone and th driver will look a little nicer.

Yes , I will do it in next version.
> 
> --
> Balbi
-George
--
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