2022-08-30 20:41:23

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/1] pinctrl: pistachio: Switch to use fwnode instead of of_node

GPIO library now accepts fwnode as a firmware node, so
switch the driver to use it.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/pinctrl-pistachio.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index 5de691c630b4..02ef85e6261c 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -10,13 +10,13 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
-#include <linux/of.h>
-#include <linux/of_irq.h>
+#include <linux/mod_devicetable.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/spinlock.h>

@@ -1347,46 +1347,45 @@ static struct pistachio_gpio_bank pistachio_gpio_banks[] = {

static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
{
- struct device_node *node = pctl->dev->of_node;
struct pistachio_gpio_bank *bank;
unsigned int i;
int irq, ret = 0;

for (i = 0; i < pctl->nbanks; i++) {
char child_name[sizeof("gpioXX")];
- struct device_node *child;
+ struct fwnode_handle *child;
struct gpio_irq_chip *girq;

snprintf(child_name, sizeof(child_name), "gpio%d", i);
- child = of_get_child_by_name(node, child_name);
+ child = device_get_named_child_node(dev, child_name);
if (!child) {
dev_err(pctl->dev, "No node for bank %u\n", i);
ret = -ENODEV;
goto err;
}

- if (!of_find_property(child, "gpio-controller", NULL)) {
+ if (!fwnode_property_present(child, "gpio-controller")) {
+ fwnode_handle_put(child);
dev_err(pctl->dev,
"No gpio-controller property for bank %u\n", i);
- of_node_put(child);
ret = -ENODEV;
goto err;
}

- irq = irq_of_parse_and_map(child, 0);
- if (!irq) {
+ ret = fwnode_irq_get(child, 0);
+ if (ret < 0) {
+ fwnode_handle_put(child);
dev_err(pctl->dev, "No IRQ for bank %u\n", i);
- of_node_put(child);
- ret = -EINVAL;
goto err;
}
+ irq = ret;

bank = &pctl->gpio_banks[i];
bank->pctl = pctl;
bank->base = pctl->base + GPIO_BANK_BASE(i);

bank->gpio_chip.parent = pctl->dev;
- bank->gpio_chip.of_node = child;
+ bank->gpio_chip.fwnode = child;

girq = &bank->gpio_chip.irq;
girq->chip = &bank->irq_chip;
--
2.35.1


2022-08-30 23:18:07

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] pinctrl: pistachio: Switch to use fwnode instead of of_node

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linus/master v6.0-rc3 next-20220830]
[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/pinctrl-pistachio-Switch-to-use-fwnode-instead-of-of_node/20220831-034037
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: arc-randconfig-r043-20220830 (https://download.01.org/0day-ci/archive/20220831/[email protected]/config)
compiler: arceb-elf-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/6802887aaf094f08bc139caf331767217f7318a4
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/pinctrl-pistachio-Switch-to-use-fwnode-instead-of-of_node/20220831-034037
git checkout 6802887aaf094f08bc139caf331767217f7318a4
# 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=arc SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/pinctrl/pinctrl-pistachio.c: In function 'pistachio_gpio_register':
>> drivers/pinctrl/pinctrl-pistachio.c:1360:53: error: 'dev' undeclared (first use in this function); did you mean 'cdev'?
1360 | child = device_get_named_child_node(dev, child_name);
| ^~~
| cdev
drivers/pinctrl/pinctrl-pistachio.c:1360:53: note: each undeclared identifier is reported only once for each function it appears in


vim +1360 drivers/pinctrl/pinctrl-pistachio.c

1347
1348 static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
1349 {
1350 struct pistachio_gpio_bank *bank;
1351 unsigned int i;
1352 int irq, ret = 0;
1353
1354 for (i = 0; i < pctl->nbanks; i++) {
1355 char child_name[sizeof("gpioXX")];
1356 struct fwnode_handle *child;
1357 struct gpio_irq_chip *girq;
1358
1359 snprintf(child_name, sizeof(child_name), "gpio%d", i);
> 1360 child = device_get_named_child_node(dev, child_name);
1361 if (!child) {
1362 dev_err(pctl->dev, "No node for bank %u\n", i);
1363 ret = -ENODEV;
1364 goto err;
1365 }
1366
1367 if (!fwnode_property_present(child, "gpio-controller")) {
1368 fwnode_handle_put(child);
1369 dev_err(pctl->dev,
1370 "No gpio-controller property for bank %u\n", i);
1371 ret = -ENODEV;
1372 goto err;
1373 }
1374
1375 ret = fwnode_irq_get(child, 0);
1376 if (ret < 0) {
1377 fwnode_handle_put(child);
1378 dev_err(pctl->dev, "No IRQ for bank %u\n", i);
1379 goto err;
1380 }
1381 irq = ret;
1382
1383 bank = &pctl->gpio_banks[i];
1384 bank->pctl = pctl;
1385 bank->base = pctl->base + GPIO_BANK_BASE(i);
1386
1387 bank->gpio_chip.parent = pctl->dev;
1388 bank->gpio_chip.fwnode = child;
1389
1390 girq = &bank->gpio_chip.irq;
1391 girq->chip = &bank->irq_chip;
1392 girq->parent_handler = pistachio_gpio_irq_handler;
1393 girq->num_parents = 1;
1394 girq->parents = devm_kcalloc(pctl->dev, 1,
1395 sizeof(*girq->parents),
1396 GFP_KERNEL);
1397 if (!girq->parents) {
1398 ret = -ENOMEM;
1399 goto err;
1400 }
1401 girq->parents[0] = irq;
1402 girq->default_type = IRQ_TYPE_NONE;
1403 girq->handler = handle_level_irq;
1404
1405 ret = gpiochip_add_data(&bank->gpio_chip, bank);
1406 if (ret < 0) {
1407 dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
1408 i, ret);
1409 goto err;
1410 }
1411
1412 ret = gpiochip_add_pin_range(&bank->gpio_chip,
1413 dev_name(pctl->dev), 0,
1414 bank->pin_base, bank->npins);
1415 if (ret < 0) {
1416 dev_err(pctl->dev, "Failed to add GPIO range %u: %d\n",
1417 i, ret);
1418 gpiochip_remove(&bank->gpio_chip);
1419 goto err;
1420 }
1421 }
1422
1423 return 0;
1424 err:
1425 for (; i > 0; i--) {
1426 bank = &pctl->gpio_banks[i - 1];
1427 gpiochip_remove(&bank->gpio_chip);
1428 }
1429 return ret;
1430 }
1431

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-09-01 14:46:02

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] pinctrl: pistachio: Switch to use fwnode instead of of_node

On Tue, Aug 30, 2022 at 9:39 PM Andy Shevchenko
<[email protected]> wrote:

> GPIO library now accepts fwnode as a firmware node, so
> switch the driver to use it.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Patch looks all right but I don't understand the compile error from
the kernelbot... device_get_named_child_node() isn't available
on arc? No idea what's wrong here :(

Yours,
Linus Walleij

2022-09-01 15:06:04

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] pinctrl: pistachio: Switch to use fwnode instead of of_node

On Thu, Sep 1, 2022 at 5:14 PM Linus Walleij <[email protected]> wrote:
>
> On Tue, Aug 30, 2022 at 9:39 PM Andy Shevchenko
> <[email protected]> wrote:
>
> > GPIO library now accepts fwnode as a firmware node, so
> > switch the driver to use it.
> >
> > Signed-off-by: Andy Shevchenko <[email protected]>
>
> Patch looks all right but I don't understand the compile error from
> the kernelbot... device_get_named_child_node() isn't available
> on arc? No idea what's wrong here :(

No, it's simple as I used dev when there is no such variable defined
and for some reason I missed a compilation on my side. In any case
there is a v2 of it which compiles at least on x86.

--
With Best Regards,
Andy Shevchenko

2022-09-01 21:19:48

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] pinctrl: pistachio: Switch to use fwnode instead of of_node

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linus/master v6.0-rc3 next-20220901]
[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/pinctrl-pistachio-Switch-to-use-fwnode-instead-of-of_node/20220831-034037
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: arm-randconfig-r006-20220901 (https://download.01.org/0day-ci/archive/20220902/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project c55b41d5199d2394dd6cdb8f52180d8b81d809d4)
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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/6802887aaf094f08bc139caf331767217f7318a4
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/pinctrl-pistachio-Switch-to-use-fwnode-instead-of-of_node/20220831-034037
git checkout 6802887aaf094f08bc139caf331767217f7318a4
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/pinctrl/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/pinctrl/pinctrl-pistachio.c:1360:39: error: use of undeclared identifier 'dev'
child = device_get_named_child_node(dev, child_name);
^
1 error generated.


vim +/dev +1360 drivers/pinctrl/pinctrl-pistachio.c

1347
1348 static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
1349 {
1350 struct pistachio_gpio_bank *bank;
1351 unsigned int i;
1352 int irq, ret = 0;
1353
1354 for (i = 0; i < pctl->nbanks; i++) {
1355 char child_name[sizeof("gpioXX")];
1356 struct fwnode_handle *child;
1357 struct gpio_irq_chip *girq;
1358
1359 snprintf(child_name, sizeof(child_name), "gpio%d", i);
> 1360 child = device_get_named_child_node(dev, child_name);
1361 if (!child) {
1362 dev_err(pctl->dev, "No node for bank %u\n", i);
1363 ret = -ENODEV;
1364 goto err;
1365 }
1366
1367 if (!fwnode_property_present(child, "gpio-controller")) {
1368 fwnode_handle_put(child);
1369 dev_err(pctl->dev,
1370 "No gpio-controller property for bank %u\n", i);
1371 ret = -ENODEV;
1372 goto err;
1373 }
1374
1375 ret = fwnode_irq_get(child, 0);
1376 if (ret < 0) {
1377 fwnode_handle_put(child);
1378 dev_err(pctl->dev, "No IRQ for bank %u\n", i);
1379 goto err;
1380 }
1381 irq = ret;
1382
1383 bank = &pctl->gpio_banks[i];
1384 bank->pctl = pctl;
1385 bank->base = pctl->base + GPIO_BANK_BASE(i);
1386
1387 bank->gpio_chip.parent = pctl->dev;
1388 bank->gpio_chip.fwnode = child;
1389
1390 girq = &bank->gpio_chip.irq;
1391 girq->chip = &bank->irq_chip;
1392 girq->parent_handler = pistachio_gpio_irq_handler;
1393 girq->num_parents = 1;
1394 girq->parents = devm_kcalloc(pctl->dev, 1,
1395 sizeof(*girq->parents),
1396 GFP_KERNEL);
1397 if (!girq->parents) {
1398 ret = -ENOMEM;
1399 goto err;
1400 }
1401 girq->parents[0] = irq;
1402 girq->default_type = IRQ_TYPE_NONE;
1403 girq->handler = handle_level_irq;
1404
1405 ret = gpiochip_add_data(&bank->gpio_chip, bank);
1406 if (ret < 0) {
1407 dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
1408 i, ret);
1409 goto err;
1410 }
1411
1412 ret = gpiochip_add_pin_range(&bank->gpio_chip,
1413 dev_name(pctl->dev), 0,
1414 bank->pin_base, bank->npins);
1415 if (ret < 0) {
1416 dev_err(pctl->dev, "Failed to add GPIO range %u: %d\n",
1417 i, ret);
1418 gpiochip_remove(&bank->gpio_chip);
1419 goto err;
1420 }
1421 }
1422
1423 return 0;
1424 err:
1425 for (; i > 0; i--) {
1426 bank = &pctl->gpio_banks[i - 1];
1427 gpiochip_remove(&bank->gpio_chip);
1428 }
1429 return ret;
1430 }
1431

--
0-DAY CI Kernel Test Service
https://01.org/lkp