[v1,1/2] pinctrl: bcm: bcm2835: Switch to use ->add_pin_ranges()
Commit Message
Yeah, while the ->add_pin_ranges() shouldn't be used by DT drivers,
this one requires it to support quite old firmware descriptions that
do not have gpio-ranges property.
The change allows to clean up GPIO library from OF specifics.
There is no functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pinctrl/bcm/pinctrl-bcm2835.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
Comments
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on linusw-pinctrl/devel linusw-pinctrl/for-next linus/master v6.2-rc3 next-20230112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-of-Remove-no-more-used-of_gpio_ranges_fallback/20230113-005102
base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link: https://lore.kernel.org/r/20230112163825.72983-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 1/2] pinctrl: bcm: bcm2835: Switch to use ->add_pin_ranges()
config: csky-randconfig-r033-20230112
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/bdb795cd895842fc4e482dc4131406e9534738fd
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-of-Remove-no-more-used-of_gpio_ranges_fallback/20230113-005102
git checkout bdb795cd895842fc4e482dc4131406e9534738fd
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky SHELL=/bin/bash drivers/pinctrl/bcm/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/pinctrl/bcm/pinctrl-bcm2835.c: In function 'bcm2835_add_pin_ranges_fallback':
>> drivers/pinctrl/bcm/pinctrl-bcm2835.c:364:58: error: invalid use of undefined type 'struct gpio_device'
364 | struct device_node *np = dev_of_node(&gc->gpiodev->dev);
| ^~
drivers/pinctrl/bcm/pinctrl-bcm2835.c:363:33: warning: unused variable 'pc' [-Wunused-variable]
363 | struct bcm2835_pinctrl *pc = gpiochip_get_data(gc);
| ^~
vim +364 drivers/pinctrl/bcm/pinctrl-bcm2835.c
360
361 static int bcm2835_add_pin_ranges_fallback(struct gpio_chip *gc)
362 {
363 struct bcm2835_pinctrl *pc = gpiochip_get_data(gc);
> 364 struct device_node *np = dev_of_node(&gc->gpiodev->dev);
365 struct pinctrl_dev *pctldev = of_pinctrl_get(np);
366
367 if (!pctldev)
368 return 0;
369
370 if (of_property_read_bool(np, "gpio-ranges"))
371 return 0;
372
373 gpiochip_add_pin_range(gc, pinctrl_dev_get_devname(pctldev), 0, 0,
374 gc->ngpio);
375
376 return 0;
377 }
378
@@ -358,16 +358,18 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
return 0;
}
-static int bcm2835_of_gpio_ranges_fallback(struct gpio_chip *gc,
- struct device_node *np)
+static int bcm2835_add_pin_ranges_fallback(struct gpio_chip *gc)
{
+ struct bcm2835_pinctrl *pc = gpiochip_get_data(gc);
+ struct device_node *np = dev_of_node(&gc->gpiodev->dev);
struct pinctrl_dev *pctldev = of_pinctrl_get(np);
- of_node_put(np);
-
if (!pctldev)
return 0;
+ if (of_property_read_bool(np, "gpio-ranges"))
+ return 0;
+
gpiochip_add_pin_range(gc, pinctrl_dev_get_devname(pctldev), 0, 0,
gc->ngpio);
@@ -388,7 +390,7 @@ static const struct gpio_chip bcm2835_gpio_chip = {
.base = -1,
.ngpio = BCM2835_NUM_GPIOS,
.can_sleep = false,
- .of_gpio_ranges_fallback = bcm2835_of_gpio_ranges_fallback,
+ .add_pin_ranges = bcm2835_add_pin_ranges_fallback,
};
static const struct gpio_chip bcm2711_gpio_chip = {
@@ -405,7 +407,7 @@ static const struct gpio_chip bcm2711_gpio_chip = {
.base = -1,
.ngpio = BCM2711_NUM_GPIOS,
.can_sleep = false,
- .of_gpio_ranges_fallback = bcm2835_of_gpio_ranges_fallback,
+ .add_pin_ranges = bcm2835_add_pin_ranges_fallback,
};
static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,