Re: [PATCH 0/2] HID: usbhid: fix Elan touchscreen disconnects

2014-09-08 Thread Jiri Kosina
On Fri, 5 Sep 2014, Johan Hovold wrote:

> Here's the always-poll quirk that is needed to prevent the Elan
> touchscreen from disconnecting itself from the bus.
> 
> These patches are against v3.16.1, but applies fine to hid-next.
> 
> Note that this series is not dependent on the device-qualifier quirk
> [1], which is needed to get the same device to enumerate reliably, so
> these two quirks could in through the USB and HID tree, respectively.

Thanks for respinning this patchset. I have queued it for 3.18.

Oliver, could you please send me your patch for 0x093a / 0x2510 so that I 
could apply it on top of this?

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: usb_acpi_set_power_state() and usb_queue_reset_device()

2014-09-08 Thread Oliver Neukum
On Fri, 2014-09-05 at 10:15 -0400, Alan Stern wrote:
> On Fri, 5 Sep 2014, Oliver Neukum wrote:
> 
> > Hi,
> > 
> > looking at your patch for resetting HID devices
> > it occurred to me that there's a race between
> > a queued reset and a port power switch. Switching
> > a port's power state implies to a reset for for
> > all interfaces of the device connected to that port.
> > 
> > As a reset is quite disruptive it seems to me that
> > no calling off a queued reset is a bug.
> > What do you think?
> 
> There shouldn't be a race.  We never power-off a port unless the
> attached device is already runtime suspended.  A runtime-suspended
> device shouldn't have any pending resets.

Well, it shouldn't, yet I see no way we are enforcing that rule.
Actually your patch for usbhid make me think about what happens
if the device is closed. AFAICT the reset is not cancelled.
But closing will drop the pm count.

> And even if there is a pending reset, all that will happen is the reset 
> will cause the port to power up again, and then the reset will occur.

If and only if the port is still unpowered.

> If you think it would help, the runtime suspend code could be changed
> to prevent suspends if any queued resets are pending.

If error handling requires a reset, there's no special likelihood that
suspend will clear up the issue. It is specific to port power off.

Regards
Oliver



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


[PATCH RESEND v7 2/2] usb: gadget: f_fs: virtual endpoint address mapping

2014-09-08 Thread Robert Baldyga
This patch introduces virtual endpoint address mapping. It separates
function logic form physical endpoint addresses making it more hardware
independent.

Following modifications changes user space API, so to enable them user
have to switch on the FUNCTIONFS_VIRTUAL_ADDR flag in descriptors.

Endpoints are now refered using virtual endpoint addresses chosen by
user in endpoint descpriptors. This applies to each context when endpoint
address can be used:
- when accessing endpoint files in FunctionFS filesystemi (in file name),
- in setup requests directed to specific endpoint (in wIndex field),
- in descriptors returned by FUNCTIONFS_ENDPOINT_DESC ioctl.

In endpoint file names the endpoint address number is formatted as
double-digit hexadecimal value ("ep%02x") which has few advantages -
it is easy to parse, allows to easly recognize endpoint direction basing
on its name (IN endpoint number starts with digit 8, and OUT with 0)
which can be useful for debugging purpose, and it makes easier to introduce
further features allowing to use each endpoint number in both directions
to have more endpoints available for function if hardware supports this
(for example we could have ep01 which is endpoint 1 with OUT direction,
and ep81 which is endpoint 1 with IN direction).

Physical endpoint address can be still obtained using ioctl named
FUNCTIONFS_ENDPOINT_REVMAP, but now it's not neccesary to handle
USB transactions properly.

Signed-off-by: Robert Baldyga 
Acked-by: Michal Nazarewicz 
---
 drivers/usb/gadget/function/f_fs.c  | 23 +--
 drivers/usb/gadget/function/u_fs.h  |  2 ++
 include/uapi/linux/usb/functionfs.h |  1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index 6405e0f..071683d 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1551,7 +1551,10 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
epfile->ffs = ffs;
mutex_init(&epfile->mutex);
init_waitqueue_head(&epfile->wait);
-   sprintf(epfiles->name, "ep%u",  i);
+   if (ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
+   sprintf(epfiles->name, "ep%02x", ffs->eps_addrmap[i]);
+   else
+   sprintf(epfiles->name, "ep%u", i);
if (!unlikely(ffs_sb_create_file(ffs->sb, epfiles->name, epfile,
 &ffs_epfile_operations,
 &epfile->dentry))) {
@@ -2090,10 +2093,12 @@ static int __ffs_data_got_descs(struct ffs_data *ffs,
break;
case FUNCTIONFS_DESCRIPTORS_MAGIC_V2:
flags = get_unaligned_le32(data + 8);
+   ffs->user_flags = flags;
if (flags & ~(FUNCTIONFS_HAS_FS_DESC |
  FUNCTIONFS_HAS_HS_DESC |
  FUNCTIONFS_HAS_SS_DESC |
- FUNCTIONFS_HAS_MS_OS_DESC)) {
+ FUNCTIONFS_HAS_MS_OS_DESC |
+ FUNCTIONFS_VIRTUAL_ADDR)) {
ret = -ENOSYS;
goto error;
}
@@ -2420,7 +2425,13 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type 
type, u8 *valuep,
} else {
struct usb_request *req;
struct usb_ep *ep;
+   u8 bEndpointAddress;
 
+   /*
+* We back up bEndpointAddress because autoconfig overwrites
+* it with physical endpoint address.
+*/
+   bEndpointAddress = ds->bEndpointAddress;
pr_vdebug("autoconfig\n");
ep = usb_ep_autoconfig(func->gadget, ds);
if (unlikely(!ep))
@@ -2435,6 +2446,12 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type 
type, u8 *valuep,
ffs_ep->req = req;
func->eps_revmap[ds->bEndpointAddress &
 USB_ENDPOINT_NUMBER_MASK] = idx + 1;
+   /*
+* If we use virtual address mapping, we restore
+* original bEndpointAddress value.
+*/
+   if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
+   ds->bEndpointAddress = bEndpointAddress;
}
ffs_dump_mem(": Rewritten ep desc", ds, ds->bLength);
 
@@ -2879,6 +2896,8 @@ static int ffs_func_setup(struct usb_function *f,
ret = ffs_func_revmap_ep(func, le16_to_cpu(creq->wIndex));
if (unlikely(ret < 0))
return ret;
+   if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
+   ret = func->ffs->eps_addrmap[ret];
break;
 
default:
diff --git a/drivers/usb/gadget/function/u_fs.h 
b/drivers/usb/gadget/function/u_fs.h
index 63d6e

[PATCH RESEND v7 1/2] usb: gadget: f_fs: add ioctl returning ep descriptor

2014-09-08 Thread Robert Baldyga
This patch introduces ioctl named FUNCTIONFS_ENDPOINT_DESC, which
returns endpoint descriptor to userspace. It works only if function
is active.

Signed-off-by: Robert Baldyga 
Acked-by: Michal Nazarewicz 
---
 drivers/usb/gadget/function/f_fs.c  | 23 +++
 include/uapi/linux/usb/functionfs.h |  6 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index dc30adf..6405e0f 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1026,6 +1026,29 @@ static long ffs_epfile_ioctl(struct file *file, unsigned 
code,
case FUNCTIONFS_ENDPOINT_REVMAP:
ret = epfile->ep->num;
break;
+   case FUNCTIONFS_ENDPOINT_DESC:
+   {
+   int desc_idx;
+   struct usb_endpoint_descriptor *desc;
+
+   switch (epfile->ffs->gadget->speed) {
+   case USB_SPEED_SUPER:
+   desc_idx = 2;
+   break;
+   case USB_SPEED_HIGH:
+   desc_idx = 1;
+   break;
+   default:
+   desc_idx = 0;
+   }
+   desc = epfile->ep->descs[desc_idx];
+
+   spin_unlock_irq(&epfile->ffs->eps_lock);
+   ret = copy_to_user((void *)value, desc, sizeof(*desc));
+   if (ret)
+   ret = -EFAULT;
+   return ret;
+   }
default:
ret = -ENOTTY;
}
diff --git a/include/uapi/linux/usb/functionfs.h 
b/include/uapi/linux/usb/functionfs.h
index 6d2a16b..7c7a2fe 100644
--- a/include/uapi/linux/usb/functionfs.h
+++ b/include/uapi/linux/usb/functionfs.h
@@ -275,6 +275,12 @@ struct usb_functionfs_event {
  */
 #defineFUNCTIONFS_ENDPOINT_REVMAP  _IO('g', 129)
 
+/*
+ * Returns endpoint descriptor. If function is not active returns -ENODEV.
+ */
+#defineFUNCTIONFS_ENDPOINT_DESC_IOR('g', 130, \
+struct usb_endpoint_descriptor)
+
 
 
 #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
-- 
1.9.1

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


[PATCH RESEND v7 0/2] usb: gadget: f_fs: userspace API fixes and improvements

2014-09-08 Thread Robert Baldyga
Hi Felipe,

I have rebased this patchset at your testing/next/ branch.

Best regards
Robert Baldyga

Robert Baldyga (2):
  usb: gadget: f_fs: add ioctl returning ep descriptor
  usb: gadget: f_fs: virtual endpoint address mapping

 drivers/usb/gadget/function/f_fs.c  | 46 +++--
 drivers/usb/gadget/function/u_fs.h  |  2 ++
 include/uapi/linux/usb/functionfs.h |  7 ++
 3 files changed, 53 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH 1/9] usb: gadget: f_uvc: Store EP0 control request state during setup stage

2014-09-08 Thread Laurent Pinchart
To handle class requests received on ep0, the driver needs to access the
length and direction of the request after the setup stage. It currently
stores them in a v4l2 event during the setup stage, and then copies them
from the event structure to the driver internal state structure when the
event is dequeued.

This two-steps approach isn't necessary. Simplify the driver by storing
the needed information in the driver internal state structure directly
during the setup stage.

Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uvc.c|  6 ++
 drivers/usb/gadget/function/uvc_v4l2.c | 19 +--
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index ff4340a..e9d625b 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -251,6 +251,12 @@ uvc_function_setup(struct usb_function *f, const struct 
usb_ctrlrequest *ctrl)
if (le16_to_cpu(ctrl->wLength) > UVC_MAX_REQUEST_SIZE)
return -EINVAL;
 
+   /* Tell the complete callback to generate an event for the next request
+* that will be enqueued by UVCIOC_SEND_RESPONSE.
+*/
+   uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN);
+   uvc->event_length = le16_to_cpu(ctrl->wLength);
+
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_SETUP;
memcpy(&uvc_event->req, ctrl, sizeof(uvc_event->req));
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c 
b/drivers/usb/gadget/function/uvc_v4l2.c
index bcd71ce..f22b878 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -271,25 +271,8 @@ uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, 
void *arg)
 
/* Events */
case VIDIOC_DQEVENT:
-   {
-   struct v4l2_event *event = arg;
-
-   ret = v4l2_event_dequeue(&handle->vfh, event,
+   return v4l2_event_dequeue(&handle->vfh, arg,
 file->f_flags & O_NONBLOCK);
-   if (ret == 0 && event->type == UVC_EVENT_SETUP) {
-   struct uvc_event *uvc_event = (void *)&event->u.data;
-
-   /* Tell the complete callback to generate an event for
-* the next request that will be enqueued by
-* uvc_event_write.
-*/
-   uvc->event_setup_out =
-   !(uvc_event->req.bRequestType & USB_DIR_IN);
-   uvc->event_length = uvc_event->req.wLength;
-   }
-
-   return ret;
-   }
 
case VIDIOC_SUBSCRIBE_EVENT:
{
-- 
1.8.5.5

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


[PATCH v2 0/9] UVC gadget patches for v3.18 (part 2)

2014-09-08 Thread Laurent Pinchart
Hi Felipe,

These patches have previously been posted to linux-usb as part of the
following series.

[PATCH 0/2] Move UVC gagdet to video_ioctl2
[PATCH 0/7] g_webcam: Preparation for configfs

I've rebased them on top of your master branches. The result has been
successfully tested by Andrzej Pietrasiewicz.

Could you please apply them to your tree for v3.18 ?

Andrzej Pietrasiewicz (7):
  usb: gadget: uvc: move module parameters from f_uvc
  usb: gadget: uvc: rename functions to avoid conflicts with host uvc
  usb: gadget: uvc: separately compile some components of f_uvc
  usb: gadget: f_uvc: convert f_uvc to new function interface
  usb: gadget: webcam: convert webcam to new interface of f_uvc
  usb: gadget: f_uvc: remove compatibility layer
  usb: gadget: f_uvc: use usb_gstrings_attach

Laurent Pinchart (2):
  usb: gadget: f_uvc: Store EP0 control request state during setup stage
  usb: gadget: f_uvc: Move to video_ioctl2

 MAINTAINERS |   2 +-
 drivers/usb/gadget/Kconfig  |   3 +
 drivers/usb/gadget/function/Makefile|   2 +
 drivers/usb/gadget/function/f_uvc.c | 262 -
 drivers/usb/gadget/function/f_uvc.h |  13 +-
 drivers/usb/gadget/function/u_uvc.h |  39 
 drivers/usb/gadget/function/uvc.h   |   1 +
 drivers/usb/gadget/function/uvc_queue.c |  44 ++---
 drivers/usb/gadget/function/uvc_queue.h |  33 
 drivers/usb/gadget/function/uvc_v4l2.c  | 327 
 drivers/usb/gadget/function/uvc_v4l2.h  |  22 +++
 drivers/usb/gadget/function/uvc_video.c |  38 ++--
 drivers/usb/gadget/function/uvc_video.h |  24 +++
 drivers/usb/gadget/legacy/Kconfig   |   1 +
 drivers/usb/gadget/legacy/webcam.c  |  75 ++--
 15 files changed, 511 insertions(+), 375 deletions(-)
 create mode 100644 drivers/usb/gadget/function/u_uvc.h
 create mode 100644 drivers/usb/gadget/function/uvc_v4l2.h
 create mode 100644 drivers/usb/gadget/function/uvc_video.h

-- 
Regards,

Laurent Pinchart

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


[PATCH 5/9] usb: gadget: uvc: separately compile some components of f_uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Compile uvc_queue, uvc_v4l2, uvc_video separately so that later they can
be all combined in a separately compiled f_uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Make uvc_v4l2_ioctl_ops non-static]
[Rename __UVC__V4L2__H__ and __UVC__VIDEO__H__]
[Update MAINTAINERS]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 MAINTAINERS |  2 +-
 drivers/usb/gadget/function/f_uvc.c |  2 ++
 drivers/usb/gadget/function/f_uvc.h |  8 +++
 drivers/usb/gadget/function/uvc.h   |  1 +
 drivers/usb/gadget/function/uvc_queue.c | 39 ++---
 drivers/usb/gadget/function/uvc_queue.h | 33 
 drivers/usb/gadget/function/uvc_v4l2.c  |  6 +++--
 drivers/usb/gadget/function/uvc_v4l2.h  | 22 +++
 drivers/usb/gadget/function/uvc_video.c | 10 -
 drivers/usb/gadget/function/uvc_video.h | 24 
 drivers/usb/gadget/legacy/Makefile  |  2 +-
 drivers/usb/gadget/legacy/webcam.c  |  6 +
 12 files changed, 118 insertions(+), 37 deletions(-)
 create mode 100644 drivers/usb/gadget/function/uvc_v4l2.h
 create mode 100644 drivers/usb/gadget/function/uvc_video.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1ff06de..228703b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9655,7 +9655,7 @@ USB WEBCAM GADGET
 M: Laurent Pinchart 
 L: linux-usb@vger.kernel.org
 S: Maintained
-F: drivers/usb/gadget/function/*uvc*.c
+F: drivers/usb/gadget/function/*uvc*
 F: drivers/usb/gadget/legacy/webcam.c
 
 USB WIRELESS RNDIS DRIVER (rndis_wlan)
diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index ae5bcb4..825080d 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -27,6 +27,8 @@
 #include 
 
 #include "uvc.h"
+#include "uvc_v4l2.h"
+#include "uvc_video.h"
 
 unsigned int uvc_gadget_trace_param;
 static unsigned int streaming_interval;
diff --git a/drivers/usb/gadget/function/f_uvc.h 
b/drivers/usb/gadget/function/f_uvc.h
index 74b9602..71b38dd 100644
--- a/drivers/usb/gadget/function/f_uvc.h
+++ b/drivers/usb/gadget/function/f_uvc.h
@@ -16,6 +16,14 @@
 #include 
 #include 
 
+#include "uvc.h"
+
+void uvc_function_setup_continue(struct uvc_device *uvc);
+
+void uvc_function_connect(struct uvc_device *uvc);
+
+void uvc_function_disconnect(struct uvc_device *uvc);
+
 int uvc_bind_config(struct usb_configuration *c,
const struct uvc_descriptor_header * const *fs_control,
const struct uvc_descriptor_header * const *hs_control,
diff --git a/drivers/usb/gadget/function/uvc.h 
b/drivers/usb/gadget/function/uvc.h
index 0a283b1..f67695c 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -53,6 +53,7 @@ struct uvc_event
 #ifdef __KERNEL__
 
 #include  /* For usb_endpoint_* */
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/usb/gadget/function/uvc_queue.c 
b/drivers/usb/gadget/function/uvc_queue.c
index 1e1bc73..8ea8b3b 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -126,8 +126,7 @@ static struct vb2_ops uvc_queue_qops = {
.wait_finish = uvc_wait_finish,
 };
 
-static int uvcg_queue_init(struct uvc_video_queue *queue,
-  enum v4l2_buf_type type)
+int uvcg_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
 {
int ret;
 
@@ -154,7 +153,7 @@ static int uvcg_queue_init(struct uvc_video_queue *queue,
 /*
  * Free the video buffers.
  */
-static void uvcg_free_buffers(struct uvc_video_queue *queue)
+void uvcg_free_buffers(struct uvc_video_queue *queue)
 {
mutex_lock(&queue->mutex);
vb2_queue_release(&queue->queue);
@@ -164,7 +163,7 @@ static void uvcg_free_buffers(struct uvc_video_queue *queue)
 /*
  * Allocate the video buffers.
  */
-static int uvcg_alloc_buffers(struct uvc_video_queue *queue,
+int uvcg_alloc_buffers(struct uvc_video_queue *queue,
  struct v4l2_requestbuffers *rb)
 {
int ret;
@@ -176,8 +175,7 @@ static int uvcg_alloc_buffers(struct uvc_video_queue *queue,
return ret ? ret : rb->count;
 }
 
-static int uvcg_query_buffer(struct uvc_video_queue *queue,
-struct v4l2_buffer *buf)
+int uvcg_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
int ret;
 
@@ -188,8 +186,7 @@ static int uvcg_query_buffer(struct uvc_video_queue *queue,
return ret;
 }
 
-static int uvcg_queue_buffer(struct uvc_video_queue *queue,
-struct v4l2_buffer *buf)
+int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
unsigned long flags;
int ret;
@@ -213,8 +210,8 @@ done:
  * Dequeue a video buffer. If nonblocking is false, block until a buffer is
  * available.
  */
-static in

[PATCH 9/9] usb: gadget: f_uvc: use usb_gstrings_attach

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Attach strings to gadget with usb_strings_attach.
It is required for correct instantiation of functions more than once:
instead of modifying the local uvc_en_us_strings a function instance
specific copy is created with usb_gstrings_attach.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/function/f_uvc.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 1eff416..95dc1c6 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -562,6 +562,7 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct uvc_device *uvc = to_uvc(f);
+   struct usb_string *us;
unsigned int max_packet_mult;
unsigned int max_packet_size;
struct usb_ep *ep;
@@ -637,22 +638,17 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address;
uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address;
 
-   /* String descriptors are global, we only need to allocate string IDs
-* for the first UVC function. UVC functions beyond the first (if any)
-* will reuse the same IDs.
-*/
-   if (uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id == 0) {
-   ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings);
-   if (ret)
-   goto error;
-   uvc_iad.iFunction =
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id;
-   uvc_control_intf.iInterface =
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id;
-   ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id;
-   uvc_streaming_intf_alt0.iInterface = ret;
-   uvc_streaming_intf_alt1.iInterface = ret;
+   us = usb_gstrings_attach(cdev, uvc_function_strings,
+ARRAY_SIZE(uvc_en_us_strings));
+   if (IS_ERR(us)) {
+   ret = PTR_ERR(us);
+   goto error;
}
+   uvc_iad.iFunction = us[UVC_STRING_CONTROL_IDX].id;
+   uvc_control_intf.iInterface = us[UVC_STRING_CONTROL_IDX].id;
+   ret = us[UVC_STRING_STREAMING_IDX].id;
+   uvc_streaming_intf_alt0.iInterface = ret;
+   uvc_streaming_intf_alt1.iInterface = ret;
 
/* Allocate interface IDs. */
if ((ret = usb_interface_id(c, f)) < 0)
@@ -771,7 +767,6 @@ static void uvc_unbind(struct usb_configuration *c, struct 
usb_function *f)
uvc->control_ep->driver_data = NULL;
uvc->video.ep->driver_data = NULL;
 
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = 0;
usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
kfree(uvc->control_buf);
 
@@ -798,7 +793,6 @@ struct usb_function *uvc_alloc(struct usb_function_instance 
*fi)
 
/* Register the function. */
uvc->func.name = "uvc";
-   uvc->func.strings = uvc_function_strings;
uvc->func.bind = uvc_function_bind;
uvc->func.unbind = uvc_unbind;
uvc->func.get_alt = uvc_function_get_alt;
-- 
1.8.5.5

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


[PATCH 7/9] usb: gadget: webcam: convert webcam to new interface of f_uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Use the new function interface of f_uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/legacy/Kconfig  |  1 +
 drivers/usb/gadget/legacy/Makefile |  2 +-
 drivers/usb/gadget/legacy/webcam.c | 53 +++---
 3 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/legacy/Kconfig 
b/drivers/usb/gadget/legacy/Kconfig
index bbd4b85..24392d2 100644
--- a/drivers/usb/gadget/legacy/Kconfig
+++ b/drivers/usb/gadget/legacy/Kconfig
@@ -468,6 +468,7 @@ config USB_G_WEBCAM
depends on VIDEO_DEV
select USB_LIBCOMPOSITE
select VIDEOBUF2_VMALLOC
+   select USB_F_UVC
help
  The Webcam Gadget acts as a composite USB Audio and Video Class
  device. It provides a userspace API to process UVC control requests
diff --git a/drivers/usb/gadget/legacy/Makefile 
b/drivers/usb/gadget/legacy/Makefile
index ed7367e..7f485f2 100644
--- a/drivers/usb/gadget/legacy/Makefile
+++ b/drivers/usb/gadget/legacy/Makefile
@@ -19,7 +19,7 @@ g_multi-y := multi.o
 g_hid-y:= hid.o
 g_dbgp-y   := dbgp.o
 g_nokia-y  := nokia.o
-g_webcam-y := webcam.o ../function/uvc_queue.o 
../function/uvc_v4l2.o ../function/uvc_video.o
+g_webcam-y := webcam.o
 g_ncm-y:= ncm.o
 g_acm_ms-y := acm_ms.o
 g_tcm_usb_gadget-y := tcm_usb_gadget.o
diff --git a/drivers/usb/gadget/legacy/webcam.c 
b/drivers/usb/gadget/legacy/webcam.c
index 50d27db..04a3da2 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -15,15 +15,7 @@
 #include 
 #include 
 
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
-#define USBF_UVC_INCLUDED
-#include "f_uvc.c"
+#include "u_uvc.h"
 
 USB_GADGET_COMPOSITE_OPTIONS();
 
@@ -79,6 +71,9 @@ static struct usb_gadget_strings *webcam_device_strings[] = {
NULL,
 };
 
+static struct usb_function_instance *fi_uvc;
+static struct usb_function *f_uvc;
+
 static struct usb_device_descriptor webcam_device_descriptor = {
.bLength= USB_DT_DEVICE_SIZE,
.bDescriptorType= USB_DT_DEVICE,
@@ -342,11 +337,17 @@ static const struct uvc_descriptor_header * const 
uvc_ss_streaming_cls[] = {
 static int __init
 webcam_config_bind(struct usb_configuration *c)
 {
-   return uvc_bind_config(c, uvc_fs_control_cls,
-   uvc_ss_control_cls, uvc_fs_streaming_cls,
-   uvc_hs_streaming_cls, uvc_ss_streaming_cls,
-   streaming_interval, streaming_maxpacket,
-   streaming_maxburst, trace);
+   int status = 0;
+
+   f_uvc = usb_get_function(fi_uvc);
+   if (IS_ERR(f_uvc))
+   return PTR_ERR(f_uvc);
+
+   status = usb_add_function(c, f_uvc);
+   if (status < 0)
+   usb_put_function(f_uvc);
+
+   return status;
 }
 
 static struct usb_configuration webcam_config_driver = {
@@ -360,14 +361,36 @@ static struct usb_configuration webcam_config_driver = {
 static int /* __init_or_exit */
 webcam_unbind(struct usb_composite_dev *cdev)
 {
+   if (!IS_ERR_OR_NULL(f_uvc))
+   usb_put_function(f_uvc);
+   if (!IS_ERR_OR_NULL(fi_uvc))
+   usb_put_function_instance(fi_uvc);
return 0;
 }
 
 static int __init
 webcam_bind(struct usb_composite_dev *cdev)
 {
+   struct f_uvc_opts *uvc_opts;
int ret;
 
+   fi_uvc = usb_get_function_instance("uvc");
+   if (IS_ERR(fi_uvc))
+   return PTR_ERR(fi_uvc);
+
+   uvc_opts = container_of(fi_uvc, struct f_uvc_opts, func_inst);
+
+   uvc_opts->streaming_interval = streaming_interval;
+   uvc_opts->streaming_maxpacket = streaming_maxpacket;
+   uvc_opts->streaming_maxburst = streaming_maxburst;
+   uvc_set_trace_param(trace);
+
+   uvc_opts->fs_control = uvc_fs_control_cls;
+   uvc_opts->ss_control = uvc_ss_control_cls;
+   uvc_opts->fs_streaming = uvc_fs_streaming_cls;
+   uvc_opts->hs_streaming = uvc_hs_streaming_cls;
+   uvc_opts->ss_streaming = uvc_ss_streaming_cls;
+
/* Allocate string descriptor numbers ... note that string contents
 * can be overridden by the composite_dev glue.
 */
@@ -391,7 +414,7 @@ webcam_bind(struct usb_composite_dev *cdev)
return 0;
 
 error:
-   webcam_unbind(cdev);
+   usb_put_function_instance(fi_uvc);
return ret;
 }
 
-- 
1.8.5.5

--
To unsubscribe from this list: send the line "unsub

[PATCH 6/9] usb: gadget: f_uvc: convert f_uvc to new function interface

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Use the new function registration interface. It is required
in order to integrate configfs support.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Updated copyright years]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/Kconfig   |   3 +
 drivers/usb/gadget/function/Makefile |   2 +
 drivers/usb/gadget/function/f_uvc.c  | 204 +--
 drivers/usb/gadget/function/u_uvc.h  |  39 +++
 drivers/usb/gadget/legacy/webcam.c   |   1 +
 5 files changed, 219 insertions(+), 30 deletions(-)
 create mode 100644 drivers/usb/gadget/function/u_uvc.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 68302aa..c4880fc 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -187,6 +187,9 @@ config USB_F_UAC1
 config USB_F_UAC2
tristate
 
+config USB_F_UVC
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/function/Makefile 
b/drivers/usb/gadget/function/Makefile
index a49fdf7..90701aa 100644
--- a/drivers/usb/gadget/function/Makefile
+++ b/drivers/usb/gadget/function/Makefile
@@ -36,3 +36,5 @@ usb_f_uac1-y  := f_uac1.o u_uac1.o
 obj-$(CONFIG_USB_F_UAC1)   += usb_f_uac1.o
 usb_f_uac2-y   := f_uac2.o
 obj-$(CONFIG_USB_F_UAC2)   += usb_f_uac2.o
+usb_f_uvc-y:= f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o
+obj-$(CONFIG_USB_F_UVC)+= usb_f_uvc.o
diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 825080d..fe50a9b 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -11,6 +11,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,11 +30,14 @@
 #include "uvc.h"
 #include "uvc_v4l2.h"
 #include "uvc_video.h"
+#include "u_uvc.h"
 
 unsigned int uvc_gadget_trace_param;
+#ifdef USBF_UVC_INCLUDED
 static unsigned int streaming_interval;
 static unsigned int streaming_maxpacket;
 static unsigned int streaming_maxburst;
+#endif
 
 /* --
  * Function descriptors
@@ -65,7 +69,7 @@ static struct usb_gadget_strings *uvc_function_strings[] = {
 
 #define UVC_STATUS_MAX_PACKET_SIZE 16  /* 16 bytes status */
 
-static struct usb_interface_assoc_descriptor uvc_iad __initdata = {
+static struct usb_interface_assoc_descriptor uvc_iad = {
.bLength= sizeof(uvc_iad),
.bDescriptorType= USB_DT_INTERFACE_ASSOCIATION,
.bFirstInterface= 0,
@@ -76,7 +80,7 @@ static struct usb_interface_assoc_descriptor uvc_iad 
__initdata = {
.iFunction  = 0,
 };
 
-static struct usb_interface_descriptor uvc_control_intf __initdata = {
+static struct usb_interface_descriptor uvc_control_intf = {
.bLength= USB_DT_INTERFACE_SIZE,
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = UVC_INTF_VIDEO_CONTROL,
@@ -88,7 +92,7 @@ static struct usb_interface_descriptor uvc_control_intf 
__initdata = {
.iInterface = 0,
 };
 
-static struct usb_endpoint_descriptor uvc_control_ep __initdata = {
+static struct usb_endpoint_descriptor uvc_control_ep = {
.bLength= USB_DT_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_ENDPOINT,
.bEndpointAddress   = USB_DIR_IN,
@@ -97,7 +101,7 @@ static struct usb_endpoint_descriptor uvc_control_ep 
__initdata = {
.bInterval  = 8,
 };
 
-static struct usb_ss_ep_comp_descriptor uvc_ss_control_comp __initdata = {
+static struct usb_ss_ep_comp_descriptor uvc_ss_control_comp = {
.bLength= sizeof(uvc_ss_control_comp),
.bDescriptorType= USB_DT_SS_ENDPOINT_COMP,
/* The following 3 values can be tweaked if necessary. */
@@ -106,14 +110,14 @@ static struct usb_ss_ep_comp_descriptor 
uvc_ss_control_comp __initdata = {
.wBytesPerInterval  = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
 };
 
-static struct uvc_control_endpoint_descriptor uvc_control_cs_ep __initdata = {
+static struct uvc_control_endpoint_descriptor uvc_control_cs_ep = {
.bLength= UVC_DT_CONTROL_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_CS_ENDPOINT,
.bDescriptorSubType = UVC_EP_INTERRUPT,
.wMaxTransferSize   = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
 };
 
-static struct usb_interface_descriptor uvc_streaming_intf_alt0 __initdata = {
+static struct usb_interface_descriptor uvc_streaming_intf_alt0 = {
.bLength= USB_DT_INTERFACE_SIZE,
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = UVC_INTF_VIDEO_STREAMING,
@@ -125,7 +129,7 @@ static struct usb_interface_descriptor 
uvc_streaming_intf_alt0 __initdata = {

[PATCH 4/9] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Prepare for separate compilation of uvc function's components.
Some symbols will have to be exported, so rename to avoid
conflicts with functions of the same name in host uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Rename uvc_video_pump and uvc_queue_head as well]
[Rename forgotten uvc_queue_cancel instance in a comment]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uvc.c |  2 +-
 drivers/usb/gadget/function/uvc_queue.c | 49 +
 drivers/usb/gadget/function/uvc_v4l2.c  | 26 -
 drivers/usb/gadget/function/uvc_video.c | 34 +++
 4 files changed, 56 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 187c3a0..ae5bcb4 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -693,7 +693,7 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
}
 
/* Initialise video. */
-   ret = uvc_video_init(&uvc->video);
+   ret = uvcg_video_init(&uvc->video);
if (ret < 0)
goto error;
 
diff --git a/drivers/usb/gadget/function/uvc_queue.c 
b/drivers/usb/gadget/function/uvc_queue.c
index 8590f9f..1e1bc73 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -28,7 +28,7 @@
 /* 
  * Video buffers queue management.
  *
- * Video queues is initialized by uvc_queue_init(). The function performs
+ * Video queues is initialized by uvcg_queue_init(). The function performs
  * basic initialization of the uvc_video_queue struct and never fails.
  *
  * Video buffers are managed by videobuf2. The driver uses a mutex to protect
@@ -126,8 +126,8 @@ static struct vb2_ops uvc_queue_qops = {
.wait_finish = uvc_wait_finish,
 };
 
-static int uvc_queue_init(struct uvc_video_queue *queue,
- enum v4l2_buf_type type)
+static int uvcg_queue_init(struct uvc_video_queue *queue,
+  enum v4l2_buf_type type)
 {
int ret;
 
@@ -154,7 +154,7 @@ static int uvc_queue_init(struct uvc_video_queue *queue,
 /*
  * Free the video buffers.
  */
-static void uvc_free_buffers(struct uvc_video_queue *queue)
+static void uvcg_free_buffers(struct uvc_video_queue *queue)
 {
mutex_lock(&queue->mutex);
vb2_queue_release(&queue->queue);
@@ -164,8 +164,8 @@ static void uvc_free_buffers(struct uvc_video_queue *queue)
 /*
  * Allocate the video buffers.
  */
-static int uvc_alloc_buffers(struct uvc_video_queue *queue,
-struct v4l2_requestbuffers *rb)
+static int uvcg_alloc_buffers(struct uvc_video_queue *queue,
+ struct v4l2_requestbuffers *rb)
 {
int ret;
 
@@ -176,8 +176,8 @@ static int uvc_alloc_buffers(struct uvc_video_queue *queue,
return ret ? ret : rb->count;
 }
 
-static int uvc_query_buffer(struct uvc_video_queue *queue,
-   struct v4l2_buffer *buf)
+static int uvcg_query_buffer(struct uvc_video_queue *queue,
+struct v4l2_buffer *buf)
 {
int ret;
 
@@ -188,8 +188,8 @@ static int uvc_query_buffer(struct uvc_video_queue *queue,
return ret;
 }
 
-static int uvc_queue_buffer(struct uvc_video_queue *queue,
-   struct v4l2_buffer *buf)
+static int uvcg_queue_buffer(struct uvc_video_queue *queue,
+struct v4l2_buffer *buf)
 {
unsigned long flags;
int ret;
@@ -213,8 +213,8 @@ done:
  * Dequeue a video buffer. If nonblocking is false, block until a buffer is
  * available.
  */
-static int uvc_dequeue_buffer(struct uvc_video_queue *queue,
- struct v4l2_buffer *buf, int nonblocking)
+static int uvcg_dequeue_buffer(struct uvc_video_queue *queue,
+  struct v4l2_buffer *buf, int nonblocking)
 {
int ret;
 
@@ -231,8 +231,8 @@ static int uvc_dequeue_buffer(struct uvc_video_queue *queue,
  * This function implements video queue polling and is intended to be used by
  * the device poll handler.
  */
-static unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
-  struct file *file, poll_table *wait)
+static unsigned int uvcg_queue_poll(struct uvc_video_queue *queue,
+   struct file *file, poll_table *wait)
 {
unsigned int ret;
 
@@ -243,8 +243,8 @@ static unsigned int uvc_queue_poll(struct uvc_video_queue 
*queue,
return ret;
 }
 
-static int uvc_queue_mmap(struct uvc_video_queue *queue,
- struct vm_area_struct *vma)
+static int uvcg_queue_mmap(struct uvc_video_queue *queue,
+  struct vm_area_struct *vma)
 {
int ret;
 
@@ -2

[PATCH 3/9] usb: gadget: uvc: move module parameters from f_uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

When configfs support is integrated the future uvc function
module must not take any parameters. Move parameters to
webcam.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/function/f_uvc.c | 26 +-
 drivers/usb/gadget/function/f_uvc.h |  6 +-
 drivers/usb/gadget/legacy/webcam.c  | 27 ---
 3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index b347530..187c3a0 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -29,21 +29,9 @@
 #include "uvc.h"
 
 unsigned int uvc_gadget_trace_param;
-
-/*-*/
-
-/* module parameters specific to the Video streaming endpoint */
-static unsigned int streaming_interval = 1;
-module_param(streaming_interval, uint, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(streaming_interval, "1 - 16");
-
-static unsigned int streaming_maxpacket = 1024;
-module_param(streaming_maxpacket, uint, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(streaming_maxpacket, "1 - 1023 (FS), 1 - 3072 (hs/ss)");
-
+static unsigned int streaming_interval;
+static unsigned int streaming_maxpacket;
 static unsigned int streaming_maxburst;
-module_param(streaming_maxburst, uint, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(streaming_maxburst, "0 - 15 (ss only)");
 
 /* --
  * Function descriptors
@@ -756,7 +744,9 @@ uvc_bind_config(struct usb_configuration *c,
const struct uvc_descriptor_header * const *ss_control,
const struct uvc_descriptor_header * const *fs_streaming,
const struct uvc_descriptor_header * const *hs_streaming,
-   const struct uvc_descriptor_header * const *ss_streaming)
+   const struct uvc_descriptor_header * const *ss_streaming,
+   unsigned int stream_interv, unsigned int stream_maxpkt,
+   unsigned int stream_maxburst, unsigned int trace)
 {
struct uvc_device *uvc;
int ret = 0;
@@ -794,6 +784,10 @@ uvc_bind_config(struct usb_configuration *c,
ss_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
goto error;
 
+   streaming_interval = stream_interv;
+   streaming_maxpacket = stream_maxpkt;
+   streaming_maxburst = stream_maxburst;
+   uvc_gadget_trace_param = trace;
uvc->desc.fs_control = fs_control;
uvc->desc.ss_control = ss_control;
uvc->desc.fs_streaming = fs_streaming;
@@ -838,6 +832,4 @@ error:
return ret;
 }
 
-module_param_named(trace, uvc_gadget_trace_param, uint, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(trace, "Trace level bitmask");
 
diff --git a/drivers/usb/gadget/function/f_uvc.h 
b/drivers/usb/gadget/function/f_uvc.h
index ec52752..74b9602 100644
--- a/drivers/usb/gadget/function/f_uvc.h
+++ b/drivers/usb/gadget/function/f_uvc.h
@@ -21,7 +21,11 @@ int uvc_bind_config(struct usb_configuration *c,
const struct uvc_descriptor_header * const *hs_control,
const struct uvc_descriptor_header * const *fs_streaming,
const struct uvc_descriptor_header * const *hs_streaming,
-   const struct uvc_descriptor_header * const *ss_streaming);
+   const struct uvc_descriptor_header * const *ss_streaming,
+   unsigned int streaming_interval_webcam,
+   unsigned int streaming_maxpacket_webcam,
+   unsigned int streaming_maxburst_webcam,
+   unsigned int uvc_gadget_trace_webcam);
 
 #endif /* _F_UVC_H_ */
 
diff --git a/drivers/usb/gadget/legacy/webcam.c 
b/drivers/usb/gadget/legacy/webcam.c
index a11d8e4..f826622 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -29,6 +29,25 @@
 #include "f_uvc.c"
 
 USB_GADGET_COMPOSITE_OPTIONS();
+
+/*-*/
+
+/* module parameters specific to the Video streaming endpoint */
+static unsigned int streaming_interval = 1;
+module_param(streaming_interval, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(streaming_interval, "1 - 16");
+
+static unsigned int streaming_maxpacket = 1024;
+module_param(streaming_maxpacket, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(streaming_maxpacket, "1 - 1023 (FS), 1 - 3072 (hs/ss)");
+
+static unsigned int streaming_maxburst;
+module_param(streaming_maxburst, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(streaming_maxburst, "0 - 15 (ss only)");
+
+static unsigned int trace;
+module_param(trace, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(trace, "Trace level bitmask");
 /* --
  * Device descriptor
  */
@@ -326,9 +345,11 @@ static 

[PATCH 2/9] usb: gadget: f_uvc: Move to video_ioctl2

2014-09-08 Thread Laurent Pinchart
Simplify ioctl handling by using video_ioctl2.

Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uvc.c|   2 +
 drivers/usb/gadget/function/uvc_v4l2.c | 298 +
 2 files changed, 159 insertions(+), 141 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index e9d625b..b347530 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -414,7 +414,9 @@ uvc_register_video(struct uvc_device *uvc)
 
video->v4l2_dev = &uvc->v4l2_dev;
video->fops = &uvc_v4l2_fops;
+   video->ioctl_ops = &uvc_v4l2_ioctl_ops;
video->release = video_device_release;
+   video->vfl_dir = VFL_DIR_TX;
strlcpy(video->name, cdev->gadget->name, sizeof(video->name));
 
uvc->vdev = video;
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c 
b/drivers/usb/gadget/function/uvc_v4l2.c
index f22b878..14c3a37 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -48,7 +48,7 @@ uvc_send_response(struct uvc_device *uvc, struct 
uvc_request_data *data)
 }
 
 /* --
- * V4L2
+ * V4L2 ioctls
  */
 
 struct uvc_format
@@ -63,8 +63,29 @@ static struct uvc_format uvc_formats[] = {
 };
 
 static int
-uvc_v4l2_get_format(struct uvc_video *video, struct v4l2_format *fmt)
+uvc_v4l2_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
+{
+   struct video_device *vdev = video_devdata(file);
+   struct uvc_device *uvc = video_get_drvdata(vdev);
+   struct usb_composite_dev *cdev = uvc->func.config->cdev;
+
+   strlcpy(cap->driver, "g_uvc", sizeof(cap->driver));
+   strlcpy(cap->card, cdev->gadget->name, sizeof(cap->card));
+   strlcpy(cap->bus_info, dev_name(&cdev->gadget->dev),
+   sizeof(cap->bus_info));
+
+   cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
+
+   return 0;
+}
+
+static int
+uvc_v4l2_get_format(struct file *file, void *fh, struct v4l2_format *fmt)
 {
+   struct video_device *vdev = video_devdata(file);
+   struct uvc_device *uvc = video_get_drvdata(vdev);
+   struct uvc_video *video = &uvc->video;
+
fmt->fmt.pix.pixelformat = video->fcc;
fmt->fmt.pix.width = video->width;
fmt->fmt.pix.height = video->height;
@@ -78,8 +99,11 @@ uvc_v4l2_get_format(struct uvc_video *video, struct 
v4l2_format *fmt)
 }
 
 static int
-uvc_v4l2_set_format(struct uvc_video *video, struct v4l2_format *fmt)
+uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
 {
+   struct video_device *vdev = video_devdata(file);
+   struct uvc_device *uvc = video_get_drvdata(vdev);
+   struct uvc_video *video = &uvc->video;
struct uvc_format *format;
unsigned int imagesize;
unsigned int bpl;
@@ -116,192 +140,184 @@ uvc_v4l2_set_format(struct uvc_video *video, struct 
v4l2_format *fmt)
 }
 
 static int
-uvc_v4l2_open(struct file *file)
+uvc_v4l2_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *b)
 {
struct video_device *vdev = video_devdata(file);
struct uvc_device *uvc = video_get_drvdata(vdev);
-   struct uvc_file_handle *handle;
-
-   handle = kzalloc(sizeof(*handle), GFP_KERNEL);
-   if (handle == NULL)
-   return -ENOMEM;
-
-   v4l2_fh_init(&handle->vfh, vdev);
-   v4l2_fh_add(&handle->vfh);
+   struct uvc_video *video = &uvc->video;
 
-   handle->device = &uvc->video;
-   file->private_data = &handle->vfh;
+   if (b->type != video->queue.queue.type)
+   return -EINVAL;
 
-   uvc_function_connect(uvc);
-   return 0;
+   return uvc_alloc_buffers(&video->queue, b);
 }
 
 static int
-uvc_v4l2_release(struct file *file)
+uvc_v4l2_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
 {
struct video_device *vdev = video_devdata(file);
struct uvc_device *uvc = video_get_drvdata(vdev);
-   struct uvc_file_handle *handle = to_uvc_file_handle(file->private_data);
-   struct uvc_video *video = handle->device;
-
-   uvc_function_disconnect(uvc);
-
-   uvc_video_enable(video, 0);
-   uvc_free_buffers(&video->queue);
-
-   file->private_data = NULL;
-   v4l2_fh_del(&handle->vfh);
-   v4l2_fh_exit(&handle->vfh);
-   kfree(handle);
+   struct uvc_video *video = &uvc->video;
 
-   return 0;
+   return uvc_query_buffer(&video->queue, b);
 }
 
-static long
-uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
+static int
+uvc_v4l2_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
 {
struct video_device *vdev = video_devdata(file);
struct uvc_device *uvc = video_get_drvdata(vdev);
-   struct uvc_file_handle *handle = to_uvc_file_handle(file->private_data);
-   struct usb_composite_dev *cdev

[PATCH 8/9] usb: gadget: f_uvc: remove compatibility layer

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

There are no users of the old interface left. Remove it.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/function/f_uvc.c | 166 
 drivers/usb/gadget/function/f_uvc.h |  11 ---
 2 files changed, 177 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index fe50a9b..1eff416 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -33,11 +33,6 @@
 #include "u_uvc.h"
 
 unsigned int uvc_gadget_trace_param;
-#ifdef USBF_UVC_INCLUDED
-static unsigned int streaming_interval;
-static unsigned int streaming_maxpacket;
-static unsigned int streaming_maxburst;
-#endif
 
 /* --
  * Function descriptors
@@ -202,16 +197,12 @@ static const struct usb_descriptor_header * const 
uvc_ss_streaming[] = {
NULL,
 };
 
-#ifndef USBF_UVC_INCLUDED
-
 void uvc_set_trace_param(unsigned int trace)
 {
uvc_gadget_trace_param = trace;
 }
 EXPORT_SYMBOL(uvc_set_trace_param);
 
-#endif
-
 /* --
  * Control requests
  */
@@ -566,30 +557,6 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum 
usb_device_speed speed)
return hdr;
 }
 
-#ifdef USBF_UVC_INCLUDED
-static void
-uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct usb_composite_dev *cdev = c->cdev;
-   struct uvc_device *uvc = to_uvc(f);
-
-   INFO(cdev, "uvc_function_unbind\n");
-
-   video_unregister_device(uvc->vdev);
-   v4l2_device_unregister(&uvc->v4l2_dev);
-   uvc->control_ep->driver_data = NULL;
-   uvc->video.ep->driver_data = NULL;
-
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = 0;
-   usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
-   kfree(uvc->control_buf);
-
-   usb_free_all_descriptors(f);
-
-   kfree(uvc);
-}
-#endif
-
 static int
 uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
 {
@@ -598,51 +565,11 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
unsigned int max_packet_mult;
unsigned int max_packet_size;
struct usb_ep *ep;
-#ifndef USBF_UVC_INCLUDED
struct f_uvc_opts *opts;
-#endif
int ret = -EINVAL;
 
INFO(cdev, "uvc_function_bind\n");
 
-#ifdef USBF_UVC_INCLUDED
-   /* Sanity check the streaming endpoint module parameters.
-*/
-   streaming_interval = clamp(streaming_interval, 1U, 16U);
-   streaming_maxpacket = clamp(streaming_maxpacket, 1U, 3072U);
-   streaming_maxburst = min(streaming_maxburst, 15U);
-
-   /* Fill in the FS/HS/SS Video Streaming specific descriptors from the
-* module parameters.
-*
-* NOTE: We assume that the user knows what they are doing and won't
-* give parameters that their UDC doesn't support.
-*/
-   if (streaming_maxpacket <= 1024) {
-   max_packet_mult = 1;
-   max_packet_size = streaming_maxpacket;
-   } else if (streaming_maxpacket <= 2048) {
-   max_packet_mult = 2;
-   max_packet_size = streaming_maxpacket / 2;
-   } else {
-   max_packet_mult = 3;
-   max_packet_size = streaming_maxpacket / 3;
-   }
-
-   uvc_fs_streaming_ep.wMaxPacketSize = min(streaming_maxpacket, 1023U);
-   uvc_fs_streaming_ep.bInterval = streaming_interval;
-
-   uvc_hs_streaming_ep.wMaxPacketSize = max_packet_size;
-   uvc_hs_streaming_ep.wMaxPacketSize |= ((max_packet_mult - 1) << 11);
-   uvc_hs_streaming_ep.bInterval = streaming_interval;
-
-   uvc_ss_streaming_ep.wMaxPacketSize = max_packet_size;
-   uvc_ss_streaming_ep.bInterval = streaming_interval;
-   uvc_ss_streaming_comp.bmAttributes = max_packet_mult - 1;
-   uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst;
-   uvc_ss_streaming_comp.wBytesPerInterval =
-   max_packet_size * max_packet_mult * streaming_maxburst;
-#else
opts = to_f_uvc_opts(f->fi);
/* Sanity check the streaming endpoint module parameters.
 */
@@ -681,7 +608,6 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
uvc_ss_streaming_comp.bMaxBurst = opts->streaming_maxburst;
uvc_ss_streaming_comp.wBytesPerInterval =
max_packet_size * max_packet_mult * opts->streaming_maxburst;
-#endif
 
/* Allocate endpoints. */
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
@@ -807,96 +733,6 @@ error:
  * USB gadget function
  */
 
-#ifdef USBF_UVC_INCLUDED
-/**
- * uvc_bind_config - add a UVC function to a configuration
- * @c: the configuration to support the UVC instance
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, 

Re: [PATCH RESEND v3 01/12] usb: dwc2/gadget: fix phy disable sequence

2014-09-08 Thread Robert Baldyga
On 09/04/2014 09:49 PM, Felipe Balbi wrote:
> Hi,
> 
> On Thu, Sep 04, 2014 at 07:37:20PM +, Paul Zimmerman wrote:
>>> From: Felipe Balbi [mailto:ba...@ti.com]
>>> Sent: Thursday, September 04, 2014 12:18 PM
>>>
>>> On Thu, Sep 04, 2014 at 12:04:23PM -0700, Paul Zimmerman wrote:
 From: Kamil Debski 

 When the driver is removed s3c_hsotg_phy_disable is called three times
 instead of once. This results in decreasing of the phy reference counter
 below zero and thus consecutive inserts of the module fails.

 This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
 and s3c_hsotg_udc_stop.

 s3c_hsotg_udc_stop is called from udc-core.c only after
 usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
 already calls s3c_hsotg_phy_disable.

 s3c_hsotg_remove must be called only after udc_stop, so there is no
 point in disabling phy once again there.

 Signed-off-by: Kamil Debski 
 Signed-off-by: Marek Szyprowski 
 Signed-off-by: Robert Baldyga 
 Signed-off-by: Paul Zimmerman 
>>>
>>> looks like this one deserves a Cc: stable ?
>>
>> Good point. Robert, what do you think? Only problem is, this file
>> moved from drivers/usb/gadget/ to here in 3.16, so earlier stable
>> versions would require some additional backporting.
> 
> Right, you'll receive a notification from Greg that the patch FAILED to
> apply and all you gotta do is provide a modified patch which, in this
> case, is just a path modification.

I can rebase patchset at stable branch and send it separately.

Felipe, should I rebase only patches you have pointed or rather entire
patchset?
--
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


[no subject]

2014-09-08 Thread ®®®


Sehr geehrte Begünstigte,

Sie haben als einzige Begünstigte der Summe von fünfhunderttausend Euro (€ 
500.000,00 Euro), die hier in WESTERN UNION OFFICE von der ONU Organisation für 
Sie hinterlegt ausgewählt wurde.

Bitte kontaktieren Sie uns für Ansprüche Email: wes_sp...@outlook.com

Kundendienst
Western Union Office®
--
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 stable 0/6] usb: dwc2/gadget: fix series

2014-09-08 Thread Robert Baldyga
This patchset contains fixes for dwc2/gadget driver.
It should apply to stable-3.16.

Best regards
Robert Baldyga

Kamil Debski (2):
  usb: dwc2/gadget: fix phy disable sequence
  usb: dwc2/gadget: fix phy initialization sequence

Marek Szyprowski (3):
  usb: dwc2/gadget: break infinite loop in endpoint disable code
  usb: dwc2/gadget: do not call disconnect method in pullup
  usb: dwc2/gadget: delay enabling irq once hardware is configured
properly

Robert Baldyga (1):
  usb: dwc2/gadget: avoid disabling ep0

 drivers/usb/dwc2/gadget.c | 52 +++
 1 file changed, 25 insertions(+), 27 deletions(-)

-- 
1.9.1

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


[PATCH stable 1/6] usb: dwc2/gadget: fix phy disable sequence

2014-09-08 Thread Robert Baldyga
From: Kamil Debski 

When the driver is removed s3c_hsotg_phy_disable is called three times
instead of once. This results in decreasing of the phy reference counter
below zero and thus consecutive inserts of the module fails.

This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
and s3c_hsotg_udc_stop.

s3c_hsotg_udc_stop is called from udc-core.c only after
usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
already calls s3c_hsotg_phy_disable.

s3c_hsotg_remove must be called only after udc_stop, so there is no
point in disabling phy once again there.

Signed-off-by: Kamil Debski 
Signed-off-by: Marek Szyprowski 
Signed-off-by: Robert Baldyga 
---
 drivers/usb/dwc2/gadget.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f3c56a2..ccef3a7 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2898,8 +2898,6 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
 
spin_lock_irqsave(&hsotg->lock, flags);
 
-   s3c_hsotg_phy_disable(hsotg);
-
if (!driver)
hsotg->driver = NULL;
 
@@ -3586,7 +3584,6 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
usb_gadget_unregister_driver(hsotg->driver);
}
 
-   s3c_hsotg_phy_disable(hsotg);
if (hsotg->phy)
phy_exit(hsotg->phy);
clk_disable_unprepare(hsotg->clk);
-- 
1.9.1

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


[PATCH stable 2/6] usb: dwc2/gadget: fix phy initialization sequence

2014-09-08 Thread Robert Baldyga
From: Kamil Debski 

In the Generic PHY Framework a NULL phy is considered to be a valid phy
thus the "if (hsotg->phy)" check does not give us the information whether
the Generic PHY Framework is used.

In addition to the above this patch also removes phy_init from probe and
phy_exit from remove. This is not necessary when init/exit is done in the
s3c_hsotg_phy_enable/disable functions.

Signed-off-by: Kamil Debski 
Signed-off-by: Marek Szyprowski 
Signed-off-by: Robert Baldyga 
---
 drivers/usb/dwc2/gadget.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ccef3a7..70eab95 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2748,13 +2748,14 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg 
*hsotg)
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
 
-   if (hsotg->phy) {
-   phy_init(hsotg->phy);
-   phy_power_on(hsotg->phy);
-   } else if (hsotg->uphy)
+   if (hsotg->uphy)
usb_phy_init(hsotg->uphy);
-   else if (hsotg->plat->phy_init)
+   else if (hsotg->plat && hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
+   else {
+   phy_init(hsotg->phy);
+   phy_power_on(hsotg->phy);
+   }
 }
 
 /**
@@ -2768,13 +2769,14 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
*hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->phy) {
-   phy_power_off(hsotg->phy);
-   phy_exit(hsotg->phy);
-   } else if (hsotg->uphy)
+   if (hsotg->uphy)
usb_phy_shutdown(hsotg->uphy);
-   else if (hsotg->plat->phy_exit)
+   else if (hsotg->plat && hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
+   else {
+   phy_power_off(hsotg->phy);
+   phy_exit(hsotg->phy);
+   }
 }
 
 /**
@@ -3489,9 +3491,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
if (hsotg->phy && (phy_get_bus_width(phy) == 8))
hsotg->phyif = GUSBCFG_PHYIF8;
 
-   if (hsotg->phy)
-   phy_init(hsotg->phy);
-
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3584,8 +3583,6 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
usb_gadget_unregister_driver(hsotg->driver);
}
 
-   if (hsotg->phy)
-   phy_exit(hsotg->phy);
clk_disable_unprepare(hsotg->clk);
 
return 0;
-- 
1.9.1

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


[PATCH stable 3/6] usb: dwc2/gadget: break infinite loop in endpoint disable code

2014-09-08 Thread Robert Baldyga
From: Marek Szyprowski 

This patch fixes possible freeze caused by infinite loop in interrupt
context.

Signed-off-by: Marek Szyprowski 
Signed-off-by: Robert Baldyga 
---
 drivers/usb/dwc2/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 70eab95..f3198dc 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1650,6 +1650,7 @@ static void s3c_hsotg_txfifo_flush(struct s3c_hsotg 
*hsotg, unsigned int idx)
dev_err(hsotg->dev,
"%s: timeout flushing fifo (GRSTCTL=%08x)\n",
__func__, val);
+   break;
}
 
udelay(1);
-- 
1.9.1

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


[PATCH stable 5/6] usb: dwc2/gadget: delay enabling irq once hardware is configured properly

2014-09-08 Thread Robert Baldyga
From: Marek Szyprowski 

This patch fixes kernel panic/interrupt storm/etc issues if bootloader
left s3c-hsotg module in enabled state. Now interrupt handler is enabled
only after proper configuration of hardware registers.

Signed-off-by: Marek Szyprowski 
Signed-off-by: Robert Baldyga 
---
 drivers/usb/dwc2/gadget.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 1c2b8dd..2d48ffb 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3444,13 +3444,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 
hsotg->irq = ret;
 
-   ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
-   dev_name(dev), hsotg);
-   if (ret < 0) {
-   dev_err(dev, "cannot claim IRQ\n");
-   goto err_clk;
-   }
-
dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
 
hsotg->gadget.max_speed = USB_SPEED_HIGH;
@@ -3498,6 +3491,17 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
s3c_hsotg_init(hsotg);
s3c_hsotg_hw_cfg(hsotg);
 
+   ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
+   dev_name(dev), hsotg);
+   if (ret < 0) {
+   s3c_hsotg_phy_disable(hsotg);
+   clk_disable_unprepare(hsotg->clk);
+   regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
+  hsotg->supplies);
+   dev_err(dev, "cannot claim IRQ\n");
+   goto err_clk;
+   }
+
/* hsotg->num_of_eps holds number of EPs other than ep0 */
 
if (hsotg->num_of_eps == 0) {
-- 
1.9.1

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


[PATCH stable 6/6] usb: dwc2/gadget: avoid disabling ep0

2014-09-08 Thread Robert Baldyga
Endpoint 0 should not be disabled, so we start loop counter from number 1.

Signed-off-by: Robert Baldyga 
---
 drivers/usb/dwc2/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 2d48ffb..a0d2f31 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2896,7 +2896,7 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
return -ENODEV;
 
/* all endpoints should be shutdown */
-   for (ep = 0; ep < hsotg->num_of_eps; ep++)
+   for (ep = 1; ep < hsotg->num_of_eps; ep++)
s3c_hsotg_ep_disable(&hsotg->eps[ep].ep);
 
spin_lock_irqsave(&hsotg->lock, flags);
-- 
1.9.1

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


[PATCH stable 4/6] usb: dwc2/gadget: do not call disconnect method in pullup

2014-09-08 Thread Robert Baldyga
From: Marek Szyprowski 

This leads to potential spinlock recursion in composite framework, other
udc drivers also don't call it directly from pullup method.

Signed-off-by: Marek Szyprowski 
Signed-off-by: Robert Baldyga 
---
 drivers/usb/dwc2/gadget.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f3198dc..1c2b8dd 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2943,7 +2943,6 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, 
int is_on)
s3c_hsotg_phy_enable(hsotg);
s3c_hsotg_core_init(hsotg);
} else {
-   s3c_hsotg_disconnect(hsotg);
s3c_hsotg_phy_disable(hsotg);
}
 
-- 
1.9.1

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


[RFC v3 1/2] usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode

2014-09-08 Thread Kiran Kumar Raparthy
From: Todd Poynor 

usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode

Purpose of this is to prevent the system to enter into suspend state from USB
peripheral traffic by hodling a wakeupsource when USB is connected and
enumerated in peripheral mode(say adb).

Disabled by default, can enable with:
   echo Y > /sys/module/otg_wakeupsource/parameters/enabled

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team 
Cc: John Stultz 
Cc: Sumit Semwal 
Cc: Arve Hj�nnev�g 
Cc: Benoit Goby 
Signed-off-by: Todd Poynor 
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy 
---
v3:
* As per the feedback,no global phy pointer used.
* called the one-liner wakeupsource handling calls
  directly instead of indirect functions implemented in v2.
* Removed indirect function get_phy_hook and used usb_get_phy
  to get the phy handle..

v2:
* wakeupsource handling implemeted per-PHY
* Implemented wakeupsource handling calls in phy
* included Todd's refactoring logic.

v1:
* changed to "disabled by default" from "enable by default".
* Kconfig help text modified
* Included better commit text
* otgws_nb moved to otg_wakeupsource_init function
* Introduced get_phy_hook to handle otgws_xceiv per-PHY

RFC:
* Included build fix from Benoit Goby and Arve Hj�nnev�g
* Removed lock->held field in driver as this mechanism is
  provided in wakeupsource driver.
* wakelock(wl) terminology replaced with wakeup_source(ws).

 drivers/usb/phy/Kconfig|   8 +++
 drivers/usb/phy/Makefile   |   1 +
 drivers/usb/phy/otg-wakeupsource.c | 136 +
 include/linux/usb/phy.h|   4 ++
 4 files changed, 149 insertions(+)
 create mode 100644 drivers/usb/phy/otg-wakeupsource.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index e253fa0..d9ddd85 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -6,6 +6,14 @@ menu "USB Physical Layer drivers"
 config USB_PHY
def_bool n
 
+config USB_OTG_WAKEUPSOURCE
+   bool "Hold wakeupsource when USB is enumerated in peripheral mode"
+   depends on PM_SLEEP
+   select USB_PHY
+   help
+ Prevent the system going into automatic suspend while
+ it is attached as a USB peripheral by holding a wakeupsource.
+
 #
 # USB Transceiver Drivers
 #
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 24a9133..ca2fbaf 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -3,6 +3,7 @@
 #
 obj-$(CONFIG_USB_PHY)  += phy.o
 obj-$(CONFIG_OF)   += of.o
+obj-$(CONFIG_USB_OTG_WAKEUPSOURCE) += otg-wakeupsource.o
 
 # transceiver drivers, keep the list sorted
 
diff --git a/drivers/usb/phy/otg-wakeupsource.c 
b/drivers/usb/phy/otg-wakeupsource.c
new file mode 100644
index 000..d9a1720
--- /dev/null
+++ b/drivers/usb/phy/otg-wakeupsource.c
@@ -0,0 +1,136 @@
+/*
+ * otg-wakeupsource.c
+ *
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+bool enabled = false;
+
+static DEFINE_SPINLOCK(otgws_spinlock);
+
+static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long 
event)
+{
+   unsigned long irqflags;
+
+   spin_lock_irqsave(&otgws_spinlock, irqflags);
+
+   if (!enabled) {
+   __pm_relax(&otgws_xceiv->wsource);
+   spin_unlock_irqrestore(&otgws_spinlock, irqflags);
+   return;
+   }
+
+   switch (event) {
+   case USB_EVENT_VBUS:
+   case USB_EVENT_ENUMERATED:
+   __pm_stay_awake(&otgws_xceiv->wsource);
+   break;
+
+   case USB_EVENT_NONE:
+   case USB_EVENT_ID:
+   case USB_EVENT_CHARGER:
+   __pm_relax(&otgws_xceiv->wsource);
+   break;
+
+   default:
+   break;
+   }
+
+   spin_unlock_irqrestore(&otgws_spinlock, irqflags);
+}
+
+static int otgws_otg_notifications(struct notifier_block *nb,
+   unsigned long event, void *unused)
+{
+   static struct usb_phy *otgws_xceiv;
+
+   otgws_xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+
+   if (IS_ERR(otgws_xceiv)) {
+   pr_err("%

[RFC v3 2/2] usb: phy: Temporarily hold timed wakeup source on charger and disconnect events

2014-09-08 Thread Kiran Kumar Raparthy
From: Todd Poynor 

usb: phy: Temporarily hold timed wakeup source on charger and disconnect
events

It temporarily holds a timed wakeup source on USB disconnect events, to allow
the rest of the system time to react to the USB disconnection (dropping host
sessions, updating charger status, etc.) prior to re-allowing suspend

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team 
Cc: John Stultz 
Cc: Sumit Semwal 
Signed-off-by: Todd Poynor 
[kiran: Added context to commit message and
addressed community feedback]
Signed-off-by: Kiran Raparthy 
---
v3:
* Modified the commit log.
* Remove indirect function usb_temporary_hold_wsource and call
  __pm_wakeup_even directly.

v2:
* Implement usb_temporary_hold_wsource function in phy.

v1:
* Removed the refactoring logic from this integrated into main driver code.

RFC:
* Integrated the refactoring logic and logic to hold wakeupsource
  temporarily.

 drivers/usb/phy/otg-wakeupsource.c | 3 ++-
 include/linux/usb/phy.h| 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/otg-wakeupsource.c 
b/drivers/usb/phy/otg-wakeupsource.c
index d9a1720..7bc9657 100644
--- a/drivers/usb/phy/otg-wakeupsource.c
+++ b/drivers/usb/phy/otg-wakeupsource.c
@@ -47,7 +47,8 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, 
unsigned long event)
case USB_EVENT_NONE:
case USB_EVENT_ID:
case USB_EVENT_CHARGER:
-   __pm_relax(&otgws_xceiv->wsource);
+   __pm_wakeup_event(&otgws_xceiv->wsource,
+   msecs_to_jiffies(TEMPORARY_HOLD_TIME));
break;
 
default:
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index c71cf15..f8f9f1f 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -12,6 +12,8 @@
 #include 
 #include 
 
+#define TEMPORARY_HOLD_TIME2000
+
 enum usb_phy_interface {
USBPHY_INTERFACE_MODE_UNKNOWN,
USBPHY_INTERFACE_MODE_UTMI,
-- 
1.8.2.1

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


[PATCH] usb: gadget: zero: Fix warning generated by kbuild

2014-09-08 Thread Amit Virdi
The kbuild test bot generated the warning:
drivers/usb/gadget/function/f_sourcesink.c:1498: warning: comparison is
always false due to limited range of data type

This patch fixes it.

Reported-by: kbuild test robot 
Signed-off-by: Amit Virdi 
CC: Felipe Balbi 
---
 drivers/usb/gadget/function/f_sourcesink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_sourcesink.c 
b/drivers/usb/gadget/function/f_sourcesink.c
index 7c091a328228..065e9d4e4785 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -1483,7 +1483,7 @@ static ssize_t f_ss_opts_int_interval_store(struct 
f_ss_opts *opts,
   const char *page, size_t len)
 {
int ret;
-   u8 num;
+   u32 num;
 
mutex_lock(&opts->lock);
if (opts->refcnt) {
-- 
1.8.0

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


Re: [RFC v3 2/2] usb: phy: Temporarily hold timed wakeup source on charger and disconnect events

2014-09-08 Thread Sergei Shtylyov

Hello.

On 9/8/2014 2:10 PM, Kiran Kumar Raparthy wrote:


From: Todd Poynor 



usb: phy: Temporarily hold timed wakeup source on charger and disconnect
events


   No need to duplicate the summary.


It temporarily holds a timed wakeup source on USB disconnect events, to allow


   What "it"?


the rest of the system time to react to the USB disconnection (dropping host
sessions, updating charger status, etc.) prior to re-allowing suspend



Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team 
Cc: John Stultz 
Cc: Sumit Semwal 
Signed-off-by: Todd Poynor 
[kiran: Added context to commit message and
addressed community feedback]
Signed-off-by: Kiran Raparthy 


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] usb: host: xhci: fix compliance mode workaround

2014-09-08 Thread Mathias Nyman
On 08/28/2014 01:07 AM, Greg KH wrote:
> On Wed, Aug 27, 2014 at 04:38:04PM -0500, Felipe Balbi wrote:
>> Commit 71c731a (usb: host: xhci: Fix Compliance Mode
>> on SN65LVP3502CP Hardware) implemented a workaround
>> for a known issue with Texas Instruments' USB 3.0
>> redriver IC but it left a condition where any xHCI
>> host would be taken out of reset if port was placed
>> in compliance mode and there was no device connected
>> to the port.
>>
>> That condition would trigger a fake connection to a
>> non-existent device so that usbcore would trigger a
>> warm reset of the port, thus taking the link out of
>> reset.
>>
>> This has the side-effect of preventing any xHCI host
>> connected to a Linux machine from starting and running
>> the USB 3.0 Electrical Compliance Suite because the
>> port will mysteriously taken out of compliance mode
>> and, thus, xHCI won't step through the necessary
>> compliance patterns for link validation.
>>
>> This patch fixes the issue by just adding a missing
>> check for XHCI_COMP_MODE_QUIRK inside
>> xhci_hub_report_usb3_link_state() when PORT_CAS isn't
>> set.
>>
>> This patch should be backported to all kernels containing
>> commit 71c731a.
>>
>> Fixes: 71c731a (usb: host: xhci: Fix Compliance Mode on SN65LVP3502CP 
>> Hardware)
>> Cc: Alexis R. Cortes 
>> Cc:  # v3.2+
>> Signed-off-by: Felipe Balbi 
>> ---
>>
>> This has been tested on a certification setup with LeCroy Voyager M3i
>> and a really expensive oscilloscope :-)
>>
>> Without this patch we cannot keep the host in compliance.
>>
>>  drivers/usb/host/xhci-hub.c | 8 +---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
>> index aa79e87..69aece3 100644
>> --- a/drivers/usb/host/xhci-hub.c
>> +++ b/drivers/usb/host/xhci-hub.c
>> @@ -468,7 +468,8 @@ static void xhci_hub_report_usb2_link_state(u32 *status, 
>> u32 status_reg)
>>  }
>>  
>>  /* Updates Link Status for super Speed port */
>> -static void xhci_hub_report_usb3_link_state(u32 *status, u32 status_reg)
>> +static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
>> +u32 *status, u32 status_reg)
>>  {
>>  u32 pls = status_reg & PORT_PLS_MASK;
>>  
>> @@ -507,7 +508,8 @@ static void xhci_hub_report_usb3_link_state(u32 *status, 
>> u32 status_reg)
>>   * in which sometimes the port enters compliance mode
>>   * caused by a delay on the host-device negotiation.
>>   */
>> -if (pls == USB_SS_PORT_LS_COMP_MOD)
>> +if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
>> +(pls == USB_SS_PORT_LS_COMP_MOD))
>>  pls |= USB_PORT_STAT_CONNECTION;
>>  }
>>  
>> @@ -666,7 +668,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
>>  }
>>  /* Update Port Link State */
>>  if (hcd->speed == HCD_USB3) {
>> -xhci_hub_report_usb3_link_state(&status, raw_port_status);
>> +xhci_hub_report_usb3_link_state(xhci, &status, raw_port_status);
>>  /*
>>   * Verify if all USB3 Ports Have entered U0 already.
>>   * Delete Compliance Mode Timer if so.
> 
> Looks good, Mathias, can I get an ACK so I can queue this up now?
> 

Somehow I didn't notice this one until now, anyways,

Acked-by: Mathias Nyman 





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


Re: [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-08 Thread Johan Hovold
On Fri, Sep 05, 2014 at 06:17:57PM +0300, Octavian Purdila wrote:
> This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
> Master Adapter DLN-2. Details about the device can be found here:
> 
> https://www.diolan.com/i2c/i2c_interface.html.
> 
> Information about the USB protocol can be found in the Programmer's
> Reference Manual [1], see section 1.7.
> 
> Because the hardware has a single transmit endpoint and a single
> receive endpoint the communication between the various DLN2 drivers
> and the hardware will be muxed/demuxed by this driver.
> 
> Each DLN2 module will be identified by the handle field within the DLN2
> message header. If a DLN2 module issues multiple commands in parallel
> they will be identified by the echo counter field in the message header.
> 
> The DLN2 modules can use the dln2_transfer() function to issue a
> command and wait for its response. They can also register a callback
> that is going to be called when a specific event id is generated by
> the device (e.g. GPIO interrupts). The device uses handle 0 for
> sending events.
> 
> [1] https://www.diolan.com/downloads/dln-api-manual.pdf
> 
> Signed-off-by: Octavian Purdila 
> ---
>  drivers/mfd/Kconfig  |   9 +
>  drivers/mfd/Makefile |   1 +
>  drivers/mfd/dln2.c   | 653 
> +++
>  include/linux/mfd/dln2.h |  61 +
>  4 files changed, 724 insertions(+)
>  create mode 100644 drivers/mfd/dln2.c
>  create mode 100644 include/linux/mfd/dln2.h

First of all, this is much cleaner than the first non-MFD version. I'll
have a look at the subdrivers shortly as well.

>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index de5abf2..7bcf895 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -183,6 +183,15 @@ config MFD_DA9063
> Additional drivers must be enabled in order to use the functionality
> of the device.
>  
> +config MFD_DLN2
> + tristate "Diolan DLN2 support"
> + select MFD_CORE
> + depends on USB
> + help
> +   This adds support for Diolan USB-I2C/SPI/GPIO Master Adapter DLN-2.
> +   Additional drivers must be enabled in order to use the functionality
> +   of the device.
> +
>  config MFD_MC13XXX
>   tristate
>   depends on (SPI_MASTER || I2C)
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index f001487..591988d 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_AS3711)  += as3711.o
>  obj-$(CONFIG_MFD_AS3722) += as3722.o
>  obj-$(CONFIG_MFD_STW481X)+= stw481x.o
>  obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
> +obj-$(CONFIG_MFD_DLN2)   += dln2.o
>  
>  intel-soc-pmic-objs  := intel_soc_pmic_core.o intel_soc_pmic_crc.o
>  obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
> diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
> new file mode 100644
> index 000..81ff58e
> --- /dev/null
> +++ b/drivers/mfd/dln2.c
> @@ -0,0 +1,653 @@
> +/*
> + * Driver for the Diolan DLN-2 USB adapter
> + *
> + * Copyright (c) 2014 Intel Corporation
> + *
> + * Derived from:
> + *  i2c-diolan-u2c.c
> + *  Copyright (c) 2010-2011 Ericsson AB
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME  "usb-dln2"
> +
> +struct dln2_header {
> + __le16 size;
> + __le16 id;
> + __le16 echo;
> + __le16 handle;
> +} __packed;
> +
> +struct dln2_response {
> + struct dln2_header hdr;
> + __le16 result;
> +} __packed;
> +
> +#define DLN2_GENERIC_MODULE_ID   0x00
> +#define DLN2_GENERIC_CMD(cmd)DLN2_CMD(cmd, 
> DLN2_GENERIC_MODULE_ID)
> +#define CMD_GET_DEVICE_VER   DLN2_GENERIC_CMD(0x30)
> +#define CMD_GET_DEVICE_SNDLN2_GENERIC_CMD(0x31)
> +
> +#define DLN2_HW_ID   0x200
> +#define DLN2_USB_TIMEOUT 200 /* in ms */
> +#define DLN2_MAX_RX_SLOTS16
> +#define DLN2_MAX_MODULES 5
> +#define DLN2_MAX_URBS16
> +
> +#define DLN2_HANDLE_GPIO_EVENT   0

Just DLN2_HANDLE_EVENT?

> +#define DLN2_HANDLE_CTRL 1
> +#define DLN2_HANDLE_GPIO 2
> +#define DLN2_HANDLE_I2C  3
> +
> +/* Receive context used between the receive demultiplexer and the
> + * transfer routine. While sending a request the transfer routine
> + * will look for a free receive context and use it to wait for a
> + * response and to receive the URB and thus the response data. */

The recommended style for multi-line comments is

/*
 * ...
 */

This applies to all three patches.

> +struct dln2_rx_cont

[PATCH v6 3/5] usb: host: ehci-st: Add ehci-st devicetree bindings documentation

2014-09-08 Thread Peter Griffin
This patch documents the device tree bindings required for the
ehci on-chip controller found in ST consumer electronics SoC's.

Signed-off-by: Peter Griffin 
---
 Documentation/devicetree/bindings/usb/ehci-st.txt | 39 +++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-st.txt

diff --git a/Documentation/devicetree/bindings/usb/ehci-st.txt 
b/Documentation/devicetree/bindings/usb/ehci-st.txt
new file mode 100644
index 000..fb45fa5
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ehci-st.txt
@@ -0,0 +1,39 @@
+ST USB EHCI controller
+
+Required properties:
+ - compatible  : must be "st,st-ehci-300x"
+ - reg : physical base addresses of the controller and length 
of memory mapped
+ region
+ - interrupts  : one EHCI interrupt should be described here
+ - pinctrl-names   : a pinctrl state named "default" must be defined
+ - pinctrl-0   : phandle referencing pin configuration of the USB 
controller
+See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+ - clocks  : phandle list of usb clocks
+ - clock-names : should be "ic" for interconnect clock and "clk48"
+See: Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+ - phys: phandle for the PHY device
+ - phy-names   : should be "usb"
+ - resets  : phandle + reset specifier pairs to the powerdown and 
softreset lines
+ of the USB IP
+ - reset-names : should be "power" and "softreset"
+See: Documentation/devicetree/bindings/reset/st,sti-powerdown.txt
+See: Documentation/devicetree/bindings/reset/reset.txt
+
+Example:
+
+   ehci1: usb@0xfe203e00 {
+   compatible = "st,st-ehci-300x";
+   reg = <0xfe203e00 0x100>;
+   interrupts = ;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_usb1>;
+   clocks = <&clk_s_a1_ls 0>;
+   phys = <&usb2_phy>;
+   phy-names = "usb";
+   status = "okay";
+
+   resets = <&powerdown STIH416_USB1_POWERDOWN>,
+<&softreset STIH416_USB1_SOFTRESET>;
+   reset-names = "power", "softreset";
+   };
-- 
1.9.1

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


[PATCH v6 5/5] MAINTAINERS: Add ehci-st.c and ohci-st.c to ARCH/STI architecture

2014-09-08 Thread Peter Griffin
This patch adds the ehci-st.c and ohci-st.c files for the usb 2.0
& usb1.1 host controller drivers found on stih41x and stih4xx STMicroelectronics
SoC's into the STI arch section of the maintainers file.

Signed-off-by: Peter Griffin 
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index cf24bb5..5abd281 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1398,6 +1398,8 @@ F:drivers/media/rc/st_rc.c
 F: drivers/i2c/busses/i2c-st.c
 F: drivers/tty/serial/st-asc.c
 F: drivers/mmc/host/sdhci-st.c
+F: drivers/usb/host/ehci-st.c
+F: drivers/usb/host/ohci-st.c
 
 ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT
 M: Lennert Buytenhek 
-- 
1.9.1

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


[PATCH v6 0/5] Add EHCI and OHCI drivers for STi SoC's

2014-09-08 Thread Peter Griffin
Hi,

I believe all feedback has been incorporated, and this series has also been 
rebased on
3.17-rc3.

It was re-worked from v2 onwards to split out the ehci and ohci parts
into their own drivers / devices like most other ARM platforms based on
feedback from Arnd Bergmann (see here 
http://www.spinics.net/lists/linux-usb/msg24.html. 

The ehci-platform & ohci-platform have been used as a basis for this in case we
wish to merge the drivers again in the future.

Changes since v5:
 - Remove shared header file and duplicate private structure to help readability
   and keep driver self contained, based on Arnd feedback.
 - Rebased on 3.17-rc3

Changes since v4:
 - Ensure suspend / resume callbacks are wrapped in #ifdef CONFIG_PM_SLEEP as 
otherwise we
   will get linker 'unused function' warnings when this option is disabled.
 - Only declare and reference pm_ops struct if CONFIG_PM_SLEEP is enabled, this 
saves a few bytes

Changes since v3:
 - Make reset / power, clocks etc non optional dt options to simplify code
 - Get rid of non DT boot code left over from *hci-platform drivers
 - Remove DMA mask code
 - Remove pre_setup func ptr and configure ahb2st bus convertor in 
ehci_platform_reset
 - Unabstract and remove usb-st-common.c
 - Have one kconfig which enables both ehci-st & ohci-st drivers

Changes since v2:
 - Based on Arnd Berghman feedback, split out into 2 devices / drivers
 - Base drivers oh ehci-platform.c & ohci-platform.c with required extensions
   to allow possible re-merge in the furture.

Changes since v1:
 - Correct s/OCHI/OHCI/ spelling
 - Improve kconfig help message
 - Various formating / spelling nits identified by Lee Jones
 - Make driver depend on OF & remove node checks in code
 - Use devm_ioremap_resource
 - Remove unnecessary header files

Peter Griffin (5):
  usb: host: ehci-st: Add EHCI support for ST STB devices
  usb: host: ohci-st: Add OHCI driver support for ST STB devices
  usb: host: ehci-st: Add ehci-st devicetree bindings documentation
  usb: host: ohci-st: Add ohci-st devicetree bindings documentation
  MAINTAINERS: Add ehci-st.c and ohci-st.c to ARCH/STI architecture

 Documentation/devicetree/bindings/usb/ehci-st.txt |  39 +++
 Documentation/devicetree/bindings/usb/ohci-st.txt |  37 +++
 MAINTAINERS   |   2 +
 drivers/usb/host/Kconfig  |   8 +
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/ehci-st.c| 375 ++
 drivers/usb/host/ohci-st.c| 349 
 7 files changed, 811 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-st.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-st.txt
 create mode 100644 drivers/usb/host/ehci-st.c
 create mode 100644 drivers/usb/host/ohci-st.c

-- 
1.9.1

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


[PATCH v6 2/5] usb: host: ohci-st: Add OHCI driver support for ST STB devices

2014-09-08 Thread Peter Griffin
This patch adds the glue code required to ensure the on-chip OHCI
controller works on STi consumer electronics SoC's from STMicroelectronics.

It mainly manages the setting and enabling of the relevant clocks and manages
the reset / power signals to the IP block.

Signed-off-by: Peter Griffin 
---
 drivers/usb/host/Kconfig   |   8 ++
 drivers/usb/host/Makefile  |   1 +
 drivers/usb/host/ohci-st.c | 349 +
 3 files changed, 358 insertions(+)
 create mode 100644 drivers/usb/host/ohci-st.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 82800a7..609efe2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -761,6 +761,14 @@ config USB_HCD_SSB
 
  If unsure, say N.
 
+config USB_HCD_ST
+   tristate "ST USB driver for ST SoC Series"
+   depends on ARCH_STI && OF
+   select GENERIC_PHY
+   help
+ Enable support for the on-chip OHCI & EHCI controller found on
+ STMicroelectronics consumer electronics SoC's.
+
 config USB_HCD_TEST_MODE
bool "HCD test mode support"
---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 144c038..ae2db0b 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o
 obj-$(CONFIG_USB_FUSBH200_HCD) += fusbh200-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)  += fotg210-hcd.o
 obj-$(CONFIG_USB_MAX3421_HCD)  += max3421-hcd.o
+obj-$(CONFIG_USB_HCD_ST)   += ehci-st.o ohci-st.o
diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
new file mode 100644
index 000..df9028e
--- /dev/null
+++ b/drivers/usb/host/ohci-st.c
@@ -0,0 +1,349 @@
+/*
+ * ST OHCI driver
+ *
+ * Copyright (C) 2014 STMicroelectronics – All Rights Reserved
+ *
+ * Author: Peter Griffin 
+ *
+ * Derived from ohci-platform.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ohci.h"
+
+#define USB_MAX_CLKS 3
+
+struct st_ohci_platform_priv {
+   struct clk *clks[USB_MAX_CLKS];
+   struct clk *clk48;
+   struct reset_control *rst;
+   struct reset_control *pwr;
+   struct phy *phy;
+};
+
+#define DRIVER_DESC "OHCI STMicroelectronics driver"
+
+#define hcd_to_ohci_priv(h) \
+   ((struct st_ohci_platform_priv *)hcd_to_ohci(h)->priv)
+
+static const char hcd_name[] = "ohci-st";
+
+static int st_ohci_platform_power_on(struct platform_device *dev)
+{
+   struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct st_ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
+   int clk, ret;
+
+   ret = reset_control_deassert(priv->pwr);
+   if (ret)
+   return ret;
+
+   ret = reset_control_deassert(priv->rst);
+   if (ret)
+   goto err_assert_power;
+
+   /* some SoCs don't have a dedicated 48Mhz clock, but those that do
+  need the rate to be explicitly set */
+   if (priv->clk48) {
+   ret = clk_set_rate(priv->clk48, 4800);
+   if (ret)
+   goto err_assert_reset;
+   }
+
+   for (clk = 0; clk < USB_MAX_CLKS && priv->clks[clk]; clk++) {
+   ret = clk_prepare_enable(priv->clks[clk]);
+   if (ret)
+   goto err_disable_clks;
+   }
+
+   ret = phy_init(priv->phy);
+   if (ret)
+   goto err_disable_clks;
+
+   ret = phy_power_on(priv->phy);
+   if (ret)
+   goto err_exit_phy;
+
+   return 0;
+
+err_exit_phy:
+   phy_exit(priv->phy);
+err_disable_clks:
+   while (--clk >= 0)
+   clk_disable_unprepare(priv->clks[clk]);
+err_assert_reset:
+   reset_control_assert(priv->rst);
+err_assert_power:
+   reset_control_assert(priv->pwr);
+
+   return ret;
+}
+
+static void st_ohci_platform_power_off(struct platform_device *dev)
+{
+   struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct st_ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
+
+   int clk;
+
+   reset_control_assert(priv->pwr);
+
+   reset_control_assert(priv->rst);
+
+   phy_power_off(priv->phy);
+
+   phy_exit(priv->phy);
+
+   for (clk = USB_MAX_CLKS - 1; clk >= 0; clk--)
+   if (priv->clks[clk])
+   clk_disable_unprepare(priv->clks[clk]);
+}
+
+static struct hc_driver __read_mostly ohci_platform_hc_driver;
+
+static const struct ohci_driver_overrides platform_overrides __initconst = {
+   .product_desc = "ST OHCI controller",
+   .extra_priv_size =  sizeof(struct st_ohci_platform_priv),
+};
+
+static struct usb_ohci_pdata ohci_platform_defaults = {
+   .power_on = st

[PATCH v6 4/5] usb: host: ohci-st: Add ohci-st devicetree bindings documentation

2014-09-08 Thread Peter Griffin
This patch documents the device tree bindings required for
the ohci on-chip controller found in ST consumer electronics SoC's.

Signed-off-by: Peter Griffin 
---
 Documentation/devicetree/bindings/usb/ohci-st.txt | 37 +++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-st.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-st.txt 
b/Documentation/devicetree/bindings/usb/ohci-st.txt
new file mode 100644
index 000..6d83937
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-st.txt
@@ -0,0 +1,37 @@
+ST USB OHCI controller
+
+Required properties:
+
+ - compatible  : must be "st,st-ohci-300x"
+ - reg : physical base addresses of the controller and length 
of memory mapped
+ region
+ - interrupts  : one OHCI controller interrupt should be described here
+ - clocks  : phandle list of usb clocks
+ - clock-names : should be "ic" for interconnect clock and "clk48"
+See: Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+ - phys: phandle for the PHY device
+ - phy-names   : should be "usb"
+
+ - resets  : phandle to the powerdown and reset controller for the 
USB IP
+ - reset-names : should be "power" and "softreset".
+See: Documentation/devicetree/bindings/reset/st,sti-powerdown.txt
+See: Documentation/devicetree/bindings/reset/reset.txt
+
+Example:
+
+   ohci0: usb@0xfe1ffc00 {
+   compatible = "st,st-ohci-300x";
+   reg = <0xfe1ffc00 0x100>;
+   interrupts = ;
+   clocks = <&clk_s_a1_ls 0>,
+<&clockgen_b0 0>;
+   clock-names = "ic", "clk48";
+   phys = <&usb2_phy>;
+   phy-names = "usb";
+   status = "okay";
+
+   resets = <&powerdown STIH416_USB0_POWERDOWN>,
+<&softreset STIH416_USB0_SOFTRESET>;
+   reset-names = "power", "softreset";
+   };
-- 
1.9.1

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


[PATCH v6 1/5] usb: host: ehci-st: Add EHCI support for ST STB devices

2014-09-08 Thread Peter Griffin
This patch adds the glue code required to ensure the on-chip EHCI
controller works on STi consumer electronics SoC's from STMicroelectronics.

It mainly manages the setting and enabling of the relevant clocks and manages
the reset / power signals to the IP block.

Signed-off-by: Peter Griffin 
---
 drivers/usb/host/ehci-st.c | 375 +
 1 file changed, 375 insertions(+)
 create mode 100644 drivers/usb/host/ehci-st.c

diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
new file mode 100644
index 000..7e4bd39
--- /dev/null
+++ b/drivers/usb/host/ehci-st.c
@@ -0,0 +1,375 @@
+/*
+ * ST EHCI driver
+ *
+ * Copyright (C) 2014 STMicroelectronics – All Rights Reserved
+ *
+ * Author: Peter Griffin 
+ *
+ * Derived from ehci-platform.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define USB_MAX_CLKS 3
+
+struct st_ehci_platform_priv {
+   struct clk *clks[USB_MAX_CLKS];
+   struct clk *clk48;
+   struct reset_control *rst;
+   struct reset_control *pwr;
+   struct phy *phy;
+};
+
+#define DRIVER_DESC "EHCI STMicroelectronics driver"
+
+#define hcd_to_ehci_priv(h) \
+   ((struct st_ehci_platform_priv *)hcd_to_ehci(h)->priv)
+
+static const char hcd_name[] = "ehci-st";
+
+#define EHCI_CAPS_SIZE 0x10
+#define AHB2STBUS_INSREG01 (EHCI_CAPS_SIZE + 0x84)
+
+static int st_ehci_platform_reset(struct usb_hcd *hcd)
+{
+   struct platform_device *pdev = to_platform_device(hcd->self.controller);
+   struct usb_ehci_pdata *pdata = dev_get_platdata(&pdev->dev);
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   int retval;
+   u32 threshold;
+
+   /* Set EHCI packet buffer IN/OUT threshold to 128 bytes */
+   threshold = 128 | (128 << 16);
+   writel(threshold, hcd->regs + AHB2STBUS_INSREG01);
+
+   ehci->caps = hcd->regs + pdata->caps_offset;
+   retval = ehci_setup(hcd);
+   if (retval)
+   return retval;
+
+   return 0;
+}
+
+static int st_ehci_platform_power_on(struct platform_device *dev)
+{
+   struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct st_ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
+   int clk, ret;
+
+   ret = reset_control_deassert(priv->pwr);
+   if (ret)
+   return ret;
+
+   ret = reset_control_deassert(priv->rst);
+   if (ret)
+   goto err_assert_power;
+
+   /* some SoCs don't have a dedicated 48Mhz clock, but those that do
+  need the rate to be explicitly set */
+   if (priv->clk48) {
+   ret = clk_set_rate(priv->clk48, 4800);
+   if (ret)
+   goto err_assert_reset;
+   }
+
+   for (clk = 0; clk < USB_MAX_CLKS && priv->clks[clk]; clk++) {
+   ret = clk_prepare_enable(priv->clks[clk]);
+   if (ret)
+   goto err_disable_clks;
+   }
+
+   ret = phy_init(priv->phy);
+   if (ret)
+   goto err_disable_clks;
+
+   ret = phy_power_on(priv->phy);
+   if (ret)
+   goto err_exit_phy;
+
+   return 0;
+
+err_exit_phy:
+   phy_exit(priv->phy);
+err_disable_clks:
+   while (--clk >= 0)
+   clk_disable_unprepare(priv->clks[clk]);
+err_assert_reset:
+   reset_control_assert(priv->rst);
+err_assert_power:
+   reset_control_assert(priv->pwr);
+
+   return ret;
+}
+
+static void st_ehci_platform_power_off(struct platform_device *dev)
+{
+   struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct st_ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
+   int clk;
+
+   reset_control_assert(priv->pwr);
+
+   reset_control_assert(priv->rst);
+
+   phy_power_off(priv->phy);
+
+   phy_exit(priv->phy);
+
+   for (clk = USB_MAX_CLKS - 1; clk >= 0; clk--)
+   if (priv->clks[clk])
+   clk_disable_unprepare(priv->clks[clk]);
+
+}
+
+static struct hc_driver __read_mostly ehci_platform_hc_driver;
+
+static const struct ehci_driver_overrides platform_overrides __initconst = {
+   .reset =st_ehci_platform_reset,
+   .extra_priv_size =  sizeof(struct st_ehci_platform_priv),
+};
+
+static struct usb_ehci_pdata ehci_platform_defaults = {
+   .power_on = st_ehci_platform_power_on,
+   .power_suspend =st_ehci_platform_power_off,
+   .power_off =st_ehci_platform_power_off,
+};
+
+static int st_ehci_platform_probe(struct platform_device *dev)
+{
+   struct usb_hcd *hcd;
+   struct resource *res_mem;
+   struct usb_ehci_pdata *pdata = &ehci_platform_defaults;
+   str

Re: [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-08 Thread Johan Hovold
On Mon, Sep 08, 2014 at 01:32:33PM +0200, Johan Hovold wrote:
> On Fri, Sep 05, 2014 at 06:17:57PM +0300, Octavian Purdila wrote:

> > +static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
> > + void *obuf, int obuf_len, void *ibuf, int *ibuf_len)
> > +{



> > +   /* if we got here we know that the response header has been checked */
> > +   rsp = rxc->urb->transfer_buffer;
> > +   result = le16_to_cpu(rsp->result);
> 
> Yes, but you haven't verified that rsp->hdr.size > 0, so you may still
> be reading stale data.

I meant that you haven't verified that the payload size > 1 (the header
size is included in rsp->hdr.size and result is two byte wide).

> > +
> > +   if (result) {
> > +   dev_dbg(dev, "%d received response with error %d\n",
> > +   handle, result);
> > +   ret = -EREMOTEIO;
> > +   goto out_free_rx_slot;
> > +   }
> > +
> > +   if (!ibuf) {
> > +   ret = 0;
> > +   goto out_free_rx_slot;
> > +   }
> > +
> > +   if (*ibuf_len > rxc->urb->actual_length - sizeof(*rsp))
> > +   *ibuf_len = rxc->urb->actual_length - sizeof(*rsp);
> 
> And then you get an underflow here, although that doesn't seem to cause
> any troubles in this case.

Unless ibuf_len is -1... 

> But why isn't ibuf_len unsigned?
>
> > +
> > +   memcpy(ibuf, rsp + 1, *ibuf_len);
> > +
> > +out_free_rx_slot:
> > +   free_rx_slot(dln2, rxs, rx_slot);
> > +
> > +   return ret;
> > +}

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


[no subject]

2014-09-08 Thread ®®®


Sehr geehrte Begünstigte,

Sie haben als einzige Begünstigte der Summe von fünfhunderttausend Euro (€ 
500.000,00 Euro), die hier in WESTERN UNION OFFICE von der ONU Organisation für 
Sie hinterlegt ausgewählt wurde.

Bitte kontaktieren Sie uns für Ansprüche Email: wes_sp...@outlook.com

Kundendienst
Western Union Office®
--
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


[no subject]

2014-09-08 Thread ®®®


Sehr geehrte Begünstigte,

Sie haben als einzige Begünstigte der Summe von fünfhunderttausend Euro (€ 
500.000,00 Euro), die hier in WESTERN UNION OFFICE von der ONU Organisation für 
Sie hinterlegt ausgewählt wurde.

Bitte kontaktieren Sie uns für Ansprüche Email: wes_sp...@outlook.com

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


Re: [PATCH v6 0/5] Add EHCI and OHCI drivers for STi SoC's

2014-09-08 Thread Arnd Bergmann
On Monday 08 September 2014 13:04:43 Peter Griffin wrote:
> I believe all feedback has been incorporated, and this series has also been 
> rebased on
> 3.17-rc3.
> 
> It was re-worked from v2 onwards to split out the ehci and ohci parts
> into their own drivers / devices like most other ARM platforms based on
> feedback from Arnd Bergmann (see here 
> http://www.spinics.net/lists/linux-usb/msg24.html. 
> 
> The ehci-platform & ohci-platform have been used as a basis for this in case 
> we
> wish to merge the drivers again in the future.
> 

Looks good to me. Whole series

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


Re: [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-08 Thread Octavian Purdila
On Mon, Sep 8, 2014 at 2:32 PM, Johan Hovold  wrote:
>
> On Fri, Sep 05, 2014 at 06:17:57PM +0300, Octavian Purdila wrote:
> > This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
> > Master Adapter DLN-2. Details about the device can be found here:
> >

>
> First of all, this is much cleaner than the first non-MFD version. I'll
> have a look at the subdrivers shortly as well.
>

Hi Johan,

I have addressed all you comments except one, please see bellow. I
will wait for the review on the subdrivers before submitting a new
version of the patch set. Thanks for for review !


> > +static bool find_free_slot(struct dln2_mod_rx_slots *rxs, int *slot)
> > +{
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&rxs->lock, flags);
> > +
> > + *slot = find_first_zero_bit(&rxs->bmap, DLN2_MAX_RX_SLOTS);
> > +
> > + if (*slot < DLN2_MAX_RX_SLOTS) {
> > + struct dln2_rx_context *rxc = &rxs->slots[*slot];
> > +
> > + init_completion(&rxc->done);
>
> Initialise the completions when you allocate them (and there's no need
> to re-init here).
>

You are right, but I think we need a reinit_completion(). Technically
we don't, as we don't use complete_all(), but I feel it is cleaner
that way. I will move the initialization in probe and add the
reinit_completion() in free_rx_slot. Is that OK with you?
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-08 Thread Lee Jones
On Mon, 08 Sep 2014, Octavian Purdila wrote:
> On Mon, Sep 8, 2014 at 2:32 PM, Johan Hovold  wrote:
> >
> > On Fri, Sep 05, 2014 at 06:17:57PM +0300, Octavian Purdila wrote:
> > > This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
> > > Master Adapter DLN-2. Details about the device can be found here:
> > >
> 
> >
> > First of all, this is much cleaner than the first non-MFD version. I'll
> > have a look at the subdrivers shortly as well.
> >
> 
> Hi Johan,
> 
> I have addressed all you comments except one, please see bellow. I
> will wait for the review on the subdrivers before submitting a new
> version of the patch set. Thanks for for review !

No, please don't.  Fix-up and resubmit.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 0/7] usb: gadget: add reset API at usb_gadget_driver

2014-09-08 Thread Felipe Balbi
On Sat, Sep 06, 2014 at 12:09:22AM +, Peter Chen wrote:
>  
> > On Fri, Sep 05, 2014 at 08:44:08AM +0800, Peter Chen wrote:
> > > On Thu, Sep 04, 2014 at 11:04:38AM -0400, Alan Stern wrote:
> > > > On Thu, 4 Sep 2014, Peter Chen wrote:
> > > >
> > > > > Hi Felipe & Alan, how about using below steps for this
> > > > > reset/vbus/pullup changes? It mainly uses Alan's suggestion.
> > > > >
> > > > > Step 1:
> > > > >   The initial implementation in the four gadget
> > > > >   drivers can be very simple: It calls the disconnect handler.
> > > > >   the ->reset is mandatory for all gadget drivers (currently,
> > > > >   only four, they are composite, configfs, gadgetfs , dbgp.
> > > > > Step 2:
> > > > >   Add routines to udc-core to handle Vbus changes, function
> > > > >   activation changes, and resets. It will include three sub-steps,
> > > > >   from easy to hard: reset handler, vbus handler, and activation
> > > > >   handler.
> > > >
> > > > Perhaps the activation handler can be delayed until step 4.  It
> > > > won't get used until composite.c is modified to call it.
> > > >
> > > > > Step 3:
> > > > >   Modify all UDCs to call udc-core's reset and vbus handler, 
> > > > > delete
> > > > >   usb_gadget_connect/usb_gadget_disconnect operation at all UDC
> > drivers,
> > > > >   and delete invoking usb_gadget_connect unconditional at
> > > > > udc_bind_to_driver Step 4:
> > > > >   Modify the composite.c to disable pullup for adding every 
> > > > > function, and
> > > > >   enable pullup when necessary.
> > > >
> > > > Actually, composite.c should be modified to call the activation
> > > > handler in udc-core, and then _that_ routine would adjust the pullup
> > > > as necessary.
> > > >
> > > > This plan is okay with me.
> > > >
> > >
> > > OK, let's put the function activation change to the last. If the
> > > Felipe has no other comments, I will send the patch for step one next
> > Monday.
> > 
> > Please do, the thread already has too much information and we better put all
> > that in code. Keep in mind that me and Alan have resurected an old patchset
> > adding ->reset() callback to the gadget framework. If you want to take a 
> > look
> > it's at [1]
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/log/?h=gadget-add-
> > reset-method
> > 
> 
> Thanks, Felipe.
> 
> It still takes gadget driver's ->reset as optional, but we want to
> take it as mandatory per our discussion.

right, I was going to change that but since you're already working on it
I figured you might prefer doing it all yourself :-)

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH RESEND v3 01/12] usb: dwc2/gadget: fix phy disable sequence

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 10:42:19AM +0200, Robert Baldyga wrote:
> On 09/04/2014 09:49 PM, Felipe Balbi wrote:
> > Hi,
> > 
> > On Thu, Sep 04, 2014 at 07:37:20PM +, Paul Zimmerman wrote:
> >>> From: Felipe Balbi [mailto:ba...@ti.com]
> >>> Sent: Thursday, September 04, 2014 12:18 PM
> >>>
> >>> On Thu, Sep 04, 2014 at 12:04:23PM -0700, Paul Zimmerman wrote:
>  From: Kamil Debski 
> 
>  When the driver is removed s3c_hsotg_phy_disable is called three times
>  instead of once. This results in decreasing of the phy reference counter
>  below zero and thus consecutive inserts of the module fails.
> 
>  This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
>  and s3c_hsotg_udc_stop.
> 
>  s3c_hsotg_udc_stop is called from udc-core.c only after
>  usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
>  already calls s3c_hsotg_phy_disable.
> 
>  s3c_hsotg_remove must be called only after udc_stop, so there is no
>  point in disabling phy once again there.
> 
>  Signed-off-by: Kamil Debski 
>  Signed-off-by: Marek Szyprowski 
>  Signed-off-by: Robert Baldyga 
>  Signed-off-by: Paul Zimmerman 
> >>>
> >>> looks like this one deserves a Cc: stable ?
> >>
> >> Good point. Robert, what do you think? Only problem is, this file
> >> moved from drivers/usb/gadget/ to here in 3.16, so earlier stable
> >> versions would require some additional backporting.
> > 
> > Right, you'll receive a notification from Greg that the patch FAILED to
> > apply and all you gotta do is provide a modified patch which, in this
> > case, is just a path modification.
> 
> I can rebase patchset at stable branch and send it separately.
> 
> Felipe, should I rebase only patches you have pointed or rather entire
> patchset?

YBased on my latest comments, you need to figure out if some of these
patches need to be sent for stable too, that would mean you need to add
proper annotation to Cc:  together with which
is the earliest version that suffers from the problem and which commit
introduced the bug. Then you need something like below in your commit
log:

Fixes: $abbreviated_commit (commit log summary)
Cc:  # v3.X+
Signed-off-by: Kamil Debski 
Signed-off-by: Marek Szyprowski 
Signed-off-by: Robert Baldyga 
Signed-off-by: Paul Zimmerman 

Then, you need to resend your series so stable gets those patches.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/4] usb: dwc3: add tracepoints to aid debugging

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 09:30:27AM +0530, Pratyush Anand wrote:
> On Fri, Sep 05, 2014 at 10:56:26PM +0800, Felipe Balbi wrote:
> > When we're debugging hard-to-reproduce and time-sensitive
> > use cases, printk() poses too much overhead. That's when
> > the kernel's tracing infrastructure comes into play.
> > 
> > This patch implements a few initial tracepoints for the
> > dwc3 driver. More traces can be added as necessary in order
> > to ease the task of debugging dwc3.
> > 
> > Reviewed-by: Paul Zimmerman 
> > Signed-off-by: Felipe Balbi 
> > ---
> 
> Reviewed-by: Pratyush Anand 

oh sorry, this patch is already on my 'next' branch. Can't add this note
anymore :-s

-- 
balbi


signature.asc
Description: Digital signature


Re: [RFC v3 1/2] usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 03:39:23PM +0530, Kiran Kumar Raparthy wrote:
> From: Todd Poynor 
> 
> usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode
> 
> Purpose of this is to prevent the system to enter into suspend state from USB
> peripheral traffic by hodling a wakeupsource when USB is connected and
> enumerated in peripheral mode(say adb).
> 
> Disabled by default, can enable with:
>echo Y > /sys/module/otg_wakeupsource/parameters/enabled
> 
> Cc: Felipe Balbi 
> Cc: Greg Kroah-Hartman 
> Cc: linux-ker...@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: Android Kernel Team 
> Cc: John Stultz 
> Cc: Sumit Semwal 
> Cc: Arve Hj�nnev�g 
> Cc: Benoit Goby 
> Signed-off-by: Todd Poynor 
> [kiran: Added context to commit message, squished build fixes
> from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
> to wakeupsource, merged Todd's refactoring logic and simplified
> the structures and code and addressed community feedback]
> Signed-off-by: Kiran Raparthy 
> ---
> v3:
> * As per the feedback,no global phy pointer used.
> * called the one-liner wakeupsource handling calls
>   directly instead of indirect functions implemented in v2.
> * Removed indirect function get_phy_hook and used usb_get_phy
>   to get the phy handle..
> 
> v2:
> * wakeupsource handling implemeted per-PHY
> * Implemented wakeupsource handling calls in phy
> * included Todd's refactoring logic.
> 
> v1:
> * changed to "disabled by default" from "enable by default".
> * Kconfig help text modified
> * Included better commit text
> * otgws_nb moved to otg_wakeupsource_init function
> * Introduced get_phy_hook to handle otgws_xceiv per-PHY
> 
> RFC:
> * Included build fix from Benoit Goby and Arve Hj�nnev�g
> * Removed lock->held field in driver as this mechanism is
>   provided in wakeupsource driver.
> * wakelock(wl) terminology replaced with wakeup_source(ws).
> 
>  drivers/usb/phy/Kconfig|   8 +++
>  drivers/usb/phy/Makefile   |   1 +
>  drivers/usb/phy/otg-wakeupsource.c | 136 
> +
>  include/linux/usb/phy.h|   4 ++
>  4 files changed, 149 insertions(+)
>  create mode 100644 drivers/usb/phy/otg-wakeupsource.c
> 
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index e253fa0..d9ddd85 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -6,6 +6,14 @@ menu "USB Physical Layer drivers"
>  config USB_PHY
>   def_bool n
>  
> +config USB_OTG_WAKEUPSOURCE
> + bool "Hold wakeupsource when USB is enumerated in peripheral mode"
> + depends on PM_SLEEP
> + select USB_PHY
> + help
> +   Prevent the system going into automatic suspend while
> +   it is attached as a USB peripheral by holding a wakeupsource.
> +
>  #
>  # USB Transceiver Drivers
>  #
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index 24a9133..ca2fbaf 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -3,6 +3,7 @@
>  #
>  obj-$(CONFIG_USB_PHY)+= phy.o
>  obj-$(CONFIG_OF) += of.o
> +obj-$(CONFIG_USB_OTG_WAKEUPSOURCE)   += otg-wakeupsource.o
>  
>  # transceiver drivers, keep the list sorted
>  
> diff --git a/drivers/usb/phy/otg-wakeupsource.c 
> b/drivers/usb/phy/otg-wakeupsource.c
> new file mode 100644
> index 000..d9a1720
> --- /dev/null
> +++ b/drivers/usb/phy/otg-wakeupsource.c
> @@ -0,0 +1,136 @@
> +/*
> + * otg-wakeupsource.c
> + *
> + * Copyright (C) 2011 Google, Inc.
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +bool enabled = false;
> +
> +static DEFINE_SPINLOCK(otgws_spinlock);

why do you continue to ignore my comment that this should be built
*into* struct usb_phy so it's a per-PHY setting ? Is this some sort of a
joke that I'm not getting ?

> +static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long 
> event)
> +{
> + unsigned long irqflags;
> +
> + spin_lock_irqsave(&otgws_spinlock, irqflags);
> +
> + if (!enabled) {
> + __pm_relax(&otgws_xceiv->wsource);
> + spin_unlock_irqrestore(&otgws_spinlock, irqflags);
> + return;
> + }
> +
> + switch (event) {
> + case USB_EVENT_VBUS:
> + case USB_EVENT_ENUMERATED:
> + __pm_stay_awake(&otgws_xceiv->wsource);
> + break;
> +
> + case USB_EVENT_NONE:
> + case USB_EVENT_ID:
> + case USB_EVENT_

Re: [RFC v3 2/2] usb: phy: Temporarily hold timed wakeup source on charger and disconnect events

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 03:40:49PM +0530, Kiran Kumar Raparthy wrote:
> From: Todd Poynor 
> 
> usb: phy: Temporarily hold timed wakeup source on charger and disconnect
> events
> 
> It temporarily holds a timed wakeup source on USB disconnect events, to allow
> the rest of the system time to react to the USB disconnection (dropping host
> sessions, updating charger status, etc.) prior to re-allowing suspend
> 
> Cc: Felipe Balbi 
> Cc: Greg Kroah-Hartman 
> Cc: linux-ker...@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: Android Kernel Team 
> Cc: John Stultz 
> Cc: Sumit Semwal 
> Signed-off-by: Todd Poynor 
> [kiran: Added context to commit message and
> addressed community feedback]
> Signed-off-by: Kiran Raparthy 
> ---
> v3:
> * Modified the commit log.
> * Remove indirect function usb_temporary_hold_wsource and call
>   __pm_wakeup_even directly.
> 
> v2:
> * Implement usb_temporary_hold_wsource function in phy.
> 
> v1:
> * Removed the refactoring logic from this integrated into main driver code.
> 
> RFC:
> * Integrated the refactoring logic and logic to hold wakeupsource
>   temporarily.
> 
>  drivers/usb/phy/otg-wakeupsource.c | 3 ++-
>  include/linux/usb/phy.h| 2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/otg-wakeupsource.c 
> b/drivers/usb/phy/otg-wakeupsource.c
> index d9a1720..7bc9657 100644
> --- a/drivers/usb/phy/otg-wakeupsource.c
> +++ b/drivers/usb/phy/otg-wakeupsource.c
> @@ -47,7 +47,8 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, 
> unsigned long event)
>   case USB_EVENT_NONE:
>   case USB_EVENT_ID:
>   case USB_EVENT_CHARGER:
> - __pm_relax(&otgws_xceiv->wsource);
> + __pm_wakeup_event(&otgws_xceiv->wsource,
> + msecs_to_jiffies(TEMPORARY_HOLD_TIME));

this was introduced by patch 1, why don't you merge this with that
patch? This is another comment that I have already provided. Why are you
ignoring my comments ? At a minimum, explain why are you ignoring them.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH stable 1/6] usb: dwc2/gadget: fix phy disable sequence

2014-09-08 Thread Felipe Balbi
On Mon, Sep 08, 2014 at 11:45:27AM +0200, Robert Baldyga wrote:
> From: Kamil Debski 
> 
> When the driver is removed s3c_hsotg_phy_disable is called three times
> instead of once. This results in decreasing of the phy reference counter
> below zero and thus consecutive inserts of the module fails.
> 
> This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
> and s3c_hsotg_udc_stop.
> 
> s3c_hsotg_udc_stop is called from udc-core.c only after
> usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
> already calls s3c_hsotg_phy_disable.
> 
> s3c_hsotg_remove must be called only after udc_stop, so there is no
> point in disabling phy once again there.
> 
> Signed-off-by: Kamil Debski 
> Signed-off-by: Marek Szyprowski 
> Signed-off-by: Robert Baldyga 

you should have received a note from Greg that this is not how you send
patches to be included in Stable, please read
Documentation/stable_kernel_rules.txt

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v6 4/4] phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 09:53:09AM +0530, Vivek Gautam wrote:
> On Fri, Sep 5, 2014 at 11:26 PM, Felipe Balbi  wrote:
> > On Thu, Sep 04, 2014 at 12:01:19PM +0530, Vivek Gautam wrote:
> >> > Don't we have phy_power_on()
> >> > for that ? It looks like you could just as well do this from
> >> > phy_power_on() ?
> >>
> >> No, unfortunately keeping these calibration settings in phy_power_on()
> >> doesn't help, since we need to do this after XHCI reset has happened.
> >
> > teach xHCI about PHYs ?
> 
> sorry i couldn't understand you here.
> Aren't we trying to do the same with Heikki's patch about dwc3 :
> [PATCH 6/6] usb: dwc3: host: convey the PHYs to xhci
> 
> and the 2nd patch in this series :
> [PATCH v6 2/4] usb: host: xhci-plat: Get PHYs for xhci's hcds
> 
> Is there something else that is expected ?

right, use that to call phy_init() at the right time, then you need to
add a new ->calibrate() method which, likely, will only be used by you
;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH RESEND v7 2/2] usb: gadget: f_fs: virtual endpoint address mapping

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 09:57:00AM +0200, Robert Baldyga wrote:
> This patch introduces virtual endpoint address mapping. It separates
> function logic form physical endpoint addresses making it more hardware
> independent.
> 
> Following modifications changes user space API, so to enable them user
> have to switch on the FUNCTIONFS_VIRTUAL_ADDR flag in descriptors.
> 
> Endpoints are now refered using virtual endpoint addresses chosen by
> user in endpoint descpriptors. This applies to each context when endpoint
> address can be used:
> - when accessing endpoint files in FunctionFS filesystemi (in file name),
> - in setup requests directed to specific endpoint (in wIndex field),
> - in descriptors returned by FUNCTIONFS_ENDPOINT_DESC ioctl.
> 
> In endpoint file names the endpoint address number is formatted as
> double-digit hexadecimal value ("ep%02x") which has few advantages -
> it is easy to parse, allows to easly recognize endpoint direction basing
> on its name (IN endpoint number starts with digit 8, and OUT with 0)
> which can be useful for debugging purpose, and it makes easier to introduce
> further features allowing to use each endpoint number in both directions
> to have more endpoints available for function if hardware supports this
> (for example we could have ep01 which is endpoint 1 with OUT direction,
> and ep81 which is endpoint 1 with IN direction).
> 
> Physical endpoint address can be still obtained using ioctl named
> FUNCTIONFS_ENDPOINT_REVMAP, but now it's not neccesary to handle
> USB transactions properly.
> 
> Signed-off-by: Robert Baldyga 
> Acked-by: Michal Nazarewicz 

after this patch I get build errors:

drivers/usb/gadget/function/f_fs.c: In function ‘ffs_epfiles_create’:
drivers/usb/gadget/function/f_fs.c:1555:40: error: ‘struct ffs_data’ has no 
member named ‘eps_addrmap’
sprintf(epfiles->name, "ep%02x", ffs->eps_addrmap[i]);
^
drivers/usb/gadget/function/f_fs.c: In function ‘ffs_func_setup’:
drivers/usb/gadget/function/f_fs.c:2900:19: error: ‘struct ffs_data’ has no 
member named ‘eps_addrmap’
ret = func->ffs->eps_addrmap[ret];
   ^
make[3]: *** [drivers/usb/gadget/function/f_fs.o] Error 1
make[3]: *** Waiting for unfinished jobs
make[2]: *** [drivers/usb/gadget/function] Error 2
make[1]: *** [drivers/usb/gadget] Error 2
make[1]: *** Waiting for unfinished jobs
make: *** [drivers/usb/] Error 2

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-08 Thread Johan Hovold
On Mon, Sep 08, 2014 at 04:20:34PM +0300, Octavian Purdila wrote:
> On Mon, Sep 8, 2014 at 2:32 PM, Johan Hovold  wrote:

> > > +static bool find_free_slot(struct dln2_mod_rx_slots *rxs, int *slot)
> > > +{
> > > + unsigned long flags;
> > > +
> > > + spin_lock_irqsave(&rxs->lock, flags);
> > > +
> > > + *slot = find_first_zero_bit(&rxs->bmap, DLN2_MAX_RX_SLOTS);
> > > +
> > > + if (*slot < DLN2_MAX_RX_SLOTS) {
> > > + struct dln2_rx_context *rxc = &rxs->slots[*slot];
> > > +
> > > + init_completion(&rxc->done);
> >
> > Initialise the completions when you allocate them (and there's no need
> > to re-init here).
> 
> You are right, but I think we need a reinit_completion(). Technically
> we don't, as we don't use complete_all(), but I feel it is cleaner
> that way. I will move the initialization in probe and add the
> reinit_completion() in free_rx_slot. Is that OK with you?

Sure, that's fine. 

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


Re: [PATCH 4/9] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Felipe Balbi
On Mon, Sep 08, 2014 at 11:18:17AM +0300, Laurent Pinchart wrote:
> From: Andrzej Pietrasiewicz 
> 
> Prepare for separate compilation of uvc function's components.
> Some symbols will have to be exported, so rename to avoid
> conflicts with functions of the same name in host uvc.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> Tested-by: Michael Grzeschik 
> [Rename uvc_video_pump and uvc_queue_head as well]
> [Rename forgotten uvc_queue_cancel instance in a comment]
> Signed-off-by: Laurent Pinchart 
> Acked-by: Andrzej Pietrasiewicz 

doesn't apply:

checking file drivers/usb/gadget/function/f_uvc.c
checking file drivers/usb/gadget/function/uvc_queue.c
checking file drivers/usb/gadget/function/uvc_v4l2.c
checking file drivers/usb/gadget/function/uvc_video.c
Hunk #4 FAILED at 195.
Hunk #5 succeeded at 273 with fuzz 2 (offset -1 lines).
Hunk #6 succeeded at 286 (offset -2 lines).
Hunk #7 succeeded at 308 (offset -2 lines).
Hunk #8 FAILED at 324.
Hunk #9 succeeded at 337 (offset -3 lines).
Hunk #10 succeeded at 353 (offset -3 lines).
Hunk #11 succeeded at 369 (offset -3 lines).
Hunk #12 succeeded at 388 (offset -3 lines).
2 out of 12 hunks FAILED

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: zero: Fix warning generated by kbuild

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 04:05:33PM +0530, Amit Virdi wrote:
> The kbuild test bot generated the warning:
>   drivers/usb/gadget/function/f_sourcesink.c:1498: warning: comparison is
>   always false due to limited range of data type
> 
> This patch fixes it.
> 
> Reported-by: kbuild test robot 
> Signed-off-by: Amit Virdi 
> CC: Felipe Balbi 

did you *really* build test this patch ?

drivers/usb/gadget/function/f_sourcesink.c: In function 
‘f_ss_opts_int_interval_store’:
drivers/usb/gadget/function/f_sourcesink.c:1494:2: warning: passing argument 3 
of ‘kstrtou8’ from incompatible pointer type [enabled by default]
  ret = kstrtou8(page, 0, &num);
  ^
In file included from include/asm-generic/bug.h:13:0,
 from ./arch/arm/include/asm/bug.h:61,
 from include/linux/bug.h:4,
 from include/linux/thread_info.h:11,
 from include/asm-generic/preempt.h:4,
 from arch/arm/include/generated/asm/preempt.h:1,
 from include/linux/preempt.h:18,
 from include/linux/spinlock.h:50,
 from include/linux/mmzone.h:7,
 from include/linux/gfp.h:5,
 from include/linux/slab.h:14,
 from drivers/usb/gadget/function/f_sourcesink.c:15:
include/linux/kernel.h:339:41: note: expected ‘u8 *’ but argument is of type 
‘u32 *’
 int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);

-- 
balbi


signature.asc
Description: Digital signature


Re: [RFC v3 1/2] usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 07:48:06PM +0530, Kiran Raparthy wrote:
> On 8 September 2014 19:08, Felipe Balbi  wrote:
> 
> > Hi,
> >
> > On Mon, Sep 08, 2014 at 03:39:23PM +0530, Kiran Kumar Raparthy wrote:
> > > From: Todd Poynor 
> > >
> > > usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode
> > >
> > > Purpose of this is to prevent the system to enter into suspend state
> > from USB
> > > peripheral traffic by hodling a wakeupsource when USB is connected and
> > > enumerated in peripheral mode(say adb).
> > >
> > > Disabled by default, can enable with:
> > >echo Y > /sys/module/otg_wakeupsource/parameters/enabled
> > >
> > > Cc: Felipe Balbi 
> > > Cc: Greg Kroah-Hartman 
> > > Cc: linux-ker...@vger.kernel.org
> > > Cc: linux-usb@vger.kernel.org
> > > Cc: Android Kernel Team 
> > > Cc: John Stultz 
> > > Cc: Sumit Semwal 
> > > Cc: Arve Hj�nnev�g 
> > > Cc: Benoit Goby 
> > > Signed-off-by: Todd Poynor 
> > > [kiran: Added context to commit message, squished build fixes
> > > from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
> > > to wakeupsource, merged Todd's refactoring logic and simplified
> > > the structures and code and addressed community feedback]
> > > Signed-off-by: Kiran Raparthy 
> > > ---
> > > v3:
> > > * As per the feedback,no global phy pointer used.
> > > * called the one-liner wakeupsource handling calls
> > >   directly instead of indirect functions implemented in v2.
> > > * Removed indirect function get_phy_hook and used usb_get_phy
> > >   to get the phy handle..
> > >
> > > v2:
> > > * wakeupsource handling implemeted per-PHY
> > > * Implemented wakeupsource handling calls in phy
> > > * included Todd's refactoring logic.
> > >
> > > v1:
> > > * changed to "disabled by default" from "enable by default".
> > > * Kconfig help text modified
> > > * Included better commit text
> > > * otgws_nb moved to otg_wakeupsource_init function
> > > * Introduced get_phy_hook to handle otgws_xceiv per-PHY
> > >
> > > RFC:
> > > * Included build fix from Benoit Goby and Arve Hj�nnev�g
> > > * Removed lock->held field in driver as this mechanism is
> > >   provided in wakeupsource driver.
> > > * wakelock(wl) terminology replaced with wakeup_source(ws).
> > >
> > >  drivers/usb/phy/Kconfig|   8 +++
> > >  drivers/usb/phy/Makefile   |   1 +
> > >  drivers/usb/phy/otg-wakeupsource.c | 136
> > +
> > >  include/linux/usb/phy.h|   4 ++
> > >  4 files changed, 149 insertions(+)
> > >  create mode 100644 drivers/usb/phy/otg-wakeupsource.c
> > >
> > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> > > index e253fa0..d9ddd85 100644
> > > --- a/drivers/usb/phy/Kconfig
> > > +++ b/drivers/usb/phy/Kconfig
> > > @@ -6,6 +6,14 @@ menu "USB Physical Layer drivers"
> > >  config USB_PHY
> > >   def_bool n
> > >
> > > +config USB_OTG_WAKEUPSOURCE
> > > + bool "Hold wakeupsource when USB is enumerated in peripheral mode"
> > > + depends on PM_SLEEP
> > > + select USB_PHY
> > > + help
> > > +   Prevent the system going into automatic suspend while
> > > +   it is attached as a USB peripheral by holding a wakeupsource.
> > > +
> > >  #
> > >  # USB Transceiver Drivers
> > >  #
> > > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> > > index 24a9133..ca2fbaf 100644
> > > --- a/drivers/usb/phy/Makefile
> > > +++ b/drivers/usb/phy/Makefile
> > > @@ -3,6 +3,7 @@
> > >  #
> > >  obj-$(CONFIG_USB_PHY)+= phy.o
> > >  obj-$(CONFIG_OF) += of.o
> > > +obj-$(CONFIG_USB_OTG_WAKEUPSOURCE)   += otg-wakeupsource.o
> > >
> > >  # transceiver drivers, keep the list sorted
> > >
> > > diff --git a/drivers/usb/phy/otg-wakeupsource.c
> > b/drivers/usb/phy/otg-wakeupsource.c
> > > new file mode 100644
> > > index 000..d9a1720
> > > --- /dev/null
> > > +++ b/drivers/usb/phy/otg-wakeupsource.c
> > > @@ -0,0 +1,136 @@
> > > +/*
> > > + * otg-wakeupsource.c
> > > + *
> > > + * Copyright (C) 2011 Google, Inc.
> > > + *
> > > + * This software is licensed under the terms of the GNU General Public
> > > + * License version 2, as published by the Free Software Foundation, and
> > > + * may be copied, distributed, and modified under those terms.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > + * GNU General Public License for more details.
> > > + *
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +
> > > +bool enabled = false;
> > > +
> > > +static DEFINE_SPINLOCK(otgws_spinlock);
> >
> > why do you continue to ignore my comment that this should be built
> > *into* struct usb_phy so it's a per-PHY setting ? Is this some sort of a
> > joke that I'm n

Re: [PATCH 3/5] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls

2014-09-08 Thread Kishon Vijay Abraham I
Hi Tony,

On Thursday 04 September 2014 10:37 PM, Tony Lindgren wrote:
> * Kishon Vijay Abraham I  [140904 06:51]:
>> Hi Tony,
>>
>> On Thursday 28 August 2014 04:58 AM, Tony Lindgren wrote:
>>> We don't need twl4030_phy_power() any longer now that we have
>>> the runtime PM calls. Let's get rid of it as it's confusing.
>>> No functional changes, just move the code and use res instead
>>> of ret as we are not returning that value.
>>
>> Now that you are doing pm_runtime_get_sync in twl4030_phy_init, won't it 
>> power
>> on the phy even before initializing it (since runtime_resume will be invoked
>> even before doing phy_init)?
> 
> Yes. The logic being that it should not matter as we are not
> configuring the phy until in twl4030_phy_power_on(). Maybe we
> should add code to make sure the phy is deconfigured initially
> though :)
> 
> In twl4030_phy_init() we just want to check the ID pin state to get
> things right initially. In the twl4030-usb case the I2C chip is
> always on, but let's try to get the runtime PM set up like any
> standard Linux driver would do it to avoid confusion.
> 
>> Even if pm_runtime_get_sync in not done in twl4030_phy_init, phy-core itself
>> does pm_runtime_get_sync in phy_init().
> 
> Hmm OK. Looking at that, looks like we don't neeed any of these
> custom exports though:
> 
> $ git grep phy_pm_runtime | grep EXPORT_SYMBOL
> drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_get);
> drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync);
> drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_put);
> drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_put_sync);
> drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_allow);
> drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_forbid);
> 
> The reasons why I think we don't need the above at all is:
> 
> 1. We already have a framework for that in Linux runtime PM and we
>can follow the standard Linux runtime PM calls and not proxy
>them in phy-core.c

The reason for adding these are for providing fine grained control of the PHY
by the controller drivers. In most cases the controller driver determines when
the PHY should be active or idle.
> 
> 2. We can allow idling the phy properly on the bus it's connected
>to, in this case I2C, even if USB driver is not loaded. We
>eventually should idle the phy even if usb_add_phy_dev()
>failed

yes.. that's why we have ops like phy_power_on to tell when the PHY should be
active. So these PHYs can be idled in probe.
> 
> 3. There's no actual need for phy-core.c to proxy the runtime
>PM calls
> 
> So we can and should just let the phy drivers do their own runtime PM
> as needed based on just the phy init, power_on and power_off calls.
> 
> Probably the same goes for the regulator_enable in phy-core.c. That
> should be handled in the phy driver as phy-core is already unable
> to handle it properly. For example, for phy-twl4030-usb.c we have
> three regulators to deal with and the phy framework won't have any
> idea how to deal with those.

hmm.. It was modelled for basic PHY drivers that have a single regulator (e.g.,
TI PIPE3 PHY). The idea is not to duplicate getting and enabling regulator in
each of the PHY drivers when it can be abstracted in phy-core.

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


Re: [PATCH stable 3.12.y] usb: host: ohci-spear: fix ohci_dump parameters

2014-09-08 Thread Alan Stern
On Sun, 7 Sep 2014, Vincent Stehlé wrote:

> Commit 6a04d05acfb51355 ("USB: OHCI: fix bugs in debug routines") has removed
> the unused `verbose' argument of the debug function ohci_dump(); adapt
> ohci-spear accordingly.
> 
> This fixes the following compilation error:
> 
>   drivers/usb/host/ohci-spear.c: In function ‘ohci_spear_start’:
>   drivers/usb/host/ohci-spear.c:56:2: error: too many arguments to function 
> ‘ohci_dump’
> 
> Signed-off-by: Vincent Stehlé 
> Cc: Alan Stern 
> Cc: Greg Kroah-Hartman 
> Cc: Jiri Slaby 
> ---
> 
> Hi,
> 
> This can be seen with Linux v3.12.28, arm allmodconfig.
> 
> And FWIW, it means `DEBUG' is defined in ohci-spear.c for arm allmodconfig.
> 
> Best regards,
> 
> V.
> 
>  drivers/usb/host/ohci-spear.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
> index cc9dd9e..45f8773 100644
> --- a/drivers/usb/host/ohci-spear.c
> +++ b/drivers/usb/host/ohci-spear.c
> @@ -53,7 +53,7 @@ static int ohci_spear_start(struct usb_hcd *hcd)
>   create_debug_files(ohci);
>  
>  #ifdef DEBUG
> - ohci_dump(ohci, 1);
> + ohci_dump(ohci);
>  #endif
>   return 0;
>  }

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 v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-08 Thread Johan Hovold
On Fri, Sep 05, 2014 at 06:17:58PM +0300, Octavian Purdila wrote:
> From: Laurentiu Palcu 
> 
> This patch adds support for the Diolan DLN-2 I2C master module. Due
> to hardware limitations it does not support SMBUS quick commands.
> 
> Information about the USB protocol interface can be found in the
> Programmer's Reference Manual [1], see section 6.2.2 for the I2C
> master module commands and responses.
> 
> [1] https://www.diolan.com/downloads/dln-api-manual.pdf
> 
> Signed-off-by: Laurentiu Palcu 
> Signed-off-by: Octavian Purdila 
> ---
>  drivers/i2c/busses/Kconfig|  10 ++
>  drivers/i2c/busses/Makefile   |   1 +
>  drivers/i2c/busses/i2c-dln2.c | 301 
> ++
>  3 files changed, 312 insertions(+)
>  create mode 100644 drivers/i2c/busses/i2c-dln2.c
> 
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 2ac87fa..4873161 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -1021,4 +1021,14 @@ config SCx200_ACB
> This support is also available as a module.  If so, the module
> will be called scx200_acb.
>  
> +config I2C_DLN2
> +   tristate "Diolan DLN-2 USB I2C adapter"
> +   depends on USB && MFD_DLN2

MFD_DLN2 should be sufficient.

> +   help
> + If you say yes to this option, support will be included for Diolan
> + DLN2, a USB to I2C interface.
> +
> + This driver can also be built as a module.  If so, the module
> + will be called i2c-dln2.
> +
>  endmenu
> diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> index 49bf07e..3118fea 100644
> --- a/drivers/i2c/busses/Makefile
> +++ b/drivers/i2c/busses/Makefile
> @@ -100,5 +100,6 @@ obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
>  obj-$(CONFIG_I2C_PCA_ISA)+= i2c-pca-isa.o
>  obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
>  obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
> +obj-$(CONFIG_I2C_DLN2)   += i2c-dln2.o
>  
>  ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
> diff --git a/drivers/i2c/busses/i2c-dln2.c b/drivers/i2c/busses/i2c-dln2.c
> new file mode 100644
> index 000..93e85ff
> --- /dev/null
> +++ b/drivers/i2c/busses/i2c-dln2.c
> @@ -0,0 +1,301 @@
> +/*
> + * Driver for the Diolan DLN-2 USB-I2C adapter
> + *
> + * Copyright (c) 2014 Intel Corporation
> + *
> + * Derived from:
> + *  i2c-diolan-u2c.c
> + *  Copyright (c) 2010-2011 Ericsson AB
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +

No newline.

> +#include 
> +#include 
> +
> +#define DRIVER_NAME  "dln2-i2c"
> +
> +#define DLN2_I2C_MODULE_ID   0x03
> +#define DLN2_I2C_CMD(cmd)DLN2_CMD(cmd, DLN2_I2C_MODULE_ID)
> +
> +/* I2C commands */
> +#define DLN2_I2C_GET_PORT_COUNT  DLN2_I2C_CMD(0x00)
> +#define DLN2_I2C_ENABLE  DLN2_I2C_CMD(0x01)
> +#define DLN2_I2C_DISABLE DLN2_I2C_CMD(0x02)
> +#define DLN2_I2C_IS_ENABLED  DLN2_I2C_CMD(0x03)
> +#define DLN2_I2C_SET_FREQUENCY   DLN2_I2C_CMD(0x04)
> +#define DLN2_I2C_GET_FREQUENCY   DLN2_I2C_CMD(0x05)
> +#define DLN2_I2C_WRITE   DLN2_I2C_CMD(0x06)
> +#define DLN2_I2C_READDLN2_I2C_CMD(0x07)
> +#define DLN2_I2C_SCAN_DEVICESDLN2_I2C_CMD(0x08)
> +#define DLN2_I2C_PULLUP_ENABLE   DLN2_I2C_CMD(0x09)
> +#define DLN2_I2C_PULLUP_DISABLE  DLN2_I2C_CMD(0x0A)
> +#define DLN2_I2C_PULLUP_IS_ENABLED   DLN2_I2C_CMD(0x0B)
> +#define DLN2_I2C_TRANSFERDLN2_I2C_CMD(0x0C)
> +#define DLN2_I2C_SET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0D)
> +#define DLN2_I2C_GET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0E)
> +#define DLN2_I2C_GET_MIN_FREQUENCY   DLN2_I2C_CMD(0x40)
> +#define DLN2_I2C_GET_MAX_FREQUENCY   DLN2_I2C_CMD(0x41)
> +
> +#define DLN2_I2C_FREQ_FAST   40
> +#define DLN2_I2C_FREQ_STD10
> +
> +#define DLN2_I2C_MAX_XFER_SIZE   256
> +
> +struct dln2_i2c {
> + struct platform_device *pdev;
> + struct i2c_adapter adapter;
> +};
> +
> +static uint frequency = DLN2_I2C_FREQ_STD;   /* I2C clock frequency in Hz */
> +
> +module_param(frequency, uint, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");

These seems like a very bad idea. Why set one common frequency for all
connected USB-I2C devices using a module parameter? That might have made
sense a long time ago with embedded i2c-controller, but certainly does
not with usb-i2c controllers.

This should probably be set through sysfs on a per-device basis.

> +
> +static int dln2_i2c_set_state(struct dln2_i2c *dln2, u8 state)
> +{
> + int ret;
> + u8 port = 0;

So these devices can apparently have more than one i2

Re: [PATCH 4/9] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Andrzej Pietrasiewicz

Hi Felipe,

W dniu 08.09.2014 o 15:51, Felipe Balbi pisze:

On Mon, Sep 08, 2014 at 11:18:17AM +0300, Laurent Pinchart wrote:

From: Andrzej Pietrasiewicz 

Prepare for separate compilation of uvc function's components.
Some symbols will have to be exported, so rename to avoid
conflicts with functions of the same name in host uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Rename uvc_video_pump and uvc_queue_head as well]
[Rename forgotten uvc_queue_cancel instance in a comment]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 


doesn't apply:

checking file drivers/usb/gadget/function/f_uvc.c
checking file drivers/usb/gadget/function/uvc_queue.c
checking file drivers/usb/gadget/function/uvc_v4l2.c
checking file drivers/usb/gadget/function/uvc_video.c
Hunk #4 FAILED at 195.


I think this series depends now on Michael's patch:

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

As far as I know Laurent already has it in his tree:

http://git.linuxtv.org/cgit.cgi/pinchartl/media.git/log/?h=uvc/gadget

AP
--
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_acpi_set_power_state() and usb_queue_reset_device()

2014-09-08 Thread Alan Stern
On Mon, 8 Sep 2014, Oliver Neukum wrote:

> On Fri, 2014-09-05 at 10:15 -0400, Alan Stern wrote:
> > On Fri, 5 Sep 2014, Oliver Neukum wrote:
> > 
> > > Hi,
> > > 
> > > looking at your patch for resetting HID devices
> > > it occurred to me that there's a race between
> > > a queued reset and a port power switch. Switching
> > > a port's power state implies to a reset for for
> > > all interfaces of the device connected to that port.
> > > 
> > > As a reset is quite disruptive it seems to me that
> > > no calling off a queued reset is a bug.
> > > What do you think?
> > 
> > There shouldn't be a race.  We never power-off a port unless the
> > attached device is already runtime suspended.  A runtime-suspended
> > device shouldn't have any pending resets.
> 
> Well, it shouldn't, yet I see no way we are enforcing that rule.
> Actually your patch for usbhid make me think about what happens
> if the device is closed. AFAICT the reset is not cancelled.
> But closing will drop the pm count.

Yes, okay, I suppose that might happen.

> > And even if there is a pending reset, all that will happen is the reset 
> > will cause the port to power up again, and then the reset will occur.
> 
> If and only if the port is still unpowered.

If the port is powered, then:

If the device is runtime-suspended, it will be resumed.

The reset will occur normally.

Perhaps the device will be runtime suspended again.

What's the problem?

> > If you think it would help, the runtime suspend code could be changed
> > to prevent suspends if any queued resets are pending.
> 
> If error handling requires a reset, there's no special likelihood that
> suspend will clear up the issue. It is specific to port power off.

I don't understand what you mean.  Neither suspend nor port power-off 
is meant for handling errors.  We use resets for that purpose.

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 4/9] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Felipe Balbi
HI,

On Mon, Sep 08, 2014 at 04:56:56PM +0200, Andrzej Pietrasiewicz wrote:
> Hi Felipe,
> 
> W dniu 08.09.2014 o 15:51, Felipe Balbi pisze:
> >On Mon, Sep 08, 2014 at 11:18:17AM +0300, Laurent Pinchart wrote:
> >>From: Andrzej Pietrasiewicz 
> >>
> >>Prepare for separate compilation of uvc function's components.
> >>Some symbols will have to be exported, so rename to avoid
> >>conflicts with functions of the same name in host uvc.
> >>
> >>Signed-off-by: Andrzej Pietrasiewicz 
> >>Tested-by: Michael Grzeschik 
> >>[Rename uvc_video_pump and uvc_queue_head as well]
> >>[Rename forgotten uvc_queue_cancel instance in a comment]
> >>Signed-off-by: Laurent Pinchart 
> >>Acked-by: Andrzej Pietrasiewicz 
> >
> >doesn't apply:
> >
> >checking file drivers/usb/gadget/function/f_uvc.c
> >checking file drivers/usb/gadget/function/uvc_queue.c
> >checking file drivers/usb/gadget/function/uvc_v4l2.c
> >checking file drivers/usb/gadget/function/uvc_video.c
> >Hunk #4 FAILED at 195.
> 
> I think this series depends now on Michael's patch:
> 
> http://www.spinics.net/lists/linux-usb/msg111692.html
> 
> As far as I know Laurent already has it in his tree:
> 
> http://git.linuxtv.org/cgit.cgi/pinchartl/media.git/log/?h=uvc/gadget

I applied the series in order and patch 4 didn't apply.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/9] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Andrzej Pietrasiewicz

W dniu 08.09.2014 o 17:03, Felipe Balbi pisze:

HI,






I think this series depends now on Michael's patch:

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

As far as I know Laurent already has it in his tree:

http://git.linuxtv.org/cgit.cgi/pinchartl/media.git/log/?h=uvc/gadget


I applied the series in order and patch 4 didn't apply.



Have you?

$ git log balbi/testing/next | grep -A3 ^Author:.*Grzeschik
Author: Michael Grzeschik 
Date:   Thu Aug 21 16:54:46 2014 +0200

usb: gadget: uvc: remove DRIVER_VERSION{,_NUMBER}
--
Author: Michael Grzeschik 
Date:   Thu Aug 21 16:54:43 2014 +0200

usb: gadget: uvc: Change KERN_INFO to KERN_DEBUG on request shutdown
--
Author: Michael Grzeschik 
Date:   Wed Feb 19 13:41:43 2014 +0800

usb: chipidea: udc: add maximum-speed = full-speed option
--
Author: Michael Grzeschik 
Date:   Thu Feb 13 10:52:03 2014 +0100

serial: omap: fix rs485 probe on defered pinctrl
--
Author: Michael Grzeschik 
Date:   Fri Dec 6 15:56:40 2013 +0100

ARM: i.MX28: dts: rename usbphy pin names

no more patches dated 2014.

AP


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


Re: [PATCH v3 0/9] Tegra xHCI support

2014-09-08 Thread Tomeu Vizoso
On 2 September 2014 23:34, Andrew Bresticker  wrote:
>
> Tested on Venice2, Jetson TK1, and Big with a variety of USB2.0 and
> USB3.0 memory sticks and ethernet dongles using controller firmware
> recently posted by Andrew Chew [2].

I have had mixed results when testing this on a Jetson TK1 board. Of 8
USB devices I tested with, about half where probed correctly, but the
other half repeatedly fail in hub_port_init because in the GET_STATUS
right after the reset, the C_PORT_CONNECTION bit is set.

I don't see any correlation between the failure and the kind of usb
device, but I don't have much experience with USB implementations
either.

Regards,

Tomeu

> Notes:
>  - HSIC support is mostly untested and I think there are still some issues
>to work out there.  I do have a Tegra124 board with a HSIC hub so I'll
>try to sort those out later.
>  - The XUSB padctl driver doesn't play nice with the existing Tegra USB2.0
>PHY driver, so all ports should be assigned to the XHCI controller.
>
> Based on work by:
>   a lot of people, but from what I can tell from the L4T tree [3], the
>   original authors of the Tegra xHCI driver are:
> Ajay Gupta 
> Bharath Yadav 
>
> Chagnes from v2:
>  - Dropped mailbox channel specifier.  The mailbox driver allocates virtual
>channels backed by the single physical channel.
>  - Added support for HS_CURR_LEVEL adjustment pinconfig property, which
>will be required for the Blaze board.
>  - Addressed Stephen's review comments.
>
> Changes from v1:
>  - Converted mailbox driver to use the common mailbox framework.
>  - Fixed up host driver so that it can now be built and used as a module.
>  - Addressed Stephen's review comments.
>  - Misc. cleanups.
>
> Changes from RFC:
>  - Dropped Tegra114 support.
>  - Split out mailbox into separate driver.
>  - Stopped using child xhci-plat device in xHCI host-controller driver.
>  - Added PHY support to Thierry's XUSB padctl driver instead of in a separate
>USB PHY driver.
>  - Added Jetson TK1 support.
>  - Misc. cleanups.
>
> [0] https://lkml.org/lkml/2014/8/1/200
> [1] https://lkml.org/lkml/2014/8/18/504
> [2] https://patchwork.ozlabs.org/patch/384013/
> [3] git://nv-tegra.nvidia.com/linux-3.10.git
>
> Andrew Bresticker (9):
>   of: Add NVIDIA Tegra XUSB mailbox binding
>   mailbox: Add NVIDIA Tegra XUSB mailbox driver
>   of: Update Tegra XUSB pad controller binding for USB
>   pinctrl: tegra-xusb: Add USB PHY support
>   of: Add NVIDIA Tegra xHCI controller binding
>   usb: xhci: Add NVIDIA Tegra xHCI host-controller driver
>   ARM: tegra: Add Tegra124 XUSB mailbox and xHCI controller
>   ARM: tegra: jetson-tk1: Add xHCI support
>   ARM: tegra: venice2: Add xHCI support
>
>  .../bindings/mailbox/nvidia,tegra124-xusb-mbox.txt |   32 +
>  .../pinctrl/nvidia,tegra124-xusb-padctl.txt|   56 +-
>  .../bindings/usb/nvidia,tegra124-xhci.txt  |  104 ++
>  arch/arm/boot/dts/tegra124-jetson-tk1.dts  |   48 +-
>  arch/arm/boot/dts/tegra124-venice2.dts |   79 +-
>  arch/arm/boot/dts/tegra124.dtsi|   41 +
>  drivers/mailbox/Kconfig|3 +
>  drivers/mailbox/Makefile   |2 +
>  drivers/mailbox/tegra-xusb-mailbox.c   |  290 +
>  drivers/pinctrl/Kconfig|1 +
>  drivers/pinctrl/pinctrl-tegra-xusb.c   | 1233 
> +++-
>  drivers/usb/host/Kconfig   |9 +
>  drivers/usb/host/Makefile  |1 +
>  drivers/usb/host/xhci-tegra.c  |  905 ++
>  include/dt-bindings/pinctrl/pinctrl-tegra-xusb.h   |   20 +
>  include/soc/tegra/xusb.h   |   53 +
>  16 files changed, 2796 insertions(+), 81 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/mailbox/nvidia,tegra124-xusb-mbox.txt
>  create mode 100644 
> Documentation/devicetree/bindings/usb/nvidia,tegra124-xhci.txt
>  create mode 100644 drivers/mailbox/tegra-xusb-mailbox.c
>  create mode 100644 drivers/usb/host/xhci-tegra.c
>  create mode 100644 include/soc/tegra/xusb.h
>
> --
> 2.1.0.rc2.206.gedb03e5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Linux xHCI compartmentalization

2014-09-08 Thread Gary Cordelli
Sarah:

Thanks for the prompt response.  It unfortunately confirmed what I expected our 
situation to be.

I am intrigued by one aspect of your response -- that regarding the nature of 
early xHCI driver operation with xHCI 1.0 "integrated" hosts such as those 
produced by Intel.  I am wondering in particular if you had any experience with 
using the Texas Instruments 73x0 host controllers with your driver, and if 
there are any specific issues you can recall using that host device?  My 
understanding, in fact, was that at least some of the Intel devices actually 
supported a USB 2.0-compliant operating mode that allowed them to be used as 
USB 2.0 hosts in environments where USB 3.0 support was not (yet) available in 
the OS.  I currently have an inquiry with TI tech support regarding whether 
such an option exists on the 7320 device.

Ultimately, I believe you highlighted the substantive issues with producing a 
driver by back-porting from 3.x to 2.6.29.  Back-porting even the 2.6.32 driver 
to 2.6.29 required not merely additions to the usb/host area (i.e., the new 
xhci* files), but modifications to existing usb/core files as well -- and the 
ultimate result is spotty operation of USB 2.0 devices on the USB 3.0 ports 
(i.e., sometimes they work, sometimes they crash Linux).  Meanwhile, 
back-porting a 3.x driver to 2.6.29 confronts significant re-factoring changes 
in the entire USB source code tree.

Nevertheless, we may well be facing no viable alternative than to attempt just 
such a back-port while limiting the changes made outside the drivers/usb/host 
scope to the minimum necessary to support the new xHCI host operation.  If you 
are interested, I'll let you know if such a port proves successful.

Thanks again for taking the time to respond to my inquiry.

Gary Cordelli
Embedded Computer Engineer
Mentor Computer Consulting LLC
the embedded computer company

-Original Message-
From: Sarah Sharp [mailto:sarah.a.sh...@linux.intel.com] 
Sent: Friday, September 05, 2014 6:18 PM
To: Gary Cordelli
Cc: linux-usb@vger.kernel.org
Subject: Re: Linux xHCI compartmentalization

On Wed, Sep 03, 2014 at 09:20:28PM +, Gary Cordelli wrote:
> Sarah:
> 
> Thank you for all the great work you put into providing the xHCI driver for 
> USB 3.0 host hardware support in Linux.
> 
> Alas, I am stuck with an installed base of platforms that run a 2.6.29.6 
> kernel that has just absorbed a whole mess of hardware using a different SBC 
> that has a combination of USB 3.0 and USB 2.0 interfaces (where the installed 
> base has all USB 2.0 interfaces).  Ach!  After several tweaks to support the 
> different chipset (GPIO driver, SATA driver, HDA audio driver, and 
> USB2.0-to-serial), I discovered that we could not do without using at least 
> one of the USB 3.0 interfaces.  In looking at the xHCI driver, however, it 
> appears that its tentacles may reach deep into the bowels of Linux - at least 
> looking at recent kernels.
> 
> Do you know if there is a kernel release close to the 2.6.29.6 architecture 
> that you would also consider to include a reasonably stable xHCI 
> implementation?  I have looked at 2.6.32.5 briefly, but was given information 
> that this "experimental" xHCI support is not recommended for use.  Frankly, 
> it does not have to be a full-featured implementation (since we are only 
> trying to reproduce/replace a USB 2.0 capability), but it would hopefully be 
> a stable implementation (no unexpected crashes).  Can you advise?

The xHCI driver wasn't really stable for xHCI 1.0 host controllers (integrated 
hosts like Intel) until the 3.0 kernel.  I would recommend installing one of 
the supported long-term stable kernels like 3.2.

But I really can't help you or support you through backporting those drivers 
from the stable kernel to your ancient 2.6.29.6 kernel.  There are far too many 
changes in the USB core to just do a straight backport of the xHCI driver -- 
and many of those changes are necessary for full xHCI driver support.

If you're on a vanilla stable kernel, the kernel community will happily help 
you debug it.  If not, you're on your own.

> Gary Cordelli
> Embedded Computer Engineer
> Mentor Computer Consulting LLC
> the embedded computer company

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


Re: [PATCH v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-08 Thread Octavian Purdila
On Mon, Sep 8, 2014 at 5:44 PM, Johan Hovold  wrote:



Hi Johan,

Again, thanks for the detailed review, I am addressing your review
comments as we speak. Some questions below.



> > + int ret, len;
> > + struct tx_data {
> > + u8 port;
> > + u8 addr;
> > + u8 mem_addr_len;
> > + __le32 mem_addr;
> > + __le16 buf_len;
> > + u8 buf[DLN2_I2C_MAX_XFER_SIZE];
> > + } __packed tx;
>
> Allocate these buffers dynamically (possibly at probe).
>

I double checked this, and DLN2_I2C_MAX_XFER_SIZE should actually be <
64 as the USB endpoint configuration max packet size is 64. In this
case, can we keep it on the stack?



> > + int ret, buf_len, rx_len = sizeof(rx);
>
> Again, one declaration per line.
>

AFAICS there are many places where declaration on the same line
(initialization included) are used. When did this became a coding
style issue?


Thanks,
Tavi
--
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 v3 2/2] usb: phy: Temporarily hold timed wakeup source on charger and disconnect events

2014-09-08 Thread Sergei Shtylyov

Hello.

On 9/8/2014 2:55 PM, Kiran Raparthy wrote:


From: Todd Poynor mailto:toddpoy...@google.com>>



usb: phy: Temporarily hold timed wakeup source on charger and disconnect
events



No need to duplicate the summary.



It temporarily holds a timed wakeup source on USB disconnect events,
to allow



What "it"?



I was referring to "This patch" ,if required,i can change the terminology.
Regards,
Kiran


   Yes, please. Just write "Temporarily hold ...", no need for a noun.
And please don't send HTML mails to the mailing list (it should bounce them 
anyway).


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 v3 0/9] Tegra xHCI support

2014-09-08 Thread Andrew Bresticker
On Mon, Sep 8, 2014 at 8:34 AM, Tomeu Vizoso  wrote:
> On 2 September 2014 23:34, Andrew Bresticker  wrote:
>>
>> Tested on Venice2, Jetson TK1, and Big with a variety of USB2.0 and
>> USB3.0 memory sticks and ethernet dongles using controller firmware
>> recently posted by Andrew Chew [2].
>
> I have had mixed results when testing this on a Jetson TK1 board. Of 8
> USB devices I tested with, about half where probed correctly, but the
> other half repeatedly fail in hub_port_init because in the GET_STATUS
> right after the reset, the C_PORT_CONNECTION bit is set.
>
> I don't see any correlation between the failure and the kind of usb
> device, but I don't have much experience with USB implementations
> either.

Hmm... I haven't seen that before.  Which particular devices were you using?
--
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: Iomega SCSI-to-USB cable problem

2014-09-08 Thread Mark
Hi,

On Tue, 2 Sep 2014 13:30:31 -0400 (EDT)
Alan Stern  wrote:
>Good, this is very clear.  I'll skip to the interesting parts
>
>> 8801355a29c0 1148408426 S Ci:004:00 s a1 fe   0001 1 <
>> 8801355a29c0 1148410477 C Ci:004:00 0 1 = 10
>
>This is the Get-Max-LUN command.  The device claims to have 17 logical 
>units!  That's an awful lot.  It probably is a bug, meaning the device 
>needs to have the US_FL_SINGLE_LUN quirk.
>
>> 8801355a29c0 1148410844 S Bo:004:01 -115 31 = 55534243 0100 2400 
>> 8612 0024
>>  00
>> 8801355a29c0 1148411469 C Bo:004:01 0 31 >
>> 8801350a59c0 1148411514 S Bi:004:02 -115 36 <
>> 8801350a59c0 1150435754 C Bi:004:02 -32 0
>> 8801355a29c0 1150435882 S Co:004:00 s 02 01  0082  0
>> 8801355a29c0 1150437469 C Co:004:00 0 0
>> 8801355a29c0 1150437569 S Bi:004:02 -115 13 <
>> 8801355a29c0 1150438472 C Bi:004:02 0 13 = 55534253   01
>
>This is the INQUIRY command.  The device fails the command, but worse,
>it uses the wrong tag value in the CSW message.  Maybe that won't
>continue after the US_FL_SINGLE_LUN quirk is added.  But if it does
>then the device needs to have the US_FL_BULK_IGNORE_TAG quirk.

Thanks very much for that! I booted with usb-storage.quirks=059b:0040:s to
enable the single-LUN quirk. No change in dmesg output on connecting the
drive/cable. I also compiled the kernel to add both US_FL_SINGLE_LUN and
US_FL_BULK_IGNORE_TAG quirks. [For that I was using a VirtualBox VM and
had booted the host with the single-LUN quirk.] I can post usbmon logs for
both cases if that would be of interest. (I didn't paste them here to
avoid bloating this message too much; there are other usbmon logs below.)

I noticed a couple of lines in the JAZ USB Adapter manual:
  "When using the Jaz USB Adapter, you cannot connect other devices or
cables to your Jaz drive."
  "NOTE: If you are connecting two Jaz drives via two Jaz USB Adapters to
your computer, set each drive to a different SCSI ID number."

The first point could be a limitation of either the cable firmware or
Iomega's driver software. [There's also a physical limitation; with an
external Jaz drive, you can't plug a cable into the other connector when
the SCSI-USB cable is connected, because the connectors are too close.]
Presumably the second point relates to Iomega's Windows driver.

I managed to find an old Jaz drive and tested it with my cable. It seems
to work fine, so the cable firmware does restrict itself to working with
Jaz drives. I had the drive SCSI ID set to 4, so it seems the firmware
scans the bus and talks to the first(?) Jaz drive it sees.

However there were still four messages saying "usb 7-1: reset full speed
USB device number 2 using uhci_hcd" in dmesg output. But the drive could
be accessed, INQUIRY returned sensible data etc. Those reset messages
didn't appear on booting with the single-LUN quirk. Take a look at the
usbmon logs below. So it seems the Iomega SCSI-USB cable needs
US_FL_SINGLE_LUN.

I also tried having another (non-Jaz) drive in the SCSI chain, with both
US_FL_SINGLE_LUN and US_FL_SCM_MULT_TARG quirks. (US_FL_SCM_MULT_TARG is
required for other Shuttle/SCM SCSI-USB devices to work with multiple
drives in the chain.) Only the Jaz drive could be accessed. I have yet to
try having two Jaz drives in the SCSI chain. My guess is, only one will be
accessible.


usbmon with Jaz drive, no quirk:
880134d4aa80 1019591802 S Ci:7:001:0 s a3 00  0001 0004 4 <
880134d4aa80 1019591832 C Ci:7:001:0 0 4 = 01010100
880134d4aa80 1019591838 S Co:7:001:0 s 23 01 0010 0001  0
880134d4aa80 1019591846 C Co:7:001:0 0 0
880134d4aa80 1019591850 S Ci:7:001:0 s a3 00  0002 0004 4 <
880134d4aa80 1019591860 C Ci:7:001:0 0 4 = 0001
8801356da240 1019695833 S Ii:7:001:1 -115:128 2 <
880121a6d300 1019695919 S Ci:7:001:0 s a3 00  0001 0004 4 <
880121a6d300 1019695943 C Ci:7:001:0 0 4 = 0101
880121a6d300 1019695964 S Co:7:001:0 s 23 03 0004 0001  0
880121a6d300 1019695972 C Co:7:001:0 0 0
880121a6d300 1019752052 S Ci:7:001:0 s a3 00  0001 0004 4 <
880121a6d300 1019752096 C Ci:7:001:0 0 4 = 0301
880121a6d300 1019808051 S Co:7:001:0 s 23 01 0014 0001  0
880121a6d300 1019808065 C Co:7:001:0 0 0
880121a6d300 1019808096 S Ci:7:000:0 s 80 06 0100  0040 64 <
880121a6d300 1019813379 C Ci:7:000:0 0 18 = 12010001 0040 9b054000 
00010102 0501
880121a6d300 1019813448 S Co:7:001:0 s 23 03 0004 0001  0
880121a6d300 1019813460 C Co:7:001:0 0 0
8801356da240 1019836060 C Ii:7:001:1 0:128 1 = 02
8801356da240 1019836074 S Ii:7:001:1 -115:128 2 <
880121a6d300 1019868055 S Ci:7:001:0 s a3 00  0001 0004 4 <
880121a6d300 1019868099 C Ci:7:001:0 0 4 = 0301
880121a6d300 1019924058 S Co:7:001:0 s 23 01 0014 0001  0
880121a6d300 1019924073 C Co:7:001:0 0 0
880121a6d300 1019924082 S Co:7:000:

Re: [PATCH v3 3/3] gpio: add support for the Diolan DLN-2 USB GPIO driver

2014-09-08 Thread Johan Hovold
On Fri, Sep 05, 2014 at 06:17:59PM +0300, Octavian Purdila wrote:
> From: Daniel Baluta 
> 
> This patch adds GPIO and IRQ support for the Diolan DLN-2 GPIO module.
> 
> Information about the USB protocol interface can be found in the
> Programmer's Reference Manual [1], see section 2.9 for the GPIO
> module commands and responses.
> 
> [1] https://www.diolan.com/downloads/dln-api-manual.pdf
> 
> Signed-off-by: Daniel Baluta 
> Signed-off-by: Octavian Purdila 
> ---
>  drivers/gpio/Kconfig |  12 ++
>  drivers/gpio/Makefile|   1 +
>  drivers/gpio/gpio-dln2.c | 537 
> +++
>  3 files changed, 550 insertions(+)
>  create mode 100644 drivers/gpio/gpio-dln2.c
> 
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 9de1515..6a9e352 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -897,4 +897,16 @@ config GPIO_VIPERBOARD
>River Tech's viperboard.h for detailed meaning
>of the module parameters.
>  
> +config GPIO_DLN2
> + tristate "Diolan DLN2 GPIO support"
> + depends on USB && MFD_DLN2

Just MFD_DLN2.

> + select GPIOLIB_IRQCHIP
> +
> + help
> +   Select this option to enable GPIO driver for the Diolan DLN2
> +   board.
> +
> +   This driver can also be built as a module. If so, the module
> +   will be called gpio-dln2.
> +
>  endif
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index 5d024e3..eaa97a0 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -26,6 +26,7 @@ obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o
>  obj-$(CONFIG_GPIO_DA9052)+= gpio-da9052.o
>  obj-$(CONFIG_GPIO_DA9055)+= gpio-da9055.o
>  obj-$(CONFIG_GPIO_DAVINCI)   += gpio-davinci.o
> +obj-$(CONFIG_GPIO_DLN2)  += gpio-dln2.o
>  obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o
>  obj-$(CONFIG_GPIO_EM)+= gpio-em.o
>  obj-$(CONFIG_GPIO_EP93XX)+= gpio-ep93xx.o
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> new file mode 100644
> index 000..f8c0bcb
> --- /dev/null
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -0,0 +1,537 @@
> +/*
> + * Driver for the Diolan DLN-2 USB-GPIO adapter
> + *
> + * Copyright (c) 2014 Intel Corporation
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "dln2-gpio"
> +
> +#define DLN2_GPIO_ID 0x01
> +
> +#define DLN2_GPIO_GET_PORT_COUNT DLN2_CMD(0x00, DLN2_GPIO_ID)
> +#define DLN2_GPIO_GET_PIN_COUNT  DLN2_CMD(0x01, DLN2_GPIO_ID)
> +#define DLN2_GPIO_SET_DEBOUNCE   DLN2_CMD(0x04, DLN2_GPIO_ID)
> +#define DLN2_GPIO_GET_DEBOUNCE   DLN2_CMD(0x05, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PORT_GET_VAL   DLN2_CMD(0x06, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_GET_VALDLN2_CMD(0x0B, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_SET_OUT_VALDLN2_CMD(0x0C, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_GET_OUT_VALDLN2_CMD(0x0D, DLN2_GPIO_ID)
> +#define DLN2_GPIO_CONDITION_MET_EV   DLN2_CMD(0x0F, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_ENABLE DLN2_CMD(0x10, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_DISABLEDLN2_CMD(0x11, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_SET_DIRECTION  DLN2_CMD(0x13, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_GET_DIRECTION  DLN2_CMD(0x14, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_SET_EVENT_CFG  DLN2_CMD(0x1E, DLN2_GPIO_ID)
> +#define DLN2_GPIO_PIN_GET_EVENT_CFG  DLN2_CMD(0x1F, DLN2_GPIO_ID)
> +
> +#define DLN2_GPIO_EVENT_NONE 0
> +#define DLN2_GPIO_EVENT_CHANGE   1
> +#define DLN2_GPIO_EVENT_LVL_HIGH 2
> +#define DLN2_GPIO_EVENT_LVL_LOW  3
> +#define DLN2_GPIO_EVENT_CHANGE_RISING0x11
> +#define DLN2_GPIO_EVENT_CHANGE_FALLING  0x21
> +#define DLN2_GPIO_EVENT_MASK 0x0F
> +
> +#define DLN2_GPIO_MAX_PINS 32
> +
> +struct dln2_irq_work {
> + struct work_struct work;
> + struct dln2_gpio *dln2;
> + int pin, type;

One declaration per line.

Please consider my previous style comments also for this patch.

> +};
> +
> +struct dln2_remove_work {
> + struct delayed_work work;
> + struct dln2_gpio *dln2;
> +};
> +
> +struct dln2_gpio {
> + struct platform_device *pdev;
> + struct gpio_chip gpio;
> +
> + DECLARE_BITMAP(irqs_masked, DLN2_GPIO_MAX_PINS);
> + DECLARE_BITMAP(irqs_enabled, DLN2_GPIO_MAX_PINS);
> + DECLARE_BITMAP(irqs_pending, DLN2_GPIO_MAX_PINS);
> + struct dln2_irq_work irq_work[DLN2_GPIO_MAX_PINS];
> + struct dln2_remove_work remove_work;
> +};
> +
> +struct dln2_gpio_pin {
> + __le16 pin;
> +} __packe

Re: [PATCH v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-08 Thread Johan Hovold
On Mon, Sep 08, 2014 at 06:57:29PM +0300, Octavian Purdila wrote:
> On Mon, Sep 8, 2014 at 5:44 PM, Johan Hovold  wrote:
> 
> 
> 
> Hi Johan,
> 
> Again, thanks for the detailed review, I am addressing your review
> comments as we speak. Some questions below.
> 
> 
> 
> > > + int ret, len;
> > > + struct tx_data {
> > > + u8 port;
> > > + u8 addr;
> > > + u8 mem_addr_len;
> > > + __le32 mem_addr;
> > > + __le16 buf_len;
> > > + u8 buf[DLN2_I2C_MAX_XFER_SIZE];
> > > + } __packed tx;
> >
> > Allocate these buffers dynamically (possibly at probe).
> >
> 
> I double checked this, and DLN2_I2C_MAX_XFER_SIZE should actually be <
> 64 as the USB endpoint configuration max packet size is 64. In this
> case, can we keep it on the stack?

It's better to lift that restriction and allocate it dynamically. Using
larger buffers (> EP size) is also more efficient.

> 
> 
> > > + int ret, buf_len, rx_len = sizeof(rx);
> >
> > Again, one declaration per line.
> 
> AFAICS there are many places where declaration on the same line
> (initialization included) are used. When did this became a coding
> style issue?

It's ugly, hurts readability, and can also obfuscate the fact that your
function really needs to be refactored.

And it's in the CodingStyle:

"To this end, use just one data declaration per line (no commas
for multiple data declarations)."

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


Re: [PATCH 3/5] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls

2014-09-08 Thread Tony Lindgren
* Kishon Vijay Abraham I  [140908 07:26]:
> Hi Tony,
> 
> On Thursday 04 September 2014 10:37 PM, Tony Lindgren wrote:
> > * Kishon Vijay Abraham I  [140904 06:51]:
> >> Hi Tony,
> >>
> >> On Thursday 28 August 2014 04:58 AM, Tony Lindgren wrote:
> >>> We don't need twl4030_phy_power() any longer now that we have
> >>> the runtime PM calls. Let's get rid of it as it's confusing.
> >>> No functional changes, just move the code and use res instead
> >>> of ret as we are not returning that value.
> >>
> >> Now that you are doing pm_runtime_get_sync in twl4030_phy_init, won't it 
> >> power
> >> on the phy even before initializing it (since runtime_resume will be 
> >> invoked
> >> even before doing phy_init)?
> > 
> > Yes. The logic being that it should not matter as we are not
> > configuring the phy until in twl4030_phy_power_on(). Maybe we
> > should add code to make sure the phy is deconfigured initially
> > though :)
> > 
> > In twl4030_phy_init() we just want to check the ID pin state to get
> > things right initially. In the twl4030-usb case the I2C chip is
> > always on, but let's try to get the runtime PM set up like any
> > standard Linux driver would do it to avoid confusion.
> > 
> >> Even if pm_runtime_get_sync in not done in twl4030_phy_init, phy-core 
> >> itself
> >> does pm_runtime_get_sync in phy_init().
> > 
> > Hmm OK. Looking at that, looks like we don't neeed any of these
> > custom exports though:
> > 
> > $ git grep phy_pm_runtime | grep EXPORT_SYMBOL
> > drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_get);
> > drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync);
> > drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_put);
> > drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_put_sync);
> > drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_allow);
> > drivers/phy/phy-core.c:EXPORT_SYMBOL_GPL(phy_pm_runtime_forbid);
> > 
> > The reasons why I think we don't need the above at all is:
> > 
> > 1. We already have a framework for that in Linux runtime PM and we
> >can follow the standard Linux runtime PM calls and not proxy
> >them in phy-core.c
> 
> The reason for adding these are for providing fine grained control of the PHY
> by the controller drivers. In most cases the controller driver determines when
> the PHY should be active or idle.

Yeah but having the USB controller driver attempt to manage the
PHY did not work well. That all had to be ripped out of musb driver
in commits 30a70b026b4c and 8b2bc2c9351b.

I took a brief look at trying to fix musb + twl4030-usb runtime PM
so the USB controller driver would manage it. And that's probably
so far the only USB driver and PHY controller combo where we've had
runtime PM working in various forms in the mainline kernel.

Attempting to make the USB controller driver manage the runtime PM
for the PHY would make things unnecesarily complicated. The PHY can
sleep since it's on the I2C bus. So we'd have to implement some kind
of completion checking all over the place to attempt to keep things
in sync.

Meanwhile, having independent PHY drivers doing their own runtime
PM avoids all these issues. At minimum, it just means the PHY
driver needs to implement PHY init, power_on and power_off functions
like they already do. Then as needed, the PHY driver can implement
it's runtime PM calls.

I think what does make sense to do in the PHY framework is to keep
track of the PHY state in a generic way, and have a generic way of
telling the USB controller driver of the PHY state. That might allow
us eventually remove things like omap_musb_mailbox() calls.

And the custom exported functions above are unused AFAIK, so let's
just remove them.

> > 2. We can allow idling the phy properly on the bus it's connected
> >to, in this case I2C, even if USB driver is not loaded. We
> >eventually should idle the phy even if usb_add_phy_dev()
> >failed
> 
> yes.. that's why we have ops like phy_power_on to tell when the PHY should be
> active. So these PHYs can be idled in probe.

Yeah phy_power_on et al are good, and needed. But the runtime PM
should be implemented in the actual PHY drivers because of the
reasons above.
 
> > 3. There's no actual need for phy-core.c to proxy the runtime
> >PM calls
> > 
> > So we can and should just let the phy drivers do their own runtime PM
> > as needed based on just the phy init, power_on and power_off calls.
> > 
> > Probably the same goes for the regulator_enable in phy-core.c. That
> > should be handled in the phy driver as phy-core is already unable
> > to handle it properly. For example, for phy-twl4030-usb.c we have
> > three regulators to deal with and the phy framework won't have any
> > idea how to deal with those.
> 
> hmm.. It was modelled for basic PHY drivers that have a single regulator 
> (e.g.,
> TI PIPE3 PHY). The idea is not to duplicate getting and enabling regulator in
> each of the PHY drivers when it can be abstracted in phy-core.

There's no need t

Re: [PATCH v3 3/3] gpio: add support for the Diolan DLN-2 USB GPIO driver

2014-09-08 Thread Johan Hovold
On Fri, Sep 05, 2014 at 06:17:59PM +0300, Octavian Purdila wrote:

> --- /dev/null
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -0,0 +1,537 @@
> +/*
> + * Driver for the Diolan DLN-2 USB-GPIO adapter
> + *
> + * Copyright (c) 2014 Intel Corporation
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

It seems you don't need all these includes (usb, ptrace, wait...). Only
include what you actually use.

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


OOPS: musb_hdrc

2014-09-08 Thread Matwey V. Kornilov
Hi,

Running 3.16.1 on beaglebone black, I have the following issue with
musb_hdrc on boot:


[   11.151063] Unable to handle kernel paging request at virtual
address e09bb05c
[   11.158774] pgd = de5d8000
[   11.161613] [e09bb05c] *pgd=9e02d811, *pte=, *ppte=
[   11.168247] Internal error: Oops: 807 [#1] SMP ARM
[   11.173269] Modules linked in: musb_dsps(+) musb_hdrc udc_core
davinci_mdio(+) mmc_block phy_am335x usbcore phy_am335x_control
phy_generic usb_common ti_cpsw davinci_cpdma omap_hsmmc mmc_core
musb_am335x
[   11.192315] CPU: 0 PID: 205 Comm: systemd-udevd Not tainted
3.16.1-2.g2ab6585-default #1
[   11.200799] task: de58a080 ti: de5cc000 task.ti: de5cc000
[   11.206541] PC is at dma_controller_create+0x18/0x120 [musb_hdrc]
[   11.212943] LR is at musb_probe+0x528/0x664 [musb_hdrc]
[   11.218420] pc : []lr : []psr: a013
[   11.218420] sp : de5cdbf8  ip : de5ee8d8  fp : 0010
[   11.230454] r10:   r9 : 0003  r8 : de5ee810
[   11.235930] r7 : 0023  r6 : de5ee800  r5 : de71aec0  r4 : de2ec010
[   11.242771] r3 : e09ba800  r2 : 7fff  r1 : e09b8c00  r0 : de2ec010
[   11.249615] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[   11.257096] Control: 10c5387d  Table: 9e5d8019  DAC: 0015
[   11.263118] Process systemd-udevd (pid: 205, stack limit = 0xde5cc250)
[   11.269959] Stack: (0xde5cdbf8 to 0xde5ce000)
[   11.274527] dbe0:
de2ec010 de71aec0
[   11.283102] dc00: de5ee800 0023 de5ee810 0003 
bf125fec c0b21088 de71b5d8
[   11.291678] dc20: 0001 de71b0d8 0010 de5ee810 bf134a84
c0ddfbc8  bf134a84
[   11.300254] dc40: 0010 de5ee800 bf146760 c065a1bc c065a19c
de5ee810 c0eaee3c c0658318
[   11.308830] dc60: 1304 c065a2c8 bf134a84  de5ee810
c0658570 de5f1210 
[   11.317405] dc80:  c06565d4 de0bff70 de79c7b8 de5ee810
de5ee844 c0d9c810 c0658154
[   11.325981] dca0: de5ee818 de5ee810 c0d9c810 c0657648 de5ee818
 de5ee810 c06557b4
[   11.334558] dcc0: 8000 c0de8840 c0d35e54 de7f6f40 de5f1200
0002 de5ee800 de5ee810
[   11.343134] dce0: de5f1200 de7f3790 dfadf0a0 c0659edc 0001
  de5f1210
[   11.351710] dd00: de5f1200 bf145ef4 bf146870 01f4 de01c901
25f0 0007 de71b6fa
[   11.360286] dd20: c0e97a00 de71af10 de71b628 bf146760 47401c00
47401fff c8005480 0200
[   11.368861] dd40:    0023 0023
c80054a8 0400 
[   11.377436] dd60:   0010 de5f1210 bf14679c
c0ddfbc8  bf14679c
[   11.386011] dd80: 0010  bf146870 c065a1bc c065a19c
de5f1210 c0eaee3c c0658318
[   11.394587] dda0: c065a2a8 de5f1210 bf14679c de5f1210 bf14679c
de5f1244  bf149000
[   11.403164] ddc0: de5cc020 c0658650  bf14679c c06585bc
c0656524 de0bff5c de5924b4
[   11.411739] dde0: bf14679c de79ce00 c0d9c810 c0657924 bf146664
c04df5e8 bf14679c bf14679c
[   11.420315] de00: c0cf1aa0 de7ed340 de5cdf18 c0658e14 
c0cf1aa0 c0cf1aa0 c0209ab4
[   11.428891] de20:  c0ad03e8 c0ad03d4 c034195c c0cf1984
dfebf820  0008
[   11.437467] de40:  dfaf1000  c034338c 0007
dfebf820 c0e93d08 c036d8e0
[   11.446043] de60: bf146870 0005 de7ed340 c036f26c 0005
de5cdf54  bf14687c
[   11.454618] de80: de5cdf18 de5cc018   bf146870
c02df0d8 8000 7fff
[   11.463194] dea0: c02dc1f4 c0390948  e09a6000 
de5cdf18 c0ced560 b6e7fc80
[   11.471770] dec0: e09a8880 00ae de5cdf5c de5cdf88 1c7e
 0002 de5c81a4
[   11.480344] dee0: 0001    
  
[   11.488919] df00:     
  
[   11.497496] df20: de5cc000  000b b6e7fc80 017b
c021b008 de5cc000 1000
[   11.506071] df40: 009fadb0 c02df738 0002  de5cdf5c
e09a6000 4b2e e09a8880
[   11.514647] df60: e09a8707 e09a9928 1a04 1fb4 bf1467e0
0006  0023
[   11.523223] df80: 0024 001b 0016 0012 
 0001 0001
[   11.531798] dfa0:  c021ae20 0001 0001 000b
b6e7fc80  b6f1d370
[   11.540374] dfc0: 0001 0001  017b 
 0002 009fadb0
[   11.548949] dfe0: beeb12d8 beeb12c8 b6e76530 b6da66a0 60010010
000b  
[   11.557582] [] (dma_controller_create [musb_hdrc]) from
[] (musb_probe+0x528/0x664 [musb_hdrc])
[   11.568554] [] (musb_probe [musb_hdrc]) from []
(platform_drv_probe+0x20/0x50)
[   11.577969] [] (platform_drv_probe) from []
(driver_probe_device+0x154/0x3ac)
[   11.587278] [] (driver_probe_device) from []
(bus_for_each_drv+0x60/0x94)
[   11.596221] [] (bus_for_each_drv) from []
(device_attach+0x7c/0x90)
[   11.604617] [] (device_attach) from []
(bus_probe_device+0x8c/0xb0)
[   11.613013] [] (bus_probe_device) from []
(device_add+0x45c/0x578)
[   11.621317] [] (devic

Re: [PATCH v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-08 Thread Octavian Purdila
On Mon, Sep 8, 2014 at 7:30 PM, Johan Hovold  wrote:
> On Mon, Sep 08, 2014 at 06:57:29PM +0300, Octavian Purdila wrote:
>> On Mon, Sep 8, 2014 at 5:44 PM, Johan Hovold  wrote:
>>
>> 
>>
>> Hi Johan,
>>
>> Again, thanks for the detailed review, I am addressing your review
>> comments as we speak. Some questions below.
>>
>> 
>>
>> > > + int ret, len;
>> > > + struct tx_data {
>> > > + u8 port;
>> > > + u8 addr;
>> > > + u8 mem_addr_len;
>> > > + __le32 mem_addr;
>> > > + __le16 buf_len;
>> > > + u8 buf[DLN2_I2C_MAX_XFER_SIZE];
>> > > + } __packed tx;
>> >
>> > Allocate these buffers dynamically (possibly at probe).
>> >
>>
>> I double checked this, and DLN2_I2C_MAX_XFER_SIZE should actually be <
>> 64 as the USB endpoint configuration max packet size is 64. In this
>> case, can we keep it on the stack?
>
> It's better to lift that restriction and allocate it dynamically. Using
> larger buffers (> EP size) is also more efficient.
>
>> 
>>
>> > > + int ret, buf_len, rx_len = sizeof(rx);
>> >
>> > Again, one declaration per line.
>>
>> AFAICS there are many places where declaration on the same line
>> (initialization included) are used. When did this became a coding
>> style issue?
>
> It's ugly, hurts readability, and can also obfuscate the fact that your
> function really needs to be refactored.
>
> And it's in the CodingStyle:
>
> "To this end, use just one data declaration per line (no commas
> for multiple data declarations)."
>

OK, I always thought that was for when declaring structures/unions.
Just one more question on this subject: is the following allowed:

int ret, len;

or should it be:

int ret;
int len;
--
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 stable 1/6] usb: dwc2/gadget: fix phy disable sequence

2014-09-08 Thread Greg KH
On Mon, Sep 08, 2014 at 08:41:28AM -0500, Felipe Balbi wrote:
> On Mon, Sep 08, 2014 at 11:45:27AM +0200, Robert Baldyga wrote:
> > From: Kamil Debski 
> > 
> > When the driver is removed s3c_hsotg_phy_disable is called three times
> > instead of once. This results in decreasing of the phy reference counter
> > below zero and thus consecutive inserts of the module fails.
> > 
> > This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
> > and s3c_hsotg_udc_stop.
> > 
> > s3c_hsotg_udc_stop is called from udc-core.c only after
> > usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
> > already calls s3c_hsotg_phy_disable.
> > 
> > s3c_hsotg_remove must be called only after udc_stop, so there is no
> > point in disabling phy once again there.
> > 
> > Signed-off-by: Kamil Debski 
> > Signed-off-by: Marek Szyprowski 
> > Signed-off-by: Robert Baldyga 
> 
> you should have received a note from Greg that this is not how you send
> patches to be included in Stable, please read
> Documentation/stable_kernel_rules.txt

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


Re: [PATCH v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-08 Thread Johan Hovold
On Mon, Sep 08, 2014 at 08:15:07PM +0300, Octavian Purdila wrote:

> Just one more question on this subject: is the following allowed:
> 
> int ret, len;
> 
> or should it be:
> 
> int ret;
> int len;

I try to avoid it, at least unless obviously related such as min/max or
x/y.

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


Re: [PATCH v5 0/4] Patches to add support for Rockchip dwc2 controller

2014-09-08 Thread Heiko Stübner
Hi Greg,

Am Freitag, 8. August 2014, 11:55:55 schrieb Kever Yang:
> These patches to add support for dwc2 controller found in
> Rockchip processors rk3066, rk3188 and rk3288,
> and enable dts for rk3288 evb.

will you take patches 1 and 2?


Thanks
Heiko


> 
> Changes in v5:
> - max_transfer_size change to 65535 to met the requirement of
>   header file
> - change the sort order of dwc2 in rk3288.dtsi
> - don't enable otg port for evb
> 
> Changes in v4:
> - max_transfer_size change to 65536, this should be enough
>   for most transfer, the hardware auto-detect will set this
>   to 0x7 which may make dma_alloc_coherent fail when
>   non-dword aligned buf from driver like usbnet happen.
> - remove EHCI and HSIC dts patch for Doug had post it seprately.
> 
> Changes in v3:
> - EHCI and HSIC move new for version 3.
> - Rebase
> 
> Changes in v2:
> - Split out dr_mode and rk3288 bindings.
> - add compatible "snps,dwc2" bingding info
> - set most parameters as driver auto-detect
> - evb patch added in version 2
> 
> Kever Yang (4):
>   Documentation: dt-bindings: add dt binding info for Rockchip dwc2
>   usb: dwc2: add compatible data for rockchip soc
>   ARM: dts: add rk3288 dwc2 controller support
>   ARM: dts: Enable USB host1(dwc) on rk3288-evb
> 
>  Documentation/devicetree/bindings/usb/dwc2.txt |  3 +++
>  arch/arm/boot/dts/rk3288-evb.dtsi  |  4 
>  arch/arm/boot/dts/rk3288.dtsi  | 20 ++
>  drivers/usb/dwc2/platform.c| 29
> ++ 4 files changed, 56 insertions(+)

--
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: dwc2: Read GNPTXFSIZ when in forced HOST mode.

2014-09-08 Thread Doug Anderson
Greg,

On Thu, Aug 7, 2014 at 1:18 PM, Paul Zimmerman
 wrote:
>> From: Doug Anderson [mailto:diand...@chromium.org]
>> Sent: Thursday, August 07, 2014 12:48 PM
>>
>> The documentation for GNPTXFSIZ says that "For host mode, this field
>> is always valid."  Since we're already switching to host mode for
>> HPTXFSIZ, let's also read GNPTXFSIZ in host mode.
>>
>> On an rk3288 SoC, without this change we see this at bootup:
>>   dwc2 ff58.usb: gnptxfsiz=00100400
>>   dwc2 ff58.usb: 128 invalid for host_nperio_tx_fifo_size. Check HW 
>> configuration.
>>
>> After this change we see:
>>   dwc2 ff58.usb: gnptxfsiz=04000400
>>
>> Signed-off-by: Doug Anderson 
>> ---
>>  drivers/usb/dwc2/core.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>> index 27d2c9b..c184ed43 100644
>> --- a/drivers/usb/dwc2/core.c
>> +++ b/drivers/usb/dwc2/core.c
>> @@ -2674,23 +2674,23 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
>>   hwcfg2 = readl(hsotg->regs + GHWCFG2);
>>   hwcfg3 = readl(hsotg->regs + GHWCFG3);
>>   hwcfg4 = readl(hsotg->regs + GHWCFG4);
>> - gnptxfsiz = readl(hsotg->regs + GNPTXFSIZ);
>>   grxfsiz = readl(hsotg->regs + GRXFSIZ);
>>
>>   dev_dbg(hsotg->dev, "hwcfg1=%08x\n", hwcfg1);
>>   dev_dbg(hsotg->dev, "hwcfg2=%08x\n", hwcfg2);
>>   dev_dbg(hsotg->dev, "hwcfg3=%08x\n", hwcfg3);
>>   dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4);
>> - dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
>>   dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz);
>>
>> - /* Force host mode to get HPTXFSIZ exact power on value */
>> + /* Force host mode to get HPTXFSIZ / GNPTXFSIZ exact power on value */
>>   gusbcfg = readl(hsotg->regs + GUSBCFG);
>>   gusbcfg |= GUSBCFG_FORCEHOSTMODE;
>>   writel(gusbcfg, hsotg->regs + GUSBCFG);
>>   usleep_range(10, 15);
>>
>> + gnptxfsiz = readl(hsotg->regs + GNPTXFSIZ);
>>   hptxfsiz = readl(hsotg->regs + HPTXFSIZ);
>> + dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
>>   dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz);
>>   gusbcfg = readl(hsotg->regs + GUSBCFG);
>>   gusbcfg &= ~GUSBCFG_FORCEHOSTMODE;
>
> Nice! I wonder if this is a bug in the original driver, and they
> actually meant to read this register instead of HPTXFSIZ? Well, it
> doesn't really matter I guess.
>
> Acked-by: Paul Zimmerman 
>
> You may want to resend this to Greg after -rc1 is out and he reopens
> his usb-next tree.

Is this something you want me to resend with Paul's Acked-by and
Kever's Reviewed-by?  Please let me know and I'm happy to repost.

-Doug
--
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: OOPS: musb_hdrc

2014-09-08 Thread Felipe Balbi
Hi,

it kinda helps if you Cc the maintainer :-) scripts/get_maintainer.pl
helps by returning a (usually) correct (and extensive) list of people
and mailing lists to Cc :-)

anyway...

On Mon, Sep 08, 2014 at 09:08:07PM +0400, Matwey V. Kornilov wrote:
> Hi,
> 
> Running 3.16.1 on beaglebone black, I have the following issue with
> musb_hdrc on boot:
> 
> 
> [   11.151063] Unable to handle kernel paging request at virtual
> address e09bb05c
> [   11.158774] pgd = de5d8000
> [   11.161613] [e09bb05c] *pgd=9e02d811, *pte=, *ppte=
> [   11.168247] Internal error: Oops: 807 [#1] SMP ARM
> [   11.173269] Modules linked in: musb_dsps(+) musb_hdrc udc_core
> davinci_mdio(+) mmc_block phy_am335x usbcore phy_am335x_control
> phy_generic usb_common ti_cpsw davinci_cpdma omap_hsmmc mmc_core
> musb_am335x
> [   11.192315] CPU: 0 PID: 205 Comm: systemd-udevd Not tainted
> 3.16.1-2.g2ab6585-default #1
> [   11.200799] task: de58a080 ti: de5cc000 task.ti: de5cc000
> [   11.206541] PC is at dma_controller_create+0x18/0x120 [musb_hdrc]

Can you add a few printks around drivers/usb/musb/musb_cppi41.c to
further narrow down where the problem is ? I ran v3.17-rc1 on my
beaglebone black (a while back) and didn't have any issues.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: Iomega SCSI-to-USB cable problem

2014-09-08 Thread Alan Stern
On Mon, 8 Sep 2014, Mark wrote:

> Thanks very much for that! I booted with usb-storage.quirks=059b:0040:s to
> enable the single-LUN quirk. No change in dmesg output on connecting the
> drive/cable. I also compiled the kernel to add both US_FL_SINGLE_LUN and
> US_FL_BULK_IGNORE_TAG quirks. [For that I was using a VirtualBox VM and
> had booted the host with the single-LUN quirk.] I can post usbmon logs for
> both cases if that would be of interest. (I didn't paste them here to
> avoid bloating this message too much; there are other usbmon logs below.)
> 
> I noticed a couple of lines in the JAZ USB Adapter manual:
>   "When using the Jaz USB Adapter, you cannot connect other devices or
> cables to your Jaz drive."
>   "NOTE: If you are connecting two Jaz drives via two Jaz USB Adapters to
> your computer, set each drive to a different SCSI ID number."
> 
> The first point could be a limitation of either the cable firmware or
> Iomega's driver software. [There's also a physical limitation; with an
> external Jaz drive, you can't plug a cable into the other connector when
> the SCSI-USB cable is connected, because the connectors are too close.]
> Presumably the second point relates to Iomega's Windows driver.
> 
> I managed to find an old Jaz drive and tested it with my cable. It seems
> to work fine, so the cable firmware does restrict itself to working with
> Jaz drives. I had the drive SCSI ID set to 4, so it seems the firmware
> scans the bus and talks to the first(?) Jaz drive it sees.
> 
> However there were still four messages saying "usb 7-1: reset full speed
> USB device number 2 using uhci_hcd" in dmesg output. But the drive could
> be accessed, INQUIRY returned sensible data etc. Those reset messages
> didn't appear on booting with the single-LUN quirk. Take a look at the
> usbmon logs below. So it seems the Iomega SCSI-USB cable needs
> US_FL_SINGLE_LUN.

Indeed, all the messages attempting to probe LUN 1 failed.  That's what
caused the resets.

On the other hand, even with the SINGLE_LUN flag and a Jaz drive
attached, it didn't really work.  Every TEST UNIT READY command got a
Not Ready; No Medium Present error response.

It's not clear what messages the adapter expects to receive.  If you 
can sniff the USB data on a system where it works (Windows most likely) 
then perhaps it could be made to work on Linux.

But how much time do you really want to spend on this?  Unless you've
got some highly important data stored on those old Jaz drives, it
doesn't seem worthwhile.  The adapter connects at a measly 12 Mb/s
(which means transfer rates well under 1 MB/s in practice) and the
drives probably don't have a large storage capacity.  A small USB flash
drive would hold more data and communicate much faster.

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 4/9] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Felipe Balbi
Hi,

On Mon, Sep 08, 2014 at 05:16:04PM +0200, Andrzej Pietrasiewicz wrote:
> W dniu 08.09.2014 o 17:03, Felipe Balbi pisze:
> >HI,
> >
> 
> 
> 
> >>I think this series depends now on Michael's patch:
> >>
> >>http://www.spinics.net/lists/linux-usb/msg111692.html
> >>
> >>As far as I know Laurent already has it in his tree:
> >>
> >>http://git.linuxtv.org/cgit.cgi/pinchartl/media.git/log/?h=uvc/gadget
> >
> >I applied the series in order and patch 4 didn't apply.
> >
> 
> Have you?
> 
> $ git log balbi/testing/next | grep -A3 ^Author:.*Grzeschik
> Author: Michael Grzeschik 
> Date:   Thu Aug 21 16:54:46 2014 +0200
> 
> usb: gadget: uvc: remove DRIVER_VERSION{,_NUMBER}
> --
> Author: Michael Grzeschik 
> Date:   Thu Aug 21 16:54:43 2014 +0200
> 
> usb: gadget: uvc: Change KERN_INFO to KERN_DEBUG on request shutdown
> --
> Author: Michael Grzeschik 
> Date:   Wed Feb 19 13:41:43 2014 +0800
> 
> usb: chipidea: udc: add maximum-speed = full-speed option
> --
> Author: Michael Grzeschik 
> Date:   Thu Feb 13 10:52:03 2014 +0100
> 
> serial: omap: fix rs485 probe on defered pinctrl
> --
> Author: Michael Grzeschik 
> Date:   Fri Dec 6 15:56:40 2013 +0100
> 
> ARM: i.MX28: dts: rename usbphy pin names
> 
> no more patches dated 2014.

I merged -rc4 on my next (and testing/next) and now even patch 1 fails
to apply.

Laurent, can you rebase one more time ? sorry.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 1/2] bcma: store more alternative addresses

2014-09-08 Thread Hauke Mehrtens
Each core could have more than one alternative address. There are cores
with 8 alternative addresses for different functions. The PHY control
in the Chip common B core is done through the 2. alternative address
and not the first one.

Signed-off-by: Hauke Mehrtens 
CC: linux-usb@vger.kernel.org
---
 drivers/bcma/scan.c | 9 +
 drivers/usb/host/bcma-hcd.c | 2 +-
 include/linux/bcma/bcma.h   | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index e9bd772..3cd5a5b 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -276,7 +276,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 
__iomem **eromptr,
  struct bcma_device *core)
 {
u32 tmp;
-   u8 i, j;
+   u8 i, j, k;
s32 cia, cib;
u8 ports[2], wrappers[2];
 
@@ -367,6 +367,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 
__iomem **eromptr,
core->addr = tmp;
 
/* get & parse slave ports */
+   k = 0;
for (i = 0; i < ports[1]; i++) {
for (j = 0; ; j++) {
tmp = bcma_erom_get_addr_desc(bus, eromptr,
@@ -376,9 +377,9 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 
__iomem **eromptr,
/* pr_debug("erom: slave port %d "
 * "has %d descriptors\n", i, j); */
break;
-   } else {
-   if (i == 0 && j == 0)
-   core->addr1 = tmp;
+   } else if (k < ARRAY_SIZE(core->addr_s)) {
+   core->addr_s[k] = tmp;
+   k++;
}
}
}
diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index 205f4a3..cd6d0af 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -237,7 +237,7 @@ static int bcma_hcd_probe(struct bcma_device *dev)
bcma_hcd_init_chip(dev);
 
/* In AI chips EHCI is addrspace 0, OHCI is 1 */
-   ohci_addr = dev->addr1;
+   ohci_addr = dev->addr_s[0];
if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749)
&& chipinfo->rev == 0)
ohci_addr = 0x18009000;
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 0272e49..ad44711 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -267,7 +267,7 @@ struct bcma_device {
u8 core_unit;
 
u32 addr;
-   u32 addr1;
+   u32 addr_s[8];
u32 wrap;
 
void __iomem *io_addr;
-- 
1.9.1

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


Re: [PATCH RESEND v3 00/12] usb: dwc2/gadget: fix series (for v3.18)

2014-09-08 Thread Greg KH
On Thu, Sep 04, 2014 at 12:04:22PM -0700, Paul Zimmerman wrote:
> From: Robert Baldyga 
> 
> I'm resending this patchset rebased on linux-next. Now it should apply.


I'm lost, it seems some of these should be for 3.17-final and some for
3.18, can you please split this up into 2 series, one for each branch so
that I have a chance to get it right?

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: [PATCHv4 03/12] usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure

2014-09-08 Thread Greg KH
On Tue, Aug 26, 2014 at 11:19:54AM -0500, dingu...@opensource.altera.com wrote:
> From: Dinh Nguyen 
> 
> Adds the gadget data structure and appropriate data structure pointers
> to the common dwc2_hsotg data structure. To keep the driver data
> dereference code looking clean, the gadget variable declares are only 
> available
> for peripheral and dual-role mode. This is needed so that the dwc2_hsotg data
> structure can be used by the hcd and gadget drivers.
> 
> Updates gadget.c to use the dwc2_hsotg data structure and gadget pointers
> that have been moved into the common dwc2_hsotg structure. Along
> with the updating the gadget driver to use the common dwc2_hsotg structure,
> a few other things are required in order for this patch to build properly.
> Those are:
> 
> - Remove gadget module defines. Since the driver probing will be handled
>   by either the platform or pci code.
> - Change the gadget probe function into gadget_init.
> 
> Signed-off-by: Dinh Nguyen 
> Signed-off-by: Paul Zimmerman 
> ---
> v3: Updated with paulz's suggestion to avoid double pointers.
> v2: Left the function parameter name as 'hsotg' and just changed its type.
> ---
>  drivers/usb/dwc2/core.h   | 176 +---
>  drivers/usb/dwc2/gadget.c | 226 
> +-
>  drivers/usb/dwc2/hcd.h|  10 --
>  3 files changed, 184 insertions(+), 228 deletions(-)

This doesn't apply as I couldn't take the patches you depended on here
:(

Can you work with Paul to get this into a series that I can take?

Paul, you can just take it and resend it with any previous patches that
are needed as well.

thanks,

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


RE: [PATCH RESEND v3 00/12] usb: dwc2/gadget: fix series (for v3.18)

2014-09-08 Thread Paul Zimmerman
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Monday, September 08, 2014 3:49 PM
> 
> On Thu, Sep 04, 2014 at 12:04:22PM -0700, Paul Zimmerman wrote:
> > From: Robert Baldyga 
> >
> > I'm resending this patchset rebased on linux-next. Now it should apply.
> 
> 
> I'm lost, it seems some of these should be for 3.17-final and some for
> 3.18, can you please split this up into 2 series, one for each branch so
> that I have a chance to get it right?

Hi Greg,

None of these have been in -next yet, so it was my understanding that
they could not be applied for 3.17-final. Am I wrong?

-- 
Paul

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


Re: [PATCH RESEND v3 00/12] usb: dwc2/gadget: fix series (for v3.18)

2014-09-08 Thread Greg KH
On Mon, Sep 08, 2014 at 10:52:06PM +, Paul Zimmerman wrote:
> > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > Sent: Monday, September 08, 2014 3:49 PM
> > 
> > On Thu, Sep 04, 2014 at 12:04:22PM -0700, Paul Zimmerman wrote:
> > > From: Robert Baldyga 
> > >
> > > I'm resending this patchset rebased on linux-next. Now it should apply.
> > 
> > 
> > I'm lost, it seems some of these should be for 3.17-final and some for
> > 3.18, can you please split this up into 2 series, one for each branch so
> > that I have a chance to get it right?
> 
> Hi Greg,
> 
> None of these have been in -next yet, so it was my understanding that
> they could not be applied for 3.17-final. Am I wrong?

Not if you send them to me now, and I get them into -next for a week or
so before sending them on.  They need to be bugfix and/or regression
fixes only.

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


[PATCH v3 5/6] usb: gadget: f_uvc: remove compatibility layer

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

There are no users of the old interface left. Remove it.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/function/f_uvc.c | 166 
 drivers/usb/gadget/function/f_uvc.h |  11 ---
 2 files changed, 177 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index fe50a9b..1eff416 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -33,11 +33,6 @@
 #include "u_uvc.h"
 
 unsigned int uvc_gadget_trace_param;
-#ifdef USBF_UVC_INCLUDED
-static unsigned int streaming_interval;
-static unsigned int streaming_maxpacket;
-static unsigned int streaming_maxburst;
-#endif
 
 /* --
  * Function descriptors
@@ -202,16 +197,12 @@ static const struct usb_descriptor_header * const 
uvc_ss_streaming[] = {
NULL,
 };
 
-#ifndef USBF_UVC_INCLUDED
-
 void uvc_set_trace_param(unsigned int trace)
 {
uvc_gadget_trace_param = trace;
 }
 EXPORT_SYMBOL(uvc_set_trace_param);
 
-#endif
-
 /* --
  * Control requests
  */
@@ -566,30 +557,6 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum 
usb_device_speed speed)
return hdr;
 }
 
-#ifdef USBF_UVC_INCLUDED
-static void
-uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct usb_composite_dev *cdev = c->cdev;
-   struct uvc_device *uvc = to_uvc(f);
-
-   INFO(cdev, "uvc_function_unbind\n");
-
-   video_unregister_device(uvc->vdev);
-   v4l2_device_unregister(&uvc->v4l2_dev);
-   uvc->control_ep->driver_data = NULL;
-   uvc->video.ep->driver_data = NULL;
-
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = 0;
-   usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
-   kfree(uvc->control_buf);
-
-   usb_free_all_descriptors(f);
-
-   kfree(uvc);
-}
-#endif
-
 static int
 uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
 {
@@ -598,51 +565,11 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
unsigned int max_packet_mult;
unsigned int max_packet_size;
struct usb_ep *ep;
-#ifndef USBF_UVC_INCLUDED
struct f_uvc_opts *opts;
-#endif
int ret = -EINVAL;
 
INFO(cdev, "uvc_function_bind\n");
 
-#ifdef USBF_UVC_INCLUDED
-   /* Sanity check the streaming endpoint module parameters.
-*/
-   streaming_interval = clamp(streaming_interval, 1U, 16U);
-   streaming_maxpacket = clamp(streaming_maxpacket, 1U, 3072U);
-   streaming_maxburst = min(streaming_maxburst, 15U);
-
-   /* Fill in the FS/HS/SS Video Streaming specific descriptors from the
-* module parameters.
-*
-* NOTE: We assume that the user knows what they are doing and won't
-* give parameters that their UDC doesn't support.
-*/
-   if (streaming_maxpacket <= 1024) {
-   max_packet_mult = 1;
-   max_packet_size = streaming_maxpacket;
-   } else if (streaming_maxpacket <= 2048) {
-   max_packet_mult = 2;
-   max_packet_size = streaming_maxpacket / 2;
-   } else {
-   max_packet_mult = 3;
-   max_packet_size = streaming_maxpacket / 3;
-   }
-
-   uvc_fs_streaming_ep.wMaxPacketSize = min(streaming_maxpacket, 1023U);
-   uvc_fs_streaming_ep.bInterval = streaming_interval;
-
-   uvc_hs_streaming_ep.wMaxPacketSize = max_packet_size;
-   uvc_hs_streaming_ep.wMaxPacketSize |= ((max_packet_mult - 1) << 11);
-   uvc_hs_streaming_ep.bInterval = streaming_interval;
-
-   uvc_ss_streaming_ep.wMaxPacketSize = max_packet_size;
-   uvc_ss_streaming_ep.bInterval = streaming_interval;
-   uvc_ss_streaming_comp.bmAttributes = max_packet_mult - 1;
-   uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst;
-   uvc_ss_streaming_comp.wBytesPerInterval =
-   max_packet_size * max_packet_mult * streaming_maxburst;
-#else
opts = to_f_uvc_opts(f->fi);
/* Sanity check the streaming endpoint module parameters.
 */
@@ -681,7 +608,6 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
uvc_ss_streaming_comp.bMaxBurst = opts->streaming_maxburst;
uvc_ss_streaming_comp.wBytesPerInterval =
max_packet_size * max_packet_mult * opts->streaming_maxburst;
-#endif
 
/* Allocate endpoints. */
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
@@ -807,96 +733,6 @@ error:
  * USB gadget function
  */
 
-#ifdef USBF_UVC_INCLUDED
-/**
- * uvc_bind_config - add a UVC function to a configuration
- * @c: the configuration to support the UVC instance
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, 

[PATCH v3 2/6] usb: gadget: uvc: separately compile some components of f_uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Compile uvc_queue, uvc_v4l2, uvc_video separately so that later they can
be all combined in a separately compiled f_uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Make uvc_v4l2_ioctl_ops non-static]
[Rename __UVC__V4L2__H__ and __UVC__VIDEO__H__]
[Update MAINTAINERS]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 MAINTAINERS |  2 +-
 drivers/usb/gadget/function/f_uvc.c |  2 ++
 drivers/usb/gadget/function/f_uvc.h |  8 +++
 drivers/usb/gadget/function/uvc.h   |  1 +
 drivers/usb/gadget/function/uvc_queue.c | 39 ++---
 drivers/usb/gadget/function/uvc_queue.h | 33 
 drivers/usb/gadget/function/uvc_v4l2.c  |  6 +++--
 drivers/usb/gadget/function/uvc_v4l2.h  | 22 +++
 drivers/usb/gadget/function/uvc_video.c | 10 -
 drivers/usb/gadget/function/uvc_video.h | 24 
 drivers/usb/gadget/legacy/Makefile  |  2 +-
 drivers/usb/gadget/legacy/webcam.c  |  6 +
 12 files changed, 118 insertions(+), 37 deletions(-)
 create mode 100644 drivers/usb/gadget/function/uvc_v4l2.h
 create mode 100644 drivers/usb/gadget/function/uvc_video.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5d66c03..96568a8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9669,7 +9669,7 @@ USB WEBCAM GADGET
 M: Laurent Pinchart 
 L: linux-usb@vger.kernel.org
 S: Maintained
-F: drivers/usb/gadget/function/*uvc*.c
+F: drivers/usb/gadget/function/*uvc*
 F: drivers/usb/gadget/legacy/webcam.c
 
 USB WIRELESS RNDIS DRIVER (rndis_wlan)
diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index ae5bcb4..825080d 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -27,6 +27,8 @@
 #include 
 
 #include "uvc.h"
+#include "uvc_v4l2.h"
+#include "uvc_video.h"
 
 unsigned int uvc_gadget_trace_param;
 static unsigned int streaming_interval;
diff --git a/drivers/usb/gadget/function/f_uvc.h 
b/drivers/usb/gadget/function/f_uvc.h
index 74b9602..71b38dd 100644
--- a/drivers/usb/gadget/function/f_uvc.h
+++ b/drivers/usb/gadget/function/f_uvc.h
@@ -16,6 +16,14 @@
 #include 
 #include 
 
+#include "uvc.h"
+
+void uvc_function_setup_continue(struct uvc_device *uvc);
+
+void uvc_function_connect(struct uvc_device *uvc);
+
+void uvc_function_disconnect(struct uvc_device *uvc);
+
 int uvc_bind_config(struct usb_configuration *c,
const struct uvc_descriptor_header * const *fs_control,
const struct uvc_descriptor_header * const *hs_control,
diff --git a/drivers/usb/gadget/function/uvc.h 
b/drivers/usb/gadget/function/uvc.h
index 0a283b1..f67695c 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -53,6 +53,7 @@ struct uvc_event
 #ifdef __KERNEL__
 
 #include  /* For usb_endpoint_* */
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/usb/gadget/function/uvc_queue.c 
b/drivers/usb/gadget/function/uvc_queue.c
index 1e1bc73..8ea8b3b 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -126,8 +126,7 @@ static struct vb2_ops uvc_queue_qops = {
.wait_finish = uvc_wait_finish,
 };
 
-static int uvcg_queue_init(struct uvc_video_queue *queue,
-  enum v4l2_buf_type type)
+int uvcg_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
 {
int ret;
 
@@ -154,7 +153,7 @@ static int uvcg_queue_init(struct uvc_video_queue *queue,
 /*
  * Free the video buffers.
  */
-static void uvcg_free_buffers(struct uvc_video_queue *queue)
+void uvcg_free_buffers(struct uvc_video_queue *queue)
 {
mutex_lock(&queue->mutex);
vb2_queue_release(&queue->queue);
@@ -164,7 +163,7 @@ static void uvcg_free_buffers(struct uvc_video_queue *queue)
 /*
  * Allocate the video buffers.
  */
-static int uvcg_alloc_buffers(struct uvc_video_queue *queue,
+int uvcg_alloc_buffers(struct uvc_video_queue *queue,
  struct v4l2_requestbuffers *rb)
 {
int ret;
@@ -176,8 +175,7 @@ static int uvcg_alloc_buffers(struct uvc_video_queue *queue,
return ret ? ret : rb->count;
 }
 
-static int uvcg_query_buffer(struct uvc_video_queue *queue,
-struct v4l2_buffer *buf)
+int uvcg_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
int ret;
 
@@ -188,8 +186,7 @@ static int uvcg_query_buffer(struct uvc_video_queue *queue,
return ret;
 }
 
-static int uvcg_queue_buffer(struct uvc_video_queue *queue,
-struct v4l2_buffer *buf)
+int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
unsigned long flags;
int ret;
@@ -213,8 +210,8 @@ done:
  * Dequeue a video buffer. If nonblocking is false, block until a buffer is
  * available.
  */
-static in

[PATCH v3 4/6] usb: gadget: webcam: convert webcam to new interface of f_uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Use the new function interface of f_uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/legacy/Kconfig  |  1 +
 drivers/usb/gadget/legacy/Makefile |  2 +-
 drivers/usb/gadget/legacy/webcam.c | 53 +++---
 3 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/legacy/Kconfig 
b/drivers/usb/gadget/legacy/Kconfig
index bbd4b85..24392d2 100644
--- a/drivers/usb/gadget/legacy/Kconfig
+++ b/drivers/usb/gadget/legacy/Kconfig
@@ -468,6 +468,7 @@ config USB_G_WEBCAM
depends on VIDEO_DEV
select USB_LIBCOMPOSITE
select VIDEOBUF2_VMALLOC
+   select USB_F_UVC
help
  The Webcam Gadget acts as a composite USB Audio and Video Class
  device. It provides a userspace API to process UVC control requests
diff --git a/drivers/usb/gadget/legacy/Makefile 
b/drivers/usb/gadget/legacy/Makefile
index ed7367e..7f485f2 100644
--- a/drivers/usb/gadget/legacy/Makefile
+++ b/drivers/usb/gadget/legacy/Makefile
@@ -19,7 +19,7 @@ g_multi-y := multi.o
 g_hid-y:= hid.o
 g_dbgp-y   := dbgp.o
 g_nokia-y  := nokia.o
-g_webcam-y := webcam.o ../function/uvc_queue.o 
../function/uvc_v4l2.o ../function/uvc_video.o
+g_webcam-y := webcam.o
 g_ncm-y:= ncm.o
 g_acm_ms-y := acm_ms.o
 g_tcm_usb_gadget-y := tcm_usb_gadget.o
diff --git a/drivers/usb/gadget/legacy/webcam.c 
b/drivers/usb/gadget/legacy/webcam.c
index 50d27db..04a3da2 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -15,15 +15,7 @@
 #include 
 #include 
 
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
-#define USBF_UVC_INCLUDED
-#include "f_uvc.c"
+#include "u_uvc.h"
 
 USB_GADGET_COMPOSITE_OPTIONS();
 
@@ -79,6 +71,9 @@ static struct usb_gadget_strings *webcam_device_strings[] = {
NULL,
 };
 
+static struct usb_function_instance *fi_uvc;
+static struct usb_function *f_uvc;
+
 static struct usb_device_descriptor webcam_device_descriptor = {
.bLength= USB_DT_DEVICE_SIZE,
.bDescriptorType= USB_DT_DEVICE,
@@ -342,11 +337,17 @@ static const struct uvc_descriptor_header * const 
uvc_ss_streaming_cls[] = {
 static int __init
 webcam_config_bind(struct usb_configuration *c)
 {
-   return uvc_bind_config(c, uvc_fs_control_cls,
-   uvc_ss_control_cls, uvc_fs_streaming_cls,
-   uvc_hs_streaming_cls, uvc_ss_streaming_cls,
-   streaming_interval, streaming_maxpacket,
-   streaming_maxburst, trace);
+   int status = 0;
+
+   f_uvc = usb_get_function(fi_uvc);
+   if (IS_ERR(f_uvc))
+   return PTR_ERR(f_uvc);
+
+   status = usb_add_function(c, f_uvc);
+   if (status < 0)
+   usb_put_function(f_uvc);
+
+   return status;
 }
 
 static struct usb_configuration webcam_config_driver = {
@@ -360,14 +361,36 @@ static struct usb_configuration webcam_config_driver = {
 static int /* __init_or_exit */
 webcam_unbind(struct usb_composite_dev *cdev)
 {
+   if (!IS_ERR_OR_NULL(f_uvc))
+   usb_put_function(f_uvc);
+   if (!IS_ERR_OR_NULL(fi_uvc))
+   usb_put_function_instance(fi_uvc);
return 0;
 }
 
 static int __init
 webcam_bind(struct usb_composite_dev *cdev)
 {
+   struct f_uvc_opts *uvc_opts;
int ret;
 
+   fi_uvc = usb_get_function_instance("uvc");
+   if (IS_ERR(fi_uvc))
+   return PTR_ERR(fi_uvc);
+
+   uvc_opts = container_of(fi_uvc, struct f_uvc_opts, func_inst);
+
+   uvc_opts->streaming_interval = streaming_interval;
+   uvc_opts->streaming_maxpacket = streaming_maxpacket;
+   uvc_opts->streaming_maxburst = streaming_maxburst;
+   uvc_set_trace_param(trace);
+
+   uvc_opts->fs_control = uvc_fs_control_cls;
+   uvc_opts->ss_control = uvc_ss_control_cls;
+   uvc_opts->fs_streaming = uvc_fs_streaming_cls;
+   uvc_opts->hs_streaming = uvc_hs_streaming_cls;
+   uvc_opts->ss_streaming = uvc_ss_streaming_cls;
+
/* Allocate string descriptor numbers ... note that string contents
 * can be overridden by the composite_dev glue.
 */
@@ -391,7 +414,7 @@ webcam_bind(struct usb_composite_dev *cdev)
return 0;
 
 error:
-   webcam_unbind(cdev);
+   usb_put_function_instance(fi_uvc);
return ret;
 }
 
-- 
1.8.5.5

--
To unsubscribe from this list: send the line "unsub

[PATCH v3 6/6] usb: gadget: f_uvc: use usb_gstrings_attach

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Attach strings to gadget with usb_strings_attach.
It is required for correct instantiation of functions more than once:
instead of modifying the local uvc_en_us_strings a function instance
specific copy is created with usb_gstrings_attach.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
Signed-off-by: Laurent Pinchart 
---
 drivers/usb/gadget/function/f_uvc.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 1eff416..95dc1c6 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -562,6 +562,7 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct uvc_device *uvc = to_uvc(f);
+   struct usb_string *us;
unsigned int max_packet_mult;
unsigned int max_packet_size;
struct usb_ep *ep;
@@ -637,22 +638,17 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address;
uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address;
 
-   /* String descriptors are global, we only need to allocate string IDs
-* for the first UVC function. UVC functions beyond the first (if any)
-* will reuse the same IDs.
-*/
-   if (uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id == 0) {
-   ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings);
-   if (ret)
-   goto error;
-   uvc_iad.iFunction =
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id;
-   uvc_control_intf.iInterface =
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id;
-   ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id;
-   uvc_streaming_intf_alt0.iInterface = ret;
-   uvc_streaming_intf_alt1.iInterface = ret;
+   us = usb_gstrings_attach(cdev, uvc_function_strings,
+ARRAY_SIZE(uvc_en_us_strings));
+   if (IS_ERR(us)) {
+   ret = PTR_ERR(us);
+   goto error;
}
+   uvc_iad.iFunction = us[UVC_STRING_CONTROL_IDX].id;
+   uvc_control_intf.iInterface = us[UVC_STRING_CONTROL_IDX].id;
+   ret = us[UVC_STRING_STREAMING_IDX].id;
+   uvc_streaming_intf_alt0.iInterface = ret;
+   uvc_streaming_intf_alt1.iInterface = ret;
 
/* Allocate interface IDs. */
if ((ret = usb_interface_id(c, f)) < 0)
@@ -771,7 +767,6 @@ static void uvc_unbind(struct usb_configuration *c, struct 
usb_function *f)
uvc->control_ep->driver_data = NULL;
uvc->video.ep->driver_data = NULL;
 
-   uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = 0;
usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
kfree(uvc->control_buf);
 
@@ -798,7 +793,6 @@ struct usb_function *uvc_alloc(struct usb_function_instance 
*fi)
 
/* Register the function. */
uvc->func.name = "uvc";
-   uvc->func.strings = uvc_function_strings;
uvc->func.bind = uvc_function_bind;
uvc->func.unbind = uvc_unbind;
uvc->func.get_alt = uvc_function_get_alt;
-- 
1.8.5.5

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


[PATCH v3 1/6] usb: gadget: uvc: rename functions to avoid conflicts with host uvc

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Prepare for separate compilation of uvc function's components.
Some symbols will have to be exported, so rename to avoid
conflicts with functions of the same name in host uvc.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Rename uvc_video_pump and uvc_queue_head as well]
[Rename forgotten uvc_queue_cancel instance in a comment]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uvc.c |  2 +-
 drivers/usb/gadget/function/uvc_queue.c | 49 +
 drivers/usb/gadget/function/uvc_v4l2.c  | 26 -
 drivers/usb/gadget/function/uvc_video.c | 34 +++
 4 files changed, 56 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 187c3a0..ae5bcb4 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -693,7 +693,7 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
}
 
/* Initialise video. */
-   ret = uvc_video_init(&uvc->video);
+   ret = uvcg_video_init(&uvc->video);
if (ret < 0)
goto error;
 
diff --git a/drivers/usb/gadget/function/uvc_queue.c 
b/drivers/usb/gadget/function/uvc_queue.c
index 8590f9f..1e1bc73 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -28,7 +28,7 @@
 /* 
  * Video buffers queue management.
  *
- * Video queues is initialized by uvc_queue_init(). The function performs
+ * Video queues is initialized by uvcg_queue_init(). The function performs
  * basic initialization of the uvc_video_queue struct and never fails.
  *
  * Video buffers are managed by videobuf2. The driver uses a mutex to protect
@@ -126,8 +126,8 @@ static struct vb2_ops uvc_queue_qops = {
.wait_finish = uvc_wait_finish,
 };
 
-static int uvc_queue_init(struct uvc_video_queue *queue,
- enum v4l2_buf_type type)
+static int uvcg_queue_init(struct uvc_video_queue *queue,
+  enum v4l2_buf_type type)
 {
int ret;
 
@@ -154,7 +154,7 @@ static int uvc_queue_init(struct uvc_video_queue *queue,
 /*
  * Free the video buffers.
  */
-static void uvc_free_buffers(struct uvc_video_queue *queue)
+static void uvcg_free_buffers(struct uvc_video_queue *queue)
 {
mutex_lock(&queue->mutex);
vb2_queue_release(&queue->queue);
@@ -164,8 +164,8 @@ static void uvc_free_buffers(struct uvc_video_queue *queue)
 /*
  * Allocate the video buffers.
  */
-static int uvc_alloc_buffers(struct uvc_video_queue *queue,
-struct v4l2_requestbuffers *rb)
+static int uvcg_alloc_buffers(struct uvc_video_queue *queue,
+ struct v4l2_requestbuffers *rb)
 {
int ret;
 
@@ -176,8 +176,8 @@ static int uvc_alloc_buffers(struct uvc_video_queue *queue,
return ret ? ret : rb->count;
 }
 
-static int uvc_query_buffer(struct uvc_video_queue *queue,
-   struct v4l2_buffer *buf)
+static int uvcg_query_buffer(struct uvc_video_queue *queue,
+struct v4l2_buffer *buf)
 {
int ret;
 
@@ -188,8 +188,8 @@ static int uvc_query_buffer(struct uvc_video_queue *queue,
return ret;
 }
 
-static int uvc_queue_buffer(struct uvc_video_queue *queue,
-   struct v4l2_buffer *buf)
+static int uvcg_queue_buffer(struct uvc_video_queue *queue,
+struct v4l2_buffer *buf)
 {
unsigned long flags;
int ret;
@@ -213,8 +213,8 @@ done:
  * Dequeue a video buffer. If nonblocking is false, block until a buffer is
  * available.
  */
-static int uvc_dequeue_buffer(struct uvc_video_queue *queue,
- struct v4l2_buffer *buf, int nonblocking)
+static int uvcg_dequeue_buffer(struct uvc_video_queue *queue,
+  struct v4l2_buffer *buf, int nonblocking)
 {
int ret;
 
@@ -231,8 +231,8 @@ static int uvc_dequeue_buffer(struct uvc_video_queue *queue,
  * This function implements video queue polling and is intended to be used by
  * the device poll handler.
  */
-static unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
-  struct file *file, poll_table *wait)
+static unsigned int uvcg_queue_poll(struct uvc_video_queue *queue,
+   struct file *file, poll_table *wait)
 {
unsigned int ret;
 
@@ -243,8 +243,8 @@ static unsigned int uvc_queue_poll(struct uvc_video_queue 
*queue,
return ret;
 }
 
-static int uvc_queue_mmap(struct uvc_video_queue *queue,
- struct vm_area_struct *vma)
+static int uvcg_queue_mmap(struct uvc_video_queue *queue,
+  struct vm_area_struct *vma)
 {
int ret;
 
@@ -2

[PATCH v3 0/6] UVC gadget patches for v3.18 (part 2)

2014-09-08 Thread Laurent Pinchart
Hi Felipe,

These patches have previously been posted to linux-usb as part of the
"[PATCH v2 0/9] UVC gadget patches for v3.18 (part 2)" series.

I've rebased them on top of your next branch and dropped the ones that
have already been applied. Could you please apply them to your tree for
v3.18 ?

Andrzej Pietrasiewicz (6):
  usb: gadget: uvc: rename functions to avoid conflicts with host uvc
  usb: gadget: uvc: separately compile some components of f_uvc
  usb: gadget: f_uvc: convert f_uvc to new function interface
  usb: gadget: webcam: convert webcam to new interface of f_uvc
  usb: gadget: f_uvc: remove compatibility layer
  usb: gadget: f_uvc: use usb_gstrings_attach

 MAINTAINERS |   2 +-
 drivers/usb/gadget/Kconfig  |   3 +
 drivers/usb/gadget/function/Makefile|   2 +
 drivers/usb/gadget/function/f_uvc.c | 248 ++--
 drivers/usb/gadget/function/f_uvc.h |  17 +--
 drivers/usb/gadget/function/u_uvc.h |  39 +
 drivers/usb/gadget/function/uvc.h   |   1 +
 drivers/usb/gadget/function/uvc_queue.c |  44 +++---
 drivers/usb/gadget/function/uvc_queue.h |  33 +
 drivers/usb/gadget/function/uvc_v4l2.c  |  32 +++--
 drivers/usb/gadget/function/uvc_v4l2.h  |  22 +++
 drivers/usb/gadget/function/uvc_video.c |  38 +++--
 drivers/usb/gadget/function/uvc_video.h |  24 
 drivers/usb/gadget/legacy/Kconfig   |   1 +
 drivers/usb/gadget/legacy/webcam.c  |  58 +---
 15 files changed, 338 insertions(+), 226 deletions(-)
 create mode 100644 drivers/usb/gadget/function/u_uvc.h
 create mode 100644 drivers/usb/gadget/function/uvc_v4l2.h
 create mode 100644 drivers/usb/gadget/function/uvc_video.h

-- 
Regards,

Laurent Pinchart

--
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/6] usb: gadget: f_uvc: convert f_uvc to new function interface

2014-09-08 Thread Laurent Pinchart
From: Andrzej Pietrasiewicz 

Use the new function registration interface. It is required
in order to integrate configfs support.

Signed-off-by: Andrzej Pietrasiewicz 
Tested-by: Michael Grzeschik 
[Updated copyright years]
Signed-off-by: Laurent Pinchart 
Acked-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/Kconfig   |   3 +
 drivers/usb/gadget/function/Makefile |   2 +
 drivers/usb/gadget/function/f_uvc.c  | 204 +--
 drivers/usb/gadget/function/u_uvc.h  |  39 +++
 drivers/usb/gadget/legacy/webcam.c   |   1 +
 5 files changed, 219 insertions(+), 30 deletions(-)
 create mode 100644 drivers/usb/gadget/function/u_uvc.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 68302aa..c4880fc 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -187,6 +187,9 @@ config USB_F_UAC1
 config USB_F_UAC2
tristate
 
+config USB_F_UVC
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/function/Makefile 
b/drivers/usb/gadget/function/Makefile
index a49fdf7..90701aa 100644
--- a/drivers/usb/gadget/function/Makefile
+++ b/drivers/usb/gadget/function/Makefile
@@ -36,3 +36,5 @@ usb_f_uac1-y  := f_uac1.o u_uac1.o
 obj-$(CONFIG_USB_F_UAC1)   += usb_f_uac1.o
 usb_f_uac2-y   := f_uac2.o
 obj-$(CONFIG_USB_F_UAC2)   += usb_f_uac2.o
+usb_f_uvc-y:= f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o
+obj-$(CONFIG_USB_F_UVC)+= usb_f_uvc.o
diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 825080d..fe50a9b 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -11,6 +11,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,11 +30,14 @@
 #include "uvc.h"
 #include "uvc_v4l2.h"
 #include "uvc_video.h"
+#include "u_uvc.h"
 
 unsigned int uvc_gadget_trace_param;
+#ifdef USBF_UVC_INCLUDED
 static unsigned int streaming_interval;
 static unsigned int streaming_maxpacket;
 static unsigned int streaming_maxburst;
+#endif
 
 /* --
  * Function descriptors
@@ -65,7 +69,7 @@ static struct usb_gadget_strings *uvc_function_strings[] = {
 
 #define UVC_STATUS_MAX_PACKET_SIZE 16  /* 16 bytes status */
 
-static struct usb_interface_assoc_descriptor uvc_iad __initdata = {
+static struct usb_interface_assoc_descriptor uvc_iad = {
.bLength= sizeof(uvc_iad),
.bDescriptorType= USB_DT_INTERFACE_ASSOCIATION,
.bFirstInterface= 0,
@@ -76,7 +80,7 @@ static struct usb_interface_assoc_descriptor uvc_iad 
__initdata = {
.iFunction  = 0,
 };
 
-static struct usb_interface_descriptor uvc_control_intf __initdata = {
+static struct usb_interface_descriptor uvc_control_intf = {
.bLength= USB_DT_INTERFACE_SIZE,
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = UVC_INTF_VIDEO_CONTROL,
@@ -88,7 +92,7 @@ static struct usb_interface_descriptor uvc_control_intf 
__initdata = {
.iInterface = 0,
 };
 
-static struct usb_endpoint_descriptor uvc_control_ep __initdata = {
+static struct usb_endpoint_descriptor uvc_control_ep = {
.bLength= USB_DT_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_ENDPOINT,
.bEndpointAddress   = USB_DIR_IN,
@@ -97,7 +101,7 @@ static struct usb_endpoint_descriptor uvc_control_ep 
__initdata = {
.bInterval  = 8,
 };
 
-static struct usb_ss_ep_comp_descriptor uvc_ss_control_comp __initdata = {
+static struct usb_ss_ep_comp_descriptor uvc_ss_control_comp = {
.bLength= sizeof(uvc_ss_control_comp),
.bDescriptorType= USB_DT_SS_ENDPOINT_COMP,
/* The following 3 values can be tweaked if necessary. */
@@ -106,14 +110,14 @@ static struct usb_ss_ep_comp_descriptor 
uvc_ss_control_comp __initdata = {
.wBytesPerInterval  = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
 };
 
-static struct uvc_control_endpoint_descriptor uvc_control_cs_ep __initdata = {
+static struct uvc_control_endpoint_descriptor uvc_control_cs_ep = {
.bLength= UVC_DT_CONTROL_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_CS_ENDPOINT,
.bDescriptorSubType = UVC_EP_INTERRUPT,
.wMaxTransferSize   = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
 };
 
-static struct usb_interface_descriptor uvc_streaming_intf_alt0 __initdata = {
+static struct usb_interface_descriptor uvc_streaming_intf_alt0 = {
.bLength= USB_DT_INTERFACE_SIZE,
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = UVC_INTF_VIDEO_STREAMING,
@@ -125,7 +129,7 @@ static struct usb_interface_descriptor 
uvc_streaming_intf_alt0 __initdata = {

RE: [PATCH RESEND v3 00/12] usb: dwc2/gadget: fix series (for v3.18)

2014-09-08 Thread Paul Zimmerman
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Monday, September 08, 2014 4:01 PM
> 
> On Mon, Sep 08, 2014 at 10:52:06PM +, Paul Zimmerman wrote:
> > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > Sent: Monday, September 08, 2014 3:49 PM
> > >
> > > On Thu, Sep 04, 2014 at 12:04:22PM -0700, Paul Zimmerman wrote:
> > > > From: Robert Baldyga 
> > > >
> > > > I'm resending this patchset rebased on linux-next. Now it should apply.
> > >
> > >
> > > I'm lost, it seems some of these should be for 3.17-final and some for
> > > 3.18, can you please split this up into 2 series, one for each branch so
> > > that I have a chance to get it right?
> >
> > Hi Greg,
> >
> > None of these have been in -next yet, so it was my understanding that
> > they could not be applied for 3.17-final. Am I wrong?
> 
> Not if you send them to me now, and I get them into -next for a week or
> so before sending them on.  They need to be bugfix and/or regression
> fixes only.

OK.

Robert, I see you are rebasing this series already, so please split
the patches as Greg suggests, the pure bugfixes can go to 3-17-final,
and I guess they should be marked for stable too.

-- 
Paul

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


[PATCH 3/5] usb: gadget: configfs: add reset API at usb_gadget_driver

2014-09-08 Thread Peter Chen
Add reset API at usb_gadget_driver, it calls disconnect handler currently,
but may do different things in future.

Signed-off-by: Peter Chen 
---
 drivers/usb/gadget/configfs.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 811c2c7..3403433 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1450,6 +1450,7 @@ static const struct usb_gadget_driver 
configfs_driver_template = {
.unbind = configfs_composite_unbind,
 
.setup  = composite_setup,
+   .reset  = composite_disconnect,
.disconnect = composite_disconnect,
 
.max_speed  = USB_SPEED_SUPER,
-- 
1.7.9.5

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


[PATCH 5/5] usb: gadget: dbgp: add reset API at usb_gadget_driver

2014-09-08 Thread Peter Chen
Add reset API at usb_gadget_driver, it calls disconnect handler currently,
but may do different things in future.

Signed-off-by: Peter Chen 
---
 drivers/usb/gadget/legacy/dbgp.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 225e385..1b07513 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -410,6 +410,7 @@ static __refdata struct usb_gadget_driver dbgp_driver = {
.bind = dbgp_bind,
.unbind = dbgp_unbind,
.setup = dbgp_setup,
+   .reset = dbgp_disconnect,
.disconnect = dbgp_disconnect,
.driver = {
.owner = THIS_MODULE,
-- 
1.7.9.5

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


[PATCH 1/5] usb: gadget: add reset API at usb_gadget_driver

2014-09-08 Thread Peter Chen
Adding reset API for UDC bus reset handler is useful for below
two issues.

Current disconnect API at usb_gadget_driver is also invoked at
udc's bus reset handler, but the document says it is invoked when
the host is disconnected.

Besides, we may expect the gadget_driver to do different things
for host sends bus reset and host disconnects gadget, eg, we may not
want to flush dirty page for mass storage at bus reset, and want to
do it at disconnection.

Signed-off-by: Peter Chen 
---
 include/linux/usb/gadget.h |3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c3a6185..31a6046 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -816,6 +816,8 @@ static inline int usb_gadget_disconnect(struct usb_gadget 
*gadget)
  * Called in a context that permits sleeping.
  * @suspend: Invoked on USB suspend.  May be called in_interrupt.
  * @resume: Invoked on USB resume.  May be called in_interrupt.
+ * @reset: Invoked on USB bus reset. It is mandatory for all gadget drivers
+ * and should be called in_interrupt.
  * @driver: Driver model state for this driver.
  *
  * Devices are disabled till a gadget driver successfully bind()s, which
@@ -873,6 +875,7 @@ struct usb_gadget_driver {
void(*disconnect)(struct usb_gadget *);
void(*suspend)(struct usb_gadget *);
void(*resume)(struct usb_gadget *);
+   void(*reset)(struct usb_gadget *);
 
/* FIXME support safe rmmod */
struct device_driverdriver;
-- 
1.7.9.5

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


[PATCH 4/5] usb: gadget: gadgetfs: add reset API at usb_gadget_driver

2014-09-08 Thread Peter Chen
Add reset API at usb_gadget_driver, it calls disconnect handler currently,
but may do different things in future.

Signed-off-by: Peter Chen 
---
 drivers/usb/gadget/legacy/inode.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/legacy/inode.c 
b/drivers/usb/gadget/legacy/inode.c
index e96077b..edefec2 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1775,6 +1775,7 @@ static struct usb_gadget_driver gadgetfs_driver = {
.bind   = gadgetfs_bind,
.unbind = gadgetfs_unbind,
.setup  = gadgetfs_setup,
+   .reset  = gadgetfs_disconnect,
.disconnect = gadgetfs_disconnect,
.suspend= gadgetfs_suspend,
 
-- 
1.7.9.5

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


[PATCH 2/5] usb: gadget: composite: add reset API at usb_gadget_driver

2014-09-08 Thread Peter Chen
Add reset API at usb_gadget_driver, it calls disconnect handler currently,
but may do different things in future.

Signed-off-by: Peter Chen 
---
 drivers/usb/gadget/composite.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 6935a82..e07eddb 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2073,6 +2073,7 @@ static const struct usb_gadget_driver 
composite_driver_template = {
.unbind = composite_unbind,
 
.setup  = composite_setup,
+   .reset  = composite_disconnect,
.disconnect = composite_disconnect,
 
.suspend= composite_suspend,
-- 
1.7.9.5

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


[PATCH 0/5] Add reset API for usb_gadget_driver

2014-09-08 Thread Peter Chen
Hi Felipe & Alan,

It is the first step for our discussion for adding reset,
vbus, activation handler for udc framework. This patchset
just adds .reset API at usb_gadget_driver, and the four
gadget drivers still call disconnect handler at .reset.

Peter Chen (5):
  usb: gadget: add reset API at usb_gadget_driver
  usb: gadget: composite: add reset API at usb_gadget_driver
  usb: gadget: configfs: add reset API at usb_gadget_driver
  usb: gadget: gadgetfs: add reset API at usb_gadget_driver
  usb: gadget: dbgp: add reset API at usb_gadget_driver

 drivers/usb/gadget/composite.c|1 +
 drivers/usb/gadget/configfs.c |1 +
 drivers/usb/gadget/legacy/dbgp.c  |1 +
 drivers/usb/gadget/legacy/inode.c |1 +
 include/linux/usb/gadget.h|3 +++
 5 files changed, 7 insertions(+)

-- 
1.7.9.5

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


Re: [PATCH v6 4/4] phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800

2014-09-08 Thread Vivek Gautam
Hi,


On Mon, Sep 8, 2014 at 7:14 PM, Felipe Balbi  wrote:
> Hi,
>
> On Mon, Sep 08, 2014 at 09:53:09AM +0530, Vivek Gautam wrote:
>> On Fri, Sep 5, 2014 at 11:26 PM, Felipe Balbi  wrote:
>> > On Thu, Sep 04, 2014 at 12:01:19PM +0530, Vivek Gautam wrote:
>> >> > Don't we have phy_power_on()
>> >> > for that ? It looks like you could just as well do this from
>> >> > phy_power_on() ?
>> >>
>> >> No, unfortunately keeping these calibration settings in phy_power_on()
>> >> doesn't help, since we need to do this after XHCI reset has happened.
>> >
>> > teach xHCI about PHYs ?
>>
>> sorry i couldn't understand you here.
>> Aren't we trying to do the same with Heikki's patch about dwc3 :
>> [PATCH 6/6] usb: dwc3: host: convey the PHYs to xhci
>>
>> and the 2nd patch in this series :
>> [PATCH v6 2/4] usb: host: xhci-plat: Get PHYs for xhci's hcds
>>
>> Is there something else that is expected ?
>
> right, use that to call phy_init() at the right time, then you need to
> add a new ->calibrate() method which, likely, will only be used by you
> ;-)

so you mean, the xhci should itself call phy_init() at a time suitable,
so that ->calibrate() is not required at all ?

i think you meant there - "then you __do not__ need to
> add a new ->calibrate() method which, likely,
will only be used by you", is it ?




-- 
Best Regards
Vivek Gautam
Samsung R&D Institute, Bangalore
India
--
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


  1   2   >