From: Linus Walleij Date: Fri, 13 Apr 2018 13:40:45 +0000 (+0200) Subject: gpio: mvebu: Use the proper APIs X-Git-Tag: v4.18-rc1~91^2~52 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=ba78d83be7d04f03a7fe6133efb5b6f83b9b0e7c;p=linux.git gpio: mvebu: Use the proper APIs The MVEBU driver is requesting GPIO descriptors from itself, which is fine, but we have proper APIs to do this in a controlled way, so stop calling into the private functions of the GPIO library and use the gpiochip_* functions instead. Only include and since we are both producers and consumers in this case. Cc: Gregory CLEMENT Cc: Thomas Petazzoni Cc: Jason Cooper Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 45c65f805fd6..6e02148c208b 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -36,7 +36,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -51,8 +52,6 @@ #include #include -#include "gpiolib.h" - /* * GPIO unit register offsets. */ @@ -608,19 +607,16 @@ static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) if (mvpwm->gpiod) { ret = -EBUSY; } else { - desc = gpio_to_desc(mvchip->chip.base + pwm->hwpwm); - if (!desc) { - ret = -ENODEV; + desc = gpiochip_request_own_desc(&mvchip->chip, + pwm->hwpwm, "mvebu-pwm"); + if (IS_ERR(desc)) { + ret = PTR_ERR(desc); goto out; } - ret = gpiod_request(desc, "mvebu-pwm"); - if (ret) - goto out; - ret = gpiod_direction_output(desc, 0); if (ret) { - gpiod_free(desc); + gpiochip_free_own_desc(desc); goto out; } @@ -637,7 +633,7 @@ static void mvebu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) unsigned long flags; spin_lock_irqsave(&mvpwm->lock, flags); - gpiod_free(mvpwm->gpiod); + gpiochip_free_own_desc(mvpwm->gpiod); mvpwm->gpiod = NULL; spin_unlock_irqrestore(&mvpwm->lock, flags); }