Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105826
b: refs/heads/master
c: 28130be
h: refs/heads/master
v: v3
  • Loading branch information
Ben Dooks authored and Linus Torvalds committed Jul 25, 2008
1 parent 2d8eb78 commit 4ba839a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 42cd2366fb9b58cdfc1855be32b31a78e40b2079
refs/heads/master: 28130bea3bcfefe3437b0a5dcab786f1f0296953
24 changes: 16 additions & 8 deletions trunk/drivers/mfd/sm501.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm,
struct gpio_chip *gchip = &chip->gpio;
int base = pdata->gpio_base;

memcpy(chip, &gpio_chip_template, sizeof(struct gpio_chip));
chip->gpio = gpio_chip_template;

if (chip == &gpio->high) {
if (base > 0)
Expand Down Expand Up @@ -1039,7 +1039,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
if (gpio->regs == NULL) {
dev_err(sm->dev, "gpio: failed to remap registers\n");
ret = -ENXIO;
goto err_mapped;
goto err_claimed;
}

/* Register both our chips. */
Expand Down Expand Up @@ -1068,6 +1068,9 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
}

err_mapped:
iounmap(gpio->regs);

err_claimed:
release_resource(gpio->regs_res);
kfree(gpio->regs_res);

Expand All @@ -1076,33 +1079,38 @@ static int sm501_register_gpio(struct sm501_devdata *sm)

static void sm501_gpio_remove(struct sm501_devdata *sm)
{
struct sm501_gpio *gpio = &sm->gpio;
int ret;

ret = gpiochip_remove(&sm->gpio.low.gpio);
ret = gpiochip_remove(&gpio->low.gpio);
if (ret)
dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n");

ret = gpiochip_remove(&sm->gpio.high.gpio);
ret = gpiochip_remove(&gpio->high.gpio);
if (ret)
dev_err(sm->dev, "cannot remove high chip, cannot tidy up\n");

iounmap(gpio->regs);
release_resource(gpio->regs_res);
kfree(gpio->regs_res);
}

static int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin)
static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin)
{
struct sm501_gpio *gpio = &sm->gpio;
return pin + (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base;
}
#else
static int sm501_register_gpio(struct sm501_devdata *sm)
static inline int sm501_register_gpio(struct sm501_devdata *sm)
{
return 0;
}

static void sm501_gpio_remove(struct sm501_devdata *sm)
static inline void sm501_gpio_remove(struct sm501_devdata *sm)
{
}

static int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin)
static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin)
{
return -1;
}
Expand Down

0 comments on commit 4ba839a

Please sign in to comment.