Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933503AbbESOcV (ORCPT ); Tue, 19 May 2015 10:32:21 -0400 Received: from smtprelay0187.hostedemail.com ([216.40.44.187]:42415 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933467AbbESOcT (ORCPT ); Tue, 19 May 2015 10:32:19 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:3871:3872:4321:4470:5007:6261:7903:10004:10400:10848:11026:11232:11658:11914:12043:12438:12517:12519:12740:13069:13161:13229:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: girls77_8851c2a0a5963 X-Filterd-Recvd-Size: 1852 Message-ID: <1432045935.2870.152.camel@perches.com> Subject: Re: [PATCH] irda: irda-usb: use msecs_to_jiffies for conversions From: Joe Perches To: Nicholas Mc Guire Cc: Samuel Ortiz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 19 May 2015 07:32:15 -0700 In-Reply-To: <1432032711-7020-1-git-send-email-hofrat@osadl.org> References: <1432032711-7020-1-git-send-email-hofrat@osadl.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1237 Lines: 29 On Tue, 2015-05-19 at 12:51 +0200, Nicholas Mc Guire wrote: > Converting milliseconds to jiffies by "val * HZ / 1000" is technically > is not a clean solution as it does not handle all corner cases correctly. > By changing the conversion to use msecs_to_jiffies(val) conversion is > correct in all cases. > > in the current code: > mod_timer(&self->rx_defer_timer, jiffies + (10 * HZ / 1000)); > for HZ < 100 (e.g. CONFIG_HZ == 64|32 in alpha) this effectively results > in no delay at all. [] > diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c [] > @@ -848,7 +848,9 @@ static void irda_usb_receive(struct urb *urb) > * Jean II */ > self->rx_defer_timer.function = irda_usb_rx_defer_expired; > self->rx_defer_timer.data = (unsigned long) urb; > - mod_timer(&self->rx_defer_timer, jiffies + (10 * HZ / 1000)); > + mod_timer(&self->rx_defer_timer, > + jiffies + (msecs_to_jiffies(10))); The unnecessary () around msecs_to_jiffies could be removed. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/