Re: [RFC PATCH 7/7] basic_mmio_gpio: support direction registers

From: Anton Vorontsov
Date: Wed Apr 06 2011 - 08:12:35 EST


On Wed, Apr 06, 2011 at 12:11:03PM +0100, Jamie Iles wrote:
> Most controllers require the direction of a GPIO to be set by writing to
> a direction register. Add support for either an input direction
> register or an output direction register.
>
> Signed-off-by: Jamie Iles <jamie@xxxxxxxxxxxxx>
> Cc: Anton Vorontsov <cbouatmailru@xxxxxxxxx>
> Cc: Grant Likely <grant.likely@xxxxxxxxxxxx>
[...]
> @@ -71,6 +71,8 @@ struct bgpio_chip {
> void __iomem *reg_set;
> void __iomem *reg_clr;
> void __iomem *reg_in;
> + void __iomem *reg_dirout;
> + void __iomem *reg_dirin;
>

I guess you don't need both reg_dirout and reg_dirin in the runtime.
How about just renaming it to "reg_dir" and just assinging it with
either dirout or dirin in bgpio_setup_direction()?

[...]
> + /* Shadowed direction registers to clear/set direction safely. */
> + unsigned long outputs, inputs;

Same as obove, maybe just a single 'dir' variable?

Plus, a minor nit: the coding style suggests:

unsigned long outputs;
unsigned long inputs;

[...]
> static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
> {
> + struct bgpio_chip *bgc = to_bgpio_chip(gc);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&bgc->lock, flags);
> + bgc->outputs &= ~bgc->pin2mask(bgc, gpio);
> + bgc->write_reg(bgc->reg_dirout, bgc->outputs);
> + spin_unlock_irqrestore(&bgc->lock, flags);
>

Because of the lock, the code in these routines is dense and hard to
read, so I would rather add empty lines near the locking calls, just
like in bgpio_set() (also makes it look consistent).

Otherwise,

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/