Skip to content

Commit e5ec1f9

Browse files
committed
pinctrl: nomadik: Dereference gpio_chip properly
The irq data passed to irc_chip handlers i the struct gpio_chip and nothing else. We are just lucky that the nomadik chip pointer is first in the struct. Use the proper dereferencing and helpers. Reported-by: Marc Zyngier <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 92858eb commit e5ec1f9

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

drivers/pinctrl/nomadik/pinctrl-nomadik.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ static int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev,
608608

609609
static void nmk_gpio_irq_ack(struct irq_data *d)
610610
{
611-
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
612-
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip);
611+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
612+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
613613

614614
clk_enable(nmk_chip->clk);
615615
writel(BIT(d->hwirq), nmk_chip->addr + NMK_GPIO_IC);
@@ -677,13 +677,10 @@ static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip,
677677

678678
static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable)
679679
{
680-
struct nmk_gpio_chip *nmk_chip;
680+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
681+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
681682
unsigned long flags;
682683

683-
nmk_chip = irq_data_get_irq_chip_data(d);
684-
if (!nmk_chip)
685-
return -EINVAL;
686-
687684
clk_enable(nmk_chip->clk);
688685
spin_lock_irqsave(&nmk_gpio_slpm_lock, flags);
689686
spin_lock(&nmk_chip->lock);
@@ -712,13 +709,10 @@ static void nmk_gpio_irq_unmask(struct irq_data *d)
712709

713710
static int nmk_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
714711
{
715-
struct nmk_gpio_chip *nmk_chip;
712+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
713+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
716714
unsigned long flags;
717715

718-
nmk_chip = irq_data_get_irq_chip_data(d);
719-
if (!nmk_chip)
720-
return -EINVAL;
721-
722716
clk_enable(nmk_chip->clk);
723717
spin_lock_irqsave(&nmk_gpio_slpm_lock, flags);
724718
spin_lock(&nmk_chip->lock);
@@ -740,14 +734,12 @@ static int nmk_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
740734

741735
static int nmk_gpio_irq_set_type(struct irq_data *d, unsigned int type)
742736
{
737+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
738+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
743739
bool enabled = !irqd_irq_disabled(d);
744740
bool wake = irqd_is_wakeup_set(d);
745-
struct nmk_gpio_chip *nmk_chip;
746741
unsigned long flags;
747742

748-
nmk_chip = irq_data_get_irq_chip_data(d);
749-
if (!nmk_chip)
750-
return -EINVAL;
751743
if (type & IRQ_TYPE_LEVEL_HIGH)
752744
return -EINVAL;
753745
if (type & IRQ_TYPE_LEVEL_LOW)
@@ -784,7 +776,8 @@ static int nmk_gpio_irq_set_type(struct irq_data *d, unsigned int type)
784776

785777
static unsigned int nmk_gpio_irq_startup(struct irq_data *d)
786778
{
787-
struct nmk_gpio_chip *nmk_chip = irq_data_get_irq_chip_data(d);
779+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
780+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
788781

789782
clk_enable(nmk_chip->clk);
790783
nmk_gpio_irq_unmask(d);
@@ -793,7 +786,8 @@ static unsigned int nmk_gpio_irq_startup(struct irq_data *d)
793786

794787
static void nmk_gpio_irq_shutdown(struct irq_data *d)
795788
{
796-
struct nmk_gpio_chip *nmk_chip = irq_data_get_irq_chip_data(d);
789+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
790+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
797791

798792
nmk_gpio_irq_mask(d);
799793
clk_disable(nmk_chip->clk);

0 commit comments

Comments
 (0)