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

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

 



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-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux