#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/pci.h>
-#include <linux/gpio.h>
#include <linux/i2c-gpio.h>
#include <linux/sm501.h>
struct sm501_gpio;
+#ifdef CONFIG_MFD_SM501_GPIO
+#include <linux/gpio.h>
+
struct sm501_gpio_chip {
struct gpio_chip gpio;
struct sm501_gpio *ourgpio; /* to get back to parent. */
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;
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");
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)
{
{
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,
}
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);
}
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)