Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: sirf/atlas7: stop poking around in GPIO internals

This code is poking around in the gpio_chip:s internal structures
to achieve some kind of pin to GPIO mappings.

- It is wrong to poke around in these structs and the pinctrl
maintainer was stupid to let it pass unnoticed, mea culpa.

- The right interface to use is gpiochip_add_pin_range()

- The code appears unused: the pin control part of the driver
is not adding any ranges, so we're iterating over an empty
list. Maybe it is poking around in some other pin controllers
GPIO ranges, and that's just totally wrong, again use
gpiochip_add_pin_range() and specify the right pin
controller.

Cc: Barry Song <baohua@kernel.org>
Cc: Guoying Zhang <Guoying.Zhang@csr.com>
Cc: Wei Chen <Wei.Chen@csr.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

-18
-18
drivers/pinctrl/sirf/pinctrl-atlas7.c
··· 338 338 #define ATLAS7_GPIO_CTL_DATAIN_MASK BIT(7) 339 339 340 340 struct atlas7_gpio_bank { 341 - struct pinctrl_dev *pctldev; 342 341 int id; 343 342 int irq; 344 343 void __iomem *base; ··· 6069 6070 } 6070 6071 6071 6072 for (idx = 0; idx < nbank; idx++) { 6072 - struct gpio_pin_range *pin_range; 6073 6073 struct atlas7_gpio_bank *bank; 6074 6074 6075 6075 bank = &a7gc->banks[idx]; ··· 6086 6088 6087 6089 gpiochip_set_chained_irqchip(chip, &atlas7_gpio_irq_chip, 6088 6090 bank->irq, atlas7_gpio_handle_irq); 6089 - 6090 - /* Records gpio_pin_range to a7gc */ 6091 - list_for_each_entry(pin_range, &chip->pin_ranges, node) { 6092 - struct pinctrl_gpio_range *range; 6093 - 6094 - range = &pin_range->range; 6095 - if (range->id == NGPIO_OF_BANK * idx) { 6096 - bank->gpio_offset = range->id; 6097 - bank->ngpio = range->npins; 6098 - bank->gpio_pins = range->pins; 6099 - bank->pctldev = pin_range->pctldev; 6100 - break; 6101 - } 6102 - } 6103 - 6104 - BUG_ON(!bank->pctldev); 6105 6091 } 6106 6092 6107 6093 platform_set_drvdata(pdev, a7gc);