Re: [PATCH] usb: dwc2: host: fix Wmaybe-uninitialized warning

2017-01-12 Thread Nicholas Mc Guire
On Thu, Jan 12, 2017 at 05:25:00PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Jan 12, 2017 at 04:54:38PM +0100, Nicholas Mc Guire wrote:
> > Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
> > ---
> > Problem reported by sparse
> > drivers/usb/dwc2/hcd.c: In function 'dwc2_dump_urb_info':
> > ./include/linux/dynamic_debug.h:134:3: warning: 'pipetype' may be used 
> > uninitialized in this function [-Wmaybe-uninitialized]
> >__dynamic_dev_dbg(, dev, fmt, \
> >^
> > drivers/usb/dwc2/hcd.c:4492:8: note: 'pipetype' was declared here
> >   char *pipetype;
> > ^
> > Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2=m +
> > CONFIG_USB_DWC2_VERBOSE=y
> 
> Put the above in the changelog text please, I can't take patches without
> any changelog text :(
>
sorry - simply forgot to put that in - just resent as V2

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


[PATCH V2] usb: dwc2: host: fix Wmaybe-uninitialized warning

2017-01-12 Thread Nicholas Mc Guire
Uninitialized char* causes a sparse build-warning, fix it up by
initializing it to NULL.

Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
---

V2: add missing change-log as requested by Greg Kroah-Hartman 
<gre...@linuxfoundation.org> 

Problem reported by sparse
drivers/usb/dwc2/hcd.c: In function 'dwc2_dump_urb_info':
./include/linux/dynamic_debug.h:134:3: warning: 'pipetype' may be used 
uninitialized in this function [-Wmaybe-uninitialized]
   __dynamic_dev_dbg(, dev, fmt, \
   ^
drivers/usb/dwc2/hcd.c:4492:8: note: 'pipetype' was declared here
  char *pipetype;
^
Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2=m +
CONFIG_USB_DWC2_VERBOSE=y

Patch is against 4.10-rc3 (localversion-next is next-20170112)

 drivers/usb/dwc2/hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 911c3b3..9f66777 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -4489,8 +4489,8 @@ static void dwc2_dump_urb_info(struct usb_hcd *hcd, 
struct urb *urb,
 {
 #ifdef VERBOSE_DEBUG
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
-   char *pipetype;
-   char *speed;
+   char *pipetype = NULL;
+   char *speed = NULL;
 
dev_vdbg(hsotg->dev, "%s, urb %p\n", fn_name, urb);
dev_vdbg(hsotg->dev, "  Device address: %d\n",
-- 
2.1.4

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


[PATCH] usb: dwc2: host: use msleep() for long delays

2017-01-12 Thread Nicholas Mc Guire
ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 20+ ms delays here passing the adjusted "min"
value to msleep(). This helps reduce the load on the hrtimer subsystem.

Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
---

Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2
(1 sparse and 6 coccinelle warning - preparing separate patches for that)

Patch is against 4.10-rc3 (localversion-next is next-20170112)

 drivers/usb/dwc2/hcd.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 911c3b3..37ee72d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2150,7 +2150,7 @@ static int dwc2_hcd_endpoint_disable(struct dwc2_hsotg 
*hsotg,
}
 
spin_unlock_irqrestore(>lock, flags);
-   usleep_range(2, 4);
+   msleep(20);
spin_lock_irqsave(>lock, flags);
qh = ep->hcpriv;
if (!qh) {
@@ -3240,7 +3240,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
 "Waiting for Peripheral Mode, Mode=%s\n",
 dwc2_is_host_mode(hsotg) ? "Host" :
 "Peripheral");
-   usleep_range(2, 4);
+   msleep(20);
if (++count > 250)
break;
}
@@ -3261,7 +3261,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
dev_info(hsotg->dev, "Waiting for Host Mode, Mode=%s\n",
 dwc2_is_host_mode(hsotg) ?
 "Host" : "Peripheral");
-   usleep_range(2, 4);
+   msleep(20);
if (++count > 250)
break;
}
@@ -3354,7 +3354,7 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, 
u16 windex)
 
spin_unlock_irqrestore(>lock, flags);
 
-   usleep_range(20, 25);
+   msleep(200);
} else {
spin_unlock_irqrestore(>lock, flags);
}
@@ -3378,7 +3378,7 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
pcgctl &= ~PCGCTL_STOPPCLK;
dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
spin_unlock_irqrestore(>lock, flags);
-   usleep_range(2, 4);
+   msleep(20);
spin_lock_irqsave(>lock, flags);
}
 
@@ -3691,7 +3691,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, 
u16 typereq,
}
 
/* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */
-   usleep_range(5, 7);
+   msleep(50);
hprt0 &= ~HPRT0_RST;
dwc2_writel(hprt0, hsotg->regs + HPRT0);
hsotg->lx_state = DWC2_L0; /* Now back to On state */
-- 
2.1.4

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


[PATCH] usb: dwc2: host: use true/false for boolean

2017-01-12 Thread Nicholas Mc Guire
For boolean variables true/false is preferred over 1/0 for readability.

Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
---
Problem reported by scripts/coccinelle/misc/boolinit.cocci:
./drivers/usb/dwc2/hcd.c:5003:2-24: WARNING: Assignment of bool to 0/1
./drivers/usb/dwc2/hcd.c:3397:1-21: WARNING: Assignment of bool to 0/1
./drivers/usb/dwc2/hcd.c:3335:1-21: WARNING: Assignment of bool to 0/1
./drivers/usb/dwc2/hcd.c:2970:3-17: WARNING: Assignment of bool to 0/1
./drivers/usb/dwc2/hcd.c:2999:3-16: WARNING: Assignment of bool to 0/1
./drivers/usb/dwc2/hcd.c:3299:1-21: WARNING: Assignment of bool to 0/1

Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2

Patch is against 4.10-rc3 (localversion-next is next-20170112)

 drivers/usb/dwc2/hcd.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 9f66777..7467a37 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2967,7 +2967,7 @@ static void dwc2_process_periodic_channels(struct 
dwc2_hsotg *hsotg)
qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >>
TXSTS_QSPCAVAIL_SHIFT;
if (qspcavail == 0) {
-   no_queue_space = 1;
+   no_queue_space = true;
break;
}
 
@@ -2996,7 +2996,7 @@ static void dwc2_process_periodic_channels(struct 
dwc2_hsotg *hsotg)
TXSTS_FSPCAVAIL_SHIFT;
status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail);
if (status < 0) {
-   no_fifo_space = 1;
+   no_fifo_space = true;
break;
}
 
@@ -3296,7 +3296,7 @@ static void dwc2_wakeup_detected(unsigned long data)
dwc2_readl(hsotg->regs + HPRT0));
 
dwc2_hcd_rem_wakeup(hsotg);
-   hsotg->bus_suspended = 0;
+   hsotg->bus_suspended = false;
 
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
@@ -3332,7 +3332,7 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, 
u16 windex)
hprt0 |= HPRT0_SUSP;
dwc2_writel(hprt0, hsotg->regs + HPRT0);
 
-   hsotg->bus_suspended = 1;
+   hsotg->bus_suspended = true;
 
