[PATCH v4 0/8] Equivalent of g_ncm.ko with configfs

2013-05-23 Thread Andrzej Pietrasiewicz
Here I present the conversion of everthing that is required to provide
the equivalent of g_ncm.ko with configfs.

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

v3..v4:

- don't unregister a network interface if it has not been registered before

v2..v3:

- fixed a bug resulting from the delayed registration of a network interface
  (should be registered only once)

v1..v2:

- delayed registering a network interface until gadgets's bind
  (per Alan's request)
- created a helper macro to define USB Ethernet modules' parameters (Michal's
  review)
- fixed and simplified some helper functions (Michal's review)
- changed hostaddr variable name to host_mac in several modules
  (Michal's review)


BACKWARD COMPATIBILITY
==

Please note that the old g_ncm.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_ncm.ko equivalent.

The old g_ncm.ko offered three parameters:

qmult  - queue length multiplier for high/super -speed devices
dev_addr   - device's MAC address
host_addr  - host's MAC address

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ncm.

e.g. mkdir functions/ncm.usb0

In functions/ncm. there will be the following attribute files:

qmult
dev_addr
host_addr
ifname

and after creating the functions/ncm. they contain default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

The rest of the procedure (*) remains the same.

After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS (actually there is just one)
==

ncm)

On the device: ping 
On the host: ping 


Andrzej Pietrasiewicz (8):
  usb/gadget: u_ether: convert into module
  usb/gadget: rndis: convert into module
  usb/gadget: u_ether: construct with default values and add
setters/getters
  usb/gadget: f_ncm: convert to new function interface with backward
compatibility
  usb/gadget: ncm: convert to new function interface
  usb/gadget: f_ncm: remove compatibility layer
  usb/gadget: f_ncm: use usb_gstrings_attach
  usb/gadget: f_ncm: add configfs support

 drivers/usb/gadget/Kconfig   |   20 +++
 drivers/usb/gadget/Makefile  |5 +
 drivers/usb/gadget/cdc2.c|   10 +-
 drivers/usb/gadget/ether.c   |   18 ++-
 drivers/usb/gadget/f_ncm.c   |  336 ++
 drivers/usb/gadget/g_ffs.c   |   15 +-
 drivers/usb/gadget/multi.c   |   15 +-
 drivers/usb/gadget/ncm.c |   58 +---
 drivers/usb/gadget/nokia.c   |   11 +-
 drivers/usb/gadget/rndis.c   |   16 ++
 drivers/usb/gadget/rndis.h   |1 +
 drivers/usb/gadget/u_ether.c |  223 +---
 drivers/usb/gadget/u_ether.h |  155 +++-
 drivers/usb/gadget/u_ncm.h   |   36 +
 14 files changed, 779 insertions(+), 140 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ncm.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


[PATCH v4 1/8] usb/gadget: u_ether: convert into module

2013-05-23 Thread Andrzej Pietrasiewicz
u_ether.c has been #include'd by all gadgets which implement
USB Ethernet functions. In order to add configfs support,
the f_ecm.c, f_eem.c, f_ncm.c, f_subset.c, f_rndis.c need to be
converted into modules and must not be #include'd. Consequently,
the u_ether.c needs to be a module too, in a manner similar
to u_serial.c. The resulting module should not take any parameters,
so they are pushed to the current users of it, that is ether.c,
g_ffs.c, multi.c, ncm.c, nokia.c.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig   |   10 ++
 drivers/usb/gadget/Makefile  |1 +
 drivers/usb/gadget/cdc2.c|   10 ++
 drivers/usb/gadget/ether.c   |   14 --
 drivers/usb/gadget/g_ffs.c   |   13 -
 drivers/usb/gadget/multi.c   |   13 -
 drivers/usb/gadget/ncm.c |   10 ++
 drivers/usb/gadget/nokia.c   |   11 +++
 drivers/usb/gadget/u_ether.c |   38 ++
 drivers/usb/gadget/u_ether.h |   30 ++
 10 files changed, 98 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 3ddebff..9152428 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -551,6 +551,9 @@ config USB_F_SS_LB
 config USB_U_SERIAL
tristate
 
+config USB_U_ETHER
+   tristate
+
 config USB_F_SERIAL
tristate
 
@@ -647,6 +650,7 @@ config USB_ETH
tristate "Ethernet Gadget (with CDC Ethernet support)"
depends on NET
select USB_LIBCOMPOSITE
+   select USB_U_ETHER
select CRC32
help
  This driver implements Ethernet style communication, in one of
@@ -719,6 +723,7 @@ config USB_G_NCM
tristate "Network Control Model (NCM) support"
depends on NET
select USB_LIBCOMPOSITE
+   select USB_U_ETHER
select CRC32
help
  This driver implements USB CDC NCM subclass standard. NCM is
@@ -762,6 +767,7 @@ config USB_FUNCTIONFS
 config USB_FUNCTIONFS_ETH
bool "Include configuration with CDC ECM (Ethernet)"
depends on USB_FUNCTIONFS && NET
+   select USB_U_ETHER
help
  Include a configuration with CDC ECM function (Ethernet) and the
  Function Filesystem.
@@ -769,6 +775,7 @@ config USB_FUNCTIONFS_ETH
 config USB_FUNCTIONFS_RNDIS
bool "Include configuration with RNDIS (Ethernet)"
depends on USB_FUNCTIONFS && NET
+   select USB_U_ETHER
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
@@ -869,6 +876,7 @@ config USB_CDC_COMPOSITE
depends on NET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  This driver provides two functions in one configuration:
@@ -886,6 +894,7 @@ config USB_G_NOKIA
depends on PHONET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  The Nokia composite gadget provides support for acm, obex
@@ -913,6 +922,7 @@ config USB_G_MULTI
select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 2e102ff..061abec 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -46,6 +46,7 @@ usb_f_serial-y:= f_serial.o
 obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
+obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index c6ee6f1..07b3aaf 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -35,6 +35,8 @@
 /*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
+USB_ETHERNET_MODULE_PARAMETERS();
+
 /*
  * Kbuild is not very cooperative with respect to linking separately
  * compiled library objects into one module.  So for now we won't use
@@ -43,7 +45,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "f_ecm.c"
-#include "u_ether.c"
 
 /*-*/
 
@@ -102,7 +103,7 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
 static struct eth_dev *the_dev;
 /*-*/
 static struct usb_function *f_acm;
@@ -120,7 +121,7 @@ static int __init cdc_do_config(struct usb_configuration

[PATCH v4 2/8] usb/gadget: rndis: convert into module

2013-05-23 Thread Andrzej Pietrasiewicz
In order to convert to configfs the usb functions need to be converted
to a new interface and compiled as modules. This patch creates an rndis
module which will be used by the new functions. After all users of
f_rndis are converted to the new interface, this module can be
merged with f_rndis module.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
Acked-by: Michal Nazarewicz 
---
 drivers/usb/gadget/Kconfig  |6 ++
 drivers/usb/gadget/Makefile |2 ++
 drivers/usb/gadget/ether.c  |4 +++-
 drivers/usb/gadget/g_ffs.c  |2 +-
 drivers/usb/gadget/multi.c  |2 +-
 drivers/usb/gadget/rndis.c  |   16 
 drivers/usb/gadget/rndis.h  |1 +
 7 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 9152428..91b6eab 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -554,6 +554,9 @@ config USB_U_SERIAL
 config USB_U_ETHER
tristate
 
+config USB_U_RNDIS
+   tristate
+
 config USB_F_SERIAL
tristate
 
@@ -651,6 +654,7 @@ config USB_ETH
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
+   select USB_U_RNDIS
select CRC32
help
  This driver implements Ethernet style communication, in one of
@@ -776,6 +780,7 @@ config USB_FUNCTIONFS_RNDIS
bool "Include configuration with RNDIS (Ethernet)"
depends on USB_FUNCTIONFS && NET
select USB_U_ETHER
+   select USB_U_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
@@ -923,6 +928,7 @@ config USB_G_MULTI
select USB_LIBCOMPOSITE
select USB_U_SERIAL
select USB_U_ETHER
+   select USB_U_RNDIS
select USB_F_ACM
help
  The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 061abec..3f51952 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -47,6 +47,8 @@ obj-$(CONFIG_USB_F_SERIAL)+= usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
+u_rndis-y  := rndis.o
+obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 75418c7..6bff24f 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -91,6 +91,8 @@ static inline bool has_rndis(void)
 #endif
 }
 
+#include 
+
 /*-*/
 
 /*
@@ -104,7 +106,7 @@ static inline bool has_rndis(void)
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
-#include "rndis.c"
+#include "rndis.h"
 #endif
 #include "f_eem.c"
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 45f26be..fbfdb53 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -32,7 +32,7 @@
 #  include "f_subset.c"
 #  ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
-#include "rndis.c"
+#include "rndis.h"
 #  endif
 #  include "u_ether.h"
 
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index d0dd603..b8222c4 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -47,7 +47,7 @@ MODULE_LICENSE("GPL");
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #  include "f_rndis.c"
-#  include "rndis.c"
+#  include "rndis.h"
 #endif
 #include "u_ether.h"
 
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d9297ee..1ce6bae 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -761,6 +761,7 @@ int rndis_signal_connect(int configNr)
return rndis_indicate_status_msg(configNr,
  RNDIS_STATUS_MEDIA_CONNECT);
 }
+EXPORT_SYMBOL(rndis_signal_connect);
 
 int rndis_signal_disconnect(int configNr)
 {
@@ -769,6 +770,7 @@ int rndis_signal_disconnect(int configNr)
return rndis_indicate_status_msg(configNr,
  RNDIS_STATUS_MEDIA_DISCONNECT);
 }
+EXPORT_SYMBOL(rndis_signal_disconnect);
 
 void rndis_uninit(int configNr)
 {
@@ -783,11 +785,13 @@ void rndis_uninit(int configNr)
while ((buf = rndis_get_next_response(configNr, &length)))
rndis_free_response(configNr, buf);
 }
+EXPORT_SYMBOL(rndis_uninit);
 
 void rndis_set_host_mac(int configNr, const u8 *addr)
 {
rndis_per_dev_params[configNr].host_mac = addr;
 }
+EXPORT_SYMBOL(rndis_set_host_mac);
 
 /*
  * Message Parser
@@ -870,6 +874,7 @@ int rndis_msg_parser(u8 configNr, u8 *buf)
 
return -ENOTSUPP;
 }
+EXPORT_SYMBOL(rndis_msg_parser);
 
 int rndis_register(void (*resp_avail)(void *v), void *v)
 {
@@ -891,6 +896,7 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
 
return -ENODEV;
 }
+EXPORT_SYMBOL(rndis_regis

[PATCH v4 8/8] usb/gadget: f_ncm: add configfs support

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c |  166 
 drivers/usb/gadget/u_ncm.h |9 +++
 2 files changed, 175 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index effd2fa..697262e 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1175,8 +1175,10 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
 * with regard to ncm_opts->bound access
 */
if (!ncm_opts->bound) {
+   mutex_lock(&ncm_opts->lock);
gether_set_gadget(ncm_opts->net, cdev->gadget);
status = gether_register_netdev(ncm_opts->net);
+   mutex_unlock(&ncm_opts->lock);
if (status)
return status;
ncm_opts->bound = true;
@@ -1290,6 +1292,159 @@ fail:
return status;
 }
 
+static inline struct f_ncm_opts *to_f_ncm_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_ncm_opts,
+   func_inst.group);
+}
+
+CONFIGFS_ATTR_STRUCT(f_ncm_opts);
+CONFIGFS_ATTR_OPS(f_ncm_opts);
+
+static void ncm_attr_release(struct config_item *item)
+{
+   struct f_ncm_opts *opts = to_f_ncm_opts(item);
+
+   usb_put_function_instance(&opts->func_inst);
+}
+
+static struct configfs_item_operations ncm_item_ops = {
+   .release= ncm_attr_release,
+   .show_attribute = f_ncm_opts_attr_show,
+   .store_attribute = f_ncm_opts_attr_store,
+};
+
+static ssize_t ncm_opts_dev_addr_show(struct f_ncm_opts *opts, char *page)
+{
+   int result;
+
+   mutex_lock(&opts->lock);
+   result = gether_get_dev_addr(opts->net, page, PAGE_SIZE);
+   mutex_unlock(&opts->lock);
+
+   return result;
+}
+
+static ssize_t ncm_opts_dev_addr_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   int ret;
+
+   mutex_lock(&opts->lock);
+   if (opts->refcnt) {
+   mutex_unlock(&opts->lock);
+   return -EBUSY;
+   }
+
+   ret = gether_set_dev_addr(opts->net, page);
+   mutex_unlock(&opts->lock);
+   if (!ret)
+   ret = len;
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_dev_addr =
+   __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, ncm_opts_dev_addr_show,
+   ncm_opts_dev_addr_store);
+
+static ssize_t ncm_opts_host_addr_show(struct f_ncm_opts *opts, char *page)
+{
+   int result;
+
+   mutex_lock(&opts->lock);
+   result = gether_get_host_addr(opts->net, page, PAGE_SIZE);
+   mutex_unlock(&opts->lock);
+
+   return result;
+}
+
+static ssize_t ncm_opts_host_addr_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   int ret;
+
+   mutex_lock(&opts->lock);
+   if (opts->refcnt) {
+   mutex_unlock(&opts->lock);
+   return -EBUSY;
+   }
+
+   ret = gether_set_host_addr(opts->net, page);
+   mutex_unlock(&opts->lock);
+   if (!ret)
+   ret = len;
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_host_addr =
+   __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, ncm_opts_host_addr_show,
+   ncm_opts_host_addr_store);
+
+static ssize_t ncm_opts_qmult_show(struct f_ncm_opts *opts, char *page)
+{
+   unsigned qmult;
+
+   mutex_lock(&opts->lock);
+   qmult = gether_get_qmult(opts->net);
+   mutex_unlock(&opts->lock);
+   return sprintf(page, "%d", qmult);
+}
+
+static ssize_t ncm_opts_qmult_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   u8 val;
+   int ret;
+
+   mutex_lock(&opts->lock);
+   if (opts->refcnt) {
+   ret = -EBUSY;
+   goto out;
+   }
+
+   ret = kstrtou8(page, 0, &val);
+   if (ret)
+   goto out;
+
+   gether_set_qmult(opts->net, val);
+   ret = len;
+out:
+   mutex_unlock(&opts->lock);
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_qmult =
+   __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, ncm_opts_qmult_show,
+   ncm_opts_qmult_store);
+
+static ssize_t ncm_opts_ifname_show(struct f_ncm_opts *opts, char *page)
+{
+   int ret;
+
+   mutex_lock(&opts->lock);
+   ret = gether_get_ifname(opts->net, page, PAGE_SIZE);
+   mutex_unlock(&opts->lock);
+
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_ifname =
+   __CONFIGFS_ATTR_RO(ifname, ncm_opts_ifname_show);
+
+static struct configfs_attribute *ncm_attrs[] = {
+   &f_ncm_opts_dev_addr.attr,
+   &f_ncm_opts_host_addr.attr,
+   &f_ncm_opts_qmult.attr,
+   &f_ncm_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type ncm_func_type = {
+   .ct_item_ops= &ncm_ite

[PATCH v4 6/8] usb/gadget: f_ncm: remove compatibility layer

2013-05-23 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_ncm.c   |   80 --
 drivers/usb/gadget/u_ether.h |2 -
 2 files changed, 0 insertions(+), 82 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 722ca1b..d8069de 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1160,8 +1160,6 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
struct f_ncm*ncm = func_to_ncm(f);
int status;
struct usb_ep   *ep;
-
-#ifndef USB_FNCM_INCLUDED
struct f_ncm_opts   *ncm_opts;
 
if (!can_support_ecm(cdev->gadget))
@@ -1182,7 +1180,6 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
return status;
ncm_opts->bound = true;
}
-#endif
if (ncm_string_defs[0].id == 0) {
status = usb_string_ids_tab(c->cdev, ncm_string_defs);
if (status < 0)
@@ -1297,80 +1294,6 @@ fail:
return status;
 }
 
-#ifdef USB_FNCM_INCLUDED
-
-static void
-ncm_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_ncm*ncm = func_to_ncm(f);
-
-   DBG(c->cdev, "ncm unbind\n");
-
-   ncm_string_defs[0].id = 0;
-   usb_free_all_descriptors(f);
-
-   kfree(ncm->notify_req->buf);
-   usb_ep_free_request(ncm->notify, ncm->notify_req);
-
-   kfree(ncm);
-}
-
-/**
- * ncm_bind_config - add CDC Network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * 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 ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_ncm*ncm;
-   int status;
-
-   if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
-   return -EINVAL;
-
-   /* allocate and initialize one new instance */
-   ncm = kzalloc(sizeof *ncm, GFP_KERNEL);
-   if (!ncm)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr);
-   ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr;
-
-   spin_lock_init(&ncm->lock);
-   ncm_reset_values(ncm);
-   ncm->port.ioport = dev;
-   ncm->port.is_fixed = true;
-
-   ncm->port.func.name = "cdc_network";
-   ncm->port.func.strings = ncm_strings;
-   /* descriptors are per-instance copies */
-   ncm->port.func.bind = ncm_bind;
-   ncm->port.func.unbind = ncm_old_unbind;
-   ncm->port.func.set_alt = ncm_set_alt;
-   ncm->port.func.get_alt = ncm_get_alt;
-   ncm->port.func.setup = ncm_setup;
-   ncm->port.func.disable = ncm_disable;
-
-   ncm->port.wrap = ncm_wrap_ntb;
-   ncm->port.unwrap = ncm_unwrap_ntb;
-
-   status = usb_add_function(c, &ncm->port.func);
-   if (status)
-   kfree(ncm);
-   return status;
-}
-
-#else
-
 static void ncm_free_inst(struct usb_function_instance *f)
 {
struct f_ncm_opts *opts;
@@ -1466,6 +1389,3 @@ struct usb_function *ncm_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(ncm, ncm_alloc_inst, ncm_alloc);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Yauheni Kaliuta");
-
-#endif
-
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index d74b8f7..1671a79 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -262,8 +262,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 ncm_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 v4 7/8] usb/gadget: f_ncm: use usb_gstrings_attach

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c |   26 ++
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index d8069de..effd2fa 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1158,6 +1158,7 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_ncm*ncm = func_to_ncm(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
struct f_ncm_opts   *ncm_opts;
@@ -1180,20 +1181,15 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
return status;
ncm_opts->bound = true;
}
-   if (ncm_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, ncm_string_defs);
-   if (status < 0)
-   return status;
-   ncm_control_intf.iInterface =
-   ncm_string_defs[STRING_CTRL_IDX].id;
-
-   status = ncm_string_defs[STRING_DATA_IDX].id;
-   ncm_data_nop_intf.iInterface = status;
-   ncm_data_intf.iInterface = status;
-
-   ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id;
-   ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id;
-   }
+   us = usb_gstrings_attach(cdev, ncm_strings,
+ARRAY_SIZE(ncm_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   ncm_control_intf.iInterface = us[STRING_CTRL_IDX].id;
+   ncm_data_nop_intf.iInterface = us[STRING_DATA_IDX].id;
+   ncm_data_intf.iInterface = us[STRING_DATA_IDX].id;
+   ecm_desc.iMACAddress = us[STRING_MAC_IDX].id;
+   ncm_iad_desc.iFunction = us[STRING_IAD_IDX].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -1335,7 +1331,6 @@ static void ncm_unbind(struct usb_configuration *c, 
struct usb_function *f)
 
DBG(c->cdev, "ncm unbind\n");
 
-   ncm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ncm->notify_req->buf);
@@ -1370,7 +1365,6 @@ struct usb_function *ncm_alloc(struct 
usb_function_instance *fi)
ncm->port.is_fixed = true;
 
ncm->port.func.name = "cdc_network";
-   ncm->port.func.strings = ncm_strings;
/* descriptors are per-instance copies */
ncm->port.func.bind = ncm_bind;
ncm->port.func.unbind = ncm_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 v4 5/8] usb/gadget: ncm: convert to new function interface

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ncm.c   |   57 +++-
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 59908b0..629b7bb 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -731,6 +731,7 @@ config USB_G_NCM
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
+   select USB_F_NCM
select CRC32
help
  This driver implements USB CDC NCM subclass standard. NCM is
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c
index e2f97ee..81956fe 100644
--- a/drivers/usb/gadget/ncm.c
+++ b/drivers/usb/gadget/ncm.c
@@ -24,23 +24,12 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ncm.h"
 
 #define DRIVER_DESC"NCM Gadget"
 
 /*-*/
 
-/*
- * 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.
- */
-#define USB_FNCM_INCLUDED
-#include "f_ncm.c"
-
-/*-*/
-
 /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
  * Instead:  allocate your own, using normal USB-IF procedures.
  */
