Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbbESVJO (ORCPT ); Tue, 19 May 2015 17:09:14 -0400 Received: from smtprelay0123.hostedemail.com ([216.40.44.123]:59795 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751209AbbESVJL (ORCPT ); Tue, 19 May 2015 17:09:11 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800: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:2553:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3870:3871:3872:3874:4321:4470:5007:6261:7576:7903:10004:10400:10848:10967:11026:11232:11658:11914:12043:12438:12517:12519:12740:13019: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: song37_6cd878e8d6f40 X-Filterd-Recvd-Size: 2307 Message-ID: <1432069747.2870.215.camel@perches.com> Subject: Re: [PATCH] irda: irda-usb: use msecs_to_jiffies for conversions From: Joe Perches To: David Miller Cc: hofrat@osadl.org, samuel@sortiz.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 19 May 2015 14:09:07 -0700 In-Reply-To: <20150519.164555.1631069770118420652.davem@davemloft.net> References: <1432032711-7020-1-git-send-email-hofrat@osadl.org> <1432045935.2870.152.camel@perches.com> <20150519.164555.1631069770118420652.davem@davemloft.net> 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: 1572 Lines: 38 On Tue, 2015-05-19 at 16:45 -0400, David Miller wrote: > From: Joe Perches > Date: Tue, 19 May 2015 07:32:15 -0700 > > > 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. The other thing that could be done is to use max(1ul, msecs_to_jiffies()) so that there's always some delay even if HZ <= 50 -- 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/