diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-08 04:29:35 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-01-05 08:15:05 -0500 |
commit | 192d3507e2e65790f03ff43aeb1930ae097a8315 (patch) | |
tree | 1b97c05d53cb8371b77d9b5545c1253fd7b88e8f | |
parent | 9420023a5327f29a37cf0a6198bd7d8d80f9634c (diff) |
pinctrl: sirf: 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: Barry Song <baohua@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/sirf/pinctrl-sirf.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index ae97bdc75a69..aa87fa90b884 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c | |||
@@ -399,11 +399,6 @@ static int __init sirfsoc_pinmux_init(void) | |||
399 | } | 399 | } |
400 | arch_initcall(sirfsoc_pinmux_init); | 400 | arch_initcall(sirfsoc_pinmux_init); |
401 | 401 | ||
402 | static inline struct sirfsoc_gpio_chip *to_sirfsoc_gpio(struct gpio_chip *gc) | ||
403 | { | ||
404 | return container_of(gc, struct sirfsoc_gpio_chip, chip.gc); | ||
405 | } | ||
406 | |||
407 | static inline struct sirfsoc_gpio_bank * | 402 | static inline struct sirfsoc_gpio_bank * |
408 | sirfsoc_gpio_to_bank(struct sirfsoc_gpio_chip *sgpio, unsigned int offset) | 403 | sirfsoc_gpio_to_bank(struct sirfsoc_gpio_chip *sgpio, unsigned int offset) |
409 | { | 404 | { |
@@ -418,7 +413,7 @@ static inline int sirfsoc_gpio_to_bankoff(unsigned int offset) | |||
418 | static void sirfsoc_gpio_irq_ack(struct irq_data *d) | 413 | static void sirfsoc_gpio_irq_ack(struct irq_data *d) |
419 | { | 414 | { |
420 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 415 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
421 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); | 416 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); |
422 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); | 417 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); |
423 | int idx = sirfsoc_gpio_to_bankoff(d->hwirq); | 418 | int idx = sirfsoc_gpio_to_bankoff(d->hwirq); |
424 | u32 val, offset; | 419 | u32 val, offset; |
@@ -457,7 +452,7 @@ static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, | |||
457 | static void sirfsoc_gpio_irq_mask(struct irq_data *d) | 452 | static void sirfsoc_gpio_irq_mask(struct irq_data *d) |
458 | { | 453 | { |
459 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 454 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
460 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); | 455 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); |
461 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); | 456 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); |
462 | 457 | ||
463 | __sirfsoc_gpio_irq_mask(sgpio, bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE); | 458 | __sirfsoc_gpio_irq_mask(sgpio, bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE); |
@@ -466,7 +461,7 @@ static void sirfsoc_gpio_irq_mask(struct irq_data *d) | |||
466 | static void sirfsoc_gpio_irq_unmask(struct irq_data *d) | 461 | static void sirfsoc_gpio_irq_unmask(struct irq_data *d) |
467 | { | 462 | { |
468 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 463 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
469 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); | 464 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); |
470 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); | 465 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); |
471 | int idx = sirfsoc_gpio_to_bankoff(d->hwirq); | 466 | int idx = sirfsoc_gpio_to_bankoff(d->hwirq); |
472 | u32 val, offset; | 467 | u32 val, offset; |
@@ -487,7 +482,7 @@ static void sirfsoc_gpio_irq_unmask(struct irq_data *d) | |||
487 | static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) | 482 | static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) |
488 | { | 483 | { |
489 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 484 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
490 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); | 485 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); |
491 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); | 486 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); |
492 | int idx = sirfsoc_gpio_to_bankoff(d->hwirq); | 487 | int idx = sirfsoc_gpio_to_bankoff(d->hwirq); |
493 | u32 val, offset; | 488 | u32 val, offset; |
@@ -549,7 +544,7 @@ static void sirfsoc_gpio_handle_irq(struct irq_desc *desc) | |||
549 | { | 544 | { |
550 | unsigned int irq = irq_desc_get_irq(desc); | 545 | unsigned int irq = irq_desc_get_irq(desc); |
551 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); | 546 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); |
552 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); | 547 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); |
553 | struct sirfsoc_gpio_bank *bank; | 548 | struct sirfsoc_gpio_bank *bank; |
554 | u32 status, ctrl; | 549 | u32 status, ctrl; |
555 | int idx = 0; | 550 | int idx = 0; |
@@ -607,7 +602,7 @@ static inline void sirfsoc_gpio_set_input(struct sirfsoc_gpio_chip *sgpio, | |||
607 | 602 | ||
608 | static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) | 603 | static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) |
609 | { | 604 | { |
610 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); | 605 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); |
611 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); | 606 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); |
612 | unsigned long flags; | 607 | unsigned long flags; |
613 | 608 | ||
@@ -630,7 +625,7 @@ static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) | |||
630 | 625 | ||
631 | static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) | 626 | static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) |
632 | { | 627 | { |
633 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); | 628 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); |
634 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); | 629 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); |
635 | unsigned long flags; | 630 | unsigned long flags; |
636 | 631 | ||
@@ -646,7 +641,7 @@ static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) | |||
646 | 641 | ||
647 | static int sirfsoc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | 642 | static int sirfsoc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) |
648 | { | 643 | { |
649 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); | 644 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); |
650 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); | 645 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); |
651 | int idx = sirfsoc_gpio_to_bankoff(gpio); | 646 | int idx = sirfsoc_gpio_to_bankoff(gpio); |
652 | unsigned long flags; | 647 | unsigned long flags; |
@@ -689,7 +684,7 @@ static inline void sirfsoc_gpio_set_output(struct sirfsoc_gpio_chip *sgpio, | |||
689 | static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, | 684 | static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, |
690 | unsigned gpio, int value) | 685 | unsigned gpio, int value) |
691 | { | 686 | { |
692 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); | 687 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); |
693 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); | 688 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); |
694 | int idx = sirfsoc_gpio_to_bankoff(gpio); | 689 | int idx = sirfsoc_gpio_to_bankoff(gpio); |
695 | u32 offset; | 690 | u32 offset; |
@@ -708,7 +703,7 @@ static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, | |||
708 | 703 | ||
709 | static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) | 704 | static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) |
710 | { | 705 | { |
711 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); | 706 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); |
712 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); | 707 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); |
713 | u32 val; | 708 | u32 val; |
714 | unsigned long flags; | 709 | unsigned long flags; |
@@ -725,7 +720,7 @@ static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) | |||
725 | static void sirfsoc_gpio_set_value(struct gpio_chip *chip, unsigned offset, | 720 | static void sirfsoc_gpio_set_value(struct gpio_chip *chip, unsigned offset, |
726 | int value) | 721 | int value) |
727 | { | 722 | { |
728 | struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); | 723 | struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); |
729 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); | 724 | struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); |
730 | u32 ctrl; | 725 | u32 ctrl; |
731 | unsigned long flags; | 726 | unsigned long flags; |
@@ -814,7 +809,7 @@ static int sirfsoc_gpio_probe(struct device_node *np) | |||
814 | sgpio->chip.gc.parent = &pdev->dev; | 809 | sgpio->chip.gc.parent = &pdev->dev; |
815 | sgpio->chip.regs = regs; | 810 | sgpio->chip.regs = regs; |
816 | 811 | ||
817 | err = gpiochip_add(&sgpio->chip.gc); | 812 | err = gpiochip_add_data(&sgpio->chip.gc, sgpio); |
818 | if (err) { | 813 | if (err) { |
819 | dev_err(&pdev->dev, "%s: error in probe function with status %d\n", | 814 | dev_err(&pdev->dev, "%s: error in probe function with status %d\n", |
820 | np->full_name, err); | 815 | np->full_name, err); |