[PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ

Andy Shevchenko posted 6 patches 10 months ago
There is a newer version of this series
[PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ
Posted by Andy Shevchenko 10 months ago
Switch to fwnode APIs to get IRQ. In particular this enables
a support of the separate wakeup IRQ. The rest is converted
just for the sake of consistency and fwnode reuse.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index edab56e5d5e5..196b29e5924b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -33,7 +33,6 @@
 #include <linux/mutex.h>
 #include <linux/of_device.h>
 #include <linux/of.h>
-#include <linux/of_irq.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pinctrl/devinfo.h>
 #include <linux/pm_domain.h>
@@ -510,9 +509,9 @@ static int i2c_device_probe(struct device *dev)
 			pm_runtime_get_sync(&client->adapter->dev);
 			irq = i2c_smbus_host_notify_to_irq(client);
 		} else if (is_of_node(fwnode)) {
-			irq = of_irq_get_byname(dev->of_node, "irq");
+			irq = fwnode_irq_get_byname(fwnode, "irq");
 			if (irq == -EINVAL || irq == -ENODATA)
-				irq = of_irq_get(dev->of_node, 0);
+				irq = fwnode_irq_get(fwnode, 0);
 		} else if (is_acpi_device_node(fwnode)) {
 			bool wake_capable;
 
@@ -547,7 +546,7 @@ static int i2c_device_probe(struct device *dev)
 	if (client->flags & I2C_CLIENT_WAKE) {
 		int wakeirq;
 
-		wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
+		wakeirq = fwnode_irq_get_byname(fwnode, "wakeup");
 		if (wakeirq == -EPROBE_DEFER) {
 			status = wakeirq;
 			goto put_sync_adapter;
-- 
2.47.2
Re: [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ
Posted by kernel test robot 10 months ago
Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.15-rc1 next-20250407]
[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/i2c-core-Drop-duplicate-check-before-calling-OF-APIs/20250407-180528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/20250407095852.215809-4-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ
config: i386-buildonly-randconfig-002-20250407 (https://download.01.org/0day-ci/archive/20250407/202504072135.1Uy3AQ3g-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250407/202504072135.1Uy3AQ3g-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504072135.1Uy3AQ3g-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/i2c/i2c-core-base.c: In function 'i2c_dev_irq_from_resources':
>> drivers/i2c/i2c-core-base.c:911:32: error: implicit declaration of function 'irq_get_irq_data'; did you mean 'irq_set_irq_wake'? [-Werror=implicit-function-declaration]
     911 |                         irqd = irq_get_irq_data(r->start);
         |                                ^~~~~~~~~~~~~~~~
         |                                irq_set_irq_wake
>> drivers/i2c/i2c-core-base.c:911:30: warning: assignment to 'struct irq_data *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     911 |                         irqd = irq_get_irq_data(r->start);
         |                              ^
>> drivers/i2c/i2c-core-base.c:915:25: error: implicit declaration of function 'irqd_set_trigger_type' [-Werror=implicit-function-declaration]
     915 |                         irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
         |                         ^~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/i2c-core-base.c: In function 'i2c_host_notify_irq_map':
>> drivers/i2c/i2c-core-base.c:1458:9: error: implicit declaration of function 'irq_set_chip_and_handler' [-Werror=implicit-function-declaration]
    1458 |         irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/i2c/i2c-core-base.c:1458:41: error: 'dummy_irq_chip' undeclared (first use in this function)
    1458 |         irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
         |                                         ^~~~~~~~~~~~~~
   drivers/i2c/i2c-core-base.c:1458:41: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/i2c/i2c-core-base.c:1458:57: error: 'handle_simple_irq' undeclared (first use in this function)
    1458 |         irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
         |                                                         ^~~~~~~~~~~~~~~~~
   drivers/i2c/i2c-core-base.c: In function 'i2c_handle_smbus_host_notify':
>> drivers/i2c/i2c-core-base.c:1508:9: error: implicit declaration of function 'generic_handle_irq_safe' [-Werror=implicit-function-declaration]
    1508 |         generic_handle_irq_safe(irq);
         |         ^~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +911 drivers/i2c/i2c-core-base.c

70762abb9f89d97 drivers/i2c/i2c-core.c      Jarkko Nikula   2013-11-14  897  
1d7534b6adcd3e4 drivers/i2c/i2c-core-base.c Charles Keepax  2019-06-27  898  int i2c_dev_irq_from_resources(const struct resource *resources,
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  899  			       unsigned int num_resources)
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  900  {
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  901  	struct irq_data *irqd;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  902  	int i;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  903  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  904  	for (i = 0; i < num_resources; i++) {
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  905  		const struct resource *r = &resources[i];
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  906  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  907  		if (resource_type(r) != IORESOURCE_IRQ)
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  908  			continue;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  909  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  910  		if (r->flags & IORESOURCE_BITS) {
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01 @911  			irqd = irq_get_irq_data(r->start);
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  912  			if (!irqd)
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  913  				break;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  914  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01 @915  			irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  916  		}
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  917  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  918  		return r->start;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  919  	}
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  920  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  921  	return 0;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  922  }
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  923  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki