Re: [PATCH] GPIO driver for ST Microelectronics ConneXt(STA2X11/STA2X10), PCIe I/O Hub

From: Matthew Wilcox
Date: Fri Nov 13 2009 - 08:49:41 EST


On Fri, Nov 13, 2009 at 01:23:26PM +0100, Meng, Chen wrote:
> This patch is a GPIO driver for ST Microelectronics ConneXt
> (STA2X11/STA2X10), PCIe I/O Hub.
> It's derived from pl061.c and compatible with GPIOLIB.

You really need to run this driver through scripts/Lindent ...

> +#define ppwrite(dat, base, adr) writel((dat), (base) + (adr))
> +#define ppread(base, adr) readl((base) + (adr))

Why not just use readl and writel directly?

> +int pl061_pci_gpio_request(struct gpio_chip *gpio, unsigned nr) {
> + struct pl061_pci *pp = container_of(gpio, struct pl061_pci, gpio);
> + u32 flag = 1 << (nr % PINS_PER_CHIP);
> + u32 *mutex = &pp->mutex[nr / PINS_PER_CHIP];
> +
> + if (nr >= gpio->ngpio)
> + return -EINVAL;
> + if ((*mutex) & flag)
> + return -EBUSY;
> +
> + *mutex |= flag;
> +
> + return 0;
> +}

gpiolib calls chip->request without a lock held, so you need some locking
to protect pp->mutex.

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
--
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/