summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-twl4030.c
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-03-25 03:53:42 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-03-25 03:53:42 -0300
commit03dd4cb26d967f9588437b0fc9cc0e8353322bb7 (patch)
treefa581f6dc1c0596391690d1f67eceef3af8246dc /drivers/gpio/gpio-twl4030.c
parentd4e493caf788ef44982e131ff9c786546904d934 (diff)
Linux-libre 4.5-gnu
Diffstat (limited to 'drivers/gpio/gpio-twl4030.c')
-rw-r--r--drivers/gpio/gpio-twl4030.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 9e1dbb987..4b807b0e0 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -76,11 +76,6 @@ struct gpio_twl4030_priv {
/*----------------------------------------------------------------------*/
-static inline struct gpio_twl4030_priv *to_gpio_twl4030(struct gpio_chip *chip)
-{
- return container_of(chip, struct gpio_twl4030_priv, gpio_chip);
-}
-
/*
* To configure TWL4030 GPIO module registers
*/
@@ -205,7 +200,7 @@ static int twl4030_get_gpio_datain(int gpio)
static int twl_request(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
int status = 0;
mutex_lock(&priv->mutex);
@@ -256,7 +251,7 @@ static int twl_request(struct gpio_chip *chip, unsigned offset)
/* optionally have the first two GPIOs switch vMMC1
* and vMMC2 power supplies based on card presence.
*/
- pdata = dev_get_platdata(chip->dev);
+ pdata = dev_get_platdata(chip->parent);
if (pdata)
value |= pdata->mmc_cd & 0x03;
@@ -273,7 +268,7 @@ done:
static void twl_free(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
mutex_lock(&priv->mutex);
if (offset >= TWL4030_GPIO_MAX) {
@@ -293,7 +288,7 @@ out:
static int twl_direction_in(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
int ret;
mutex_lock(&priv->mutex);
@@ -312,7 +307,7 @@ static int twl_direction_in(struct gpio_chip *chip, unsigned offset)
static int twl_get(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
int ret;
int status = 0;
@@ -327,7 +322,7 @@ static int twl_get(struct gpio_chip *chip, unsigned offset)
else
status = twl4030_get_gpio_datain(offset);
- ret = (status <= 0) ? 0 : 1;
+ ret = (status < 0) ? status : !!status;
out:
mutex_unlock(&priv->mutex);
return ret;
@@ -335,7 +330,7 @@ out:
static void twl_set(struct gpio_chip *chip, unsigned offset, int value)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
mutex_lock(&priv->mutex);
if (offset < TWL4030_GPIO_MAX)
@@ -353,7 +348,7 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value)
static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
int ret = 0;
mutex_lock(&priv->mutex);
@@ -379,7 +374,7 @@ static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value)
static int twl_to_irq(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
+ struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
return (priv->irq_base && (offset < TWL4030_GPIO_MAX))
? (priv->irq_base + offset)
@@ -509,7 +504,7 @@ no_irqs:
priv->gpio_chip = template_chip;
priv->gpio_chip.base = -1;
priv->gpio_chip.ngpio = TWL4030_GPIO_MAX;
- priv->gpio_chip.dev = &pdev->dev;
+ priv->gpio_chip.parent = &pdev->dev;
mutex_init(&priv->mutex);
@@ -544,7 +539,7 @@ no_irqs:
if (pdata->use_leds)
priv->gpio_chip.ngpio += 2;
- ret = gpiochip_add(&priv->gpio_chip);
+ ret = gpiochip_add_data(&priv->gpio_chip, priv);
if (ret < 0) {
dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
priv->gpio_chip.ngpio = 0;