On Thu, Jan 28, 2016 at 10:20 AM, Peter Hung <hpeter@xxxxxxxxx> wrote:
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
Drivers should just
#include <linux/gpio/driver.h>
+static struct f81504_gpio_chip *gpio_to_f81504_chip(struct gpio_chip *chip)
+{
+ return container_of(chip, struct f81504_gpio_chip, chip);
+}
Avoid this construction in new code.
Use gpiochip_get_data(chip) everywhere that gpio_to_f81504_chip()
is used and register the gpiochip with gpiochip_add_data()
and the code will be simpler.
See any other driver in drivers/gpio for examples, I converted them
all.
+
+ if (tmp & BIT(offset))
+ return GPIOF_DIR_OUT;
+
+ return GPIOF_DIR_IN;
+}
Do not use GPIOF* flags in driver code, these are for the consumer
API. Just return 0/1.
+ status = gpiochip_add(&gc->chip);
As mentioned, use gpiochip_add_data(&gc->chip, gc);
+static struct platform_driver f81504_gpio_driver = {
+ .driver = {
+ .name = F81504_GPIO_NAME,
+ .owner = THIS_MODULE,
I saw coccinelle was already complaining about this.
Looking forward to v3!