linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jamie@shareable.org (Jamie Lokier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mach-pxa/viper: Fix timeout usage for I2C
Date: Mon, 12 Apr 2010 22:53:26 +0100	[thread overview]
Message-ID: <20100412215326.GD6148@shareable.org> (raw)
In-Reply-To: <20100412193943.GP3048@n2100.arm.linux.org.uk>

Russell King - ARM Linux wrote:
> On Mon, Apr 12, 2010 at 09:32:35PM +0200, Jean Delvare wrote:
> > On Mon, 12 Apr 2010 20:20:10 +0100, Russell King - ARM Linux wrote:
> > > On Mon, Apr 12, 2010 at 09:13:19PM +0200, Jean Delvare wrote:
> > > > On Tue, 13 Apr 2010 01:57:51 +0800, Eric Miao wrote:
> > > > > One other better and cleaner approach to such inconsistency issue is
> > > > > to have a timeout_ms field, and having i2c-gpio.c driver to convert this
> > > > > to jiffies using msec_to_jiffies() at run-time.
> > > > 
> > > > With what benefit? Expressing time values in units of HZ is very
> > > > frequent in the kernel code and shouldn't actually surprise anyone.
> > > 
> > > Actually, this patch shows there is confusion.
> > > 
> > > "Assume '100' means 100ms here and adapt accordingly."
> > > 
> > > Since this patch is for ARM, where HZ=100, the above patch is not a
> > > simple "convert how we derive this constant" patch - it's a functional
> > > change, reducing the timeouts by a factor of 10.
> > > 
> > > Could that be because the patch author misinterpreted the HZ-based
> > > values?
> > 
> > I admit I would have assumed 100 -> HZ, as hard-coded HZ-dependent
> > value typically assume HZ=100.
> > 
> > > I suspect I'm not the only one who thinks that the latter of "HZ / 10"
> > > "100ms" is easier to read and comprehend without mistake.
> > 
> > OTOH, converting from ms to jiffies each time you need the value has a
> > cost.
> 
> True; what I did for MMC stuff is converted it from ms to jiffies at
> initialization time when copying it in from platform data in the
> driver's probe function.
> 
> I'm not saying that I care either way, I'm merely showing that dealing
> with HZ-based values can be (maybe unexpectedly) more error prone.

HZ is used a lot in kernel timeouts, so even though it's confusing, it
is something everyone ought to get used to.

But I agree it is too confusing.  An obvious remedy is:

#define milliseconds(ms) (((ms) * HZ + 999) / 1000)
#define seconds(s)       ((s) * HZ)

-- Jamie

  reply	other threads:[~2010-04-12 21:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-04 14:08 [PATCH] mach-pxa/viper: Fix timeout usage for I2C Wolfram Sang
2010-04-12 17:57 ` Eric Miao
2010-04-12 19:13   ` Jean Delvare
2010-04-12 19:20     ` Russell King - ARM Linux
2010-04-12 19:32       ` Jean Delvare
2010-04-12 19:39         ` Russell King - ARM Linux
2010-04-12 21:53           ` Jamie Lokier [this message]
2010-04-12 23:04             ` Eric Miao
2010-04-18 11:48         ` [PATCH V2] " Wolfram Sang
2010-04-20  0:20           ` Eric Miao
2010-04-20  1:03             ` Wolfram Sang
2010-04-20  8:27           ` Marc Zyngier
2010-04-20  8:40             ` Marek Vasut
2010-04-20  9:21               ` Eric Miao

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=20100412215326.GD6148@shareable.org \
    --to=jamie@shareable.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).