From 512ee291727bd0fe4ca510e31ad18d8ceefdb578 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 25 Jul 2008 01:46:02 -0700 Subject: [PATCH] --- yaml --- r: 105827 b: refs/heads/master c: f2999209d779573e17468b680f5f267d8cb2a9c7 h: refs/heads/master i: 105825: 2d8eb7868f57cace9e1d348ace253b38e13d9405 105823: 5b14f455f0bbe6a24bcaf1b12bafc8ef6a622b54 v: v3 --- [refs] | 2 +- trunk/drivers/mfd/sm501.c | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 432aaa2704ed..93770d2e39b6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 28130bea3bcfefe3437b0a5dcab786f1f0296953 +refs/heads/master: f2999209d779573e17468b680f5f267d8cb2a9c7 diff --git a/trunk/drivers/mfd/sm501.c b/trunk/drivers/mfd/sm501.c index 2dfb41aabcaf..79d7aea5510b 100644 --- a/trunk/drivers/mfd/sm501.c +++ b/trunk/drivers/mfd/sm501.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -35,6 +34,9 @@ struct sm501_device { struct sm501_gpio; +#ifdef CONFIG_MFD_SM501_GPIO +#include + struct sm501_gpio_chip { struct gpio_chip gpio; struct sm501_gpio *ourgpio; /* to get back to parent. */ @@ -50,6 +52,11 @@ struct sm501_gpio { void __iomem *regs; struct resource *regs_res; }; +#else +struct sm501_gpio { + /* no gpio support, empty definition for sm501_devdata. */ +}; +#endif struct sm501_devdata { spinlock_t reg_lock; @@ -1082,6 +1089,9 @@ static void sm501_gpio_remove(struct sm501_devdata *sm) struct sm501_gpio *gpio = &sm->gpio; int ret; + if (!sm->gpio.registered) + return; + ret = gpiochip_remove(&gpio->low.gpio); if (ret) dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n"); @@ -1100,6 +1110,11 @@ 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; } + +static inline int sm501_gpio_isregistered(struct sm501_devdata *sm) +{ + return sm->gpio.registered; +} #else static inline int sm501_register_gpio(struct sm501_devdata *sm) { @@ -1114,6 +1129,11 @@ static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) { return -1; } + +static inline int sm501_gpio_isregistered(struct sm501_devdata *sm) +{ + return 0; +} #endif static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm, @@ -1330,8 +1350,8 @@ static int sm501_init_dev(struct sm501_devdata *sm) } if (pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { - if (!sm->gpio.registered) - dev_err(sm->dev, "no gpio registered for i2c gpio.\n"); + if (!sm501_gpio_isregistered(sm)) + dev_err(sm->dev, "no gpio available for i2c gpio.\n"); else sm501_register_gpio_i2c(sm, pdata); } @@ -1643,8 +1663,7 @@ static void sm501_dev_remove(struct sm501_devdata *sm) device_remove_file(sm->dev, &dev_attr_dbg_regs); - if (sm->gpio.registered) - sm501_gpio_remove(sm); + sm501_gpio_remove(sm); } static void sm501_pci_remove(struct pci_dev *dev)