aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/sm501.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-07-25 04:46:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:30 -0400
commitf2999209d779573e17468b680f5f267d8cb2a9c7 (patch)
tree4b86867c25a550bde4dd66a3e0728c3f217e961e /drivers/mfd/sm501.c
parent28130bea3bcfefe3437b0a5dcab786f1f0296953 (diff)
mfd: sm501 build fixes when CONFIG_MFD_SM501_GPIO unset
Fix the build problems if CONFIG_MFD_SM501_GPIO is not set, which is generally when there is no gpiolib support available as currently happens on x86 when building PCI SM501. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Tested-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mfd/sm501.c')
-rw-r--r--drivers/mfd/sm501.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 2dfb41aabcaf..79d7aea5510b 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -19,7 +19,6 @@
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/gpio.h>
23#include <linux/i2c-gpio.h> 22#include <linux/i2c-gpio.h>
24 23
25#include <linux/sm501.h> 24#include <linux/sm501.h>
@@ -35,6 +34,9 @@ struct sm501_device {
35 34
36struct sm501_gpio; 35struct sm501_gpio;
37 36
37#ifdef CONFIG_MFD_SM501_GPIO
38#include <linux/gpio.h>
39
38struct sm501_gpio_chip { 40struct sm501_gpio_chip {
39 struct gpio_chip gpio; 41 struct gpio_chip gpio;
40 struct sm501_gpio *ourgpio; /* to get back to parent. */ 42 struct sm501_gpio *ourgpio; /* to get back to parent. */
@@ -50,6 +52,11 @@ struct sm501_gpio {
50 void __iomem *regs; 52 void __iomem *regs;
51 struct resource *regs_res; 53 struct resource *regs_res;
52}; 54};
55#else
56struct sm501_gpio {
57 /* no gpio support, empty definition for sm501_devdata. */
58};
59#endif
53 60
54struct sm501_devdata { 61struct sm501_devdata {
55 spinlock_t reg_lock; 62 spinlock_t reg_lock;
@@ -1082,6 +1089,9 @@ static void sm501_gpio_remove(struct sm501_devdata *sm)
1082 struct sm501_gpio *gpio = &sm->gpio; 1089 struct sm501_gpio *gpio = &sm->gpio;
1083 int ret; 1090 int ret;
1084 1091
1092 if (!sm->gpio.registered)
1093 return;
1094
1085 ret = gpiochip_remove(&gpio->low.gpio); 1095 ret = gpiochip_remove(&gpio->low.gpio);
1086 if (ret) 1096 if (ret)
1087 dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n"); 1097 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)
1100 struct sm501_gpio *gpio = &sm->gpio; 1110 struct sm501_gpio *gpio = &sm->gpio;
1101 return pin + (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base; 1111 return pin + (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base;
1102} 1112}
1113
1114static inline int sm501_gpio_isregistered(struct sm501_devdata *sm)
1115{
1116 return sm->gpio.registered;
1117}
1103#else 1118#else
1104static inline int sm501_register_gpio(struct sm501_devdata *sm) 1119static inline int sm501_register_gpio(struct sm501_devdata *sm)
1105{ 1120{
@@ -1114,6 +1129,11 @@ static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin)
1114{ 1129{
1115 return -1; 1130 return -1;
1116} 1131}
1132
1133static inline int sm501_gpio_isregistered(struct sm501_devdata *sm)
1134{
1135 return 0;
1136}
1117#endif 1137#endif
1118 1138
1119static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm, 1139static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm,
@@ -1330,8 +1350,8 @@ static int sm501_init_dev(struct sm501_devdata *sm)
1330 } 1350 }
1331 1351
1332 if (pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { 1352 if (pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) {
1333 if (!sm->gpio.registered) 1353 if (!sm501_gpio_isregistered(sm))
1334 dev_err(sm->dev, "no gpio registered for i2c gpio.\n"); 1354 dev_err(sm->dev, "no gpio available for i2c gpio.\n");
1335 else 1355 else
1336 sm501_register_gpio_i2c(sm, pdata); 1356 sm501_register_gpio_i2c(sm, pdata);
1337 } 1357 }
@@ -1643,8 +1663,7 @@ static void sm501_dev_remove(struct sm501_devdata *sm)
1643 1663
1644 device_remove_file(sm->dev, &dev_attr_dbg_regs); 1664 device_remove_file(sm->dev, &dev_attr_dbg_regs);
1645 1665
1646 if (sm->gpio.registered) 1666 sm501_gpio_remove(sm);
1647 sm501_gpio_remove(sm);
1648} 1667}
1649 1668
1650static void sm501_pci_remove(struct pci_dev *dev) 1669static void sm501_pci_remove(struct pci_dev *dev)