From: Tony Lindgren <tony@atomide.com>
To: "Pandita, Vikram" <vikram.pandita@ti.com>
Cc: "Paul Walmsley" <paul@pwsan.com>,
"Russell King - ARM Linux" <linux@arm.linux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"Juha Leppänen" <juha_motorsportcom@luukku.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors
Date: Tue, 17 Nov 2009 14:24:10 -0800 [thread overview]
Message-ID: <20091117222409.GH29266@atomide.com> (raw)
In-Reply-To: <FCCFB4CDC6E5564B9182F639FC35608702FA689E6A@dbde02.ent.ti.com>
* Pandita, Vikram <vikram.pandita@ti.com> [091117 09:50]:
> Paul
>
> >-----Original Message-----
> >From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Paul
> >Walmsley
> >Sent: Tuesday, November 17, 2009 11:39 AM
> >To: Russell King - ARM Linux
> >Cc: linux-arm-kernel@lists.infradead.org; Juha Leppänen; linux-omap@vger.kernel.org
> >Subject: Re: [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors
> <snip>
> >
> >+/**
> >+ * omap_test_timeout - busy-loop, testing a condition
> >+ * @cond: condition to test until it evaluates to true
> >+ * @timeout: maximum number of microseconds in the timeout
> >+ * @index: loop index (integer)
> >+ *
> >+ * Loop waiting for @cond to become true or until at least @timeout
> >+ * microseconds have passed. To use, define some integer @index in the
> >+ * calling code. After running, if @index == @timeout, then the loop has
> >+ * timed out.
> >+ */
> >+#define omap_test_timeout(cond, timeout, index) \
> >+({ \
> >+ for (index = 0; index < timeout; index++) { \
> >+ if (cond) \
> >+ break; \
> >+ udelay(1); \
> >+ } \
> >+})
> >+
>
> There is a similar kind of function implemented in USB host, that returns -ETIMEDOUT
> Which makes more sense for failure case.
>
> Maybe such a generic function for all omaps is needed.
>
> Refer:
> drivers/usb/host/ehci-hcd.c
> static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
> u32 mask, u32 done, int usec)
> {
> u32 result;
>
> do {
> result = ehci_readl(ehci, ptr);
> if (result == ~(u32)0) /* card removed */
> return -ENODEV;
> result &= mask;
> if (result == done)
> return 0;
> udelay (1);
> usec--;
> } while (usec > 0);
> return -ETIMEDOUT;
> }
>
>
> > #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
Well we need to stick to minimal changes if we plan to send this in as a fix.
Anything more complex we should do the next merge window.
Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors
Date: Tue, 17 Nov 2009 14:24:10 -0800 [thread overview]
Message-ID: <20091117222409.GH29266@atomide.com> (raw)
In-Reply-To: <FCCFB4CDC6E5564B9182F639FC35608702FA689E6A@dbde02.ent.ti.com>
* Pandita, Vikram <vikram.pandita@ti.com> [091117 09:50]:
> Paul
>
> >-----Original Message-----
> >From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of Paul
> >Walmsley
> >Sent: Tuesday, November 17, 2009 11:39 AM
> >To: Russell King - ARM Linux
> >Cc: linux-arm-kernel at lists.infradead.org; Juha Lepp?nen; linux-omap at vger.kernel.org
> >Subject: Re: [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors
> <snip>
> >
> >+/**
> >+ * omap_test_timeout - busy-loop, testing a condition
> >+ * @cond: condition to test until it evaluates to true
> >+ * @timeout: maximum number of microseconds in the timeout
> >+ * @index: loop index (integer)
> >+ *
> >+ * Loop waiting for @cond to become true or until at least @timeout
> >+ * microseconds have passed. To use, define some integer @index in the
> >+ * calling code. After running, if @index == @timeout, then the loop has
> >+ * timed out.
> >+ */
> >+#define omap_test_timeout(cond, timeout, index) \
> >+({ \
> >+ for (index = 0; index < timeout; index++) { \
> >+ if (cond) \
> >+ break; \
> >+ udelay(1); \
> >+ } \
> >+})
> >+
>
> There is a similar kind of function implemented in USB host, that returns -ETIMEDOUT
> Which makes more sense for failure case.
>
> Maybe such a generic function for all omaps is needed.
>
> Refer:
> drivers/usb/host/ehci-hcd.c
> static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
> u32 mask, u32 done, int usec)
> {
> u32 result;
>
> do {
> result = ehci_readl(ehci, ptr);
> if (result == ~(u32)0) /* card removed */
> return -ENODEV;
> result &= mask;
> if (result == done)
> return 0;
> udelay (1);
> usec--;
> } while (usec > 0);
> return -ETIMEDOUT;
> }
>
>
> > #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
Well we need to stick to minimal changes if we plan to send this in as a fix.
Anything more complex we should do the next merge window.
Tony
next prev parent reply other threads:[~2009-11-17 22:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 13:36 [PATCH 0/3] OMAP clock and PM architecture fixes for 2.6.32-rc6 Paul Walmsley
2009-11-16 13:36 ` Paul Walmsley
2009-11-16 13:36 ` [PATCH 1/3] OMAP3 clock: Fix the DPLL freqsel computations Paul Walmsley
2009-11-16 13:36 ` Paul Walmsley
2009-11-17 22:14 ` [APPLIED] " Tony Lindgren
2009-11-16 13:36 ` [PATCH 2/3] OMAP3: Clock: Fixed dpll3_m2x2 rate calculation Paul Walmsley
2009-11-16 13:36 ` Paul Walmsley
2009-11-17 22:14 ` [APPLIED] " Tony Lindgren
2009-11-16 13:36 ` [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors Paul Walmsley
2009-11-16 13:36 ` Paul Walmsley
2009-11-16 14:08 ` Russell King - ARM Linux
2009-11-16 14:08 ` Russell King - ARM Linux
2009-11-17 17:39 ` Paul Walmsley
2009-11-17 17:39 ` Paul Walmsley
2009-11-17 17:50 ` Pandita, Vikram
2009-11-17 17:50 ` Pandita, Vikram
2009-11-17 22:24 ` Tony Lindgren [this message]
2009-11-17 22:24 ` Tony Lindgren
2009-11-18 18:47 ` Tony Lindgren
2009-11-18 18:47 ` Tony Lindgren
2009-11-18 19:11 ` Paul Walmsley
2009-11-18 19:11 ` Paul Walmsley
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=20091117222409.GH29266@atomide.com \
--to=tony@atomide.com \
--cc=juha_motorsportcom@luukku.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=paul@pwsan.com \
--cc=vikram.pandita@ti.com \
/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 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.