Re: [RFC PATCH 1/7] basic_mmio_gpio: remove runtimewidth/endianness evaluation

From: Anton Vorontsov
Date: Wed Apr 06 2011 - 08:13:11 EST


On Wed, Apr 06, 2011 at 12:10:57PM +0100, Jamie Iles wrote:
> Remove endianness/width calculations at runtime by installing function
> pointers for bit-to-mask conversion and register accessors.
>
> Signed-off-by: Jamie Iles <jamie@xxxxxxxxxxxxx>
> Cc: Anton Vorontsov <cbouatmailru@xxxxxxxxx>
> Cc: Grant Likely <grant.likely@xxxxxxxxxxxx>

I guess there should be Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

:-)

[...]
> @@ -74,7 +78,8 @@ struct bgpio_chip {
> * Some GPIO controllers work with the big-endian bits notation,
> * e.g. in a 8-bits register, GPIO7 is the least significant bit.
> */
> - int big_endian_bits;
> + unsigned long (*pin2mask)(struct bgpio_chip *bgc, unsigned int pin);
> +
>
> /*

No need for this new empty line, I think.

[...]
> +static unsigned long bgpio_write64(void __iomem *reg, unsigned long data)
> +{
> + return __raw_writeq(data, reg);
> +}

I was getting this on a 64 bit machine:

CHECK drivers/gpio/basic_mmio_gpio.c
drivers/gpio/basic_mmio_gpio.c:138:16: warning: incorrect type in return expression (different base types)
drivers/gpio/basic_mmio_gpio.c:138:16: expected unsigned long
drivers/gpio/basic_mmio_gpio.c:138:16: got void
drivers/gpio/basic_mmio_gpio.c:302:33: warning: incorrect type in assignment (different base types)
drivers/gpio/basic_mmio_gpio.c:302:33: expected void ( *write_reg )( ... )
drivers/gpio/basic_mmio_gpio.c:302:33: got unsigned long ( static [toplevel] *<noident> )( ... )
CC drivers/gpio/basic_mmio_gpio.o
drivers/gpio/basic_mmio_gpio.c: In function âbgpio_write64â:
drivers/gpio/basic_mmio_gpio.c:138: error: void value not ignored as it ought to be
drivers/gpio/basic_mmio_gpio.c: In function âbgpio_setup_accessorsâ:
drivers/gpio/basic_mmio_gpio.c:302: warning: assignment from incompatible pointer type
make[1]: *** [drivers/gpio/basic_mmio_gpio.o] Error 1

And I fixed it with this:

diff --git a/drivers/gpio/basic_mmio_gpio.c b/drivers/gpio/basic_mmio_gpio.c
index 9dad485..3ddc4b2 100644
--- a/drivers/gpio/basic_mmio_gpio.c
+++ b/drivers/gpio/basic_mmio_gpio.c
@@ -133,9 +133,9 @@ static unsigned long bgpio_read32(void __iomem *reg)
}

#if BITS_PER_LONG >= 64
-static unsigned long bgpio_write64(void __iomem *reg, unsigned long data)
+static void bgpio_write64(void __iomem *reg, unsigned long data)
{
- return __raw_writeq(data, reg);
+ __raw_writeq(data, reg);
}

static unsigned long bgpio_read64(void __iomem *reg)


Otherwise, the patch looks perfect.

Acked-by: Anton Vorontsov <cbouatmailru@xxxxxxxxx>

Thanks!

--
Anton Vorontsov
Email: cbouatmailru@xxxxxxxxx

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/