Commit 2d7af444 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Lee Jones

gpio: bd9571mwv: rid of using struct bd9571mwv

To simplify this driver, use dev_get_regmap() and
rid of using struct bd9571mwv.
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: default avatarMatti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent b9f71d14
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <linux/mfd/bd9571mwv.h> #include <linux/mfd/bd9571mwv.h>
struct bd9571mwv_gpio { struct bd9571mwv_gpio {
struct regmap *regmap;
struct gpio_chip chip; struct gpio_chip chip;
struct bd9571mwv *bd;
}; };
static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip, static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
...@@ -26,7 +26,7 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip, ...@@ -26,7 +26,7 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip);
int ret, val; int ret, val;
ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val); ret = regmap_read(gpio->regmap, BD9571MWV_GPIO_DIR, &val);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (val & BIT(offset)) if (val & BIT(offset))
...@@ -40,8 +40,7 @@ static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip, ...@@ -40,8 +40,7 @@ static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
{ {
struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip);
regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_DIR, regmap_update_bits(gpio->regmap, BD9571MWV_GPIO_DIR, BIT(offset), 0);
BIT(offset), 0);
return 0; return 0;
} }
...@@ -52,9 +51,9 @@ static int bd9571mwv_gpio_direction_output(struct gpio_chip *chip, ...@@ -52,9 +51,9 @@ static int bd9571mwv_gpio_direction_output(struct gpio_chip *chip,
struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip);
/* Set the initial value */ /* Set the initial value */
regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_OUT, regmap_update_bits(gpio->regmap, BD9571MWV_GPIO_OUT,
BIT(offset), value ? BIT(offset) : 0); BIT(offset), value ? BIT(offset) : 0);
regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_DIR, regmap_update_bits(gpio->regmap, BD9571MWV_GPIO_DIR,
BIT(offset), BIT(offset)); BIT(offset), BIT(offset));
return 0; return 0;
...@@ -65,7 +64,7 @@ static int bd9571mwv_gpio_get(struct gpio_chip *chip, unsigned int offset) ...@@ -65,7 +64,7 @@ static int bd9571mwv_gpio_get(struct gpio_chip *chip, unsigned int offset)
struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip);
int ret, val; int ret, val;
ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_IN, &val); ret = regmap_read(gpio->regmap, BD9571MWV_GPIO_IN, &val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -77,7 +76,7 @@ static void bd9571mwv_gpio_set(struct gpio_chip *chip, unsigned int offset, ...@@ -77,7 +76,7 @@ static void bd9571mwv_gpio_set(struct gpio_chip *chip, unsigned int offset,
{ {
struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip);
regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_OUT, regmap_update_bits(gpio->regmap, BD9571MWV_GPIO_OUT,
BIT(offset), value ? BIT(offset) : 0); BIT(offset), value ? BIT(offset) : 0);
} }
...@@ -105,9 +104,9 @@ static int bd9571mwv_gpio_probe(struct platform_device *pdev) ...@@ -105,9 +104,9 @@ static int bd9571mwv_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, gpio); platform_set_drvdata(pdev, gpio);
gpio->bd = dev_get_drvdata(pdev->dev.parent); gpio->regmap = dev_get_regmap(pdev->dev.parent, NULL);
gpio->chip = template_chip; gpio->chip = template_chip;
gpio->chip.parent = gpio->bd->dev; gpio->chip.parent = pdev->dev.parent;
ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment