lkml.org 
[lkml]   [2011]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [v2 2/4] platform: (TS-5500) add GPIO support
On Fri, Aug 26, 2011 at 07:40:25PM -0400, Vivien Didelot wrote:

> arch/x86/platform/ts5500/ts5500_gpio.c | 421 ++++++++++++++++++++++++++++++++
> arch/x86/platform/ts5500/ts5500_gpio.h | 60 +++++

New GPIO drivers should really go under drivers/gpiolib and be called
gpio-foo.c.

> +static int ts5500_gpio_request(struct gpio_chip *chip, unsigned offset)
> +{
> + struct ts5500_drvdata *drvdata;
> +
> + drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
> +
> + mutex_lock(&drvdata->gpio_lock);
> + if (requested_gpios[offset]) {
> + mutex_unlock(&drvdata->gpio_lock);
> + return -EBUSY;
> + }
> + requested_gpios[offset] = 1;
> + mutex_unlock(&drvdata->gpio_lock);

gpiolib should already be making sure there's only one user at once, no
need to bother open coding it in the driver.

> + bitno = line_to_bit_map[offset];
> +
> + mutex_lock(&drvdata->gpio_lock);
> + byte = inb(ioaddr);
> + mutex_unlock(&drvdata->gpio_lock);

Do you really need the lock to do a read?


\
 
 \ /
  Last update: 2011-08-30 00:15    [W:0.150 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site