pinctrl: spmi: use gpiochip data pointer

This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().

Cc: Ivan T. Ivanov <ivan.ivanov@linaro.org>
Cc: Björn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Linus Walleij 2015-12-08 09:51:47 +01:00
Родитель fded3f40bf
Коммит c52d9df14b
1 изменённых файлов: 7 добавлений и 12 удалений

Просмотреть файл

@ -158,11 +158,6 @@ static const char *const pmic_gpio_functions[] = {
PMIC_GPIO_FUNC_DTEST3, PMIC_GPIO_FUNC_DTEST4, PMIC_GPIO_FUNC_DTEST3, PMIC_GPIO_FUNC_DTEST4,
}; };
static inline struct pmic_gpio_state *to_gpio_state(struct gpio_chip *chip)
{
return container_of(chip, struct pmic_gpio_state, chip);
};
static int pmic_gpio_read(struct pmic_gpio_state *state, static int pmic_gpio_read(struct pmic_gpio_state *state,
struct pmic_gpio_pad *pad, unsigned int addr) struct pmic_gpio_pad *pad, unsigned int addr)
{ {
@ -495,7 +490,7 @@ static const struct pinconf_ops pmic_gpio_pinconf_ops = {
static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin) static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
{ {
struct pmic_gpio_state *state = to_gpio_state(chip); struct pmic_gpio_state *state = gpiochip_get_data(chip);
unsigned long config; unsigned long config;
config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1); config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1);
@ -506,7 +501,7 @@ static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
static int pmic_gpio_direction_output(struct gpio_chip *chip, static int pmic_gpio_direction_output(struct gpio_chip *chip,
unsigned pin, int val) unsigned pin, int val)
{ {
struct pmic_gpio_state *state = to_gpio_state(chip); struct pmic_gpio_state *state = gpiochip_get_data(chip);
unsigned long config; unsigned long config;
config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val); config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val);
@ -516,7 +511,7 @@ static int pmic_gpio_direction_output(struct gpio_chip *chip,
static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin) static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin)
{ {
struct pmic_gpio_state *state = to_gpio_state(chip); struct pmic_gpio_state *state = gpiochip_get_data(chip);
struct pmic_gpio_pad *pad; struct pmic_gpio_pad *pad;
int ret; int ret;
@ -538,7 +533,7 @@ static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin)
static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value) static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value)
{ {
struct pmic_gpio_state *state = to_gpio_state(chip); struct pmic_gpio_state *state = gpiochip_get_data(chip);
unsigned long config; unsigned long config;
config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value); config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value);
@ -561,7 +556,7 @@ static int pmic_gpio_of_xlate(struct gpio_chip *chip,
static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin) static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
{ {
struct pmic_gpio_state *state = to_gpio_state(chip); struct pmic_gpio_state *state = gpiochip_get_data(chip);
struct pmic_gpio_pad *pad; struct pmic_gpio_pad *pad;
pad = state->ctrl->desc->pins[pin].drv_data; pad = state->ctrl->desc->pins[pin].drv_data;
@ -571,7 +566,7 @@ static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{ {
struct pmic_gpio_state *state = to_gpio_state(chip); struct pmic_gpio_state *state = gpiochip_get_data(chip);
unsigned i; unsigned i;
for (i = 0; i < chip->ngpio; i++) { for (i = 0; i < chip->ngpio; i++) {
@ -771,7 +766,7 @@ static int pmic_gpio_probe(struct platform_device *pdev)
if (IS_ERR(state->ctrl)) if (IS_ERR(state->ctrl))
return PTR_ERR(state->ctrl); return PTR_ERR(state->ctrl);
ret = gpiochip_add(&state->chip); ret = gpiochip_add_data(&state->chip, state);
if (ret) { if (ret) {
dev_err(state->dev, "can't add gpio chip\n"); dev_err(state->dev, "can't add gpio chip\n");
goto err_chip; goto err_chip;