From: Romain Lievin <rlievin@free.fr>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Greg Kroah <greg@kroah.com>, Randy Dunlap <randy.dunlap@verizon.net>
Subject: Fwd: [PATCH] tiglusb timeouts
Date: Tue, 26 Nov 2002 21:39:18 +0100 [thread overview]
Message-ID: <20021126203918.GA4186@free.fr> (raw)
Hi,
this patch fixes some troubles in the tiglusb driver.
Patch is against 2.5.49. Please apply.
Thanks, Romain.
> From: "Randy.Dunlap" <randy.dunlap@verizon.net>
> To: linux-usb-devel@lists.sf.net, roms@lpg.ticalc.org,
> jb@technologeek.org
> Subject: [PATCH] tiglusb timeouts
>
> Hi,
>
> Here's a patch for you to consider and apply...
> It addresses the timeout parameter in the tiglusb driver.
>
> 1. timeout could be 0, causing a divide-by-zero.
> The patch prevents this.
>
> 2. The timeout value to usb_bulk_msg() could be rounded
> down to cause a divide-by-zero if timeout was < 10, e.g. 9,
> in:
> result = usb_bulk_msg (s->dev, pipe, buffer, bytes_to_read,
> &bytes_read, HZ / (timeout / 10));
> 9 / 10 == 0 => divide-by-zero !!
>
> 3. The timeout value above doesn't do very well on converting
> timeout to tenths of seconds. Even for the default timeout
> value of 15 (1.5 seconds), it becomes:
> HZ / (15 / 10) == HZ / 1 == HZ, or 1 second.
> The patch corrects this formula to use:
> (HZ * 10) / timeout
>
> Patch is against 2.5.49. Please apply.
>
> Thanks,
> ~Randy
============================[ cut here ]========================
--- ./drivers/usb/misc/tiglusb.c%times Fri Nov 22 13:40:13 2002
+++ ./drivers/usb/misc/tiglusb.c Mon Nov 25 20:03:52 2002
@@ -185,7 +185,7 @@
pipe = usb_rcvbulkpipe (s->dev, 1);
result = usb_bulk_msg (s->dev, pipe, buffer, bytes_to_read,
- &bytes_read, HZ / (timeout / 10));
+ &bytes_read, HZ * 10 / timeout);
if (result == -ETIMEDOUT) { /* NAK */
ret = result;
if (!bytes_read) {
@@ -242,7 +242,7 @@
pipe = usb_sndbulkpipe (s->dev, 2);
result = usb_bulk_msg (s->dev, pipe, buffer, bytes_to_write,
- &bytes_written, HZ / (timeout / 10));
+ &bytes_written, HZ * 10 / timeout);
if (result == -ETIMEDOUT) { /* NAK */
warn ("tiglusb_write, NAK received.");
@@ -453,6 +453,8 @@
if (ints[0] > 0) {
timeout = ints[1];
}
+ if (!timeout)
+ timeout = TIMAXTIME;
return 1;
}
@@ -494,6 +496,9 @@
info (DRIVER_DESC ", " DRIVER_VERSION);
+ if (!timeout)
+ timeout = TIMAXTIME;
+
return 0;
}
@@ -516,6 +521,6 @@
MODULE_LICENSE (DRIVER_LICENSE);
MODULE_PARM (timeout, "i");
-MODULE_PARM_DESC (timeout, "Timeout (default=1.5 seconds)");
+MODULE_PARM_DESC (timeout, "Timeout in tenths of seconds (default=1.5 seconds)");
/* --------------------------------------------------------------------- */
============================[ cut here ]========================
--
Romain Lievin, aka 'roms' <roms@lpg.ticalc.org>
Web site <http://lpg.ticalc.org/prj_tilp>
"Linux, y'a moins bien mais c'est plus cher !"
next reply other threads:[~2002-11-26 21:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-26 20:39 Romain Lievin [this message]
2002-11-26 22:19 ` Greg KH
2002-11-26 23:29 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021126203918.GA4186@free.fr \
--to=rlievin@free.fr \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@verizon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®