From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Jongsun Han <jongsun.han@samsung.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com,
Jongpill Lee <boyko.lee@samsung.com>,
ben-linux@fluff.org
Subject: Re: [PATCH 3/3] ARM: S5PV310: Add external interrupt support
Date: Sat, 9 Oct 2010 11:16:46 +0100 [thread overview]
Message-ID: <20101009101646.GC20975@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1286450698-12029-4-git-send-email-jongsun.han@samsung.com>
On Thu, Oct 07, 2010 at 08:24:58PM +0900, Jongsun Han wrote:
> +static unsigned int s5pv310_irq_split(unsigned int number)
> +{
> + u32 ret;
> + u32 test = number;
> +
> + ret = do_div(test, IRQ_EINT_BASE);
> +
> + do_div(ret, 8);
> +
> + return ret;
> +}
> +
> +static unsigned int s5pv310_irq_to_bit(unsigned int irq)
> +{
> + u32 ret;
> + u32 tmp;
> +
> + tmp = do_div(irq, IRQ_EINT_BASE);
> +
> + ret = do_div(tmp, 8);
> +
> + return 1 << ret;
> +}
These are a silly use of do_div(). do_div() is for 64-bit modulus/division,
not 32-bit. If you want to do 32-bit, then use the normal C maths.
What the above equates to is:
tmp = irq % IRQ_EINT_BASE;
ret = tmp % 8;
However, I don't think you want to do modulus operations there at all.
What I think you actually want is:
return 1 << ((irq - IRQ_EINT_BASE) % 7);
noting that the compiler will optimize this to a subtract and bit-wise and
operation.
For the former:
return ((irq - IRQ_EINT_BASE) / 8);
noting that the compiler will optimize this to a subtract and shift.
next prev parent reply other threads:[~2010-10-09 10:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 11:24 [PATCH 0/3] ARM: S5PV310: Add EINT support Jongsun Han
2010-10-07 11:24 ` [PATCH 1/3] ARM: S5P: Add GPIO2 memory map definition Jongsun Han
2010-10-07 11:24 ` [PATCH 2/3] ARM: S5PV310: Add the definition for external interrupt Jongsun Han
2010-10-15 1:58 ` Kukjin Kim
2010-10-07 11:24 ` [PATCH 3/3] ARM: S5PV310: Add external interrupt support Jongsun Han
2010-10-07 12:30 ` Marek Szyprowski
2010-10-08 10:06 ` Jongsun Han
2010-10-09 10:16 ` Russell King - ARM Linux [this message]
2010-10-15 1:18 ` Kukjin Kim
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=20101009101646.GC20975@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=ben-linux@fluff.org \
--cc=boyko.lee@samsung.com \
--cc=jongsun.han@samsung.com \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.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