All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: usbtest: Convert timers to use timer_setup()
@ 2017-10-24 10:09 Kees Cook
  2017-10-24 10:27 ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2017-10-24 10:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Alan Stern, Gustavo A. R. Silva, linux-usb, linux-kernel

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. Also adds missing call to
destroy_timer_on_stack();

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/usb/misc/usbtest.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 3639e00a51a0..7f61921e4fa0 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -576,11 +576,16 @@ alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
 	return sg;
 }
 
-static void sg_timeout(unsigned long _req)
+struct sg_timeout {
+	struct timer_list timer;
+	struct usb_sg_request *req;
+};
+
+static void sg_timeout(struct timer_list *t)
 {
-	struct usb_sg_request	*req = (struct usb_sg_request *) _req;
+	struct sg_timeout *timeout = from_timer(timeout, t, timer);
 
-	usb_sg_cancel(req);
+	usb_sg_cancel(timeout->req);
 }
 
 static int perform_sglist(
@@ -594,9 +599,11 @@ static int perform_sglist(
 {
 	struct usb_device	*udev = testdev_to_usbdev(tdev);
 	int			retval = 0;
-	struct timer_list	sg_timer;
+	struct sg_timeout	timeout = {
+		.req = req,
+	};
 
-	setup_timer_on_stack(&sg_timer, sg_timeout, (unsigned long) req);
+	timer_setup_on_stack(&timeout.timer, sg_timeout, 0);
 
 	while (retval == 0 && iterations-- > 0) {
 		retval = usb_sg_init(req, udev, pipe,
@@ -607,13 +614,14 @@ static int perform_sglist(
 
 		if (retval)
 			break;
-		mod_timer(&sg_timer, jiffies +
+		mod_timer(&timeout.timer, jiffies +
 				msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
 		usb_sg_wait(req);
-		if (!del_timer_sync(&sg_timer))
+		if (!del_timer_sync(&timeout.timer))
 			retval = -ETIMEDOUT;
 		else
 			retval = req->status;
+		destroy_timer_on_stack(&timeout.timer);
 
 		/* FIXME check resulting data pattern */
 
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: usbtest: Convert timers to use timer_setup()
  2017-10-24 10:09 [PATCH] usb: usbtest: Convert timers to use timer_setup() Kees Cook
@ 2017-10-24 10:27 ` Felipe Balbi
  2017-10-25 14:16   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2017-10-24 10:27 UTC (permalink / raw)
  To: Kees Cook, Greg Kroah-Hartman
  Cc: Alan Stern, Gustavo A. R. Silva, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]

Kees Cook <keescook@chromium.org> writes:

> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly. Also adds missing call to
> destroy_timer_on_stack();
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: usbtest: Convert timers to use timer_setup()
  2017-10-24 10:27 ` Felipe Balbi
@ 2017-10-25 14:16   ` Kees Cook
  2017-11-01 15:55     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2017-10-25 14:16 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Greg Kroah-Hartman, Alan Stern, Gustavo A. R. Silva, linux-usb, LKML

Sorry, I sent this one but forgot that timer_setup_on_stack() is in
-next only. If it's okay, I can carry it in the timers tree.

Thanks!

-Kees

On Tue, Oct 24, 2017 at 12:27 PM, Felipe Balbi
<felipe.balbi@linux.intel.com> wrote:
> Kees Cook <keescook@chromium.org> writes:
>
>> In preparation for unconditionally passing the struct timer_list pointer to
>> all timer callbacks, switch to using the new timer_setup() and from_timer()
>> to pass the timer pointer explicitly. Also adds missing call to
>> destroy_timer_on_stack();
>>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
>> Cc: Alan Stern <stern@rowland.harvard.edu>
>> Cc: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
>> Cc: linux-usb@vger.kernel.org
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
>
> --
> balbi



-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: usbtest: Convert timers to use timer_setup()
  2017-10-25 14:16   ` Kees Cook
@ 2017-11-01 15:55     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-01 15:55 UTC (permalink / raw)
  To: Kees Cook; +Cc: Felipe Balbi, Alan Stern, Gustavo A. R. Silva, linux-usb, LKML

On Wed, Oct 25, 2017 at 04:16:02PM +0200, Kees Cook wrote:
> Sorry, I sent this one but forgot that timer_setup_on_stack() is in
> -next only. If it's okay, I can carry it in the timers tree.

That's fine with me:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-01 15:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24 10:09 [PATCH] usb: usbtest: Convert timers to use timer_setup() Kees Cook
2017-10-24 10:27 ` Felipe Balbi
2017-10-25 14:16   ` Kees Cook
2017-11-01 15:55     ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.