Re: [PATCH 3/3] ARM: S5PV310: Add external interrupt support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  Powered by Linux