@@ -113,13 +102,15 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-struct eth_dev *the_dev;
-static u8 host_mac[ETH_ALEN];
+static struct usb_function_instance *f_ncm_inst;
+static struct usb_function *f_ncm;
 
 /*-*/
 
 static int __init ncm_do_config(struct usb_configuration *c)
 {
+   int status;
+
/* FIXME alloc iConfiguration string, set it in c->strings */
 
if (gadget_is_otg(c->cdev->gadget)) {
@@ -127,7 +118,19 @@ static int __init ncm_do_config(struct usb_configuration 
*c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   return ncm_bind_config(c, host_mac, the_dev);
+   f_ncm = usb_get_function(f_ncm_inst);
+   if (IS_ERR(f_ncm)) {
+   status = PTR_ERR(f_ncm);
+   return status;
+   }
+
+   status = usb_add_function(c, f_ncm);
+   if (status < 0) {
+   usb_put_function(f_ncm);
+   return status;
+   }
+
+   return 0;
 }
 
 static struct usb_configuration ncm_config_driver = {
@@ -143,13 +146,20 @@ static struct usb_configuration ncm_config_driver = {
 static int __init gncm_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev->gadget;
+   struct f_ncm_opts   *ncm_opts;
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);
+   f_ncm_inst = usb_get_function_instance("ncm");
+   if (IS_ERR(f_ncm_inst))
+   return PTR_ERR(f_ncm_inst);
+
+   ncm_opts = container_of(f_ncm_inst, struct f_ncm_opts, func_inst);
+
+   gether_set_qmult(ncm_opts->net, qmult);
+   if (!gether_set_host_addr(ncm_opts->net, host_addr))
+   pr_info("using host ethernet address: %s", host_addr);
+   if (!gether_set_dev_addr(ncm_opts->net, dev_addr))
+   pr_info("using self ethernet address: %s", dev_addr);
 
/* Allocate string descriptor numbers ... note that string
 * contents can be overridden by the composite_dev glue.
@@ -172,13 +182,16 @@ static int __init gncm_bind(struct usb_composite_dev 
*cdev)
return 0;
 
 fail:
-   gether_cleanup(the_dev);
+   usb_put_function_instance(f_ncm_inst);
return status;
 }
 
 static int __exit gncm_unbind(struct usb_composite_dev *cdev)
 {
-   gether_cleanup(the_dev);
+   if (!IS_ERR_OR_NULL(f_ncm))
+   usb_put_function(f_ncm);
+   if (!IS_ERR_OR_NULL(f_ncm_inst))
+   usb_put_function_instance(f_ncm_inst);
return 0;
 }
 
-- 
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 v4 3/8] usb/gadget: u_ether: construct with default values and add setters/getters

2013-05-23 Thread Andrzej Pietrasiewicz
Add an interface to create a struct netdev_dev filled with default values, an 
interface which makes it
an interface to fill the struct with useful values and an interface to
read the values set.

The patch also adds an interface to register the net device associated
with an ethernet-over-usb link.

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

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 5f9dacf..6d3ccdc 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -78,6 +78,7 @@ struct eth_dev {
 
boolzlp;
u8  host_mac[ETH_ALEN];
+   u8  dev_mac[ETH_ALEN];
 };
 
 /*-*/
@@ -716,6 +717,17 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
return 1;
 }
 
+static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
+{
+   if (len < 18)
+   return -EINVAL;
+
+   snprintf(str, len, "%02x:%02x:%02x:%02x:%02x:%02x",
+dev_addr[0], dev_addr[1], dev_addr[2],
+dev_addr[3], dev_addr[4], dev_addr[5]);
+   return 18;
+}
+
 static const struct net_device_ops eth_netdev_ops = {
.ndo_open   = eth_open,
.ndo_stop   = eth_stop,
@@ -796,7 +808,8 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
INFO(dev, "MAC %pM\n", net->dev_addr);
INFO(dev, "HOST MAC %pM\n", dev->host_mac);
 
-   /* two kinds of host-initiated state changes:
+   /*
+* two kinds of host-initiated state changes:
 *  - iff DATA transfer is active, carrier is "on"
 *  - tx queueing enabled if open *and* carrier is "on"
 */
@@ -807,6 +820,176 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 }
 EXPORT_SYMBOL(gether_setup_name);
 
+struct net_device *gether_setup_name_default(const char *netname)
+{
+   struct net_device   *net;
+   struct eth_dev  *dev;
+
+   net = alloc_etherdev(sizeof(*dev));
+   if (!net)
+   return ERR_PTR(-ENOMEM);
+
+   dev = netdev_priv(net);
+   spin_lock_init(&dev->lock);
+   spin_lock_init(&dev->req_lock);
+   INIT_WORK(&dev->work, eth_work);
+   INIT_LIST_HEAD(&dev->tx_reqs);
+   INIT_LIST_HEAD(&dev->rx_reqs);
+
+   skb_queue_head_init(&dev->rx_frames);
+
+   /* network device setup */
+   dev->net = net;
+   dev->qmult = QMULT_DEFAULT;
+   snprintf(net->name, sizeof(net->name), "%s%%d", netname);
+
+   eth_random_addr(dev->dev_mac);
+   pr_warn("using random %s ethernet address\n", "self");
+   eth_random_addr(dev->host_mac);
+   pr_warn("using random %s ethernet address\n", "host");
+
+   net->netdev_ops = ð_netdev_ops;
+
+   SET_ETHTOOL_OPS(net, &ops);
+   SET_NETDEV_DEVTYPE(net, &gadget_type);
+
+   return net;
+}
+EXPORT_SYMBOL(gether_setup_name_default);
+
+int gether_register_netdev(struct net_device *net)
+{
+   struct eth_dev *dev;
+   struct usb_gadget *g;
+   struct sockaddr sa;
+   int status;
+
+   if (!net->dev.parent)
+   return -EINVAL;
+   dev = netdev_priv(net);
+   g = dev->gadget;
+   status = register_netdev(net);
+   if (status < 0) {
+   dev_dbg(&g->dev, "register_netdev failed, %d\n", status);
+   return status;
+   } else {
+   INFO(dev, "HOST MAC %pM\n", dev->host_mac);
+
+   /* two kinds of host-initiated state changes:
+*  - iff DATA transfer is active, carrier is "on"
+*  - tx queueing enabled if open *and* carrier is "on"
+*/
+   netif_carrier_off(net);
+   }
+   sa.sa_family = net->type;
+   memcpy(sa.sa_data, dev->dev_mac, ETH_ALEN);
+   rtnl_lock();
+   status = dev_set_mac_address(net, &sa);
+   rtnl_unlock();
+   if (status)
+   pr_warn("cannot set self ethernet address: %d\n", status);
+   else
+   INFO(dev, "MAC %pM\n", dev->dev_mac);
+
+   return status;
+}
+EXPORT_SYMBOL(gether_register_netdev);
+
+void gether_set_gadget(struct net_device *net, struct usb_gadget *g)
+{
+   struct eth_dev *dev;
+
+   dev = netdev_priv(net);
+   dev->gadget = g;
+   SET_NETDEV_DEV(net, &g->dev);
+}
+EXPORT_SYMBOL(gether_set_gadget);
+
+int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
+{
+   struct eth_dev *dev;
+   u8 new_addr[ETH_ALEN];
+
+   dev = netdev_priv(net);
+   if (get_ether_addr(dev_addr, new_addr))
+   return -EINVAL;
+   me

[PATCH v4 4/8] usb/gadget: f_ncm: convert to new function interface with backward compatibility

2013-05-23 Thread Andrzej Pietrasiewicz
Converting ncm to the new function interface requires converting
the USB ncm's function code and its users.
This patch converts the f_ncm.c to the new function interface.
The file is now compiled into a separate usb_f_ncm.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/f_ncm.c  |  196 +++
 drivers/usb/gadget/ncm.c|1 +
 drivers/usb/gadget/u_ncm.h  |   27 ++
 5 files changed, 194 insertions(+), 35 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ncm.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 91b6eab..59908b0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -563,6 +563,9 @@ config USB_F_SERIAL
 config USB_F_OBEX
tristate
 
+config USB_F_NCM
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 3f51952..81f14fe 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -49,6 +49,8 @@ obj-$(CONFIG_USB_F_OBEX)  += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
 u_rndis-y  := rndis.o
 obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
+usb_f_ncm-y:= f_ncm.o
+obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index ee19bc8..722ca1b 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,6 +24,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ncm.h"
 
 /*
  * This function is a "CDC Network Control Model" (CDC NCM) Ethernet link.
@@ -125,7 +127,7 @@ static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
 #define NCM_STATUS_INTERVAL_MS 32
 #define NCM_STATUS_BYTECOUNT   16  /* 8 byte header + data */
 
-static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = {
+static struct usb_interface_assoc_descriptor ncm_iad_desc = {
.bLength =  sizeof ncm_iad_desc,
.bDescriptorType =  USB_DT_INTERFACE_ASSOCIATION,
 
@@ -139,7 +141,7 @@ static struct usb_interface_assoc_descriptor ncm_iad_desc 
__initdata = {
 
 /* interface descriptor: */
 
-static struct usb_interface_descriptor ncm_control_intf __initdata = {
+static struct usb_interface_descriptor ncm_control_intf = {
.bLength =  sizeof ncm_control_intf,
.bDescriptorType =  USB_DT_INTERFACE,
 
@@ -151,7 +153,7 @@ static struct usb_interface_descriptor ncm_control_intf 
__initdata = {
/* .iInterface = DYNAMIC */
 };
 
-static struct usb_cdc_header_desc ncm_header_desc __initdata = {
+static struct usb_cdc_header_desc ncm_header_desc = {
.bLength =  sizeof ncm_header_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_HEADER_TYPE,
@@ -159,7 +161,7 @@ static struct usb_cdc_header_desc ncm_header_desc 
__initdata = {
.bcdCDC =   cpu_to_le16(0x0110),
 };
 
-static struct usb_cdc_union_desc ncm_union_desc __initdata = {
+static struct usb_cdc_union_desc ncm_union_desc = {
.bLength =  sizeof(ncm_union_desc),
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_UNION_TYPE,
@@ -167,7 +169,7 @@ static struct usb_cdc_union_desc ncm_union_desc __initdata 
= {
/* .bSlaveInterface0 =  DYNAMIC */
 };
 
-static struct usb_cdc_ether_desc ecm_desc __initdata = {
+static struct usb_cdc_ether_desc ecm_desc = {
.bLength =  sizeof ecm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_ETHERNET_TYPE,
@@ -182,7 +184,7 @@ static struct usb_cdc_ether_desc ecm_desc __initdata = {
 
 #define NCAPS  (USB_CDC_NCM_NCAP_ETH_FILTER | USB_CDC_NCM_NCAP_CRC_MODE)
 
-static struct usb_cdc_ncm_desc ncm_desc __initdata = {
+static struct usb_cdc_ncm_desc ncm_desc = {
.bLength =  sizeof ncm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_NCM_TYPE,
@@ -194,7 +196,7 @@ static struct usb_cdc_ncm_desc ncm_desc __initdata = {
 
 /* the default data interface has no endpoints ... */
 
-static struct usb_interface_descriptor ncm_data_nop_intf __initdata = {
+static struct usb_interface_descriptor ncm_data_nop_intf = {
.bLength =  sizeof ncm_data_nop_intf,
.bDescriptorType =  USB_DT_INTERFACE,
 
@@ -209,7 +211,7 @@ static struct usb_interface_descriptor ncm_data_nop_intf 
__initdata = {
 
 /* ... but the "re

Re: [PATCH] build some drivers only when compile-testing

2013-05-23 Thread Tomi Valkeinen
Hi,

On 22/05/13 12:18, Jiri Slaby wrote:
> Some drivers can be built on more platforms than they run on. This
> causes users and distributors packaging burden when they have to
> manually deselect some drivers from their allmodconfigs. Or sometimes
> it is even impossible to disable the drivers without patching the
> kernel.
> 
> Introduce a new config option COMPILE_TEST and make all those drivers
> to depend on the platform they run on, or on the COMPILE_TEST option.
> Now, when users/distributors choose COMPILE_TEST=n they will not have
> the drivers in their allmodconfig setups, but developers still can
> compile-test them with COMPILE_TEST=y.
> 
> Now the drivers where we use this new option:
> * PTP_1588_CLOCK_PCH: The PCH EG20T is only compatible with Intel Atom
>   processors so it should depend on x86.
> * FB_GEODE: Geode is 32-bit only so only enable it for X86_32.
> * USB_CHIPIDEA_IMX: The OF_DEVICE dependency will be met on powerpc
>   systems -- which do not actually support the hardware via that
>   method.

I had this exact same idea some time ago. The mail below contains some
of my reasoning for this:

http://comments.gmane.org/gmane.linux.kbuild.devel/9829

I proposed a new Kconfig keyword, but Sam was quite against it as the
Kconfig language already does what is required.

 Tomi




signature.asc
Description: OpenPGP digital signature


[PATCH v3 0/5] Equivalent of g_cdc.ko with configfs

2013-05-23 Thread Andrzej Pietrasiewicz
Here I present the conversion of everthing that is required to provide
the equivalent of g_cdc.ko with configfs.

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

v2..v3:

- don't unregister a network interface if it has not been registered before

v1..v2:

- fixed a bug resulting from the delayed registration of a network interface
  (should be registered only once)

This series requires this to be applied before:

http://comments.gmane.org/gmane.linux.usb.general/86773


BACKWARD COMPATIBILITY
==

Please note that the old g_cdc.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_cdc.ko equivalent.

The old g_cdc.ko provides two functions:

- acm
- ecm

which can be used simultaneously.

The acm function usage is described in (*).

For ecm the old g_cdc.ko offered three parameters:

qmult  - queue length multiplier for high/super -speed devices
dev_addr   - device's MAC address
host_addr  - host's MAC address

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ecm.

e.g. mkdir functions/ecm.usb0

In functions/ecm. there will be the following attribute files:

qmult
dev_addr
host_addr
ifname

and after creating the functions/ecm. they contain default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

The rest of the procedure (*) remains the same.

After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS


acm)

On host: cat > /dev/ttyACM
On target: cat /dev/ttyGS

then the other way round

On target: cat > /dev/ttyGS
On host: cat /dev/ttyACM

ecm)

On the device: ping 
On the host: ping 

Andrzej Pietrasiewicz (5):
  usb/gadget: add helpers for configfs support for USB Ethernet
  usb/gadget: f_ecm: convert to new function interface with backward
compatibility
  usb/gadget: cdc2: convert to new interface of f_ecm
  usb/gadget: f_ecm: use usb_gstrings_attach
  usb/gadget: f_ecm: add configfs support

 drivers/usb/gadget/Kconfig|4 +
 drivers/usb/gadget/Makefile   |2 +
 drivers/usb/gadget/cdc2.c |   83 +--
 drivers/usb/gadget/ether.c|1 +
 drivers/usb/gadget/f_ecm.c|  196 ++---
 drivers/usb/gadget/f_ncm.c|  139 ++-
 drivers/usb/gadget/g_ffs.c|1 +
 drivers/usb/gadget/multi.c|1 +
 drivers/usb/gadget/nokia.c|3 +-
 drivers/usb/gadget/u_ecm.h|   36 ++
 drivers/usb/gadget/u_ether_configfs.h |  164 +++
 11 files changed, 454 insertions(+), 176 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ecm.h
 create mode 100644 drivers/usb/gadget/u_ether_configfs.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


[PATCH v3 2/5] usb/gadget: f_ecm: convert to new function interface with backward compatibility

2013-05-23 Thread Andrzej Pietrasiewicz
Converting ecm to the new function interface requires converting
the USB ecm's function code and its users.
This patch converts the f_ecm.c to the new function interface.
The file is now compiled into a separate usb_f_ecm.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/cdc2.c   |1 +
 drivers/usb/gadget/ether.c  |1 +
 drivers/usb/gadget/f_ecm.c  |  149 +++
 drivers/usb/gadget/g_ffs.c  |1 +
 drivers/usb/gadget/multi.c  |1 +
 drivers/usb/gadget/nokia.c  |3 +-
 drivers/usb/gadget/u_ecm.h  |   27 
 9 files changed, 174 insertions(+), 14 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ecm.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 629b7bb..bcadb5c 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -566,6 +566,9 @@ config USB_F_OBEX
 config USB_F_NCM
tristate
 
+config USB_F_ECM
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 81f14fe..ecfa7c3 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -51,6 +51,8 @@ u_rndis-y := rndis.o
 obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 usb_f_ncm-y:= f_ncm.o
 obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
+usb_f_ecm-y:= f_ecm.o
+obj-$(CONFIG_USB_F_ECM)+= usb_f_ecm.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 07b3aaf..a0cba7e 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -44,6 +44,7 @@ USB_ETHERNET_MODULE_PARAMETERS();
  * 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"
 
 /*-*/
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 6bff24f..862ef65 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -102,6 +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 "f_subset.c"
 #ifdef USB_ETH_RNDIS
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index d893d69..b3a1747 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -14,10 +14,12 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include "u_ether.h"
+#include "u_ecm.h"
 
 
 /*
@@ -687,6 +689,40 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
+#ifndef USBF_ECM_INCLUDED
+   struct f_ecm_opts   *ecm_opts;
+
+   if (!can_support_ecm(cdev->gadget))
+   return -EINVAL;
+
+   ecm_opts = container_of(f->fi, struct f_ecm_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 ecm_opts->bound access
+*/
+   if (!ecm_opts->bound) {
+   gether_set_gadget(ecm_opts->net, cdev->gadget);
+   status = gether_register_netdev(ecm_opts->net);
+   if (status)
+   return status;
+   ecm_opts->bound = true;
+   }
+#endif
+   if (ecm_string_defs[0].id == 0) {
+   status = usb_string_ids_tab(c->cdev, ecm_string_defs);
+   if (status)
+   return status;
+
+   ecm_control_intf.iInterface = ecm_string_defs[0].id;
+   ecm_data_intf.iInterface = ecm_string_defs[2].id;
+   ecm_desc.iMACAddress = ecm_string_defs[1].id;
+   ecm_iad_descriptor.iFunction = ecm_string_defs[3].id;
+   }
+
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
@@ -796,8 +832,10 @@ fail:
return status;
 }
 
+#ifdef USBF_ECM_INCLUDED
+
 static void
-ecm_unbind(struct usb_configuration *c, struct usb_function *f)
+ecm_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_ecm*ecm = func_to_ecm(f);
 
@@ -833,17 +871,6 @@ ecm_bind_config(struct usb_configuration *c, u8 
ethaddr

[PATCH v3 1/5] usb/gadget: add helpers for configfs support for USB Ethernet

2013-05-23 Thread Andrzej Pietrasiewicz
All USB Ethernet functions will have very similar attributes in configfs.
This patch provides helper definitions to ease writing the functions and
reduce source code duplication.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c|  139 ++-
 drivers/usb/gadget/u_ether_configfs.h |  164 +
 2 files changed, 175 insertions(+), 128 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ether_configfs.h

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 697262e..47a5724 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_ncm.h"
 
 /*
@@ -1298,138 +1299,20 @@ static inline struct f_ncm_opts *to_f_ncm_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_ncm_opts);
-CONFIGFS_ATTR_OPS(f_ncm_opts);
+/* f_ncm_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(ncm);
 
-static void ncm_attr_release(struct config_item *item)
-{
-   struct f_ncm_opts *opts = to_f_ncm_opts(item);
-
-   usb_put_function_instance(&opts->func_inst);
-}
-
-static struct configfs_item_operations ncm_item_ops = {
-   .release= ncm_attr_release,
-   .show_attribute = f_ncm_opts_attr_show,
-   .store_attribute = f_ncm_opts_attr_store,
-};
-
-static ssize_t ncm_opts_dev_addr_show(struct f_ncm_opts *opts, char *page)
-{
-   int result;
-
-   mutex_lock(&opts->lock);
-   result = gether_get_dev_addr(opts->net, page, PAGE_SIZE);
-   mutex_unlock(&opts->lock);
-
-   return result;
-}
-
-static ssize_t ncm_opts_dev_addr_store(struct f_ncm_opts *opts,
-   const char *page, size_t len)
-{
-   int ret;
-
-   mutex_lock(&opts->lock);
-   if (opts->refcnt) {
-   mutex_unlock(&opts->lock);
-   return -EBUSY;
-   }
-
-   ret = gether_set_dev_addr(opts->net, page);
-   mutex_unlock(&opts->lock);
-   if (!ret)
-   ret = len;
-   return ret;
-}
-
-static struct f_ncm_opts_attribute f_ncm_opts_dev_addr =
-   __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, ncm_opts_dev_addr_show,
-   ncm_opts_dev_addr_store);
-
-static ssize_t ncm_opts_host_addr_show(struct f_ncm_opts *opts, char *page)
-{
-   int result;
-
-   mutex_lock(&opts->lock);
-   result = gether_get_host_addr(opts->net, page, PAGE_SIZE);
-   mutex_unlock(&opts->lock);
-
-   return result;
-}
-
-static ssize_t ncm_opts_host_addr_store(struct f_ncm_opts *opts,
-   const char *page, size_t len)
-{
-   int ret;
+/* f_ncm_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ncm);
 
-   mutex_lock(&opts->lock);
-   if (opts->refcnt) {
-   mutex_unlock(&opts->lock);
-   return -EBUSY;
-   }
-
-   ret = gether_set_host_addr(opts->net, page);
-   mutex_unlock(&opts->lock);
-   if (!ret)
-   ret = len;
-   return ret;
-}
-
-static struct f_ncm_opts_attribute f_ncm_opts_host_addr =
-   __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, ncm_opts_host_addr_show,
-   ncm_opts_host_addr_store);
-
-static ssize_t ncm_opts_qmult_show(struct f_ncm_opts *opts, char *page)
-{
-   unsigned qmult;
-
-   mutex_lock(&opts->lock);
-   qmult = gether_get_qmult(opts->net);
-   mutex_unlock(&opts->lock);
-   return sprintf(page, "%d", qmult);
-}
-
-static ssize_t ncm_opts_qmult_store(struct f_ncm_opts *opts,
-   const char *page, size_t len)
-{
-   u8 val;
-   int ret;
+/* f_ncm_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ncm);
 
-   mutex_lock(&opts->lock);
-   if (opts->refcnt) {
-   ret = -EBUSY;
-   goto out;
-   }
-
-   ret = kstrtou8(page, 0, &val);
-   if (ret)
-   goto out;
-
-   gether_set_qmult(opts->net, val);
-   ret = len;
-out:
-   mutex_unlock(&opts->lock);
-   return ret;
-}
-
-static struct f_ncm_opts_attribute f_ncm_opts_qmult =
-   __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, ncm_opts_qmult_show,
-   ncm_opts_qmult_store);
-
-static ssize_t ncm_opts_ifname_show(struct f_ncm_opts *opts, char *page)
-{
-   int ret;
-
-   mutex_lock(&opts->lock);
-   ret = gether_get_ifname(opts->net, page, PAGE_SIZE);
-   mutex_unlock(&opts->lock);
-
-   return ret;
-}
+/* f_ncm_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
 
-static struct f_ncm_opts_attribute f_ncm_opts_ifname =
-   __CONFIGFS_ATTR_RO(ifname, ncm_opts_ifname_show);
+/* f_ncm_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
 
 static struct configfs_attribute *ncm_attrs[] = {
&f_ncm_opts_dev_addr.attr,
diff --git a/drivers/usb/gadget/u_ether_configfs.h 
b/drivers/usb/gadget/u_ether_configfs.h
new

[PATCH v3 5/5] usb/gadget: f_ecm: add configfs support

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ecm.c |   50 +++-
 drivers/usb/gadget/u_ecm.h |9 
 2 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 1b2139d..5c578fb 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -19,6 +19,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_ecm.h"
 
 
@@ -706,8 +707,10 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
 * with regard to ecm_opts->bound access
 */
if (!ecm_opts->bound) {
+   mutex_lock(&ecm_opts->lock);
gether_set_gadget(ecm_opts->net, cdev->gadget);
status = gether_register_netdev(ecm_opts->net);
+   mutex_unlock(&ecm_opts->lock);
if (status)
return status;
ecm_opts->bound = true;
@@ -898,6 +901,41 @@ ecm_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
 
 #else
 
+static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_ecm_opts,
+   func_inst.group);
+}
+
+/* f_ecm_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(ecm);
+
+/* f_ecm_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ecm);
+
+/* f_ecm_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ecm);
+
+/* f_ecm_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
+
+/* f_ecm_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
+
+static struct configfs_attribute *ecm_attrs[] = {
+   &f_ecm_opts_dev_addr.attr,
+   &f_ecm_opts_host_addr.attr,
+   &f_ecm_opts_qmult.attr,
+   &f_ecm_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type ecm_func_type = {
+   .ct_item_ops= &ecm_item_ops,
+   .ct_attrs   = ecm_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void ecm_free_inst(struct usb_function_instance *f)
 {
struct f_ecm_opts *opts;
@@ -917,21 +955,28 @@ static struct usb_function_instance *ecm_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 = ecm_free_inst;
opts->net = gether_setup_default();
if (IS_ERR(opts->net))
return ERR_PTR(PTR_ERR(opts->net));
 
+   config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type);
+
return &opts->func_inst;
 }
 
 static void ecm_free(struct usb_function *f)
 {
struct f_ecm *ecm;
+   struct f_ecm_opts *opts;
 
ecm = func_to_ecm(f);
+   opts = container_of(f->fi, struct f_ecm_opts, func_inst);
kfree(ecm);
+   mutex_lock(&opts->lock);
+   opts->refcnt--;
+   mutex_unlock(&opts->lock);
 }
 
 static void ecm_unbind(struct usb_configuration *c, struct usb_function *f)
@@ -958,6 +1003,8 @@ struct usb_function *ecm_alloc(struct 
usb_function_instance *fi)
return ERR_PTR(-ENOMEM);
 
opts = container_of(fi, struct f_ecm_opts, func_inst);
+   mutex_lock(&opts->lock);
+   opts->refcnt++;
 
/* export host's Ethernet address in CDC format */
status = gether_get_host_addr_cdc(opts->net, ecm->ethaddr,
@@ -969,6 +1016,7 @@ struct usb_function *ecm_alloc(struct 
usb_function_instance *fi)
ecm_string_defs[1].s = ecm->ethaddr;
 
ecm->port.ioport = netdev_priv(opts->net);
+   mutex_unlock(&opts->lock);
ecm->port.cdc_filter = DEFAULT_FILTER;
 
ecm->port.func.name = "cdc_ethernet";
diff --git a/drivers/usb/gadget/u_ecm.h b/drivers/usb/gadget/u_ecm.h
index 99b6b99..262cc03 100644
--- a/drivers/usb/gadget/u_ecm.h
+++ b/drivers/usb/gadget/u_ecm.h
@@ -22,6 +22,15 @@ struct f_ecm_opts {
struct usb_function_instancefunc_inst;
struct net_device   *net;
boolbound;
+
+   /*
+* Read/write access to configfs attributes is handled by configfs.
+*
+* This is to protect the data from concurrent access by read/write
+* and create symlink/remove symlink.
+*/
+   struct mutexlock;
+   int refcnt;
 };
 
 #endif /* U_ECM_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 v3 4/5] usb/gadget: f_ecm: use usb_gstrings_attach

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

diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index b3a1747..1b2139d 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -686,6 +686,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_ecm*ecm = func_to_ecm(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
@@ -712,16 +713,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
ecm_opts->bound = true;
}
 #endif
-   if (ecm_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, ecm_string_defs);
-   if (status)
-   return status;
-
-   ecm_control_intf.iInterface = ecm_string_defs[0].id;
-   ecm_data_intf.iInterface = ecm_string_defs[2].id;
-   ecm_desc.iMACAddress = ecm_string_defs[1].id;
-   ecm_iad_descriptor.iFunction = ecm_string_defs[3].id;
-   }
+   us = usb_gstrings_attach(cdev, ecm_strings,
+ARRAY_SIZE(ecm_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   ecm_control_intf.iInterface = us[0].id;
+   ecm_data_intf.iInterface = us[2].id;
+   ecm_desc.iMACAddress = us[1].id;
+   ecm_iad_descriptor.iFunction = us[3].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -841,7 +840,6 @@ ecm_old_unbind(struct usb_configuration *c, struct 
usb_function *f)
 
DBG(c->cdev, "ecm unbind\n");
 
-   ecm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ecm->notify_req->buf);
@@ -884,7 +882,6 @@ ecm_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
ecm->port.cdc_filter = DEFAULT_FILTER;
 
ecm->port.func.name = "cdc_ethernet";
-   ecm->port.func.strings = ecm_strings;
/* descriptors are per-instance copies */
ecm->port.func.bind = ecm_bind;
ecm->port.func.unbind = ecm_old_unbind;
@@ -943,7 +940,6 @@ static void ecm_unbind(struct usb_configuration *c, struct 
usb_function *f)
 
DBG(c->cdev, "ecm unbind\n");
 
-   ecm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ecm->notify_req->buf);
@@ -976,7 +972,6 @@ struct usb_function *ecm_alloc(struct usb_function_instance 
*fi)
ecm->port.cdc_filter = DEFAULT_FILTER;
 
ecm->port.func.name = "cdc_ethernet";
-   ecm->port.func.strings = ecm_strings;
/* descriptors are per-instance copies */
ecm->port.func.bind = ecm_bind;
ecm->port.func.unbind = ecm_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 v3 3/5] usb/gadget: cdc2: convert to new interface of f_ecm

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/cdc2.c  |   84 ++-
 2 files changed, 52 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index bcadb5c..d064e0f 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -890,6 +890,7 @@ config USB_CDC_COMPOSITE
select USB_U_SERIAL
select USB_U_ETHER
select USB_F_ACM
+   select USB_F_ECM
help
  This driver provides two functions in one configuration:
  a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link.
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index a0cba7e..b80b963 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -15,6 +15,7 @@
 
 #include "u_ether.h"
 #include "u_serial.h"
+#include "u_ecm.h"
 
 
 #define DRIVER_DESC"CDC Composite Gadget"
@@ -32,21 +33,10 @@
 #define CDC_VENDOR_NUM 0x0525  /* NetChip */
 #define CDC_PRODUCT_NUM0xa4aa  /* CDC Composite: ECM + ACM */
 
-/*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 USB_ETHERNET_MODULE_PARAMETERS();
 
-/*
- * 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.
- */
-#define USBF_ECM_INCLUDED
-#include "f_ecm.c"
-
 /*-*/
 
 static struct usb_device_descriptor device_desc = {
@@ -104,44 +94,54 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-static u8 host_mac[ETH_ALEN];
-static struct eth_dev *the_dev;
 /*-*/
 static struct usb_function *f_acm;
 static struct usb_function_instance *fi_serial;
 
+static struct usb_function_instance *fi_ecm;
+static struct usb_function *f_ecm;
+
 /*
  * We _always_ have both CDC ECM and CDC ACM functions.
  */
 static int __init cdc_do_config(struct usb_configuration *c)
 {
-   int status;
+   int status;
 
if (gadget_is_otg(c->cdev->gadget)) {
c->descriptors = otg_desc;
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   status = ecm_bind_config(c, host_mac, the_dev);
-   if (status < 0)
-   return status;
+   f_ecm = usb_get_function(fi_ecm);
+   if (IS_ERR(f_ecm)) {
+   status = PTR_ERR(f_ecm);
+   goto err_get_ecm;
+   }
 
-   fi_serial = usb_get_function_instance("acm");
-   if (IS_ERR(fi_serial))
-   return PTR_ERR(fi_serial);
+   status = usb_add_function(c, f_ecm);
+   if (status < 0)
+   goto err_add_ecm;
 
f_acm = usb_get_function(fi_serial);
-   if (IS_ERR(f_acm))
-   goto err_func_acm;
+   if (IS_ERR(f_acm)) {
+   status = PTR_ERR(f_acm);
+   goto err_get_acm;
+   }
 
status = usb_add_function(c, f_acm);
if (status)
-   goto err_conf;
+   goto err_add_acm;
+
return 0;
-err_conf:
+
+err_add_acm:
usb_put_function(f_acm);
-err_func_acm:
-   usb_put_function_instance(fi_serial);
+err_get_acm:
+   usb_remove_function(c, f_ecm);
+err_add_ecm:
+   usb_put_function(f_ecm);
+err_get_ecm:
return status;
 }
 
@@ -157,6 +157,7 @@ static struct usb_configuration cdc_config_driver = {
 static int __init cdc_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev->gadget;
+   struct f_ecm_opts   *ecm_opts;
int status;
 
if (!can_support_ecm(cdev->gadget)) {
@@ -165,11 +166,23 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
return -EINVAL;
}
 
-   /* 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);
+   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);
+
+   fi_serial = usb_get_function_instance("acm");
+   if (IS_ERR(fi_ser

[PATCH v2 0/9] Equivalent of g_nokia.ko with configfs

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

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

v1..v2:

- don't unregister a network interface if it has not been registered before
- add phonet function description in Documentation/ABI

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

BACKWARD COMPATIBILITY
==

Please note that the old g_nokia.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_nokia.ko equivalent.

The old g_nokia.ko provides 4 functions:

- Phonet
- Obex (2 instances)
- ACM
- ECM

in 2 configurations, which contain this same set of functions,
but differ in MaxPower.

The procedure of setting up such a gadget with configfs is given
below with an example:

$ modprobe libcomposite
 
$ mount none cfg -t configfs
 
$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
 
$ echo 0x01c8 > idProduct
$ echo 0x0421 > idVendor
$ mkdir strings/0x409
$ echo Nokia > strings/0x409/manufacturer
$ echo "N900 (PC-Suite Mode)" > strings/0x409/product
 
$ mkdir configs/c.1
$ echo 500 > configs/c.1/MaxPower
$ mkdir configs/c.1/strings/0x409
$ echo "Conf 1" > configs/c.1/strings/0x409/configuration
 
$ mkdir configs/c.2
$ echo 100 > configs/c.2/MaxPower
$ mkdir configs/c.2/strings/0x409
$ echo "Conf 2" > configs/c.2/strings/0x409/configuration
 
$ mkdir functions/phonet.pn0
$ mkdir functions/obex.obex1
$ mkdir functions/obex.obex2
$ mkdir functions/acm.tty0
$ mkdir functions/ecm.usb0
 
$ ln -s functions/phonet.pn0 configs/c.1
$ ln -s functions/obex.obex1 configs/c.1
$ ln -s functions/obex.obex2 configs/c.1
$ ln -s functions/acm.tty0 configs/c.1
$ ln -s functions/ecm.usb0 configs/c.1
 
$ ln -s functions/phonet.pn0 configs/c.2
$ ln -s functions/obex.obex1 configs/c.2
$ ln -s functions/obex.obex2 configs/c.2
$ ln -s functions/acm.tty0 configs/c.2
$ ln -s functions/ecm.usb0 configs/c.2
 
$ echo s3c-hsotg > UDC

The obex and acm functions provide only one, readonly, attribute port_num,
which contains their port number.
The phonet function provides only one, readonly, attribute ifname, which
contains the network interface name associated with the function.
The ecm function provides qmult, dev_addr, host_addr read-write attributes,
and ifname readonly attribute.
and after creating the functions/ecm. it contains default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS


phonet)

It is not possible to test the SOCK_STREAM protocol without a specific piece
of hardware, so only SOCK_DGRAM has been tested. For the latter to work,
I had to apply the patch mentioned here:

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

For this to work, these tools are required

git://git.gitorious.org/meego-cellular/phonet-utils.git

On the host:

$ ./phonet -a 0x10 -i usbpn0
$ ./pnroute add 0x6c usbpn0
$./pnroute add 0x10 usbpn0
$ ifconfig usbpn0 up

On the device:

$ ./phonet -a 0x6c -i upnlink0
$ ./pnroute add 0x10 upnlink0
$ ifconfig upnlink0 up

Then a test program can be used:

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

On the device:

$ ./pnxmit -a 0x6c -r

On the host:

$ ./pnxmit -a 0x10 -s 0x6c

As a result some data should be sent from host to device.
Then the other way round:

On the host:

$ ./pnxmit -a 0x10 -r

On the device:

$ ./pnxmit -a 0x6c -s 0x10

obex)

On device: seriald -f /dev/ttyGS -s 1024
On host: serialc -v  -p  -i -a1 -s1024 \
 -t -r

where seriald and serialc are Felipe's utilities found here:

https://git.gitorious.org/usb/usb-tools.git master

acm)

On host: cat > /dev/ttyACM
On target: cat /dev/ttyGS

then the other way round

On target: cat > /dev/ttyGS
On host: cat /dev/ttyACM

ecm)

On the device: ping 
On the host: ping 


Andrzej Pietrasiewicz (9):
  usb/gadget: f_obex: use usb_gstrings_attach
  us

[PATCH v2 3/9] usb/gadget: f_obex: remove compatibility layer

2013-05-23 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_obex.c |   52 ---
 1 files changed, 0 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 1b61fe7..ab35eac 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -402,55 +402,6 @@ fail:
return status;
 }
 
-#ifdef USBF_OBEX_INCLUDED
-
-static void
-obex_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   usb_free_all_descriptors(f);
-   kfree(func_to_obex(f));
-}
-
-/**
- * obex_bind_config - add a CDC OBEX function to a configuration
- * @c: the configuration to support the CDC OBEX instance
- * @port_num: /dev/ttyGS* port this interface will use
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- */
-int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
-{
-   struct f_obex   *obex;
-   int status;
-
-   /* allocate and initialize one new instance */
-   obex = kzalloc(sizeof *obex, GFP_KERNEL);
-   if (!obex)
-   return -ENOMEM;
-
-   obex->port_num = port_num;
-
-   obex->port.connect = obex_connect;
-   obex->port.disconnect = obex_disconnect;
-
-   obex->port.func.name = "obex";
-   /* descriptors are per-instance copies */
-   obex->port.func.bind = obex_bind;
-   obex->port.func.unbind = obex_old_unbind;
-   obex->port.func.set_alt = obex_set_alt;
-   obex->port.func.get_alt = obex_get_alt;
-   obex->port.func.disable = obex_disable;
-
-   status = usb_add_function(c, &obex->port.func);
-   if (status)
-   kfree(obex);
-
-   return status;
-}
-
-#else
-
 static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
 {
return container_of(to_config_group(item), struct f_serial_opts,
@@ -577,8 +528,5 @@ struct usb_function *obex_alloc(struct 
usb_function_instance *fi)
 }
 
 DECLARE_USB_FUNCTION_INIT(obex, obex_alloc_inst, obex_alloc);
-
-#endif
-
 MODULE_AUTHOR("Felipe Balbi");
 MODULE_LICENSE("GPL");
-- 
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 2/9] usb/gadget: nokia: convert to new interface of f_obex

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |  122 ++--
 2 files changed, 85 insertions(+), 38 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 8a0f14e..66e7577 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -974,6 +974,7 @@ config USB_G_NOKIA
select USB_U_SERIAL
select USB_U_ETHER
select USB_F_ACM
+   select USB_F_OBEX
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 8e42c88..a69e8bf 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include "u_serial.h"
@@ -39,8 +40,6 @@
  */
 #define USBF_ECM_INCLUDED
 #include "f_ecm.c"
-#define USBF_OBEX_INCLUDED
-#include "f_obex.c"
 #include "f_phonet.c"
 #include "u_ether.h"
 
@@ -102,16 +101,12 @@ MODULE_LICENSE("GPL");
 static struct usb_function *f_acm_cfg1;
 static struct usb_function *f_acm_cfg2;
 static u8 host_mac[ETH_ALEN];
+static struct usb_function *f_obex1_cfg1;
+static struct usb_function *f_obex2_cfg1;
+static struct usb_function *f_obex1_cfg2;
+static struct usb_function *f_obex2_cfg2;
 static struct eth_dev *the_dev;
 
-enum {
-   TTY_PORT_OBEX0,
-   TTY_PORT_OBEX1,
-   TTY_PORTS_MAX,
-};
-
-static unsigned char tty_lines[TTY_PORTS_MAX];
-
 static struct usb_configuration nokia_config_500ma_driver = {
.label  = "Bus Powered",
.bConfigurationValue = 1,
@@ -129,27 +124,51 @@ static struct usb_configuration nokia_config_100ma_driver 
= {
 };
 
 static struct usb_function_instance *fi_acm;
+static struct usb_function_instance *fi_obex1;
+static struct usb_function_instance *fi_obex2;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
struct usb_function *f_acm;
+   struct usb_function *f_obex1 = NULL;
+   struct usb_function *f_obex2 = NULL;
int status = 0;
+   int obex1_stat = 0;
+   int obex2_stat = 0;
 
status = phonet_bind_config(c);
if (status)
-   printk(KERN_DEBUG "could not bind phonet config\n");
+   pr_debug("could not bind phonet config\n");
 
-   status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX0]);
-   if (status)
-   printk(KERN_DEBUG "could not bind obex config %d\n", 0);
+   if (!IS_ERR(fi_obex1)) {
+   f_obex1 = usb_get_function(fi_obex1);
+   if (IS_ERR(f_obex1))
+   pr_debug("could not get obex function 0\n");
+   }
 
-   status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX1]);
-   if (status)
-   printk(KERN_DEBUG "could not bind obex config %d\n", 0);
+   if (!IS_ERR(fi_obex2)) {
+   f_obex2 = usb_get_function(fi_obex2);
+   if (IS_ERR(f_obex2))
+   pr_debug("could not get obex function 1\n");
+   }
 
f_acm = usb_get_function(fi_acm);
-   if (IS_ERR(f_acm))
-   return PTR_ERR(f_acm);
+   if (IS_ERR(f_acm)) {
+   status = PTR_ERR(f_acm);
+   goto err_get_acm;
+   }
+
+   if (!IS_ERR_OR_NULL(f_obex1)) {
+   obex1_stat = usb_add_function(c, f_obex1);
+   if (obex1_stat)
+   pr_debug("could not add obex function 0\n");
+   }
+
+   if (!IS_ERR_OR_NULL(f_obex2)) {
+   obex2_stat = usb_add_function(c, f_obex2);
+   if (obex2_stat)
+   pr_debug("could not add obex function 1\n");
+   }
 
status = usb_add_function(c, f_acm);
if (status)
@@ -160,16 +179,30 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
pr_debug("could not bind ecm config %d\n", status);
goto err_ecm;
}
-   if (c == &nokia_config_500ma_driver)
+   if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
-   else
+   f_obex1_cfg1 = f_obex1;
+   f_obex2_cfg1 = f_obex2;
+   } else {
f_acm_cfg2 = f_acm;
+   f_obex1_cfg2 = f_obex1;
+   f_obex2_cfg2 = f_obex2;
+   }
 
return status;
 err_ecm:
usb_remove_function(c, f_acm);
 err_conf:
+   if (!obex2_stat)
+   usb_remove_function(c, f_obex2);
+   if (!obex1_stat)
+   usb_remove_function(c, f_obex1);
usb_put_function(f_acm);
+err_get_acm:
+   if (!IS_ERR_OR_NULL(f_obex2))
+   usb_put_function(f_obex2);
+   if (!IS_ERR_OR_NULL(f_obex1))
+   usb_put_function(f_obex1);
return status;
 }
 
@@ -177,18 +210,11 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)

[PATCH v2 6/9] usb/gadget: nokia: convert to new interface of f_phonet

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

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 0493542..0760814 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -978,6 +978,7 @@ config USB_G_NOKIA
select USB_U_ETHER
select USB_F_ACM
select USB_F_OBEX
+   select USB_F_PHONET
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index a20bcbf..084f947 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -40,8 +40,6 @@
  */
 #define USBF_ECM_INCLUDED
 #include "f_ecm.c"
-#define USBF_PHONET_INCLUDED
-#include "f_phonet.c"
 #include "u_ether.h"
 
 /*-*/
@@ -106,8 +104,9 @@ static struct usb_function *f_obex1_cfg1;
 static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
+static struct usb_function *f_phonet_cfg1;
+static struct usb_function *f_phonet_cfg2;
 static struct eth_dev *the_dev;
-static struct net_device *phonet_dev;
 
 
 static struct usb_configuration nokia_config_500ma_driver = {
@@ -129,19 +128,24 @@ static struct usb_configuration nokia_config_100ma_driver 
= {
 static struct usb_function_instance *fi_acm;
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
+static struct usb_function_instance *fi_phonet;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
struct usb_function *f_acm;
+   struct usb_function *f_phonet = NULL;
struct usb_function *f_obex1 = NULL;
struct usb_function *f_obex2 = NULL;
int status = 0;
int obex1_stat = 0;
int obex2_stat = 0;
+   int phonet_stat = 0;
 
-   status = phonet_bind_config(c, phonet_dev);
-   if (status)
-   pr_debug("could not bind phonet config\n");
+   if (!IS_ERR(fi_phonet)) {
+   f_phonet = usb_get_function(fi_phonet);
+   if (IS_ERR(f_phonet))
+   pr_debug("could not get phonet function\n");
+   }
 
if (!IS_ERR(fi_obex1)) {
f_obex1 = usb_get_function(fi_obex1);
@@ -161,6 +165,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_acm;
}
 
+   if (!IS_ERR_OR_NULL(f_phonet)) {
+   phonet_stat = usb_add_function(c, f_phonet);
+   if (phonet_stat)
+   pr_debug("could not add phonet function\n");
+   }
+
if (!IS_ERR_OR_NULL(f_obex1)) {
obex1_stat = usb_add_function(c, f_obex1);
if (obex1_stat)
@@ -184,10 +194,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
}
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
+   f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
+   f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
}
@@ -200,12 +212,16 @@ err_conf:
usb_remove_function(c, f_obex2);
if (!obex1_stat)
usb_remove_function(c, f_obex1);
+   if (!phonet_stat)
+   usb_remove_function(c, f_phonet);
usb_put_function(f_acm);
 err_get_acm:
if (!IS_ERR_OR_NULL(f_obex2))
usb_put_function(f_obex2);
if (!IS_ERR_OR_NULL(f_obex1))
usb_put_function(f_obex1);
+   if (!IS_ERR_OR_NULL(f_phonet))
+   usb_put_function(f_phonet);
return status;
 }
 
@@ -214,12 +230,6 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   phonet_dev = gphonet_setup(cdev->gadget);
-   if (IS_ERR(phonet_dev)) {
-   status = PTR_ERR(phonet_dev);
-   goto err_phonet;
-   }
-
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
   qmult);
if (IS_ERR(the_dev)) {
@@ -239,6 +249,10 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
if (!gadget_supports_altsettings(gadget))
goto err_usb;
 
+   fi_phonet = usb_get_function_instance("phonet");
+   if (IS_ERR(fi_phonet))
+   pr_debug("could not find phonet function\n");
+
fi_obex1 = usb_get_function_instance("obex");
if (IS_ERR(fi_obex1))
pr_d

[PATCH v2 9/9] usb/gadget: f_phonet: add configfs support

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 .../ABI/testing/configfs-usb-gadget-phonet |8 +++
 drivers/usb/gadget/Kconfig |   10 
 drivers/usb/gadget/f_phonet.c  |   56 
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-phonet

diff --git a/Documentation/ABI/testing/configfs-usb-gadget-phonet 
b/Documentation/ABI/testing/configfs-usb-gadget-phonet
new file mode 100644
index 000..19b67d3
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-phonet
@@ -0,0 +1,8 @@
+What:  /config/usb-gadget/gadget/functions/phonet.name
+Date:  May 2013
+KenelVersion:  3.11
+Description:
+
+   This item contains just one readonly attribute: ifname.
+   It contains the network interface name assigned during
+   network device registration.
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 90149a3..6dd2192 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -657,6 +657,16 @@ config USB_CONFIGFS_ECM
  favor of simpler vendor-specific hardware, but is widely
  supported by firmware for smart network devices.
 
+config USB_CONFIGFS_PHONET
+   boolean "Phonet protocol"
+   depends on USB_CONFIGFS
+   depends on NET
+   depends on PHONET
+   select USB_U_ETHER
+   select USB_F_PHONET
+   help
+ The Phonet protocol implementation for USB device.
+
 
 config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 97b6f29..f265bbb 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -26,6 +26,7 @@
 #include 
 
 #include "u_phonet.h"
+#include "u_ether.h"
 
 #define PN_MEDIA_USB   0x1B
 #define MAXPACKET  512
@@ -576,6 +577,58 @@ err:
return status;
 }
 
+static inline struct f_phonet_opts *to_f_phonet_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_phonet_opts,
+   func_inst.group);
+}
+
+CONFIGFS_ATTR_STRUCT(f_phonet_opts);
+static ssize_t f_phonet_attr_show(struct config_item *item,
+   struct configfs_attribute *attr,
+   char *page)
+{
+   struct f_phonet_opts *opts = to_f_phonet_opts(item);
+   struct f_phonet_opts_attribute *f_phonet_opts_attr =
+   container_of(attr, struct f_phonet_opts_attribute, attr);
+   ssize_t ret = 0;
+
+   if (f_phonet_opts_attr->show)
+   ret = f_phonet_opts_attr->show(opts, page);
+   return ret;
+}
+
+static void phonet_attr_release(struct config_item *item)
+{
+   struct f_phonet_opts *opts = to_f_phonet_opts(item);
+
+   usb_put_function_instance(&opts->func_inst);
+}
+
+static struct configfs_item_operations phonet_item_ops = {
+   .release= phonet_attr_release,
+   .show_attribute = f_phonet_attr_show,
+};
+
+static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+{
+   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+}
+
+static struct f_phonet_opts_attribute f_phonet_ifname =
+   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+
+static struct configfs_attribute *phonet_attrs[] = {
+   &f_phonet_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type phonet_func_type = {
+   .ct_item_ops= &phonet_item_ops,
+   .ct_attrs   = phonet_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void phonet_free_inst(struct usb_function_instance *f)
 {
struct f_phonet_opts *opts;
@@ -601,6 +654,9 @@ static struct usb_function_instance *phonet_alloc_inst(void)
if (IS_ERR(opts->net))
return ERR_PTR(PTR_ERR(opts->net));
 
+   config_group_init_type_name(&opts->func_inst.group, "",
+   &phonet_func_type);
+
return &opts->func_inst;
 }
 
-- 
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 8/9] usb/gadget: nokia: convert to new interface of f_ecm

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |   66 +++
 2 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 0760814..90149a3 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -979,6 +979,7 @@ config USB_G_NOKIA
select USB_F_ACM
select USB_F_OBEX
select USB_F_PHONET
+   select USB_F_ECM
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 084f947..0a8099a 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -22,6 +22,7 @@
 #include "u_serial.h"
 #include "u_ether.h"
 #include "u_phonet.h"
+#include "u_ecm.h"
 #include "gadget_chips.h"
 
 /* Defines */
@@ -29,20 +30,6 @@
 #define NOKIA_VERSION_NUM  0x0211
 #define NOKIA_LONG_NAME"N900 (PC-Suite Mode)"
 
-/*-*/
-
-/*
- * 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.
- */
-#define USBF_ECM_INCLUDED
-#include "f_ecm.c"
-#include "u_ether.h"
-
-/*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 USB_ETHERNET_MODULE_PARAMETERS();
@@ -99,14 +86,14 @@ MODULE_LICENSE("GPL");
 /*-*/
 static struct usb_function *f_acm_cfg1;
 static struct usb_function *f_acm_cfg2;
-static u8 host_mac[ETH_ALEN];
+static struct usb_function *f_ecm_cfg1;
+static struct usb_function *f_ecm_cfg2;
 static struct usb_function *f_obex1_cfg1;
 static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
 static struct usb_function *f_phonet_cfg1;
 static struct usb_function *f_phonet_cfg2;
-static struct eth_dev *the_dev;
 
 
 static struct usb_configuration nokia_config_500ma_driver = {
@@ -126,6 +113,7 @@ static struct usb_configuration nokia_config_100ma_driver = 
{
 };
 
 static struct usb_function_instance *fi_acm;
+static struct usb_function_instance *fi_ecm;
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
 static struct usb_function_instance *fi_phonet;
@@ -135,6 +123,7 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
struct usb_function *f_acm;
struct usb_function *f_phonet = NULL;
struct usb_function *f_obex1 = NULL;
+   struct usb_function *f_ecm;
struct usb_function *f_obex2 = NULL;
int status = 0;
int obex1_stat = 0;
@@ -165,6 +154,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_acm;
}
 
+   f_ecm = usb_get_function(fi_ecm);
+   if (IS_ERR(f_ecm)) {
+   status = PTR_ERR(f_ecm);
+   goto err_get_ecm;
+   }
+
if (!IS_ERR_OR_NULL(f_phonet)) {
phonet_stat = usb_add_function(c, f_phonet);
if (phonet_stat)
@@ -187,18 +182,20 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
if (status)
goto err_conf;
 
-   status = ecm_bind_config(c, host_mac, the_dev);
+   status = usb_add_function(c, f_ecm);
if (status) {
pr_debug("could not bind ecm config %d\n", status);
goto err_ecm;
}
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
+   f_ecm_cfg1 = f_ecm;
f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
+   f_ecm_cfg2 = f_ecm;
f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
@@ -214,6 +211,8 @@ err_conf:
usb_remove_function(c, f_obex1);
if (!phonet_stat)
usb_remove_function(c, f_phonet);
+   usb_put_function(f_ecm);
+err_get_ecm:
usb_put_function(f_acm);
 err_get_acm:
if (!IS_ERR_OR_NULL(f_obex2))
@@ -230,13 +229,6 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
-  qmult);
-   if (IS_

[PATCH v2 4/9] usb/gadget: phonet: move global dev variable to its user

2013-05-23 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_phonet.c |   20 +++-
 drivers/usb/gadget/nokia.c|   14 +-
 drivers/usb/gadget/u_phonet.h |6 +++---
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index e86763f..e79ee34 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -574,9 +574,8 @@ pn_unbind(struct usb_configuration *c, struct usb_function 
*f)
 
 /*-*/
 
-static struct net_device *dev;
-
-int __init phonet_bind_config(struct usb_configuration *c)
+int __init phonet_bind_config(struct usb_configuration *c,
+ struct net_device *dev)
 {
struct f_phonet *fp;
int err, size;
@@ -601,16 +600,16 @@ int __init phonet_bind_config(struct usb_configuration *c)
return err;
 }
 
-int __init gphonet_setup(struct usb_gadget *gadget)
+struct net_device __init *gphonet_setup(struct usb_gadget *gadget)
 {
+   struct net_device *dev;
struct phonet_port *port;
int err;
 
/* Create net device */
-   BUG_ON(dev);
dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
if (!dev)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
port = netdev_priv(dev);
spin_lock_init(&port->lock);
@@ -618,12 +617,15 @@ int __init gphonet_setup(struct usb_gadget *gadget)
SET_NETDEV_DEV(dev, &gadget->dev);
 
err = register_netdev(dev);
-   if (err)
+   if (err) {
free_netdev(dev);
-   return err;
+
+   return ERR_PTR(err);
+   }
+   return dev;
 }
 
-void gphonet_cleanup(void)
+void gphonet_cleanup(struct net_device *dev)
 {
unregister_netdev(dev);
 }
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index a69e8bf..5650ece 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -106,6 +106,8 @@ static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
 static struct eth_dev *the_dev;
+static struct net_device *phonet_dev;
+
 
 static struct usb_configuration nokia_config_500ma_driver = {
.label  = "Bus Powered",
@@ -136,7 +138,7 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
int obex1_stat = 0;
int obex2_stat = 0;
 
-   status = phonet_bind_config(c);
+   status = phonet_bind_config(c, phonet_dev);
if (status)
pr_debug("could not bind phonet config\n");
 
@@ -211,9 +213,11 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   status = gphonet_setup(cdev->gadget);
-   if (status < 0)
+   phonet_dev = gphonet_setup(cdev->gadget);
+   if (IS_ERR(phonet_dev)) {
+   status = PTR_ERR(phonet_dev);
goto err_phonet;
+   }
 
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
   qmult);
@@ -278,7 +282,7 @@ err_obex2_inst:
 err_usb:
gether_cleanup(the_dev);
 err_ether:
-   gphonet_cleanup();
+   gphonet_cleanup(phonet_dev);
 err_phonet:
return status;
 }
@@ -300,7 +304,7 @@ static int __exit nokia_unbind(struct usb_composite_dev 
*cdev)
if (!IS_ERR(fi_obex2))
usb_put_function_instance(fi_obex2);
usb_put_function_instance(fi_acm);
-   gphonet_cleanup();
+   gphonet_cleanup(phonet_dev);
 
gether_cleanup(the_dev);
 
diff --git a/drivers/usb/gadget/u_phonet.h b/drivers/usb/gadget/u_phonet.h
index 09a7525..459ee32 100644
--- a/drivers/usb/gadget/u_phonet.h
+++ b/drivers/usb/gadget/u_phonet.h
@@ -14,8 +14,8 @@
 #include 
 #include 
 
-int gphonet_setup(struct usb_gadget *gadget);
-int phonet_bind_config(struct usb_configuration *c);
-void gphonet_cleanup(void);
+struct net_device *gphonet_setup(struct usb_gadget *gadget);
+int phonet_bind_config(struct usb_configuration *c, struct net_device *dev);
+void gphonet_cleanup(struct net_device *dev);
 
 #endif /* __U_PHONET_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 5/9] usb/gadget: f_phonet: convert to new function interface with backward compatibility

2013-05-23 Thread Andrzej Pietrasiewicz
Converting f_phonet to the new function interface requires converting
the f_phonet's function code and its users.
This patch converts the f_phonet.c to the new function interface.
The file is now compiled into a separate usb_f_phonet.ko module.
The old function interface is provided by means of 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/f_phonet.c |  151 +++--
 drivers/usb/gadget/nokia.c|1 +
 drivers/usb/gadget/u_phonet.h |9 +++
 5 files changed, 161 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 66e7577..0493542 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -569,6 +569,9 @@ config USB_F_NCM
 config USB_F_ECM
tristate
 
+config USB_F_PHONET
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index ecfa7c3..f065e67 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -53,6 +53,8 @@ usb_f_ncm-y   := f_ncm.o
 obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 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 gadget drivers
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index e79ee34..547c4ad 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -473,8 +474,7 @@ static void pn_disconnect(struct usb_function *f)
 
 /*-*/
 
-static __init
-int pn_bind(struct usb_configuration *c, struct usb_function *f)
+static int pn_bind(struct usb_configuration *c, struct usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct usb_gadget *gadget = cdev->gadget;
@@ -482,6 +482,27 @@ int pn_bind(struct usb_configuration *c, struct 
usb_function *f)
struct usb_ep *ep;
int status, i;
 
+#ifndef USBF_PHONET_INCLUDED
+   struct f_phonet_opts *phonet_opts;
+
+   phonet_opts = container_of(f->fi, struct f_phonet_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 phonet_opts->bound access
+*/
+   if (!phonet_opts->bound) {
+   gphonet_set_gadget(phonet_opts->net, gadget);
+   status = gphonet_register_netdev(phonet_opts->net);
+   if (status)
+   return status;
+   phonet_opts->bound = true;
+   }
+#endif
+
/* Reserve interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
@@ -555,8 +576,10 @@ err:
return status;
 }
 
+#ifdef USBF_PHONET_INCLUDED
+
 static void
-pn_unbind(struct usb_configuration *c, struct usb_function *f)
+pn_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_phonet *fp = func_to_pn(f);
int i;
@@ -588,7 +611,7 @@ int __init phonet_bind_config(struct usb_configuration *c,
fp->dev = dev;
fp->function.name = "phonet";
fp->function.bind = pn_bind;
-   fp->function.unbind = pn_unbind;
+   fp->function.unbind = pn_old_unbind;
fp->function.set_alt = pn_set_alt;
fp->function.get_alt = pn_get_alt;
fp->function.disable = pn_disconnect;
@@ -600,7 +623,125 @@ int __init phonet_bind_config(struct usb_configuration *c,
return err;
 }
 
-struct net_device __init *gphonet_setup(struct usb_gadget *gadget)
+#else
+
+static void phonet_free_inst(struct usb_function_instance *f)
+{
+   struct f_phonet_opts *opts;
+
+   opts = container_of(f, struct f_phonet_opts, func_inst);
+   if (opts->bound)
+   gphonet_cleanup(opts->net);
+   else
+   free_netdev(opts->net);
+   kfree(opts);
+}
+
+static struct usb_function_instance *phonet_alloc_inst(void)
+{
+   struct f_phonet_opts *opts;
+
+   opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+   if (!opts)
+   return ERR_PTR(-ENOMEM);
+
+   opts->func_inst.free_func_inst = phonet_free_inst;
+   opts->net = gphonet_setup_default();
+   if (IS_ERR(opts->net))
+   return ERR_PTR(PTR_ERR(opts->net));
+
+   return &opts->func_inst;
+}
+
+static void phonet_free(struct 

[PATCH v2 1/9] usb/gadget: f_obex: use usb_gstrings_attach

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

diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 29a348a..1b61fe7 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -309,23 +309,20 @@ static int obex_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_obex   *obex = func_to_obex(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
if (!can_support_obex(c))
return -EINVAL;
 
-   if (obex_string_defs[OBEX_CTRL_IDX].id == 0) {
-   status = usb_string_ids_tab(c->cdev, obex_string_defs);
-   if (status < 0)
-   return status;
-   obex_control_intf.iInterface =
-   obex_string_defs[OBEX_CTRL_IDX].id;
-
-   status = obex_string_defs[OBEX_DATA_IDX].id;
-   obex_data_nop_intf.iInterface = status;
-   obex_data_intf.iInterface = status;
-   }
+   us = usb_gstrings_attach(cdev, obex_strings,
+ARRAY_SIZE(obex_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   obex_control_intf.iInterface = us[OBEX_CTRL_IDX].id;
+   obex_data_nop_intf.iInterface = us[OBEX_DATA_IDX].id;
+   obex_data_intf.iInterface = us[OBEX_DATA_IDX].id;
 
/* allocate instance-specific interface IDs, and patch descriptors */
 
@@ -410,7 +407,6 @@ fail:
 static void
 obex_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
-   obex_string_defs[OBEX_CTRL_IDX].id = 0;
usb_free_all_descriptors(f);
kfree(func_to_obex(f));
 }
@@ -439,7 +435,6 @@ int __init obex_bind_config(struct usb_configuration *c, u8 
port_num)
obex->port.disconnect = obex_disconnect;
 
obex->port.func.name = "obex";
-   obex->port.func.strings = obex_strings;
/* descriptors are per-instance copies */
obex->port.func.bind = obex_bind;
obex->port.func.unbind = obex_old_unbind;
@@ -549,7 +544,6 @@ static void obex_free(struct usb_function *f)
 
 static void obex_unbind(struct usb_configuration *c, struct usb_function *f)
 {
-   obex_string_defs[OBEX_CTRL_IDX].id = 0;
usb_free_all_descriptors(f);
 }
 
@@ -571,7 +565,6 @@ struct usb_function *obex_alloc(struct 
usb_function_instance *fi)
obex->port.disconnect = obex_disconnect;
 
obex->port.func.name = "obex";
-   obex->port.func.strings = obex_strings;
/* descriptors are per-instance copies */
obex->port.func.bind = obex_bind;
obex->port.func.unbind = obex_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 7/9] usb/gadget: f_phonet: remove compatibility layer

2013-05-23 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_phonet.c |   84 ++---
 drivers/usb/gadget/u_phonet.h |1 -
 2 files changed, 4 insertions(+), 81 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 547c4ad..97b6f29 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -576,55 +576,6 @@ err:
return status;
 }
 
-#ifdef USBF_PHONET_INCLUDED
-
-static void
-pn_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_phonet *fp = func_to_pn(f);
-   int i;
-
-   /* We are already disconnected */
-   if (fp->in_req)
-   usb_ep_free_request(fp->in_ep, fp->in_req);
-   for (i = 0; i < phonet_rxq_size; i++)
-   if (fp->out_reqv[i])
-   usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
-
-   usb_free_all_descriptors(f);
-   kfree(fp);
-}
-
-/*-*/
-
-int __init phonet_bind_config(struct usb_configuration *c,
- struct net_device *dev)
-{
-   struct f_phonet *fp;
-   int err, size;
-
-   size = sizeof(*fp) + (phonet_rxq_size * sizeof(struct usb_request *));
-   fp = kzalloc(size, GFP_KERNEL);
-   if (!fp)
-   return -ENOMEM;
-
-   fp->dev = dev;
-   fp->function.name = "phonet";
-   fp->function.bind = pn_bind;
-   fp->function.unbind = pn_old_unbind;
-   fp->function.set_alt = pn_set_alt;
-   fp->function.get_alt = pn_get_alt;
-   fp->function.disable = pn_disconnect;
-   spin_lock_init(&fp->rx.lock);
-
-   err = usb_add_function(c, &fp->function);
-   if (err)
-   kfree(fp);
-   return err;
-}
-
-#else
-
 static void phonet_free_inst(struct usb_function_instance *f)
 {
struct f_phonet_opts *opts;
@@ -735,38 +686,11 @@ int gphonet_register_netdev(struct net_device *net)
return status;
 }
 
-DECLARE_USB_FUNCTION_INIT(phonet, phonet_alloc_inst, phonet_alloc);
-MODULE_AUTHOR("Rémi Denis-Courmont");
-MODULE_LICENSE("GPL");
-
-#endif
-
-struct net_device *gphonet_setup(struct usb_gadget *gadget)
-{
-   struct net_device *dev;
-   struct phonet_port *port;
-   int err;
-
-   /* Create net device */
-   dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
-   if (!dev)
-   return ERR_PTR(-ENOMEM);
-
-   port = netdev_priv(dev);
-   spin_lock_init(&port->lock);
-   netif_carrier_off(dev);
-   SET_NETDEV_DEV(dev, &gadget->dev);
-
-   err = register_netdev(dev);
-   if (err) {
-   free_netdev(dev);
-
-   return ERR_PTR(err);
-   }
-   return dev;
-}
-
 void gphonet_cleanup(struct net_device *dev)
 {
unregister_netdev(dev);
 }
+
+DECLARE_USB_FUNCTION_INIT(phonet, phonet_alloc_inst, phonet_alloc);
+MODULE_AUTHOR("Rémi Denis-Courmont");
+MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/u_phonet.h b/drivers/usb/gadget/u_phonet.h
index 1ff5ad5..98ced18 100644
--- a/drivers/usb/gadget/u_phonet.h
+++ b/drivers/usb/gadget/u_phonet.h
@@ -23,7 +23,6 @@ struct f_phonet_opts {
 struct net_device *gphonet_setup_default(void);
 void gphonet_set_gadget(struct net_device *net, struct usb_gadget *g);
 int gphonet_register_netdev(struct net_device *net);
-struct net_device *gphonet_setup(struct usb_gadget *gadget);
 int phonet_bind_config(struct usb_configuration *c, struct net_device *dev);
 void gphonet_cleanup(struct net_device *dev);
 
-- 
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


Re: [PATCH 0/7 v4] ARM: at91: dt: add USBA support

2013-05-23 Thread Jean-Christophe PLAGNIOL-VILLARD
Hi Felipe,

if it's ok with you I send the patch series via at91
with the DT

Best Regards,
J.
On 18:21 Mon 20 May , Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
>   v4:
>   fix multi instance support
> 
>   v3:
>   rebase againt 3.10-rc1 + dt macro cleanup
> 
>   This patch serie finish to add the usb device support to dt for at91
>   with the usba support present on the last at91 generation since sam9g45
> 
> The following changes since commit b3f442b0eedbc20b5ce3f4a96530588d14901199:
> 
>   ARM: at91: udpate defconfigs (2013-05-17 15:05:08 +0200)
> 
> are available in the git repository at:
> 
>   git://github.com/at91linux/linux-at91.git j/for-3.11-usba
> 
> for you to fetch changes up to 910026a08e2c2205953f2507cc11f4822998989b:
> 
>   ARM: at91: sam9m10g45ek add udc DT support (2013-05-20 23:52:17 +0800)
> 
> 
> Jean-Christophe PLAGNIOL-VILLARD (7):
>   USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct 
> usba_udc
>   USB: gadget: atmel_usba: allow multi instance
>   USB: gadget: atmel_usba: add DT support
>   ARM: at91: sam9x5 add udc DT support
>   ARM: at91: sam9x5ek add udc DT support
>   ARM: at91: sam9g45 add udc DT support
>   ARM: at91: sam9m10g45ek add udc DT support
> 
>  Documentation/devicetree/bindings/usb/atmel-usb.txt |   82 
> ++
>  arch/arm/boot/dts/at91sam9g45.dtsi  |   62 
> +++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts  |5 ++
>  arch/arm/boot/dts/at91sam9x5.dtsi   |   62 
> +++
>  arch/arm/boot/dts/at91sam9x5ek.dtsi |5 ++
>  arch/arm/mach-at91/at91sam9g45.c|2 +
>  arch/arm/mach-at91/at91sam9x5.c |2 +
>  drivers/usb/gadget/Kconfig  |2 +-
>  drivers/usb/gadget/atmel_usba_udc.c |  264 
> ++-
>  drivers/usb/gadget/atmel_usba_udc.h |2 +
>  10 files changed, 407 insertions(+), 81 deletions(-)
> 
> Best Regards,
> J.
> ___
> devicetree-discuss mailing list
> devicetree-disc...@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
--
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: host: use platform_{get,set}_drvdata()

2013-05-23 Thread Jingoo Han
Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Also, unnecessary dev_set_drvdata() is removed, because the driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Jingoo Han 
---
 drivers/usb/host/ehci-grlib.c |6 ++
 drivers/usb/host/ehci-ppc-of.c|6 ++
 drivers/usb/host/ehci-xilinx-of.c |5 ++---
 drivers/usb/host/isp1760-if.c |   10 --
 drivers/usb/host/ohci-ppc-of.c|5 ++---
 drivers/usb/host/uhci-grlib.c |6 ++
 drivers/usb/host/uhci-platform.c  |2 +-
 drivers/usb/host/xhci-plat.c  |2 +-
 8 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 5d75de9..a77bd8d 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -153,9 +153,7 @@ err_irq:
 
 static int ehci_hcd_grlib_remove(struct platform_device *op)
 {
-   struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
-
-   dev_set_drvdata(&op->dev, NULL);
+   struct usb_hcd *hcd = platform_get_drvdata(op);
 
dev_dbg(&op->dev, "stopping GRLIB GRUSBHC EHCI USB Controller\n");
 
@@ -171,7 +169,7 @@ static int ehci_hcd_grlib_remove(struct platform_device *op)
 
 static void ehci_hcd_grlib_shutdown(struct platform_device *op)
 {
-   struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
+   struct usb_hcd *hcd = platform_get_drvdata(op);
 
if (hcd->driver->shutdown)
hcd->driver->shutdown(hcd);
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 56dc732..86da09c 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -180,14 +180,12 @@ err_irq:
 
 static int ehci_hcd_ppc_of_remove(struct platform_device *op)
 {
-   struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
+   struct usb_hcd *hcd = platform_get_drvdata(op);
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 
struct device_node *np;
struct resource res;
 
-   dev_set_drvdata(&op->dev, NULL);
-
dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n");
 
usb_remove_hcd(hcd);
@@ -219,7 +217,7 @@ static int ehci_hcd_ppc_of_remove(struct platform_device 
*op)
 
 static void ehci_hcd_ppc_of_shutdown(struct platform_device *op)
 {
-   struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
+   struct usb_hcd *hcd = platform_get_drvdata(op);
 
if (hcd->driver->shutdown)
hcd->driver->shutdown(hcd);
diff --git a/drivers/usb/host/ehci-xilinx-of.c 
b/drivers/usb/host/ehci-xilinx-of.c
index d845e3b..35c7f90 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -209,8 +209,7 @@ err_irq:
  */
 static int ehci_hcd_xilinx_of_remove(struct platform_device *op)
 {
-   struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
-   dev_set_drvdata(&op->dev, NULL);
+   struct usb_hcd *hcd = platform_get_drvdata(op);
 
dev_dbg(&op->dev, "stopping XILINX-OF USB Controller\n");
 
@@ -229,7 +228,7 @@ static int ehci_hcd_xilinx_of_remove(struct platform_device 
*op)
  */
 static void ehci_hcd_xilinx_of_shutdown(struct platform_device *op)
 {
-   struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
+   struct usb_hcd *hcd = platform_get_drvdata(op);
 
if (hcd->driver->shutdown)
hcd->driver->shutdown(hcd);
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index a13709e..3df49b1 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -118,7 +118,7 @@ static int of_isp1760_probe(struct platform_device *dev)
goto free_gpio;
}
 
-   dev_set_drvdata(&dev->dev, drvdata);
+   platform_set_drvdata(dev, drvdata);
return ret;
 
 free_gpio:
@@ -133,9 +133,7 @@ free_data:
 
 static int of_isp1760_remove(struct platform_device *dev)
 {
-   struct isp1760 *drvdata = dev_get_drvdata(&dev->dev);
-
-   dev_set_drvdata(&dev->dev, NULL);
+   struct isp1760 *drvdata = platform_get_drvdata(dev);
 
usb_remove_hcd(drvdata->hcd);
iounmap(drvdata->hcd->regs);
@@ -398,7 +396,7 @@ static int isp1760_plat_probe(struct platform_device *pdev)
   irqflags, -ENOENT,
   &pdev->dev, dev_name(&pdev->dev), devflags);
 
-   dev_set_drvdata(&pdev->dev, hcd);
+   platform_set_drvdata(pdev, hcd);
 
if (IS_ERR(hcd)) {
pr_warning("isp1760: Failed to register the HCD device\n");
@@ -419,7 +417,7 @@ static int isp1760_plat_remove(struct platform_device *pdev)
 {
struct resource *mem_res;
resource_size_t mem_size;
-   struct usb_hcd *hcd = dev_get_drvdata(&pdev->dev);
+   struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
usb_remove_hcd(hcd);
 
diff

[PATCH] USB: gadget: use platform_{get,set}_drvdata()

2013-05-23 Thread Jingoo Han
Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Signed-off-by: Jingoo Han 
---
 drivers/usb/gadget/fsl_qe_udc.c   |4 ++--
 drivers/usb/gadget/fusb300_udc.c  |4 ++--
 drivers/usb/gadget/m66592-udc.c   |4 ++--
 drivers/usb/gadget/mv_u3d_core.c  |2 +-
 drivers/usb/gadget/r8a66597-udc.c |4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index 9a7ee33..f3bb363 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2589,7 +2589,7 @@ static int qe_udc_probe(struct platform_device *ofdev)
if (ret)
goto err6;
 
-   dev_set_drvdata(&ofdev->dev, udc);
+   platform_set_drvdata(ofdev, udc);
dev_info(udc->dev,
"%s USB controller initialized as device\n",
(udc->soc_type == PORT_QE) ? "QE" : "CPM");
@@ -2640,7 +2640,7 @@ static int qe_udc_resume(struct platform_device *dev)
 
 static int qe_udc_remove(struct platform_device *ofdev)
 {
-   struct qe_udc *udc = dev_get_drvdata(&ofdev->dev);
+   struct qe_udc *udc = platform_get_drvdata(ofdev);
struct qe_ep *ep;
unsigned int size;
DECLARE_COMPLETION(done);
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index b8632d4..c83f3e1 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -1347,7 +1347,7 @@ static const struct usb_gadget_ops fusb300_gadget_ops = {
 
 static int __exit fusb300_remove(struct platform_device *pdev)
 {
-   struct fusb300 *fusb300 = dev_get_drvdata(&pdev->dev);
+   struct fusb300 *fusb300 = platform_get_drvdata(pdev);
 
usb_del_gadget_udc(&fusb300->gadget);
iounmap(fusb300->reg);
@@ -1416,7 +1416,7 @@ static int __init fusb300_probe(struct platform_device 
*pdev)
 
spin_lock_init(&fusb300->lock);
 
-   dev_set_drvdata(&pdev->dev, fusb300);
+   platform_set_drvdata(pdev, fusb300);
 
fusb300->gadget.ops = &fusb300_gadget_ops;
 
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 51cfe72..46ba983 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1533,7 +1533,7 @@ static const struct usb_gadget_ops m66592_gadget_ops = {
 
 static int __exit m66592_remove(struct platform_device *pdev)
 {
-   struct m66592   *m66592 = dev_get_drvdata(&pdev->dev);
+   struct m66592   *m66592 = platform_get_drvdata(pdev);
 
usb_del_gadget_udc(&m66592->gadget);
 
@@ -1602,7 +1602,7 @@ static int __init m66592_probe(struct platform_device 
*pdev)
m66592->irq_trigger = ires->flags & IRQF_TRIGGER_MASK;
 
spin_lock_init(&m66592->lock);
-   dev_set_drvdata(&pdev->dev, m66592);
+   platform_set_drvdata(pdev, m66592);
 
m66592->gadget.ops = &m66592_gadget_ops;
m66592->gadget.max_speed = USB_SPEED_HIGH;
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 751b17a..07fdb3e 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -2050,7 +2050,7 @@ static SIMPLE_DEV_PM_OPS(mv_u3d_pm_ops, mv_u3d_suspend, 
mv_u3d_resume);
 
 static void mv_u3d_shutdown(struct platform_device *dev)
 {
-   struct mv_u3d *u3d = dev_get_drvdata(&dev->dev);
+   struct mv_u3d *u3d = platform_get_drvdata(dev);
u32 tmp;
 
tmp = ioread32(&u3d->op_regs->usbcmd);
diff --git a/drivers/usb/gadget/r8a66597-udc.c 
b/drivers/usb/gadget/r8a66597-udc.c
index 7ff7d9c..51ea169 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1822,7 +1822,7 @@ static const struct usb_gadget_ops r8a66597_gadget_ops = {
 
 static int __exit r8a66597_remove(struct platform_device *pdev)
 {
-   struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev);
+   struct r8a66597 *r8a66597 = platform_get_drvdata(pdev);
 
usb_del_gadget_udc(&r8a66597->gadget);
del_timer_sync(&r8a66597->timer);
@@ -1909,7 +1909,7 @@ static int __init r8a66597_probe(struct platform_device 
*pdev)
}
 
spin_lock_init(&r8a66597->lock);
-   dev_set_drvdata(&pdev->dev, r8a66597);
+   platform_set_drvdata(pdev, r8a66597);
r8a66597->pdata = pdev->dev.platform_data;
r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;
 
-- 
1.7.10.4


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


[PATCH 0/1] USB: ehci-omap: Fixes for 3.10

2013-05-23 Thread Roger Quadros
Hi Greg,

There is one patch for 3.10 that fixes an issue with dma_mask pointer
when ehci-omap is used as a module and kernel is booted using
device tree. More details in the patch.

Roger Quadros (1):
  USB: ehci-omap: Reset dma_mask pointer on probe

 drivers/usb/host/ehci-omap.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

cheers,
-roger
-- 
1.7.4.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 1/1] USB: ehci-omap: Reset dma_mask pointer on probe

2013-05-23 Thread Roger Quadros
Device tree probed devices don't get dma_mask set. Previously
we were setting the dma_mask pointer only if it was NULL.
However, the address of 'omap_ehci_dma_mask' would change
each time the module is unloaded and loaded back thus causing
the devices dma_mask pointer to be invalid on the next load.

This will cause page faults if any driver tries to access the
old dma_mask pointer.

Unconditionally re-setting the dma_mask pointer fixes this problem.

e.g. of backtrace when mass storage device is plugged in after
ehci-omap module is unloaded and loaded back when booted with device tree.

[  646.398223] Unable to handle kernel paging request at virtual address 
bf08f678
[  646.406005] pgd = c0004000
[  646.408966] [bf08f678] *pgd=8c9ec811, *pte=, *ppte=
[  646.415649] Internal error: Oops: 7 [#1] SMP ARM
[  646.420532] Modules linked in: ehci_omap ehci_hcd snd_soc_omap 
snd_soc_omap_mcbsp snd_soc_core regmap_spi snd_compress snd_pcm snd_timer snd 
soundcore snd_page_alloc [last unloaded: ehci_hcd]
[  646.438629] CPU: 0 PID: 691 Comm: kworker/u2:2 Not tainted 
3.10.0-rc2-00047-g519fe2e #490
[  646.447265] Workqueue: events_unbound async_run_entry_fn
[  646.452880] task: ce12cb80 ti: ce194000 task.ti: ce194000
[  646.458618] PC is at scsi_calculate_bounce_limit+0x34/0x48
[  646.464385] LR is at __scsi_alloc_queue+0x80/0x108
[  646.469451] pc : []lr : []psr: a013
[  646.469451] sp : ce195c88  ip : 000c  fp : 0001
[  646.481536] r10: cca4d018  r9 : cca42808  r8 : 
[  646.487060] r7 : 012a  r6 : ce527420  r5 : ce3561b0  r4 : ce415000
[  646.493927] r3 : bf08f678  r2 : ce424cd0  r1 : 00f0  r0 : ce415000
[  646.500823] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
kernel
[  646.508544] Control: 10c5387d  Table: 8c9bc019  DAC: 0015
[  646.514587] Process kworker/u2:2 (pid: 691, stack limit = 0xce194240)
[  646.521392] Stack: (0xce195c88 to 0xce196000)
[  646.526000] 5c80:    cca42800 cca4d000 ce415000 
ffe0 c032b978
[  646.534606] 5ca0: cca42800 c032c114 ce12cb80 cca4d000  ce195d64 
 ce415000
[  646.543243] 5cc0: ce194000  c07b5574 c032c654  c008c2bc 
6093 ce194000
[  646.551879] 5ce0: ce12cb80 c04cc890 0001 ce415000 ce194000  
c07b5574 c008c2bc
[  646.560485] 5d00: 6013 cca4d0a8 0004 6013  c04cc890 
c07b5880 cca4d000
[  646.569122] 5d20:   ce415180  ce194000  
c07b5574 c032cf40
[  646.577758] 5d40:   ce195d8c  c08a8208  
0002 
[  646.586364] 5d60: ce415220    0002 ce12d010 
ce12cb80 0006
[  646.595001] 5d80: 0004 c07b932c 0006 c008c0fc  ce12cb80 
ce415180 ce194000
[  646.603637] 5da0: ce12cb80 c04cc890 0001  ce194000 ce415068 
c07b5574 c008c2bc
[  646.612243] 5dc0: 6013 0001 ce415000    
ce194000 ce415180
[  646.620880] 5de0: c07b5574 c032d400  ce415000 ce415180 ce415000 
 
[  646.629516] 5e00:  ce415180 ce415068 c032d708 cc9759c0 c00690bc 
005d ce415000
[  646.638122] 5e20: ce329940 ccae4300 ce195ec0 ccb26dd0 ccb26dc0 c032d824 
 
[  646.646759] 5e40: c07b6f1c ce329940 ccae4300 c032d9c4  c07b6f1c 
ce329940 ce03f000
[  646.655395] 5e60: ce195ec0 c0065384   6013 ce047f00 
ce03f000 ccb26dd0
[  646.664001] 5e80: ce329940 ccb26dd0 ce329940 ce03f000 ce195ec0  
ce047f00 c005842c
[  646.672637] 5ea0: 0002  c00583a0 c04ca4d4 ce12cb80 0002 
 
[  646.681274] 5ec0: c07cb97c c08a8128  c06187b0 ce03f000 ce329940 
ce03f030 ce329958
[  646.689910] 5ee0: ce194000 ce194000 c07b5208 0001 ce03f000 c0058b10 
 
[  646.698516] 5f00:  ce194000 6113 ce0a1e34  ce329940 
c00589d8 
[  646.707153] 5f20:    c005ebec ce12cb80  
0001 ce329940
[  646.715789] 5f40:   dead4ead   c07cb8f4 
 
[  646.724395] 5f60: c0615efc ce195f64 ce195f64   dead4ead 
 
[  646.733032] 5f80: c07cb8f4   c0615efc ce195f90 ce195f90 
ce195fac ce0a1e34
[  646.741668] 5fa0: c005eb48   c0013688   
 
[  646.750274] 5fc0:       
 
[  646.758911] 5fe0:     0013  
2a7fef02 00b3ff00
[  646.767547] [] (scsi_calculate_bounce_limit+0x34/0x48) from 
[] (__scsi_alloc_queue+0x80/0x108)
[  646.778472] [] (__scsi_alloc_queue+0x80/0x108) from [] 
(scsi_alloc_queue+0x10/0x60)
[  646.788391] [] (scsi_alloc_queue+0x10/0x60) from [] 
(scsi_alloc_sdev+0x170/0x270)
[  646.798126] [] (scsi_alloc_sdev+0x170/0x270) from [] 
(scsi_probe_and_add_lun+0x39c/0x948)
[  646.808593] [] (scsi_probe_and_add_lun+0x39c/0x948

Re: [PATCH 1/7] USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc

2013-05-23 Thread Nicolas Ferre

On 23/05/2013 04:23, Bo Shen :

Hi J,

On 5/21/2013 00:25, Jean-Christophe PLAGNIOL-VILLARD wrote:

so we can have multiple usb gadget instance

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
Cc: Nicolas Ferre 
Cc: linux-usb@vger.kernel.org


For this series, test OK on at91sam9m10g45ek and at91sam9x5ek board
Tested-by: Bo Shen 


After reading this v4 series, it seems good. So, on the whole series:

Acked-by: Nicolas Ferre 


PS: When do testing, we need build in or choose as module: "Device
Drivers ---> Generic Target Core Mod (TCM) and ConfigFS infrastructure"


Thanks a lot to you, Bo and Jean-Christophe.

Bye,
--
Nicolas Ferre
--
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


[RFC V6 PATCH 0/3] USB: OHCI: Start splitting up the driver

2013-05-23 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.

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.

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


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  |4 +-
 drivers/usb/host/Makefile |3 +
 drivers/usb/host/ohci-hcd.c   |  129 +-
 drivers/usb/host/ohci-hub.c   |1 -
 drivers/usb/host/ohci-pci.c   |  152 -
 drivers/usb/host/ohci-q.c |8 ++-
 drivers/usb/host/ohci.h   |   21 ++
 drivers/usb/host/pci-quirks.c |   14 
 drivers/usb/host/pci-quirks.h |3 +
 9 files changed, 189 insertions(+), 146 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


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

2013-05-23 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().

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

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9e6de95..13ebbb7 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,30 @@ 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);
+
+   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 +967,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 +1027,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 +1051,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 +1102,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
+ * individual entries can be overridden as needed.
+ */
 
+static const struct hc_driver ohci_hc_driver = {
+   .description =  hcd_name,
+   

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

2013-05-23 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 "pci_dev" argument instead  of "ohci_hcd" in sb800_prefetch()
  function to avoid extra include file in pci-quirks.c.

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

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 13ebbb7..2490b81 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"
@@ -1275,7 +1266,7 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVERohci_platform_driver
 #endif
 
-#if!defined(PCI_DRIVER) && \
+#if!defined(PCI_DRIVER) && \
!defined(PLATFORM_DRIVER) &&\
!defined(OMAP1_PLATFORM_DRIVER) &&  \
!defined(OMAP3_PLATFORM_DRIVER) &&  \
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..78e0095 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 pci_dev *pdev = to_pci_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(pdev, 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 pci_dev *pdev = to_pci_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(pdev, 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..5f01540 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -91,6 +91,18 @@ static struct amd_chipset_info {
 
 static DEFINE_SPINLOCK(amd_lock);
 
+void sb800_prefetch(struct pci_dev *pdev, int on)
+{
+   u16 misc;
+
+   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..7c5fbc1 100644
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quir

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

2013-05-23 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.

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.

Signed-off-by: Manjunath Goudar 
Cc: Arnd Bergmann 
Cc: Greg KH 
Cc: Alan Stern 
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/host/Kconfig  |4 +-
 drivers/usb/host/Makefile |3 +
 drivers/usb/host/ohci-hcd.c   |   15 -
 drivers/usb/host/ohci-pci.c   |  132 ++---
 drivers/usb/host/ohci-q.c |2 +
 drivers/usb/host/ohci.h   |4 ++
 drivers/usb/host/pci-quirks.c |2 +
 drivers/usb/host/pci-quirks.h |1 +
 8 files changed, 59 insertions(+), 104 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 64d7209..7e75387 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,7 +446,7 @@ 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"
+   tristate "OHCI support for PCI-bus USB controllers"
depends on PCI && (STB03xxx || PPC_MPC52xx || USB_OHCI_HCD_PPC_OF)
default y
select USB_OHCI_LITTLE_ENDIAN
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 2490b81..36fc3f7 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1166,11 +1166,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
@@ -1341,12 +1336,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)
@@ -1440,10 +1429,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_sa:
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index c3fa936..ea088c1 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -14,12 +14,19 @@
  * This file is licenced under the GPL.
  */
 
-#ifndef CONFIG_PCI
-#error "This file is PCI bus glue.  CONFIG_PCI must be defined."
-#endif
-
-#include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ohci.h"
+#include "pci-quirks.h"
+
+#define DRIVER_DESC "OHCI PCI platform driver"

Re: [PATCH] HID: usbhid: ignore Jabra speakerphones HID interface

2013-05-23 Thread Jiri Kosina
On Wed, 22 May 2013, Vincent Palatin wrote:

> Add a quirk to ignore Jabra speakerphone 410 and 510 devices HID
> interface.
> On those devices, the USB audio interface is working nicely,
> but the HID interface is not working with the kernel usbhid driver,
> and it requires a specific userspace program.
> We could unbind it from userspace but just attaching the usbhid driver has
> sometimes nasty effects:
> either confusing the device state machine or triggering a storm of volume key
> events making eventual sound UI blinking like crazy.
> 
> Signed-off-by: Vincent Palatin 
> ---
>  drivers/hid/hid-core.c | 2 ++
>  drivers/hid/hid-ids.h  | 4 
>  2 files changed, 6 insertions(+)
> 
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 264f550..5d2ef66 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -2042,6 +2042,8 @@ static const struct hid_device_id hid_ignore_list[] = {
>   { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
>   { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
>   { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
> + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_SPEAK_410) },
> + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_SPEAK_510) },
>   { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) 
> },
>   { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, 
> USB_DEVICE_ID_KWORLD_RADIO_FM700) },
>   { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 38535c9..533815b 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -447,6 +447,10 @@
>  #define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615
>  #define USB_DEVICE_ID_IRTOUCH_INFRARED_USB   0x0070
>  
> +#define USB_VENDOR_ID_JABRA  0x0b0e
> +#define USB_DEVICE_ID_JABRA_SPEAK_4100x0412
> +#define USB_DEVICE_ID_JABRA_SPEAK_5100x0420
> +
>  #define USB_VENDOR_ID_JESS   0x0c45
>  #define USB_DEVICE_ID_JESS_YUREX 0x1010

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs
--
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 1/2] usb: dwc3: pci: PHY should be deleted later than dwc3 core

2013-05-23 Thread Felipe Balbi
Hi,

On Tue, May 21, 2013 at 09:26:32AM +0800, Peter Chen wrote:
> On Mon, May 20, 2013 at 06:18:52PM +0300, Felipe Balbi wrote:
> > On Mon, May 20, 2013 at 10:55:57AM +0800, Peter Chen wrote:
> > > 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 
> > 
> > this needs to Cc stable. Please figure out which kernels need to have
> > this and resend with proper Cc: stable tags.
> > 
> 
> I am afraid I have not worked at dwc3 platform, I don't know
> from which kernel this fix is needed.
> 
> Maybe Paul or you can figure it out?

git blame helps there

-- 
balbi


signature.asc
Description: Digital signature


Re: Huawei 3276 with option and cdc_ncm

2013-05-23 Thread Bjørn Mork
Alexey Orishko  writes:

> Hi all,
>
> On Wed, May 22, 2013 at 10:40 PM, Bjørn Mork  wrote:
>
>> Thomas Schäfer  writes:
>>
>> > TX-counter-problem
>> > ...
>> >
>> >> This is expected as a result of the cdc_ncm <=> usbnet design.
>> > .
>> >
>> >> The buffer filling may seem strange, but Alexey has explained it several
>> >> times here on this list.  It has to do with device DMA optimizations.
>> >> Google it or search this list if you want the proper explanation.
>> >>
>> >
>> > Thank you for the explanation (again).
>> > May be the following question is also repeated.
>> > Is there a different way to count the tx bytes?  On mobile devices,
>> mostly
>> > with volume-limited contracts, this number may have a higher meaning than
>> > normal.
>>
>> Yes, I understand that.  I don't have any good answers.  You really want
>> to know the number of bytes transmitted and received by the modem. This
>> is never the same as the host counters, but the approximation is good
>> enough for most drivers. Just not for cdc_ncm (or cdc_mbim which use the
>> same logic).  If you can read the modem counters via some management
>> protocol, then that would be best. But I don't know if that is supported
>> for devices using cdc_ncm with AT command managent.
>>
>> We should probably make a better "payload" counter available for cdc_ncm
>> and cdc_mbim.  I must admit that I know next to nothing about netdev
>> counter policies.  I assume the current driver behaviour is correct (it
>> really counts the number of bytes transferred from the host to the
>> device).  Maybe you could research this a bit?  If the current behaviour
>> is considered correct, how do we add other counters to a driver?  This
>> needs to be done in a generic way.  I am pretty sure there are examples
>> of net drivers counting lots of stuff.
>>
>> Actually counting the bytes isn't hard.  It's the userspace interface
>> that needs some consideration.
>>
>>
> It is possible to count exact size of IP packets in Tx(Rx) direction, since
> we know
> size of each IP packet when we add(extract) it into(from) NTB. And it's
> possible
> to make this information available to user space application as well.

Yes, looking quickly at this I believe usbnet in general could benefit
from having ethtool stats added, including a few extra counters showing
bytes/packets before calling the minidriver rx/tx fixup functions.  This
would be useful for all minidrivers using some sort of extra framing.

> However, the main problem is that host driver statistic will never be exact
> match
> of the statistic done by mobile operator while charging you for the used
> traffic.
> They most likely are charging you for the volume over the air and it means
> additional framing from 3GPP protocol stack, which is unavailable for ncm
> driver.
> Also there might be some internal applications on mobile device which are
> generating some traffic over the air.
>
> I would rather rely on Tx/Rx values provided via AT commands by each
> vendor (if implemented) instead of using usb driver counters.

Agreed.  That is definitely much better if available.  But this doesn't
rule out the possibility of adding more driver counters as well.



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


time source unstable on usb/serial/pl2303 (globalsat br-353)

2013-05-23 Thread Philippe De Muyter
Hi all,

I have a lot of linux computers equipped with a GlobalSat Br-353 GPS receiver,
which is connected via USB (an integrated PL2303).  The GPS receiver emits
one multi-line message every second, giving position and time.  I listen
to this messages in a user program running in the highest priority,
and I have noticed that under load, the messages are not delivered to my
process every second, but often delayed, which is not great for a time source.

I looked at the sources of pl2303 and added a diagnostic message if the
beginning of a message came more than one second later than the beginning
of the previous one, and I noticed that the delay was already present
in the kernel: often even more than one second delay after the expected
beginning time.

Can you give me some advice on how to avoid that delay ?  How
can I increase the polling priority of this serial line, or how may I get
some usefull debugging about the USB polling for this serial line ?

Thanks in advance

Philippe
--
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 PATCH 2/3] USB: OHCI: Generic changes to make ohci-pci a separate driver

2013-05-23 Thread Arnd Bergmann
On Thursday 23 May 2013, Manjunath Goudar wrote:
> @@ -1275,7 +1266,7 @@ MODULE_LICENSE ("GPL");
>  #define PLATFORM_DRIVERohci_platform_driver
>  #endif
>  
> -#if!defined(PCI_DRIVER) && \
> +#if!defined(PCI_DRIVER) && \
> !defined(PLATFORM_DRIVER) &&\
> !defined(OMAP1_PLATFORM_DRIVER) &&  \
> !defined(OMAP3_PLATFORM_DRIVER) &&  \

This part didn't really belong here, otherwise the patch looks right to me.

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] build some drivers only when compile-testing

2013-05-23 Thread Ben Hutchings
On Wed, 2013-05-22 at 19:23 -0700, Greg Kroah-Hartman wrote:
> On Wed, May 22, 2013 at 11:18:46AM +0200, Jiri Slaby wrote:
> > Some drivers can be built on more platforms than they run on. This
> > causes users and distributors packaging burden when they have to
> > manually deselect some drivers from their allmodconfigs. Or sometimes
> > it is even impossible to disable the drivers without patching the
> > kernel.
> > 
> > Introduce a new config option COMPILE_TEST and make all those drivers
> > to depend on the platform they run on, or on the COMPILE_TEST option.
> > Now, when users/distributors choose COMPILE_TEST=n they will not have
> > the drivers in their allmodconfig setups, but developers still can
> > compile-test them with COMPILE_TEST=y.
> 
> I understand the urge, and it's getting hard for distros to handle these
> drivers that just don't work on other architectures, but it's really
> valuable to ensure that they build properly, for those of us that don't
> have many/any cross compilers set up.
> 
> > Now the drivers where we use this new option:
> > * PTP_1588_CLOCK_PCH: The PCH EG20T is only compatible with Intel Atom
> >   processors so it should depend on x86.
> > * FB_GEODE: Geode is 32-bit only so only enable it for X86_32.
> > * USB_CHIPIDEA_IMX: The OF_DEVICE dependency will be met on powerpc
> >   systems -- which do not actually support the hardware via that
> >   method.
> 
> This seems ripe to start to get really messy, really quickly.  Shouldn't
> "default configs" handle if this "should" be enabled for a platform or
> not, and let the rest of us just build them with no problems?

Debian aims to provide a consistent feature set across all supported
architectures so far as possible, and I would expect other distributions
to do the same.  I don't believe anyone is coordinating defconfigs
across architectures to ensure that.

Distributions may also have particular requirements from userland that a
distribution-agnostic defconfig obviously doesn't cover.  (Isn't that
why we had the discussion about 'configure for my distribution' some
months back?)

For the driver configuration, what we provide in Debian is closer to
allmodconfig, only with some attempt to exclude those useless drivers.
Dependencies like this would make it easier to do that.

> What problems is this causing you?  Are you running out of space in
> kernel packages with drivers that will never be actually used?

On most x86 systems this isn't going to be an issue.  But if packages
are built natively (as they are for most distributions) then building
useless drivers for some architecture which doesn't have fast processors
available is a waste of precious resources.

This is particularly bad where the architecture doesn't support generic
kernels that boot on a wide range of machines and therefore we must
build many times over.  These unfortunately tend to be among those with
slower processors (ARM[1], MIPS, SH, ...).  Currently, Debian's linux
package takes ~48 hours to build for armel (ARM processors without FPU)
- and that's without building many of the PCI drivers we could for those
platforms which have PCI support.  So that's a minimum of 2 days to
provide a security update across all architectures[2].

[1] I'm aware that ARM is getting better in this regard and most ARMv7
machines are likely to be supportable by a single kernel image soon.
That doesn't mean the whole problem is solved.

[2] We don't always wait for all builds before releasing/announcing an
update; for example .  But
that's no comfort for those using the slower architecture.

> > +config COMPILE_TEST
> > + bool "Compile also drivers which will not load" if EXPERT
> 
> EXPERT is getting to be the "let's hide it here" option, isn't it...

This little detail seems likely to reduce the usefulness of randconfig
as many drivers will become dependent on both EXPERT and COMPILE_TEST
being selected.

> I don't know, if no one else strongly objects, I can be convinced that
> this is needed, but so far, I don't see why it really is, or what this
> is going to help with.

Ben.

-- 
Ben Hutchings
friends: People who know you well, but like you anyway.


signature.asc
Description: This is a digitally signed message part


Re: Misbehaving device

2013-05-23 Thread Alan Stern
On Wed, 22 May 2013, Joe Julian wrote:

> Right, and I'm supposed to know that how? You're the one who's an
> expert on usb. You know how HID keyboards pass data. I'm starting
> from scratch and only have data that is sensitive. It's hard to know
> what you can share when you don't know what you have.

Sorry; it's not easy to tell what other people know beforehand.

> Since you have expectations that I'm not ready to meet can you at
> least point me to documentation on how HID keyboards are supposed to
> work? My Google foo is failing me there.

http://www.usb.org/developers/hidpage/

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 1/1] usb: host: ehci-spear: Remove redundant checks

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Sachin Kamat wrote:

> 'hcd' can never be NULL and the spear_ehci_hcd_drv_remove routine
> will never be called in_interrupt. Hence remove these checks.
> 
> Signed-off-by: Sachin Kamat 
> Cc: Viresh Kumar 
> Cc: Alan Stern 
> ---
> Compile tested on linux-next (20130522).
> ---
>  drivers/usb/host/ehci-spear.c |4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
> index f5ac4e2..1cf0adb 100644
> --- a/drivers/usb/host/ehci-spear.c
> +++ b/drivers/usb/host/ehci-spear.c
> @@ -148,10 +148,6 @@ static int spear_ehci_hcd_drv_remove(struct 
> platform_device *pdev)
>   struct usb_hcd *hcd = platform_get_drvdata(pdev);
>   struct spear_ehci *sehci = to_spear_ehci(hcd);
>  
> - if (!hcd)
> - return 0;
> - if (in_interrupt())
> - BUG();
>   usb_remove_hcd(hcd);
>  
>   if (sehci->clk)

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


[RFC PATCH v3 3/4] usb: xhci: add USB2 Link power management BESL support

2013-05-23 Thread Mathias Nyman
usb 2.0 devices with link power managment (LPM) can describe their idle link
timeouts either in BESL or HIRD format, so far xHCI has only supported HIRD but
later xHCI errata add BESL support as well

BESL timeouts need to inform exit latency changes with an evaluate
context command the same way USB 3.0 link PM code does.
The same xhci_change_max_exit_latency() function is used as with USB3
but code is pulled out from #ifdef CONFIG_PM as USB2.0 BESL LPM
funcionality does not depend on CONFIG_PM.

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-ext-caps.h |1 +
 drivers/usb/host/xhci.c  |  204 ++
 drivers/usb/host/xhci.h  |   21 
 include/linux/usb.h  |2 +
 4 files changed, 164 insertions(+), 64 deletions(-)

diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index 377f424..8d7a132 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -71,6 +71,7 @@
 
 /* USB 2.0 xHCI 1.0 hardware LMP capability - section 7.2.2.1.3.2 */
 #define XHCI_HLC   (1 << 19)
+#define XHCI_BLC   (1 << 19)
 
 /* command register values to disable interrupts and halt the HC */
 /* start/stop HC execution - do not write unless HC is halted*/
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 317bf08..d1eb393 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3805,6 +3805,56 @@ int xhci_find_raw_port_number(struct usb_hcd *hcd, int 
port1)
return raw_port;
 }
 
+/*
+ * Issue an Evaluate Context command to change the Maximum Exit Latency in the
+ * slot context.  If that succeeds, store the new MEL in the xhci_virt_device.
+ */
+static int xhci_change_max_exit_latency(struct xhci_hcd *xhci,
+   struct usb_device *udev, u16 max_exit_latency)
+{
+   struct xhci_virt_device *virt_dev;
+   struct xhci_command *command;
+   struct xhci_input_control_ctx *ctrl_ctx;
+   struct xhci_slot_ctx *slot_ctx;
+   unsigned long flags;
+   int ret;
+
+   spin_lock_irqsave(&xhci->lock, flags);
+   if (max_exit_latency == xhci->devs[udev->slot_id]->current_mel) {
+   spin_unlock_irqrestore(&xhci->lock, flags);
+   return 0;
+   }
+
+   /* Attempt to issue an Evaluate Context command to change the MEL. */
+   virt_dev = xhci->devs[udev->slot_id];
+   command = xhci->lpm_command;
+   xhci_slot_copy(xhci, command->in_ctx, virt_dev->out_ctx);
+   spin_unlock_irqrestore(&xhci->lock, flags);
+
+   ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx);
+   ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG);
+   slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx);
+   slot_ctx->dev_info2 &= cpu_to_le32(~((u32) MAX_EXIT));
+   slot_ctx->dev_info2 |= cpu_to_le32(max_exit_latency);
+
+   xhci_dbg(xhci, "Set up evaluate context for LPM MEL change.\n");
+   xhci_dbg(xhci, "Slot %u Input Context:\n", udev->slot_id);
+   xhci_dbg_ctx(xhci, command->in_ctx, 0);
+
+   /* Issue and wait for the evaluate context command. */
+   ret = xhci_configure_endpoint(xhci, udev, command,
+   true, true);
+   xhci_dbg(xhci, "Slot %u Output Context:\n", udev->slot_id);
+   xhci_dbg_ctx(xhci, virt_dev->out_ctx, 0);
+
+   if (!ret) {
+   spin_lock_irqsave(&xhci->lock, flags);
+   virt_dev->current_mel = max_exit_latency;
+   spin_unlock_irqrestore(&xhci->lock, flags);
+   }
+   return ret;
+}
+
 #ifdef CONFIG_PM_RUNTIME
 
 /* BESL to HIRD Encoding array for USB2 LPM */
@@ -3846,6 +3896,28 @@ static int xhci_calculate_hird_besl(struct xhci_hcd 
*xhci,
return besl;
 }
 
+/* Calculate BESLD, L1 timeout and HIRDM for USB2 PORTHLPMC */
+static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev)
+{
+   u32 field;
+   int l1;
+   int besld = 0;
+   int hirdm = 0;
+
+   field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
+
+   /* xHCI l1 is set in steps of 256us, xHCI 1.0 section 5.4.11.2 */
+   l1 = XHCI_L1_TIMEOUT / 256;
+
+   /* device has preferred BESLD */
+   if (field & USB_BESL_DEEP_VALID) {
+   besld = USB_GET_BESL_DEEP(field);
+   hirdm = 1;
+   }
+
+   return PORT_BESLD(besld) | PORT_L1_TIMEOUT(l1) | PORT_HIRDM(hirdm);
+}
+
 static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd,
struct usb_device *udev)
 {
@@ -3978,11 +4050,12 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 {
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
__le32 __iomem  **port_array;
-   __le32 __iomem  *pm_addr;
-   u32 temp;
+   __le32 __iomem  *pm_addr, *hlpm_addr;
+   u32 pm_val, hlpm_val, field;
unsigned intport_num;
unsigned long   flags;
-   int hird;
+  

[RFC PATCH v3 4/4] usb: add usb2 Link PM variables to sysfs and usb_device

2013-05-23 Thread Mathias Nyman
Adds abitilty to tune L1 timeout (inactivity timer for usb2 link sleep)
and BESL (best effort service latency)via sysfs.

This also adds a new usb2_lpm_parameters structure with those variables to
struct usb_device.

Signed-off-by: Mathias Nyman 
---
 Documentation/ABI/testing/sysfs-bus-usb |   27 +++
 drivers/usb/core/sysfs.c|   54 +++
 drivers/usb/host/xhci.c |6 ++-
 include/linux/usb.h |   18 ++
 4 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index f093e59..9759b8c 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -236,3 +236,30 @@ Description:
This attribute is to expose these information to user space.
The file will read "hotplug", "wired" and "not used" if the
information is available, and "unknown" otherwise.
+
+What:  /sys/bus/usb/devices/.../power/usb2_lpm_l1_timeout
+Date:  May 2013
+Contact:   Mathias Nyman 
+Description:
+   USB 2.0 devices may support hardware link power management (LPM)
+   L1 sleep state. The usb2_lpm_l1_timeout attribute allows
+   tuning the timeout for L1 inactivity timer (LPM timer), e.g.
+   needed inactivity time before host requests the device to go to 
L1 sleep.
+   Useful for power management tuning.
+   Supported values are 0 - 65535 microseconds.
+
+What:  /sys/bus/usb/devices/.../power/usb2_lpm_besl
+Date:  May 2013
+Contact:   Mathias Nyman 
+Description:
+   USB 2.0 devices that support hardware link power management 
(LPM)
+   L1 sleep state now use a best effort service latency value 
(BESL) to
+   indicate the best effort to resumption of service to the device 
after the
+   initiation of the resume event.
+   If the device does not have a preferred besl value then the 
host can select
+   one instead. This usb2_lpm_besl attribute allows to tune the 
host selected besl
+   value in order to tune power saving and service latency.
+
+   Supported values are 0 - 15.
+   More information on how besl values map to microseconds can be 
found in
+   USB 2.0 ECN Errata for Link Power Management, section 4.10)
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index aa38db4..d9284b9 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -497,8 +497,62 @@ set_usb2_hardware_lpm(struct device *dev, struct 
device_attribute *attr,
 static DEVICE_ATTR(usb2_hardware_lpm, S_IRUGO | S_IWUSR, 
show_usb2_hardware_lpm,
set_usb2_hardware_lpm);
 
+static ssize_t
+show_usb2_lpm_l1_timeout(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct usb_device *udev = to_usb_device(dev);
+   return sprintf(buf, "%d\n", udev->l1_params.timeout);
+}
+
+static ssize_t
+set_usb2_lpm_l1_timeout(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct usb_device *udev = to_usb_device(dev);
+   u16 timeout;
+
+   if (kstrtou16(buf, 0, &timeout))
+   return -EINVAL;
+
+   udev->l1_params.timeout = timeout;
+
+   return count;
+}
+
+static DEVICE_ATTR(usb2_lpm_l1_timeout, S_IRUGO | S_IWUSR,
+  show_usb2_lpm_l1_timeout, set_usb2_lpm_l1_timeout);
+
+static ssize_t
+show_usb2_lpm_besl(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct usb_device *udev = to_usb_device(dev);
+   return sprintf(buf, "%d\n", udev->l1_params.besl);
+}
+
+static ssize_t
+set_usb2_lpm_besl(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct usb_device *udev = to_usb_device(dev);
+   u8 besl;
+
+   if (kstrtou8(buf, 0, &besl) || besl > 15)
+   return -EINVAL;
+
+   udev->l1_params.besl = besl;
+
+   return count;
+}
+
+static DEVICE_ATTR(usb2_lpm_besl, S_IRUGO | S_IWUSR,
+  show_usb2_lpm_besl, set_usb2_lpm_besl);
+
 static struct attribute *usb2_hardware_lpm_attr[] = {
&dev_attr_usb2_hardware_lpm.attr,
+   &dev_attr_usb2_lpm_l1_timeout.attr,
+   &dev_attr_usb2_lpm_besl.attr,
NULL,
 };
 static struct attribute_group usb2_hardware_lpm_attr_group = {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d1eb393..ba7822f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3907,7 +3907,7 @@ static int xhci_calculate_usb2_hw_lpm_params(struct 
usb_device *udev)
field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
 
/* xHCI l1 is set in steps of 256us, xHCI

Re: [PATCH 1/1] USB: ehci-omap: Reset dma_mask pointer on probe

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Roger Quadros wrote:

> Device tree probed devices don't get dma_mask set. Previously
> we were setting the dma_mask pointer only if it was NULL.
> However, the address of 'omap_ehci_dma_mask' would change
> each time the module is unloaded and loaded back thus causing
> the devices dma_mask pointer to be invalid on the next load.
> 
> This will cause page faults if any driver tries to access the
> old dma_mask pointer.
> 
> Unconditionally re-setting the dma_mask pointer fixes this problem.

> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
> index 3d1491b..b33e306 100644
> --- a/drivers/usb/host/ehci-omap.c
> +++ b/drivers/usb/host/ehci-omap.c
> @@ -146,8 +146,7 @@ static int ehci_hcd_omap_probe(struct platform_device 
> *pdev)
>* Since shared usb code relies on it, set it here for now.
>* Once we have dma capability bindings this can go away.
>*/
> - if (!pdev->dev.dma_mask)
> - pdev->dev.dma_mask = &omap_ehci_dma_mask;
> + pdev->dev.dma_mask = &omap_ehci_dma_mask;

Is this the solution that people have agreed on?  There has been a lot 
of discussion on this topic.  In particular, there has been talk about 
fixing it in the DT core.

This particular approach doesn't seem very robust.  What if 
pdev->dev.dma_mask is already set to a different value for some good 
reason?

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] USB: host: use platform_{get,set}_drvdata()

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Jingoo Han wrote:

> Use the wrapper functions for getting and setting the driver data using
> platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
> so we can directly pass a struct platform_device.
> 
> Also, unnecessary dev_set_drvdata() is removed, because the driver core
> clears the driver data to NULL after device_release or on probe failure.

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


[RFC PATCH v3 0/4] Add usb2 link powermanagement BESL support

2013-05-23 Thread Mathias Nyman
This series adds usb2 best effort service latency (BESL) link PM support
to xHCI. BESL is an updated alternative to host initated resume delay
(HIRD) method of describing idle link timeouts.

Additionally this series fixes port capability checking
and replaces magic numbers with port register names.

Changes since v1:
-Use kstrto* and unsigned values in sysfs functions as Alan Stern suggested

Changes since v2:
- Add Documentation/ABI/testing/sysfs-bus-usb entries for new sysfs attributes
- store l1_timeout value in microseconds instead of xHCI specific values

Mathias Nyman (4):
  usb: xhci: check usb2 port capabilities before adding hw link PM
support
  usb: xhci: define port register names and use them instead of magic
numbers
  usb: xhci: add USB2 Link power management BESL support
  usb: add usb2 Link PM variables to sysfs and usb_device

 Documentation/ABI/testing/sysfs-bus-usb |   27 
 drivers/usb/core/sysfs.c|   54 +++
 drivers/usb/host/xhci-ext-caps.h|1 +
 drivers/usb/host/xhci-hub.c |   16 +--
 drivers/usb/host/xhci-mem.c |   33 -
 drivers/usb/host/xhci.c |  237 ++-
 drivers/usb/host/xhci.h |   29 
 include/linux/usb.h |   20 +++
 8 files changed, 337 insertions(+), 80 deletions(-)

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


[RFC PATCH v3 1/4] usb: xhci: check usb2 port capabilities before adding hw link PM support

2013-05-23 Thread Mathias Nyman
Hardware link powermanagement in usb2 is a per-port capability.
Previously support for hw lpm was enabled for all ports if any usb2 port 
supported it.

Now instead cache the capability values and check them for each port 
individually

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-mem.c |   33 +
 drivers/usb/host/xhci.c |   27 ++-
 drivers/usb/host/xhci.h |3 +++
 3 files changed, 58 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 965b539..5fd97d1 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1851,6 +1851,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
kfree(xhci->usb3_ports);
kfree(xhci->port_array);
kfree(xhci->rh_bw);
+   kfree(xhci->ext_caps);
 
xhci->page_size = 0;
xhci->page_shift = 0;
@@ -2038,7 +2039,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
 }
 
 static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
-   __le32 __iomem *addr, u8 major_revision)
+   __le32 __iomem *addr, u8 major_revision, int max_caps)
 {
u32 temp, port_offset, port_count;
int i;
@@ -2063,6 +2064,10 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, 
unsigned int num_ports,
/* WTF? "Valid values are ‘1’ to MaxPorts" */
return;
 
+   /* cache usb2 port capabilities */
+   if (major_revision < 0x03 && xhci->num_ext_caps < max_caps)
+   xhci->ext_caps[xhci->num_ext_caps++] = temp;
+
/* Check the host's USB2 LPM capability */
if ((xhci->hci_version == 0x96) && (major_revision != 0x03) &&
(temp & XHCI_L1C)) {
@@ -2120,10 +2125,11 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, 
unsigned int num_ports,
  */
 static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
 {
-   __le32 __iomem *addr;
-   u32 offset;
+   __le32 __iomem *addr, *tmp_addr;
+   u32 offset, tmp_offset;
unsigned int num_ports;
int i, j, port_index;
+   int cap_count = 0;
 
addr = &xhci->cap_regs->hcc_params;
offset = XHCI_HCC_EXT_CAPS(xhci_readl(xhci, addr));
@@ -2156,13 +2162,32 @@ static int xhci_setup_port_arrays(struct xhci_hcd 
*xhci, gfp_t flags)
 * See section 5.3.6 for offset calculation.
 */
addr = &xhci->cap_regs->hc_capbase + offset;
+
+   tmp_addr = addr;
+   tmp_offset = offset;
+
+   /* count extended protocol capability entries for later caching */
+   do {
+   u32 cap_id;
+   cap_id = xhci_readl(xhci, tmp_addr);
+   if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
+   cap_count++;
+   tmp_offset = XHCI_EXT_CAPS_NEXT(cap_id);
+   tmp_addr += tmp_offset;
+   } while (tmp_offset);
+
+   xhci->ext_caps = kzalloc(sizeof(*xhci->ext_caps) * cap_count, flags);
+   if (!xhci->ext_caps)
+   return -ENOMEM;
+
while (1) {
u32 cap_id;
 
cap_id = xhci_readl(xhci, addr);
if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
xhci_add_in_port(xhci, num_ports, addr,
-   (u8) XHCI_EXT_PORT_MAJOR(cap_id));
+   (u8) XHCI_EXT_PORT_MAJOR(cap_id),
+   cap_count);
offset = XHCI_EXT_CAPS_NEXT(cap_id);
if (!offset || (xhci->num_usb2_ports + xhci->num_usb3_ports)
== num_ports)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b4aa79d..e540a36 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4023,15 +4023,40 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
return 0;
 }
 
+/* check if a usb2 port supports a given extened capability protocol
+ * only USB2 ports extended protocol capability values are cached.
+ * Return 1 if capability is supported
+ */
+static int xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int port,
+  unsigned capability)
+{
+   u32 port_offset, port_count;
+   int i;
+
+   for (i = 0; i < xhci->num_ext_caps; i++) {
+   if (xhci->ext_caps[i] & capability) {
+   /* port offsets starts at 1 */
+   port_offset = XHCI_EXT_PORT_OFF(xhci->ext_caps[i]) - 1;
+   port_count = XHCI_EXT_PORT_COUNT(xhci->ext_caps[i]);
+   if (port >= port_offset &&
+   port < port_offset + port_count)
+   return 1;
+   }
+   }
+   return 0;
+}
+
 int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
 {
struct xhci_hcd *xhci = hcd_to_xhci(

[RFC PATCH v3 2/4] usb: xhci: define port register names and use them instead of magic numbers

2013-05-23 Thread Mathias Nyman
Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-hub.c |   16 +++-
 drivers/usb/host/xhci.c |4 ++--
 drivers/usb/host/xhci.h |5 +
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 187a3ec..1d35459 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -867,18 +867,18 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, 
u16 wValue,
case USB_PORT_FEAT_U1_TIMEOUT:
if (hcd->speed != HCD_USB3)
goto error;
-   temp = xhci_readl(xhci, port_array[wIndex] + 1);
+   temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC);
temp &= ~PORT_U1_TIMEOUT_MASK;
temp |= PORT_U1_TIMEOUT(timeout);
-   xhci_writel(xhci, temp, port_array[wIndex] + 1);
+   xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC);
break;
case USB_PORT_FEAT_U2_TIMEOUT:
if (hcd->speed != HCD_USB3)
goto error;
-   temp = xhci_readl(xhci, port_array[wIndex] + 1);
+   temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC);
temp &= ~PORT_U2_TIMEOUT_MASK;
temp |= PORT_U2_TIMEOUT(timeout);
-   xhci_writel(xhci, temp, port_array[wIndex] + 1);
+   xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC);
break;
default:
goto error;
@@ -1098,10 +1098,8 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
__le32 __iomem *addr;
u32 tmp;
 
-   /* Add one to the port status register address to get
-* the port power control register address.
-*/
-   addr = port_array[port_index] + 1;
+   /* Get the port power control register address. */
+   addr = port_array[port_index] + PORTPMSC;
tmp = xhci_readl(xhci, addr);
tmp |= PORT_RWE;
xhci_writel(xhci, tmp, addr);
@@ -1193,7 +1191,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
/* Add one to the port status register address to get
 * the port power control register address.
 */
-   addr = port_array[port_index] + 1;
+   addr = port_array[port_index] + PORTPMSC;
tmp = xhci_readl(xhci, addr);
tmp &= ~PORT_RWE;
xhci_writel(xhci, tmp, addr);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index e540a36..317bf08 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3901,7 +3901,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd 
*hcd,
 * Check device's USB 2.0 extension descriptor to determine whether
 * HIRD or BESL shoule be used. See USB2.0 LPM errata.
 */
-   pm_addr = port_array[port_num] + 1;
+   pm_addr = port_array[port_num] + PORTPMSC;
hird = xhci_calculate_hird_besl(xhci, udev);
temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird);
xhci_writel(xhci, temp, pm_addr);
@@ -3999,7 +3999,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 
port_array = xhci->usb2_ports;
port_num = udev->portnum - 1;
-   pm_addr = port_array[port_num] + 1;
+   pm_addr = port_array[port_num] + PORTPMSC;
temp = xhci_readl(xhci, pm_addr);
 
xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1dbc63f..b6cd55e 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -132,6 +132,11 @@ struct xhci_cap_regs {
 /* Number of registers per port */
 #defineNUM_PORT_REGS   4
 
+#define PORTSC 0
+#define PORTPMSC   1
+#define PORTLI 2
+#define PORTHLPMC  3
+
 /**
  * struct xhci_op_regs - xHCI Host Controller Operational Registers.
  * @command:   USBCMD - xHC command register
-- 
1.7.4.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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue

2013-05-23 Thread Sergei Shtylyov

Hello.

On 23-05-2013 10:01, Ravi Babu wrote:


removed unused nop xceiv (un_)register API's from all musb
platform drivers


   Since when are they unused?


Signed-off-by: Ravi Babu 


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 7/9] usb: musb: dsps: use get-usb-phy by phandle for multi instance

2013-05-23 Thread Sergei Shtylyov

On 23-05-2013 10:01, Ravi Babu wrote:


In case of mutli instance support, use get-phy object using phandle
to return to repsective phy xceiv object for each instance


   Only "respective" and s/xceiv/transceiver/.


Signed-off-by: Ravi Babu 


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: [RFC V6 PATCH 1/3] USB: OHCI: prepare to make ohci-hcd a library module

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Manjunath Goudar wrote:

> 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

This patch looks good.

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: [PATCH v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx

2013-05-23 Thread Sergei Shtylyov

On 23-05-2013 10:01, Ravi Babu wrote:


The am33xx platforms suppors dual musb instance which need two instances
of usb-phy. Add dual instance usb-phy DT bindings for am333x platform.



Signed-off-by: Ravi Babu 
---
  arch/arm/boot/dts/am33xx.dtsi |   17 +
  1 files changed, 17 insertions(+), 0 deletions(-)



diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 0957645..b0b4deb 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -322,6 +322,22 @@
status = "disabled";
};

+   phy1: usbphy-gs70@44e10620 {
+   compatible = "ti,dsps-usbphy";
+   reg = <0x44e10620 0x8
+  0x44e10648 0x4>;
+   reg-names = "phy_ctrl","phy_wkup";
+   id = <0>;
+   };
+
+   phy2: usbphy-gs70@44e10628 {
+   compatible = "ti,dsps-usbphy";
+   reg = <0x44e10628 0x8
+  0x44e10648 0x4>;


   The second register conflicts with phy1.

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: [RFC PATCH 2/3] USB: OHCI: Generic changes to make ohci-pci a separate driver

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Manjunath Goudar wrote:

> 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 "pci_dev" argument instead  of "ohci_hcd" in sb800_prefetch()
>   function to avoid extra include file in pci-quirks.c.

> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> index 13ebbb7..2490b81 100644
> --- a/drivers/usb/host/ohci-hcd.c
> +++ b/drivers/usb/host/ohci-hcd.c

> @@ -1275,7 +1266,7 @@ MODULE_LICENSE ("GPL");
>  #define PLATFORM_DRIVER  ohci_platform_driver
>  #endif
>  
> -#if  !defined(PCI_DRIVER) && \
> +#if  !defined(PCI_DRIVER) && \
>   !defined(PLATFORM_DRIVER) &&\
>   !defined(OMAP1_PLATFORM_DRIVER) &&  \
>   !defined(OMAP3_PLATFORM_DRIVER) &&  \

As Arnd mentioned, this doesn't belong here.

> diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
> index 88731b7..78e0095 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 pci_dev *pdev = to_pci_dev(ohci_to_hcd(ohci)->self.controller);

You shouldn't call to_pci_dev().  At this point you don't know if the 
controller is a PCI device or not.  Instead, just do

struct device *dev = ohci_to_hcd(ohci)->self.controller;

Then in sb800_prefetch(), where it makes sense, you can call 
to_pci_dev().

> @@ -580,6 +581,7 @@ static void td_submit_urb (
>   struct urb  *urb
>  ) {
>   struct urb_priv *urb_priv = urb->hcpriv;
> + struct pci_dev *pdev = to_pci_dev(ohci_to_hcd(ohci)->self.controller);

Same thing here.

Otherwise this is okay.

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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver

2013-05-23 Thread Alan Stern
On Thu, 23 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.
> 
> 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.

This patch has a lot of extra stuff in it.  It looks like you forgot to
undo a bunch of things from the previous version, things that are no
longer needed.

As I said before, you really need to proofread your patches before
emailing them.  Don't rely on other people to find your mistakes.

Also, you left out one thing that should still be here.  What happened 
to the part about changing

#if !defined(PCI_DRIVER) && \

to

#if !ENABLED(CONFIG_USB_OHCI_HCD_PCI) &&\

?

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 1/1] USB: ehci-omap: Reset dma_mask pointer on probe

2013-05-23 Thread Roger Quadros
On 05/23/2013 05:11 PM, Alan Stern wrote:
> On Thu, 23 May 2013, Roger Quadros wrote:
> 
>> Device tree probed devices don't get dma_mask set. Previously
>> we were setting the dma_mask pointer only if it was NULL.
>> However, the address of 'omap_ehci_dma_mask' would change
>> each time the module is unloaded and loaded back thus causing
>> the devices dma_mask pointer to be invalid on the next load.
>>
>> This will cause page faults if any driver tries to access the
>> old dma_mask pointer.
>>
>> Unconditionally re-setting the dma_mask pointer fixes this problem.
> 
>> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
>> index 3d1491b..b33e306 100644
>> --- a/drivers/usb/host/ehci-omap.c
>> +++ b/drivers/usb/host/ehci-omap.c
>> @@ -146,8 +146,7 @@ static int ehci_hcd_omap_probe(struct platform_device 
>> *pdev)
>>   * Since shared usb code relies on it, set it here for now.
>>   * Once we have dma capability bindings this can go away.
>>   */
>> -if (!pdev->dev.dma_mask)
>> -pdev->dev.dma_mask = &omap_ehci_dma_mask;
>> +pdev->dev.dma_mask = &omap_ehci_dma_mask;
> 
> Is this the solution that people have agreed on?  There has been a lot 
> of discussion on this topic.  In particular, there has been talk about 
> fixing it in the DT core.

Fixing it in DT core would be best.
> 
> This particular approach doesn't seem very robust.  What if 
> pdev->dev.dma_mask is already set to a different value for some good 
> reason?
> 

Then it breaks. But for OMAP, that situation seems unlikely.

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: time source unstable on usb/serial/pl2303 (globalsat br-353)

2013-05-23 Thread Greg Kroah-Hartman
On Thu, May 23, 2013 at 03:07:09PM +0200, Philippe De Muyter wrote:
> Hi all,
> 
> I have a lot of linux computers equipped with a GlobalSat Br-353 GPS receiver,
> which is connected via USB (an integrated PL2303).  The GPS receiver emits
> one multi-line message every second, giving position and time.  I listen
> to this messages in a user program running in the highest priority,
> and I have noticed that under load, the messages are not delivered to my
> process every second, but often delayed, which is not great for a time source.
> 
> I looked at the sources of pl2303 and added a diagnostic message if the
> beginning of a message came more than one second later than the beginning
> of the previous one, and I noticed that the delay was already present
> in the kernel: often even more than one second delay after the expected
> beginning time.

Then that implies that the device itself is holding on to the message,
right?

> Can you give me some advice on how to avoid that delay ?  How
> can I increase the polling priority of this serial line, or how may I get
> some usefull debugging about the USB polling for this serial line ?

There is no "polling" of USB serial devices (well, there is, but it's a
USB thing, and the hardware does it for us, not the software).  The
pl2303 is a _very_ cheap chip, and it might buffer the message for a
long time before it decides to send it to the USB host.

The delay might also be in the GPS device itself, it has to send serial
data to the pl2303 device, and who knows at what baud rate that is
coming in at.

USB is not something that you can rely on for very high-frequency, low
latency, timing things.  Although to be fair, second delays are quite
rare, which implies that your hardware is to blame here.

Sorry,

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


[GIT PATCH] USB fixes for 3.10-rc3

2013-05-23 Thread Greg KH
The following changes since commit f722406faae2d073cc1d01063d1123c35425939e:

  Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ 
tags/usb-3.10-rc2

for you to fetch changes up to 2a0ebf80aa95cc758d4725f74a7016e992606a39:

  USB: cxacru: potential underflow in cxacru_cm_get_array() (2013-05-20 
11:35:47 -0700)


USB fixes for 3.10-rc2

Here are a number of tiny USB bugfixes / new device ids for 3.10-rc2

The majority of these are USB gadget fixes, but they are all small.
Other than that, some USB host controller fixes, and USB serial driver
fixes for problems reported with them.

Also hopefully a fixed up USB_OTG Kconfig dependancy, that one seems to
be almost impossible to get right for all of the different platforms
these days.

Signed-off-by: Greg Kroah-Hartman 


Alan Stern (6):
  USB: xHCI: override bogus bulk wMaxPacketSize values
  USB: fix Kconfig logic for USB_UHCI_HCD
  USB: UHCI: fix for suspend of virtual HP controller
  USB: fix latency in uhci-hcd and ohci-hcd
  USB: OHCI: fix logic for scheduling isochronous URBs
  USB: remove remaining instances of USB_SUSPEND

Arnd Bergmann (1):
  USB: EHCI: remove bogus #error

Dan Carpenter (1):
  USB: cxacru: potential underflow in cxacru_cm_get_array()

Dan Williams (1):
  USB: option: add device IDs for Dell 5804 (Novatel E371) WWAN card

David Rientjes (1):
  usb, chipidea: fix link error when USB_EHCI_HCD is a module

Gomella, Andrew (NIH/NHLBI) [F] (1):
  USB: ftdi_sio: Add support for Newport CONEX motor drivers

Greg Kroah-Hartman (1):
  Merge tag 'fixes-for-v3.10-rc2' of git://git.kernel.org/.../balbi/usb 
into usb-linus

Jingoo Han (1):
  usb: gadget: s3c-hsotg: pass 'struct usb_request *' to 
usb_gadget_unmap_request()

Johan Hovold (7):
  USB: serial: add wait_until_sent operation
  USB: serial: add generic wait_until_sent implementation
  USB: ftdi_sio: clean up get_modem_status
  USB: ftdi_sio: fix chars_in_buffer overhead
  USB: io_ti: fix chars_in_buffer overhead
  USB: ti_usb_3410_5052: fix chars_in_buffer overhead
  USB: serial: clean up chars_in_buffer

Libo Chen (3):
  usb: ehci-s5p: fix memleak when fallback to pdata
  usb: isp1760-if: fix memleak when platform_get_resource fail
  usb: ohci: fix goto wrong tag in err case

Michael Grzeschik (1):
  usb: otg: mxs-phy: add missing type to usb_phy

Oliver Neukum (1):
  USB: reset resume quirk needed by a hub

Paul Bolle (1):
  usb: phy: remove CONFIG_USB_OTG_UTILS once more

Robert Jarzmik (1):
  usb: phy: Fix NULL pointer exception during usb_get_phy

Robert P. J. Day (2):
  Correct typo "supperspeed" to "superspeed".
  Add a couple kernel-doc lines to prevent warnings.

Sachin Kamat (12):
  usb: gadget: atmel_usba_udc: Remove redundant platform_set_drvdata()
  usb: gadget: bcm63xx_udc: Remove redundant platform_set_drvdata()
  usb: gadget: dummy_hcd: Remove redundant platform_set_drvdata()
  usb: gadget: f_uac2: Remove redundant platform_set_drvdata()
  usb: gadget: imx_udc: Remove redundant platform_set_drvdata()
  usb: gadget: pxa25x_udc: Remove redundant platform_set_drvdata()
  usb: gadget: s3c2410_udc: Remove redundant platform_set_drvdata()
  usb: phy: ab8500-usb: Remove redundant platform_set_drvdata()
  usb: phy: gpio-vbus-usb: Remove redundant platform_set_drvdata()
  usb: phy: mv-usb: Remove redundant platform_set_drvdata()
  usb: phy: mxs-usb: Remove redundant platform_set_drvdata()
  usb: phy: nop: Remove redundant platform_set_drvdata()

Schemmel Hans-Christoph (1):
  USB: Blacklisted Cinterion's PLxx WWAN Interface

Stephen Warren (1):
  USB: set device dma_mask without reference to global data

Teppo Kotilainen (1):
  usb: option: Add Telewell TW-LTE 4G

Vivek Gautam (1):
  usb: dwc3: Fix compilation break when building with USB_DWC3_DUAL_ROLE=y

Wei WANG (1):
  USB: usb-stor: realtek_cr: Fix compile error

Wei Yongjun (9):
  usb: gadget: zero: fix error return code in zero_bind()
  usb: musb: omap2430: add missing platform_device_put() on error in 
omap2430_probe()
  usb: musb: dsps: fix error return code in dsps_create_musb_pdev()
  usb: gadget: s3c2410_udc: fix error return code in s3c2410_udc_probe()
  usb: gadget: r8a66597-udc: fix error return code in r8a66597_probe()
  usb: gadget: m66592-udc: fix error return code in m66592_probe()
  usb: gadget: fusb300_udc: fix error return code in fusb300_probe()
  usb: gadget: dummy_hcd: fix error return code in init()
  usb: gadget: fix error return code in configfs_composite_bind()

Wolfram Sang (2):
  usb: gadget: don't check resource with devm_ioremap_resource
  usb: phy: do

Re: [GIT PATCH] USB fixes for 3.10-rc3

2013-05-23 Thread Greg KH
On Thu, May 23, 2013 at 09:14:57AM -0700, Greg KH wrote:
> The following changes since commit f722406faae2d073cc1d01063d1123c35425939e:
> 
>   Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ 
> tags/usb-3.10-rc2
> 
> for you to fetch changes up to 2a0ebf80aa95cc758d4725f74a7016e992606a39:
> 
>   USB: cxacru: potential underflow in cxacru_cm_get_array() (2013-05-20 
> 11:35:47 -0700)

Linus, you will get a merge conflict with this pull request, in one of
the USB host controller driver.  The fixup should be obvious, but if you
need me to resolve it, I can create another branch for 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 V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver

2013-05-23 Thread Arnd Bergmann
On Thursday 23 May 2013, Alan Stern wrote:
> On Thu, 23 May 2013, Manjunath Goudar wrote:

> Also, you left out one thing that should still be here.  What happened 
> to the part about changing
> 
> #if   !defined(PCI_DRIVER) && \
> 
> to
> 
> #if   !ENABLED(CONFIG_USB_OHCI_HCD_PCI) &&\
> 

This section of the driver is gone now since 86510bb248 "USB: OHCI: 
clarify Kconfig dependencies", so the change is no longer needed.

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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue

2013-05-23 Thread B, Ravi
Sergei

> Subject: Re: [PATCH v1 2/9] usb: musb: nop: remove unused 
> nop_xceiv_(un)register APIs from glue
> Hello.
> On 23-05-2013 10:01, Ravi Babu wrote:

>> removed unused nop xceiv (un_)register API's from all musb
>> platform drivers

>Since when are they unused?

Please refer to commit id 662dca54 : usb: otg: support for multiple 
transceivers by a single controller.
Usb_get_phy() is used to get the of phy used by controller, phy bindings are 
done through DT. 

>> Signed-off-by: Ravi Babu 

--
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 v1 7/9] usb: musb: dsps: use get-usb-phy by phandle for multi instance

2013-05-23 Thread B, Ravi
> Subject: Re: [PATCH v1 7/9] usb: musb: dsps: use get-usb-phy by phandle for 
> multi instance

> On 23-05-2013 10:01, Ravi Babu wrote:

>> In case of mutli instance support, use get-phy object using phandle to 
>> return to repsective phy xceiv object for each instance

>   Only "respective" and s/xceiv/transceiver/.

Ok. 

>> Signed-off-by: Ravi Babu 

--
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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx

2013-05-23 Thread B, Ravi
Sergei

>>
>> +phy1: usbphy-gs70@44e10620 {
>> +compatible = "ti,dsps-usbphy";
>> +reg = <0x44e10620 0x8
>> +   0x44e10648 0x4>;
>> +reg-names = "phy_ctrl","phy_wkup";
>> +id = <0>;
>> +};
>> +
>> +phy2: usbphy-gs70@44e10628 {
>> +compatible = "ti,dsps-usbphy";
>> +reg = <0x44e10628 0x8
>> +   0x44e10648 0x4>;

> The second register conflicts with phy1.

The two instances of phy uses common phy wakeup register.

--
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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Arnd Bergmann wrote:

> On Thursday 23 May 2013, Alan Stern wrote:
> > On Thu, 23 May 2013, Manjunath Goudar wrote:
> 
> > Also, you left out one thing that should still be here.  What happened 
> > to the part about changing
> > 
> > #if !defined(PCI_DRIVER) && \
> > 
> > to
> > 
> > #if !ENABLED(CONFIG_USB_OHCI_HCD_PCI) &&\
> > 
> 
> This section of the driver is gone now since 86510bb248 "USB: OHCI: 
> clarify Kconfig dependencies", so the change is no longer needed.

I don't know what tree you're referring to.  That commit is not present
in Greg's usb-linus or usb-next branches.  The usb-next branch is what 
I use for new development.

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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver

2013-05-23 Thread Arnd Bergmann
On Thursday 23 May 2013, Alan Stern wrote:
> > > 
> > 
> > This section of the driver is gone now since 86510bb248 "USB: OHCI: 
> > clarify Kconfig dependencies", so the change is no longer needed.
> 
> I don't know what tree you're referring to.  That commit is not present
> in Greg's usb-linus or usb-next branches.  The usb-next branch is what 
> I use for new development.

Sorry, my mistake. I had looked at a temporary tree based on linux-next,
and I thought that Greg had applied my patch and put it into usb-next,
but instead it's a patch I had sitting on the branch I used for build
testing. I have not yet submitted that one again, and I'm sure that
Manjunath doesn't have it on his machine, so your comment still applies.

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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx

2013-05-23 Thread Sergei Shtylyov

Hello.

On 05/23/2013 09:13 PM, B, Ravi wrote:




+   phy1: usbphy-gs70@44e10620 {
+   compatible = "ti,dsps-usbphy";
+   reg = <0x44e10620 0x8
+  0x44e10648 0x4>;
+   reg-names = "phy_ctrl","phy_wkup";
+   id = <0>;
+   };
+
+   phy2: usbphy-gs70@44e10628 {
+   compatible = "ti,dsps-usbphy";
+   reg = <0x44e10628 0x8
+  0x44e10648 0x4>;

The second register conflicts with phy1.

The two instances of phy uses common phy wakeup register.


That's why there is a resource conflict. Have you actually tried to 
instantiate the devices out of such tree?

This register should be declared somewhere above the PHYs I think...


--
Ravi B


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 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue

2013-05-23 Thread Sergei Shtylyov

Hello.

On 05/23/2013 09:07 PM, B, Ravi wrote:


removed unused nop xceiv (un_)register API's from all musb
platform drivers

Since when are they unused?

Please refer to commit id 662dca54 : usb: otg: support for multiple 
transceivers by a single controller.
Usb_get_phy() is used to get the of phy used by controller, phy bindings are 
done through DT.


   Why are you sure that all these platforms support DT (in all 
configurations)?
It seems to me that you're simply breaking the patched glue layers with 
this patch.

I'll let Felipe decide the fate of this patch though...




Signed-off-by: Ravi Babu 

--
Ravi B


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 2/7] USB: gadget: atmel_usba: allow multi instance

2013-05-23 Thread Felipe Balbi
On Mon, May 20, 2013 at 06:25:55PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> drop static struct usba_udc the_udc
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> Cc: Nicolas Ferre 
> Cc: linux-usb@vger.kernel.org

Acked-by: Felipe Balbi 

> ---
>  drivers/usb/gadget/atmel_usba_udc.c |   36 
> +--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
> b/drivers/usb/gadget/atmel_usba_udc.c
> index d2ffd04..eea57a3 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -27,9 +27,6 @@
>  
>  #include "atmel_usba_udc.h"
>  
> -
> -static struct usba_udc the_udc;
> -
>  #ifdef CONFIG_USB_GADGET_DEBUG_FS
>  #include 
>  #include 
> @@ -1013,16 +1010,13 @@ static void nop_release(struct device *dev)
>  
>  }
>  
> -static struct usba_udc the_udc = {
> - .gadget = {
> - .ops= &usba_udc_ops,
> - .ep_list= LIST_HEAD_INIT(the_udc.gadget.ep_list),
> - .max_speed  = USB_SPEED_HIGH,
> - .name   = "atmel_usba_udc",
> - .dev= {
> - .init_name  = "gadget",
> - .release= nop_release,
> - },
> +struct usb_gadget usba_gadget_template = {
> + .ops= &usba_udc_ops,
> + .max_speed  = USB_SPEED_HIGH,
> + .name   = "atmel_usba_udc",
> + .dev= {
> + .init_name  = "gadget",
> + .release= nop_release,
>   },
>  };
>  
> @@ -1839,10 +1833,17 @@ static int __init usba_udc_probe(struct 
> platform_device *pdev)
>   struct usba_platform_data *pdata = pdev->dev.platform_data;
>   struct resource *regs, *fifo;
>   struct clk *pclk, *hclk;
> - struct usba_udc *udc = &the_udc;
> + struct usba_udc *udc;
>   static struct usba_ep *usba_ep;
>   int irq, ret, i;
>  
> + udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL);
> + if (!udc)
> + return -ENOMEM;
> +
> + udc->gadget = usba_gadget_template;
> + INIT_LIST_HEAD(&udc->gadget.ep_list);
> +
>   regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
>   fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
>   if (!regs || !fifo || !pdata)
> @@ -1897,8 +1898,7 @@ static int __init usba_udc_probe(struct platform_device 
> *pdev)
>   goto err_alloc_ep;
>  
>   udc->usba_ep = usba_ep;
> -
> - the_udc.gadget.ep0 = &usba_ep[0].ep;
> + udc->gadget.ep0 = &usba_ep[0].ep;
>  
>   INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
>   usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
> @@ -1907,7 +1907,7 @@ static int __init usba_udc_probe(struct platform_device 
> *pdev)
>   usba_ep[0].ep.ops = &usba_ep_ops;
>   usba_ep[0].ep.name = pdata->ep[0].name;
>   usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
> - usba_ep[0].udc = &the_udc;
> + usba_ep[0].udc = udc;
>   INIT_LIST_HEAD(&usba_ep[0].queue);
>   usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
>   usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
> @@ -1924,7 +1924,7 @@ static int __init usba_udc_probe(struct platform_device 
> *pdev)
>   ep->ep.ops = &usba_ep_ops;
>   ep->ep.name = pdata->ep[i].name;
>   ep->ep.maxpacket = pdata->ep[i].fifo_size;
> - ep->udc = &the_udc;
> + ep->udc = udc;
>   INIT_LIST_HEAD(&ep->queue);
>   ep->fifo_size = pdata->ep[i].fifo_size;
>   ep->nr_banks = pdata->ep[i].nr_banks;
> -- 
> 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

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/7] USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc

2013-05-23 Thread Felipe Balbi
On Mon, May 20, 2013 at 06:25:54PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> so we can have multiple usb gadget instance
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> Cc: Nicolas Ferre 
> Cc: linux-usb@vger.kernel.org

Acked-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/7] USB: gadget: atmel_usba: add DT support

2013-05-23 Thread Felipe Balbi
On Mon, May 20, 2013 at 06:25:56PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> Allow to compile the driver all the time if AT91 enabled.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> Cc: Nicolas Ferre 
> Cc: linux-usb@vger.kernel.org

Acked-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: Digital signature


usb-storage read transfer sizes with Wireless USB HCD (HWA)

2013-05-23 Thread Thomas Pugliese
Hi, 
I am attempting to get a wireless USB mass storage device to work with 
an HWA as the host controller.  Everything works fine as long as the SCSI 
reads are smaller than 4kbytes.  When the usb-storage driver receives the 
first 16kB read, it breaks it up into 4-4kB URBs and sends it to the HWA 
host controller.  This causes problems because the max packet size of the 
bulk in endpoint on the wireless device is 3854 bytes.  It responds to the 
host poll request with 7kB of data (2x3.5kB packets) which causes a babble 
since the host was only expecting 4kB.

Is there a way to get the usb-storage driver to send the entire buffer 
down to the HCD in a single URB instead of breaking it up?  I assume it 
has something to do with the SG or DMA settings when the HCD is created 
but I'm not sure what the correct settings are.  Another option would be 
for usb-storage to take into account the max packet size when segmenting 
the requests and make sure all but the last segment are multiples of the 
max packet size.

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


Re: usb-storage read transfer sizes with Wireless USB HCD (HWA)

2013-05-23 Thread Alan Stern
On Thu, 23 May 2013, Thomas Pugliese wrote:

> Hi, 
> I am attempting to get a wireless USB mass storage device to work with 
> an HWA as the host controller.  Everything works fine as long as the SCSI 
> reads are smaller than 4kbytes.  When the usb-storage driver receives the 
> first 16kB read, it breaks it up into 4-4kB URBs and sends it to the HWA 
> host controller.  This causes problems because the max packet size of the 
> bulk in endpoint on the wireless device is 3854 bytes.  It responds to the 
> host poll request with 7kB of data (2x3.5kB packets) which causes a babble 
> since the host was only expecting 4kB.
> 
> Is there a way to get the usb-storage driver to send the entire buffer 
> down to the HCD in a single URB instead of breaking it up?  I assume it 
> has something to do with the SG or DMA settings when the HCD is created 
> but I'm not sure what the correct settings are.

You're right -- the host controller driver must support SG transfers.  
I have no idea what would be involved in adding this support to the HWA 
driver.

>  Another option would be 
> for usb-storage to take into account the max packet size when segmenting 
> the requests and make sure all but the last segment are multiples of the 
> max packet size.

usb-storage doesn't break requests up at all.  The requests are already 
segmented by the block layer, which transfers data in multiples of the 
page size (which is 4 KB).  I think you will have a very difficult time 
breaking up 4-KB units into pieces that are multiples of 3.5 KB.  The 
only solution is to use bounce buffers.

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: usb-storage read transfer sizes with Wireless USB HCD (HWA)

2013-05-23 Thread Thomas Pugliese


On Thu, 23 May 2013, Alan Stern wrote:

> On Thu, 23 May 2013, Thomas Pugliese wrote:
> 
> > Hi, 
> > I am attempting to get a wireless USB mass storage device to work with 
> > an HWA as the host controller.  Everything works fine as long as the SCSI 
> > reads are smaller than 4kbytes.  When the usb-storage driver receives the 
> > first 16kB read, it breaks it up into 4-4kB URBs and sends it to the HWA 
> > host controller.  This causes problems because the max packet size of the 
> > bulk in endpoint on the wireless device is 3854 bytes.  It responds to the 
> > host poll request with 7kB of data (2x3.5kB packets) which causes a babble 
> > since the host was only expecting 4kB.
> > 
> > Is there a way to get the usb-storage driver to send the entire buffer 
> > down to the HCD in a single URB instead of breaking it up?  I assume it 
> > has something to do with the SG or DMA settings when the HCD is created 
> > but I'm not sure what the correct settings are.
> 
> You're right -- the host controller driver must support SG transfers.  
> I have no idea what would be involved in adding this support to the HWA 
> driver.
> 
> >  Another option would be 
> > for usb-storage to take into account the max packet size when segmenting 
> > the requests and make sure all but the last segment are multiples of the 
> > max packet size.
> 
> usb-storage doesn't break requests up at all.  The requests are already 
> segmented by the block layer, which transfers data in multiples of the 
> page size (which is 4 KB).  I think you will have a very difficult time 
> breaking up 4-KB units into pieces that are multiples of 3.5 KB.  The 
> only solution is to use bounce buffers.
> 
> Alan Stern
> 
> 

Thanks Alan,
Wireless USB does allow the host to force the device to use a smaller 
packet size than it advertises in its endpoint descriptor as long as the 
size is a multiple of 512 bytes.  I can update the HWA so that it will 
impose a packet size on the device that divides evenly into 4k and submit 
a patch once is working.

Tom 
--
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 V3] usb: ehci-s5p: skip phy setup for Exynos5440 based platforms

2013-05-23 Thread Jingoo Han
From: Thomas Abraham 

Exynos5440 does not require any explict USB phy configuration. So skip
the USB phy configuration for Exynos5440 based platforms.

Signed-off-by: Thomas Abraham 
Signed-off-by: Jingoo Han 
---
Changes since v2:
- changed all occurrences of s5p_ehci->pdata->phy*.
- set s5p_ehci->pdata to NULL.

Changes since v1:
- re-based on the latest 'linux-next' tree

 drivers/usb/host/ehci-s5p.c |   20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 379037f..32ba4d5 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -101,6 +101,13 @@ static int s5p_ehci_probe(struct platform_device *pdev)
return -ENOMEM;
}
s5p_ehci = to_s5p_ehci(hcd);
+
+   if (of_device_is_compatible(pdev->dev.of_node,
+   "samsung,exynos5440-ehci")) {
+   s5p_ehci->pdata = NULL;
+   goto skip_phy;
+   }
+
phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
if (IS_ERR(phy)) {
/* Fallback to pdata */
@@ -116,6 +123,8 @@ static int s5p_ehci_probe(struct platform_device *pdev)
s5p_ehci->otg = phy->otg;
}
 
+skip_phy:
+
s5p_ehci->clk = devm_clk_get(&pdev->dev, "usbhost");
 
if (IS_ERR(s5p_ehci->clk)) {
@@ -156,7 +165,7 @@ static int s5p_ehci_probe(struct platform_device *pdev)
 
if (s5p_ehci->phy)
usb_phy_init(s5p_ehci->phy);
-   else if (s5p_ehci->pdata->phy_init)
+   else if (s5p_ehci->pdata && s5p_ehci->pdata->phy_init)
s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST);
 
ehci = hcd_to_ehci(hcd);
@@ -178,7 +187,7 @@ static int s5p_ehci_probe(struct platform_device *pdev)
 fail_add_hcd:
if (s5p_ehci->phy)
usb_phy_shutdown(s5p_ehci->phy);
-   else if (s5p_ehci->pdata->phy_exit)
+   else if (s5p_ehci->pdata && s5p_ehci->pdata->phy_exit)
s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
 fail_io:
clk_disable_unprepare(s5p_ehci->clk);
@@ -199,7 +208,7 @@ static int s5p_ehci_remove(struct platform_device *pdev)
 
if (s5p_ehci->phy)
usb_phy_shutdown(s5p_ehci->phy);
-   else if (s5p_ehci->pdata->phy_exit)
+   else if (s5p_ehci->pdata && s5p_ehci->pdata->phy_exit)
s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
 
clk_disable_unprepare(s5p_ehci->clk);
@@ -234,7 +243,7 @@ static int s5p_ehci_suspend(struct device *dev)
 
if (s5p_ehci->phy)
usb_phy_shutdown(s5p_ehci->phy);
-   else if (s5p_ehci->pdata->phy_exit)
+   else if (s5p_ehci->pdata && s5p_ehci->pdata->phy_exit)
s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
 
clk_disable_unprepare(s5p_ehci->clk);
@@ -255,7 +264,7 @@ static int s5p_ehci_resume(struct device *dev)
 
if (s5p_ehci->phy)
usb_phy_init(s5p_ehci->phy);
-   else if (s5p_ehci->pdata->phy_init)
+   else if (s5p_ehci->pdata && s5p_ehci->pdata->phy_init)
s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST);
 
/* DMA burst Enable */
@@ -277,6 +286,7 @@ static const struct dev_pm_ops s5p_ehci_pm_ops = {
 #ifdef CONFIG_OF
 static const struct of_device_id exynos_ehci_match[] = {
{ .compatible = "samsung,exynos4210-ehci" },
+   { .compatible = "samsung,exynos5440-ehci" },
{},
 };
 MODULE_DEVICE_TABLE(of, exynos_ehci_match);
-- 
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] build some drivers only when compile-testing

2013-05-23 Thread Rob Landley

On 05/23/2013 09:01:40 AM, Ben Hutchings wrote:

On Wed, 2013-05-22 at 19:23 -0700, Greg Kroah-Hartman wrote:
> On Wed, May 22, 2013 at 11:18:46AM +0200, Jiri Slaby wrote:
> > Some drivers can be built on more platforms than they run on. This
> > causes users and distributors packaging burden when they have to
> > manually deselect some drivers from their allmodconfigs. Or  
sometimes

> > it is even impossible to disable the drivers without patching the
> > kernel.
> >
> > Introduce a new config option COMPILE_TEST and make all those  
drivers
> > to depend on the platform they run on, or on the COMPILE_TEST  
option.
> > Now, when users/distributors choose COMPILE_TEST=n they will not  
have

> > the drivers in their allmodconfig setups, but developers still can
> > compile-test them with COMPILE_TEST=y.
>
> I understand the urge, and it's getting hard for distros to handle  
these

> drivers that just don't work on other architectures, but it's really
> valuable to ensure that they build properly, for those of us that  
don't

> have many/any cross compilers set up.


In http://landley.net/aboriginal/bin grab the cross-compiler-*.tar.bz2  
tarballs, extract them, add the "bin" subdirectory of each to the  
$PATH. Congratulations, you have cross compilers set up. (They're  
statically linked and relocatable, so should run just about anywhere.  
If they don't, let me know and I'll fix it.)


Example build:

  make ARCH=sparc sparc32_defconfig
  PATH=/home/landley/simple-cross-compiler-sparc/bin:$PATH \
make ARCH=sparc CROSS_COMPILE=sparc-

Rob--
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 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx

2013-05-23 Thread B, Ravi
Subject: Re: [PATCH v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx

Hello.

On 05/23/2013 09:13 PM, B, Ravi wrote:

>
>>> +   phy1: usbphy-gs70@44e10620 {
>>> +   compatible = "ti,dsps-usbphy";
>>> +   reg = <0x44e10620 0x8
>>> +  0x44e10648 0x4>;
>>> +   reg-names = "phy_ctrl","phy_wkup";
>>> +   id = <0>;
>>> +   };
>>> +
>>> +   phy2: usbphy-gs70@44e10628 {
>>> +   compatible = "ti,dsps-usbphy";
>>> +   reg = <0x44e10628 0x8
>>> +  0x44e10648 0x4>;
>> The second register conflicts with phy1.
> The two instances of phy uses common phy wakeup register.

>> That's why there is a resource conflict. Have you actually tried to 
>> instantiate the devices out of such tree?
>>This register should be declared somewhere above the PHYs I think...

I did not face any problem with this, I have tested both instances of phy used 
by dual instance controller, worked fine. 
What do you suggest, in case of common register which both phy have to use this 
for wakeup functionality.  
The DT should support this.  What do you suggest in such case?

--
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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue

2013-05-23 Thread B, Ravi

Subject: Re: [PATCH v1 2/9] usb: musb: nop: remove unused 
nop_xceiv_(un)register APIs from glue

Hello.

On 05/23/2013 09:07 PM, B, Ravi wrote:

>>> removed unused nop xceiv (un_)register API's from all musb platform 
>>> drivers
>> Since when are they unused?
> Please refer to commit id 662dca54 : usb: otg: support for multiple 
> transceivers by a single controller.
> Usb_get_phy() is used to get the of phy used by controller, phy bindings are 
> done through DT.

>Why are you sure that all these platforms support DT (in all 
> configurations)?
> It seems to me that you're simply breaking the patched glue layers with this 
> patch.
> I'll let Felipe decide the fate of this patch though...

You are correct, the bindings of phy and controller need not to done through DT 
alone, there is a saperate API
Phy API's available for such bindings done in respective board platform files. 

>
>>> Signed-off-by: Ravi Babu 
> --
> Ravi B

WBR, Sergei

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


[PATCH v2 1/2] usb: dwc3: pci: PHY should be deleted later than dwc3 core

2013-05-23 Thread 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: sta...@kernel.org
---
Changes for v2:
- Add Cc: sta...@kernel.org [Needed after e3ec3eb7]

 drivers/usb/dwc3/dwc3-pci.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

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.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 2/2] usb: dwc3: exynos: PHY should be deleted later than dwc3 core

2013-05-23 Thread 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: sta...@kernel.org
---
Changes for v2:
- Add Cc: sta...@kernel.org [Needed after d720f057]

 drivers/usb/dwc3/dwc3-exynos.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index a8afe6e..df6bd5c 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.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 2/2] usb: dwc3: exynos: PHY should be deleted later than dwc3 core

2013-05-23 Thread 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: sta...@vger.kernel.org
---
Changes for v2:
- Add Cc: Cc: sta...@vger.kernel.org [Needed after d720f057]

 drivers/usb/dwc3/dwc3-exynos.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index a8afe6e..df6bd5c 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.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 1/2] usb: dwc3: pci: PHY should be deleted later than dwc3 core

2013-05-23 Thread 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: sta...@vger.kernel.org
---
Changes for v2:
- Add Cc: sta...@vger.kernel.org [Needed after e3ec3eb7]

 drivers/usb/dwc3/dwc3-pci.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

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