diff options
author | Tomasz Figa <t.figa@samsung.com> | 2012-10-11 04:11:08 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-10-15 03:10:11 -0400 |
commit | 62f14c0ef5d1bbd640b42a59f8f084f764a067c4 (patch) | |
tree | dd90d47ca020db2fef8b1a5bde48a17a2b0d9d75 /drivers/pinctrl/pinctrl-samsung.c | |
parent | 7c367d3da697846b80058859937f606c0081beda (diff) |
pinctrl: samsung: Do not pass gpio_chip to pin_to_reg_bank
The pointer to gpio_chip passed to pin_to_reg_bank utility function is
used only to retrieve a pointer to samsung_pinctrl_drv_data structure.
This patch modifies the function and its users to pass a pointer to
samsung_pinctrl_drv_data directly.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-samsung.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-samsung.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c index c660fa5071d7..aa42d54e89c6 100644 --- a/drivers/pinctrl/pinctrl-samsung.c +++ b/drivers/pinctrl/pinctrl-samsung.c | |||
@@ -250,14 +250,12 @@ static int samsung_pinmux_get_groups(struct pinctrl_dev *pctldev, | |||
250 | * given a pin number that is local to a pin controller, find out the pin bank | 250 | * given a pin number that is local to a pin controller, find out the pin bank |
251 | * and the register base of the pin bank. | 251 | * and the register base of the pin bank. |
252 | */ | 252 | */ |
253 | static void pin_to_reg_bank(struct gpio_chip *gc, unsigned pin, | 253 | static void pin_to_reg_bank(struct samsung_pinctrl_drv_data *drvdata, |
254 | void __iomem **reg, u32 *offset, | 254 | unsigned pin, void __iomem **reg, u32 *offset, |
255 | struct samsung_pin_bank **bank) | 255 | struct samsung_pin_bank **bank) |
256 | { | 256 | { |
257 | struct samsung_pinctrl_drv_data *drvdata; | ||
258 | struct samsung_pin_bank *b; | 257 | struct samsung_pin_bank *b; |
259 | 258 | ||
260 | drvdata = dev_get_drvdata(gc->dev); | ||
261 | b = drvdata->ctrl->pin_banks; | 259 | b = drvdata->ctrl->pin_banks; |
262 | 260 | ||
263 | while ((pin >= b->pin_base) && | 261 | while ((pin >= b->pin_base) && |
@@ -292,7 +290,7 @@ static void samsung_pinmux_setup(struct pinctrl_dev *pctldev, unsigned selector, | |||
292 | * pin function number in the config register. | 290 | * pin function number in the config register. |
293 | */ | 291 | */ |
294 | for (cnt = 0; cnt < drvdata->pin_groups[group].num_pins; cnt++) { | 292 | for (cnt = 0; cnt < drvdata->pin_groups[group].num_pins; cnt++) { |
295 | pin_to_reg_bank(drvdata->gc, pins[cnt] - drvdata->ctrl->base, | 293 | pin_to_reg_bank(drvdata, pins[cnt] - drvdata->ctrl->base, |
296 | ®, &pin_offset, &bank); | 294 | ®, &pin_offset, &bank); |
297 | mask = (1 << bank->func_width) - 1; | 295 | mask = (1 << bank->func_width) - 1; |
298 | shift = pin_offset * bank->func_width; | 296 | shift = pin_offset * bank->func_width; |
@@ -329,10 +327,13 @@ static int samsung_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev, | |||
329 | struct pinctrl_gpio_range *range, unsigned offset, bool input) | 327 | struct pinctrl_gpio_range *range, unsigned offset, bool input) |
330 | { | 328 | { |
331 | struct samsung_pin_bank *bank; | 329 | struct samsung_pin_bank *bank; |
330 | struct samsung_pinctrl_drv_data *drvdata; | ||
332 | void __iomem *reg; | 331 | void __iomem *reg; |
333 | u32 data, pin_offset, mask, shift; | 332 | u32 data, pin_offset, mask, shift; |
334 | 333 | ||
335 | pin_to_reg_bank(range->gc, offset, ®, &pin_offset, &bank); | 334 | drvdata = pinctrl_dev_get_drvdata(pctldev); |
335 | |||
336 | pin_to_reg_bank(drvdata, offset, ®, &pin_offset, &bank); | ||
336 | mask = (1 << bank->func_width) - 1; | 337 | mask = (1 << bank->func_width) - 1; |
337 | shift = pin_offset * bank->func_width; | 338 | shift = pin_offset * bank->func_width; |
338 | 339 | ||
@@ -366,7 +367,7 @@ static int samsung_pinconf_rw(struct pinctrl_dev *pctldev, unsigned int pin, | |||
366 | u32 cfg_value, cfg_reg; | 367 | u32 cfg_value, cfg_reg; |
367 | 368 | ||
368 | drvdata = pinctrl_dev_get_drvdata(pctldev); | 369 | drvdata = pinctrl_dev_get_drvdata(pctldev); |
369 | pin_to_reg_bank(drvdata->gc, pin - drvdata->ctrl->base, ®_base, | 370 | pin_to_reg_bank(drvdata, pin - drvdata->ctrl->base, ®_base, |
370 | &pin_offset, &bank); | 371 | &pin_offset, &bank); |
371 | 372 | ||
372 | switch (cfg_type) { | 373 | switch (cfg_type) { |
@@ -468,8 +469,11 @@ static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value) | |||
468 | { | 469 | { |
469 | void __iomem *reg; | 470 | void __iomem *reg; |
470 | u32 pin_offset, data; | 471 | u32 pin_offset, data; |
472 | struct samsung_pinctrl_drv_data *drvdata; | ||
471 | 473 | ||
472 | pin_to_reg_bank(gc, offset, ®, &pin_offset, NULL); | 474 | drvdata = dev_get_drvdata(gc->dev); |
475 | |||
476 | pin_to_reg_bank(drvdata, offset, ®, &pin_offset, NULL); | ||
473 | data = readl(reg + DAT_REG); | 477 | data = readl(reg + DAT_REG); |
474 | data &= ~(1 << pin_offset); | 478 | data &= ~(1 << pin_offset); |
475 | if (value) | 479 | if (value) |
@@ -482,8 +486,11 @@ static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset) | |||
482 | { | 486 | { |
483 | void __iomem *reg; | 487 | void __iomem *reg; |
484 | u32 pin_offset, data; | 488 | u32 pin_offset, data; |
489 | struct samsung_pinctrl_drv_data *drvdata; | ||
490 | |||
491 | drvdata = dev_get_drvdata(gc->dev); | ||
485 | 492 | ||
486 | pin_to_reg_bank(gc, offset, ®, &pin_offset, NULL); | 493 | pin_to_reg_bank(drvdata, offset, ®, &pin_offset, NULL); |
487 | data = readl(reg + DAT_REG); | 494 | data = readl(reg + DAT_REG); |
488 | data >>= pin_offset; | 495 | data >>= pin_offset; |
489 | data &= 1; | 496 | data &= 1; |