/*
 * If hibernation is supported, Phy clock will be suspended
@@ -3394,7 +3394,7 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
hprt0 = dwc2_read_hprt0(hsotg);
hprt0 &= ~(HPRT0_RES | HPRT0_SUSP);
dwc2_writel(hprt0, hsotg->regs + HPRT0);
-   hsotg->bus_suspended = 0;
+   hsotg->bus_suspended = false;
spin_unlock_irqrestore(>lock, flags);
 }
 
@@ -5000,7 +5000,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
hsotg->dev->dma_mask == NULL) {
dev_warn(hsotg->dev,
 "dma_mask not set, disabling DMA\n");
-   hsotg->params.host_dma = 0;
+   hsotg->params.host_dma = false;
hsotg->params.dma_desc_enable = 0;
}
 
-- 
2.1.4

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


[PATCH] usb: dwc2: host: fix Wmaybe-uninitialized warning

2017-01-12 Thread Nicholas Mc Guire
Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
---
Problem reported by sparse
drivers/usb/dwc2/hcd.c: In function 'dwc2_dump_urb_info':
./include/linux/dynamic_debug.h:134:3: warning: 'pipetype' may be used 
uninitialized in this function [-Wmaybe-uninitialized]
   __dynamic_dev_dbg(, dev, fmt, \
   ^
drivers/usb/dwc2/hcd.c:4492:8: note: 'pipetype' was declared here
  char *pipetype;
^
Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2=m +
CONFIG_USB_DWC2_VERBOSE=y

Patch is against 4.10-rc3 (localversion-next is next-20170112)

 drivers/usb/dwc2/hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 911c3b3..9f66777 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -4489,8 +4489,8 @@ static void dwc2_dump_urb_info(struct usb_hcd *hcd, 
struct urb *urb,
 {
 #ifdef VERBOSE_DEBUG
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
-   char *pipetype;
-   char *speed;
+   char *pipetype = NULL;
+   char *speed = NULL;
 
dev_vdbg(hsotg->dev, "%s, urb %p\n", fn_name, urb);
dev_vdbg(hsotg->dev, "  Device address: %d\n",
-- 
2.1.4

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


[PATCH RFC] usb: dwc2: host: use msleep() for long delay

2017-01-12 Thread Nicholas Mc Guire
ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 100ms delays here passing the adjusted "min"
value to msleep(). This helps reduce the load on the hrtimer subsystem.

Link: http://lkml.org/lkml/2017/1/11/377
Fixes: commit 2938fc63e0c2 ("usb: dwc2: Properly account for the force mode 
delays")
Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
---
Problem was found by cocinelle script.

Note that this originally was an msleep(25) then commit 2938fc63e0c2 
("usb: dwc2: Properly account for the force mode delays") changed this 
to usleep_range(10,11) with the comment in the function head:

 After clearing the bits, wait up to 100 ms to account for any
 potential IDDIG filter delay...

but without explaining why the API was switched to usleep_range() here
It does not look like there is any reason for using a high resolution 
timer here - the stated requirement is clearly satisfied by msleep(100)
as well. But it originally was usleep_range(15, 16) in
commit 09c96980dc72 ("usb: dwc2: Add functions to set and clear force mode")
so not sure if I am not overlooking some reason for the highrestimer here ?

This needs to be clarified by someone that knows the details and history
of this device/driver.

Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2

Patch is aginast 4.10-rc3 (localversion-next is next-20170112)

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

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 11d8ae9..439a21b 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -455,7 +455,7 @@ void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
 
if (dwc2_iddig_filter_enabled(hsotg))
-   usleep_range(10, 11);
+   msleep(100);
 }
 
 /*
-- 
2.1.4

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


Re: [PATCH] usb: renesas_usbhs: simplify list handling

2016-11-07 Thread Nicholas Mc Guire
On Tue, Nov 08, 2016 at 12:26:45PM +0900, Masahiro Yamada wrote:
> >> Fixes: 6acb95d4e070 ("usb: renesas_usbhs: modify packet queue control 
> >> method")
> 
> 
> This is not a fix, but a clean-up patch.

true - I´ve been using it incorrectly to basically just record
the origin of the issue found - but looking at Submitting patches
this seems wrong.
In any case it would be interesting to be able to trace location
of where things go in that then need cleanups - is there an
alternative tag that could be used for that purpose ?

thx!
hofrat
--
To unsubscribe from this list: send the line "unsubscribe 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: dwc2: gadget: simplify list handling

2016-11-07 Thread Nicholas Mc Guire
The current code is effectively equivalent to list_first_entry_or_null()
so simply switch and simplify the code.

Fixes: 9c39ddc60ee9 ("USB: s3c-hsotg: Fix stall condition processing")
Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
---
Found by simple coccinelle scanner

Compile tested with: x86_64_defconfig + CONFIG_USB_DWC2=m,
CONFIG_USB_DWC2_PERIPHERAL=y

Patch is against 4.9.0-rc2 (localversion-next is next-20161028)

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

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 24fbebc..9ac8ca0 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1099,10 +1099,8 @@ static int dwc2_hsotg_process_req_status(struct 
dwc2_hsotg *hsotg,
  */
 static struct dwc2_hsotg_req *get_ep_head(struct dwc2_hsotg_ep *hs_ep)
 {
-   if (list_empty(_ep->queue))
-   return NULL;
-
-   return list_first_entry(_ep->queue, struct dwc2_hsotg_req, queue);
+   return list_first_entry_or_null(_ep->queue,
+   struct dwc2_hsotg_req, queue);
 }
 
 /**
-- 
1.7.10.4

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


[PATCH] xhci: match return type of wait_for_completion_timeout

2015-03-15 Thread Nicholas Mc Guire
Return type of wait_for_completion_timeout is unsigned long not int.
As time_left is exclusively used for wait_for_completion_timeout here its 
type is simply changed to unsigned long.

Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Patch was only compile tested with x86_64_defconfig + CONFIG_USB_XHCI_HCD=m

Patch is against 4.0-rc3 (localversion-next is -next-20150313)

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

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a7865c4..9e2bbfd 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -602,7 +602,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
return 0x;
if (time_after_eq(jiffies,
bus_state-resume_done[wIndex])) {
-   int time_left;
+   unsigned long time_left;
 
xhci_dbg(xhci, Resume USB2 port %d\n,
wIndex + 1);
-- 
1.7.10.4

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


[PATCH] USB: legotower: use msecs_to_jiffies for time conversion

2015-02-06 Thread Nicholas Mc Guire
This is only an API consolidation and should make things more readable
it replaces var * HZ / 1000 by msecs_to_jiffies(var).

Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Patch was only compile tested with x86_64_defconfig + CONFIG_USB_LEGOTOWER=m

Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

 drivers/usb/misc/legousbtower.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 97cd9e2..7771be3 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -574,7 +574,7 @@ static ssize_t tower_read (struct file *file, char __user 
*buffer, size_t count,
}
 
if (read_timeout) {
-   timeout = jiffies + read_timeout * HZ / 1000;
+   timeout = jiffies + msecs_to_jiffies(read_timeout);
}
 
/* wait for data */
@@ -592,7 +592,7 @@ static ssize_t tower_read (struct file *file, char __user 
*buffer, size_t count,
/* reset read timeout during read or write activity */
if (read_timeout
 (dev-read_buffer_length || dev-interrupt_out_busy)) {
-   timeout = jiffies + read_timeout * HZ / 1000;
+   timeout = jiffies + msecs_to_jiffies(read_timeout);
}
/* check for read timeout */
if (read_timeout  time_after (jiffies, timeout)) {
@@ -831,7 +831,7 @@ static int tower_probe (struct usb_interface *interface, 
const struct usb_device
dev-read_buffer_length = 0;
dev-read_packet_length = 0;
spin_lock_init (dev-read_buffer_lock);
-   dev-packet_timeout_jiffies = packet_timeout * HZ / 1000;
+   dev-packet_timeout_jiffies = msecs_to_jiffies(packet_timeout);
dev-read_last_arrival = jiffies;
 
init_waitqueue_head (dev-read_wait);
-- 
1.7.10.4

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


[PATCH] USB: image: use msecs_to_jiffies for time conversion

2015-02-06 Thread Nicholas Mc Guire
This is only an API consolidation and should make things more readable
it replaces var * HZ / 1000 by msecs_to_jiffies(var).

Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Note that the indentation is not aligned with the correct ( here due to
lines going over 80 char - not sure if this is the right way to resolve
this (this file has quite a few coding style issues).

Patch was only compile tested with x86_64_defconfig + CONFIG_USB_MDC800=m

Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

 drivers/usb/image/mdc800.c |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index a62865a..3a72e8f 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -347,7 +347,8 @@ static int mdc800_usb_waitForIRQ (int mode, int msec)
 {
mdc800-camera_request_ready=1+mode;
 
-   wait_event_timeout(mdc800-irq_wait, mdc800-irq_woken, msec*HZ/1000);
+   wait_event_timeout(mdc800-irq_wait, mdc800-irq_woken,
+  msecs_to_jiffies(msec));
mdc800-irq_woken = 0;
 
if (mdc800-camera_request_ready0)
@@ -743,8 +744,9 @@ static ssize_t mdc800_device_read (struct file *file, char 
__user *buf, size_t l
mutex_unlock(mdc800-io_lock);
return len-left;
}
-   wait_event_timeout(mdc800-download_wait, 
mdc800-downloaded,
-   
TO_DOWNLOAD_GET_READY*HZ/1000);
+   wait_event_timeout(mdc800-download_wait,
+mdc800-downloaded,
+msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
mdc800-downloaded = 0;
if (mdc800-download_urb-status != 0)
{
@@ -867,7 +869,8 @@ static ssize_t mdc800_device_write (struct file *file, 
const char __user *buf, s
mutex_unlock(mdc800-io_lock);
return -EIO;
}
-   wait_event_timeout(mdc800-write_wait, mdc800-written, 
TO_WRITE_GET_READY*HZ/1000);
+   wait_event_timeout(mdc800-write_wait, mdc800-written,
+   msecs_to_jiffies(TO_WRITE_GET_READY));
mdc800-written = 0;
if (mdc800-state == WORKING)
{
-- 
1.7.10.4

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


[PATCH] usb: isp1760: use msecs_to_jiffies for time conversion

2015-02-06 Thread Nicholas Mc Guire
This is only an API consolidation and should make things more readable
it replaces var * HZ / 1000 by msecs_to_jiffies(var).

Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Patch was only compile tested with x86_64_defconfig + CONFIG_USB_ISP1760=m

Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

 drivers/usb/isp1760/isp1760-hcd.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c 
b/drivers/usb/isp1760/isp1760-hcd.c
index eba9b82..3cb98b1 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -1274,7 +1274,7 @@ static void errata2_function(unsigned long data)
for (slot = 0; slot  32; slot++)
if (priv-atl_slots[slot].qh  time_after(jiffies,
priv-atl_slots[slot].timestamp +
-   SLOT_TIMEOUT * HZ / 1000)) {
+   msecs_to_jiffies(SLOT_TIMEOUT))) {
ptd_read(hcd-regs, ATL_PTD_OFFSET, slot, ptd);
if (!FROM_DW0_VALID(ptd.dw0) 
!FROM_DW3_ACTIVE(ptd.dw3))
@@ -1286,7 +1286,7 @@ static void errata2_function(unsigned long data)
 
spin_unlock_irqrestore(priv-lock, spinflags);
 
-   errata2_timer.expires = jiffies + SLOT_CHECK_PERIOD * HZ / 1000;
+   errata2_timer.expires = jiffies + msecs_to_jiffies(SLOT_CHECK_PERIOD);
add_timer(errata2_timer);
 }
 
@@ -1336,7 +1336,7 @@ static int isp1760_run(struct usb_hcd *hcd)
return retval;
 
setup_timer(errata2_timer, errata2_function, (unsigned long)hcd);
-   errata2_timer.expires = jiffies + SLOT_CHECK_PERIOD * HZ / 1000;
+   errata2_timer.expires = jiffies + msecs_to_jiffies(SLOT_CHECK_PERIOD);
add_timer(errata2_timer);
 
chipid = reg_read32(hcd-regs, HC_CHIP_ID_REG);
-- 
1.7.10.4

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


Re: [PATCH] USB: image: use msecs_to_jiffies for time conversion

2015-02-06 Thread Nicholas Mc Guire
On Fri, 06 Feb 2015, Sergei Shtylyov wrote:

 Hello.

 On 2/6/2015 12:50 PM, Nicholas Mc Guire wrote:

 This is only an API consolidation and should make things more readable
 it replaces var * HZ / 1000 by msecs_to_jiffies(var).

 Signed-off-by: Nicholas Mc Guire hof...@osadl.org
 ---

 Note that the indentation is not aligned with the correct ( here due to
 lines going over 80 char - not sure if this is the right way to resolve
 this (this file has quite a few coding style issues).

 Patch was only compile tested with x86_64_defconfig + CONFIG_USB_MDC800=m

 Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

   drivers/usb/image/mdc800.c |   11 +++
   1 file changed, 7 insertions(+), 4 deletions(-)

 diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
 index a62865a..3a72e8f 100644
 --- a/drivers/usb/image/mdc800.c
 +++ b/drivers/usb/image/mdc800.c
 [...]
 @@ -743,8 +744,9 @@ static ssize_t mdc800_device_read (struct file *file, 
 char __user *buf, size_t l
  mutex_unlock(mdc800-io_lock);
  return len-left;
  }
 -wait_event_timeout(mdc800-download_wait, 
 mdc800-downloaded,
 -
 TO_DOWNLOAD_GET_READY*HZ/1000);
 +wait_event_timeout(mdc800-download_wait,
 + mdc800-downloaded,
 + msecs_to_jiffies(TO_DOWNLOAD_GET_READY));

Don't indent with spaces (you're not aligning to open paren anyway), 
 use the final tab instead, please.

thanks ! In the diff output that problem is actually not well visible.
was not really clear on how to do this properly - the problem with 
using the last tab stop is that you then get the following code

wait_event_timeout(mdc800-download_wait,
mdc800-downloaded,
msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
mdc800-downloaded = 0;

which semed really bad and 

wait_event_timeout(mdc800-download_wait,
 mdc800-downloaded,
 msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
mdc800-downloaded = 0;

makes it atleast somewhat readable. If I indent a full tab ghen it goes over
80 char.

So in this case - should one use the last tab-stop anyway ?

thx!
hofrat
--
To unsubscribe from this list: send the line unsubscribe 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] mmc: vub300: remove unreachable return value handling

2015-01-17 Thread Nicholas Mc Guire
Signed-off-by: Nicholas Mc Guire der.h...@hofr.at
---

The return value of wait_for_completion_timeout is unsigned long, 
as it is used here for wait_for_completion_timeout only the type 
of commretval was changed to unsigned long.

As wait_for_completion_timeout does not return negative values
the commretval  0 case is not reachable and can be removed.

This was only compile-tested for x86_64_defconfig + CONFIG_MMC=m,
CONFIG_MMC_VUB300=m

Patch is against 3.19.0-rc4 -next-20150116

 drivers/mmc/host/vub300.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
index 4262296..fbabbb8 100644
--- a/drivers/mmc/host/vub300.c
+++ b/drivers/mmc/host/vub300.c
@@ -659,7 +659,7 @@ static void __vub300_irqpoll_response(struct 
vub300_mmc_host *vub300)
 static void __do_poll(struct vub300_mmc_host *vub300)
 {
/* cmd_mutex is held by vub300_pollwork_thread */
-   long commretval;
+   unsigned long commretval;
mod_timer(vub300-inactivity_timer, jiffies + HZ);
init_completion(vub300-irqpoll_complete);
send_irqpoll(vub300);
@@ -671,8 +671,6 @@ static void __do_poll(struct vub300_mmc_host *vub300)
vub300-usb_timed_out = 1;
usb_kill_urb(vub300-command_out_urb);
usb_kill_urb(vub300-command_res_urb);
-   } else if (commretval  0) {
-   vub300_queue_poll_work(vub300, 1);
} else { /* commretval  0 */
__vub300_irqpoll_response(vub300);
}
-- 
1.7.10.4

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


[PATCH] cleanup on stack DECLARE_COMPLETIONs

2014-12-23 Thread Nicholas Mc Guire
fixups for incorrect use of DECLARE_COMPLETION. see also commit
6e9a4738 (completions: lockdep annotate on stack completions)
The only somewhat special case being
drivers/misc/sgi-gru/grukservices.c:quicktest2
which had a static qualifier in the original DECLARE_COMPLETION()
but that seems to be wrong (why should the completion persisted between
successive calls ?) so the conversion to DECLARE_COMPLETION_ONSTACK
was also applied and the static qualifier removed.

Not sure if this is suitable in this form or if it should go out as
5 seperate patches ? 

This was only code reviewed and compile tested

Signed-off-by: Nicholas Mc Guire der.h...@hofr.at
---
 drivers/macintosh/ams/ams-pmu.c   |4 ++--
 drivers/misc/sgi-gru/grukservices.c   |2 +-
 drivers/scsi/aha152x.c|2 +-
 drivers/usb/gadget/udc/fsl_qe_udc.c   |2 +-
 drivers/usb/gadget/udc/fsl_udc_core.c |2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/macintosh/ams/ams-pmu.c b/drivers/macintosh/ams/ams-pmu.c
index 4f61b3e..c2b178f 100644
--- a/drivers/macintosh/ams/ams-pmu.c
+++ b/drivers/macintosh/ams/ams-pmu.c
@@ -52,7 +52,7 @@ static void ams_pmu_req_complete(struct adb_request *req)
 static void ams_pmu_set_register(u8 reg, u8 value)
 {
static struct adb_request req;
-   DECLARE_COMPLETION(req_complete);
+   DECLARE_COMPLETION_ONSTACK(req_complete);

req.arg = req_complete;
if (pmu_request(req, ams_pmu_req_complete, 4, ams_pmu_cmd, 0x00, reg, 
value))
@@ -65,7 +65,7 @@ static void ams_pmu_set_register(u8 reg, u8 value)
 static u8 ams_pmu_get_register(u8 reg)
 {
static struct adb_request req;
-   DECLARE_COMPLETION(req_complete);
+   DECLARE_COMPLETION_ONSTACK(req_complete);

req.arg = req_complete;
if (pmu_request(req, ams_pmu_req_complete, 3, ams_pmu_cmd, 0x01, reg))
diff --git a/drivers/misc/sgi-gru/grukservices.c 
b/drivers/misc/sgi-gru/grukservices.c
index 913de07..4e412fe 100644
--- a/drivers/misc/sgi-gru/grukservices.c
+++ b/drivers/misc/sgi-gru/grukservices.c
@@ -1044,7 +1044,7 @@ done:

 static int quicktest2(unsigned long arg)
 {
-   static DECLARE_COMPLETION(cmp);
+   DECLARE_COMPLETION_ONSTACK(cmp);
unsigned long han;
int blade_id = 0;
int numcb = 4;
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 2b960b3..b16afb9 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1055,7 +1055,7 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
 static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
 {
struct Scsi_Host *shpnt = SCpnt-device-host;
-   DECLARE_COMPLETION(done);
+   DECLARE_COMPLETION_ONSTACK(done);
int ret, issued, disconnected;
unsigned char old_cmd_len = SCpnt-cmd_len;
unsigned long flags;
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c 
b/drivers/usb/gadget/udc/fsl_qe_udc.c
index 795c99c..e0822f1 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -2630,7 +2630,7 @@ static int qe_udc_remove(struct platform_device *ofdev)
struct qe_udc *udc = platform_get_drvdata(ofdev);
struct qe_ep *ep;
unsigned int size;
-   DECLARE_COMPLETION(done);
+   DECLARE_COMPLETION_ONSTACK(done);

usb_del_gadget_udc(udc-gadget);

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index 2df8074..c3830ad 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2529,7 +2529,7 @@ static int __exit fsl_udc_remove(struct platform_device 
*pdev)
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct fsl_usb2_platform_data *pdata = dev_get_platdata(pdev-dev);

-   DECLARE_COMPLETION(done);
+   DECLARE_COMPLETION_ONSTACK(done);

if (!udc_controller)
return -ENODEV;
--
1.7.10.4

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


[PATCH] gadget: cleanup on stack DECLARE_COMPLETIONs

2014-12-23 Thread Nicholas Mc Guire
fixups for incorrect use of DECLARE_COMPLETION. see also commit
6e9a4738 (completions: lockdep annotate on stack completions)

patch is against 3.18.0 linux-next

This was only code reviewed and compile tested

Signed-off-by: Nicholas Mc Guire der.h...@hofr.at
---
 drivers/usb/gadget/udc/fsl_qe_udc.c   |2 +-
 drivers/usb/gadget/udc/fsl_udc_core.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c 
b/drivers/usb/gadget/udc/fsl_qe_udc.c
index 795c99c..e0822f1 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -2630,7 +2630,7 @@ static int qe_udc_remove(struct platform_device *ofdev)
struct qe_udc *udc = platform_get_drvdata(ofdev);
struct qe_ep *ep;
unsigned int size;
-   DECLARE_COMPLETION(done);
+   DECLARE_COMPLETION_ONSTACK(done);

usb_del_gadget_udc(udc-gadget);

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index 2df8074..c3830ad 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2529,7 +2529,7 @@ static int __exit fsl_udc_remove(struct platform_device 
*pdev)
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct fsl_usb2_platform_data *pdata = dev_get_platdata(pdev-dev);

-   DECLARE_COMPLETION(done);
+   DECLARE_COMPLETION_ONSTACK(done);

if (!udc_controller)
return -ENODEV;
--
1.7.10.4

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