diff mbox series

[v2] pinctrl: samsung: Use bank name as irqchip name

Message ID 20200610134824.13053-1-m.szyprowski@samsung.com
State Superseded
Headers show
Series [v2] pinctrl: samsung: Use bank name as irqchip name | expand

Commit Message

Marek Szyprowski June 10, 2020, 1:48 p.m. UTC
Use the bank name as the irqchip name. This name is later visible in
/proc/interrupts, what makes it possible to easily identify each
GPIO interrupt.

/proc/interrupts before this patch:
143:    0     exynos4210_wkup_irq_chip   7 Edge      hdmi
144:    0     exynos4210_wkup_irq_chip   6 Level     wm8994
145:    1     exynos4210_wkup_irq_chip   7 Edge      max77686-pmic, max77686-rtc
146:    1     exynos_gpio_irq_chip   3 Edge      3-0048

/proc/interrupts after this patch:
143:    0     gpx3   7 Edge      hdmi
144:    0     gpx3   6 Level     wm8994
145:    1     gpx0   7 Edge      max77686-pmic, max77686-rtc
146:    1     gpm2   3 Edge      3-0048

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

---
v2:
- reordered code to fix error handling
- fixed eint_wakeup_mask_value handling
- added __init annotations

v1: https://patchwork.kernel.org/patch/11594897/
- initial version
---
 drivers/pinctrl/samsung/pinctrl-exynos.c | 52 +++++++++++++-----------
 1 file changed, 29 insertions(+), 23 deletions(-)

-- 
2.17.1

Comments

kernel test robot June 10, 2020, 4:53 p.m. UTC | #1
Hi Marek,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pinctrl-samsung/for-next]
[also build test WARNING on pinctrl/devel next-20200610]
[cannot apply to v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Marek-Szyprowski/pinctrl-samsung-Use-bank-name-as-irqchip-name/20200610-215115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/samsung.git for-next
config: s390-allyesconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.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
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/device.h:15,
from drivers/pinctrl/samsung/pinctrl-exynos.c:16:
drivers/pinctrl/samsung/pinctrl-exynos.c: In function 'exynos_pinctrl_set_eint_wakeup_mask':
drivers/pinctrl/samsung/pinctrl-exynos.c:370:4: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'u32 *' {aka 'unsigned int *'} [-Wformat=]
370 |    "Setting external wakeup interrupt mask: 0x%xn",
|    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
19 | #define dev_fmt(fmt) fmt
|                      ^~~
drivers/pinctrl/samsung/pinctrl-exynos.c:369:2: note: in expansion of macro 'dev_info'
369 |  dev_info(drvdata->dev,
|  ^~~~~~~~
drivers/pinctrl/samsung/pinctrl-exynos.c:370:48: note: format string is defined here
370 |    "Setting external wakeup interrupt mask: 0x%xn",
|                                               ~^
|                                                |
|                                                unsigned int
|                                               %n
drivers/pinctrl/samsung/pinctrl-exynos.c:374:16: warning: passing argument 3 of 'regmap_write' makes integer from pointer without a cast [-Wint-conversion]
374 |        irq_chip->eint_wake_mask_value);
|        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
|                |
|                u32 * {aka unsigned int *}
In file included from drivers/pinctrl/samsung/pinctrl-exynos.c:25:
include/linux/regmap.h:1054:69: note: expected 'unsigned int' but argument is of type 'u32 *' {aka 'unsigned int *'}
1054 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
|                                                        ~~~~~~~~~~~~~^~~
drivers/pinctrl/samsung/pinctrl-exynos.c: In function 's5pv210_pinctrl_set_eint_wakeup_mask':
>> drivers/pinctrl/samsung/pinctrl-exynos.c:393:23: warning: passing argument 1 of 'zpci_write_u32' makes integer from pointer without a cast [-Wint-conversion]
393 |  __raw_writel(irq_chip->eint_wake_mask_value,
|               ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
|                       |
|                       u32 * {aka unsigned int *}
In file included from arch/s390/include/asm/io.h:15,
from include/linux/io.h:13,
from include/linux/irq.h:20,
from drivers/pinctrl/samsung/pinctrl-exynos.c:19:
arch/s390/include/asm/pci_io.h:50:49: note: expected 'u32' {aka 'unsigned int'} but argument is of type 'u32 *' {aka 'unsigned int *'}
50 | static inline void zpci_write_##VALTYPE(VALTYPE val,             |                                                 ^
>> arch/s390/include/asm/pci_io.h:63:1: note: in expansion of macro 'zpci_write'
63 | zpci_write(4, u32)
| ^~~~~~~~~~

vim +/zpci_write_u32 +393 drivers/pinctrl/samsung/pinctrl-exynos.c

b577a279914085 Jonathan Bakker 2020-04-04  376  
b577a279914085 Jonathan Bakker 2020-04-04  377  static void
b577a279914085 Jonathan Bakker 2020-04-04  378  s5pv210_pinctrl_set_eint_wakeup_mask(struct samsung_pinctrl_drv_data *drvdata,
b577a279914085 Jonathan Bakker 2020-04-04  379  				    struct exynos_irq_chip *irq_chip)
b577a279914085 Jonathan Bakker 2020-04-04  380  
b577a279914085 Jonathan Bakker 2020-04-04  381  {
b577a279914085 Jonathan Bakker 2020-04-04  382  	void __iomem *clk_base;
b577a279914085 Jonathan Bakker 2020-04-04  383  
b577a279914085 Jonathan Bakker 2020-04-04  384  	if (!drvdata->retention_ctrl || !drvdata->retention_ctrl->priv) {
b577a279914085 Jonathan Bakker 2020-04-04  385  		dev_warn(drvdata->dev,
b577a279914085 Jonathan Bakker 2020-04-04  386  			 "No retention data configured bank with external wakeup interrupt. Wake-up mask will not be set.\n");
b577a279914085 Jonathan Bakker 2020-04-04  387  		return;
b577a279914085 Jonathan Bakker 2020-04-04  388  	}
b577a279914085 Jonathan Bakker 2020-04-04  389  
b577a279914085 Jonathan Bakker 2020-04-04  390  
b577a279914085 Jonathan Bakker 2020-04-04  391  	clk_base = (void __iomem *) drvdata->retention_ctrl->priv;
b577a279914085 Jonathan Bakker 2020-04-04  392  
b577a279914085 Jonathan Bakker 2020-04-04 @393  	__raw_writel(irq_chip->eint_wake_mask_value,
b577a279914085 Jonathan Bakker 2020-04-04  394  		     clk_base + irq_chip->eint_wake_mask_reg);
b577a279914085 Jonathan Bakker 2020-04-04  395  }
b577a279914085 Jonathan Bakker 2020-04-04  396  

:::::: The code at line 393 was first introduced by commit
:::::: b577a279914085c6b657c33e9f39ef56d96a3302 pinctrl: samsung: Correct setting of eint wakeup mask on s5pv210

:::::: TO: Jonathan Bakker <xc-racer2@live.ca>
:::::: CC: Krzysztof Kozlowski <krzk@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot June 10, 2020, 5:19 p.m. UTC | #2
Hi Marek,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pinctrl-samsung/for-next]
[also build test WARNING on pinctrl/devel next-20200610]
[cannot apply to v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Marek-Szyprowski/pinctrl-samsung-Use-bank-name-as-irqchip-name/20200610-215115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/samsung.git for-next
config: x86_64-randconfig-s021-20200607 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-247-gcadbd124-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 ARCH=x86_64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/pinctrl/samsung/pinctrl-exynos.c:374:30: sparse: sparse: incorrect type in argument 3 (different base types) @@     expected unsigned int val @@     got unsigned int [usertype] *eint_wake_mask_value @@
>> drivers/pinctrl/samsung/pinctrl-exynos.c:374:30: sparse:     expected unsigned int val
>> drivers/pinctrl/samsung/pinctrl-exynos.c:374:30: sparse:     got unsigned int [usertype] *eint_wake_mask_value
   drivers/pinctrl/samsung/pinctrl-exynos.c:393:30: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned int val @@     got unsigned int [usertype] *eint_wake_mask_value @@
   drivers/pinctrl/samsung/pinctrl-exynos.c:393:30: sparse:     expected unsigned int val
   drivers/pinctrl/samsung/pinctrl-exynos.c:393:30: sparse:     got unsigned int [usertype] *eint_wake_mask_value
>> drivers/pinctrl/samsung/pinctrl-exynos.c:374:22: sparse: sparse: non size-preserving pointer to integer cast
   drivers/pinctrl/samsung/pinctrl-exynos.c:393:22: sparse: sparse: non size-preserving pointer to integer cast

vim +374 drivers/pinctrl/samsung/pinctrl-exynos.c

ad350cd9d54113 drivers/pinctrl/pinctrl-exynos.c         Tomasz Figa     2013-05-17  355  
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  356  static void
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  357  exynos_pinctrl_set_eint_wakeup_mask(struct samsung_pinctrl_drv_data *drvdata,
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  358  				    struct exynos_irq_chip *irq_chip)
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  359  {
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  360  	struct regmap *pmu_regs;
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  361  
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  362  	if (!drvdata->retention_ctrl || !drvdata->retention_ctrl->priv) {
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  363  		dev_warn(drvdata->dev,
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  364  			 "No retention data configured bank with external wakeup interrupt. Wake-up mask will not be set.\n");
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  365  		return;
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  366  	}
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  367  
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  368  	pmu_regs = drvdata->retention_ctrl->priv;
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  369  	dev_info(drvdata->dev,
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  370  		 "Setting external wakeup interrupt mask: 0x%x\n",
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  371  		 irq_chip->eint_wake_mask_value);
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  372  
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  373  	regmap_write(pmu_regs, irq_chip->eint_wake_mask_reg,
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04 @374  		     irq_chip->eint_wake_mask_value);
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  375  }
b577a279914085 drivers/pinctrl/samsung/pinctrl-exynos.c Jonathan Bakker 2020-04-04  376  

:::::: The code at line 374 was first introduced by commit
:::::: b577a279914085c6b657c33e9f39ef56d96a3302 pinctrl: samsung: Correct setting of eint wakeup mask on s5pv210

:::::: TO: Jonathan Bakker <xc-racer2@live.ca>
:::::: CC: Krzysztof Kozlowski <krzk@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 84501c785473..21a800134c42 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -38,7 +38,7 @@  struct exynos_irq_chip {
 	u32 eint_con;
 	u32 eint_mask;
 	u32 eint_pend;
-	u32 eint_wake_mask_value;
+	u32 *eint_wake_mask_value;
 	u32 eint_wake_mask_reg;
 	void (*set_eint_wakeup_mask)(struct samsung_pinctrl_drv_data *drvdata,
 				     struct exynos_irq_chip *irq_chip);
@@ -207,7 +207,7 @@  static void exynos_irq_release_resources(struct irq_data *irqd)
 /*
  * irq_chip for gpio interrupts.
  */
-static struct exynos_irq_chip exynos_gpio_irq_chip = {
+static const struct exynos_irq_chip exynos_gpio_irq_chip __initconst = {
 	.chip = {
 		.name = "exynos_gpio_irq_chip",
 		.irq_unmask = exynos_irq_unmask,
@@ -274,7 +274,7 @@  struct exynos_eint_gpio_save {
  * exynos_eint_gpio_init() - setup handling of external gpio interrupts.
  * @d: driver data of samsung pinctrl driver.
  */
-int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
+__init int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct samsung_pin_bank *bank;
 	struct device *dev = d->dev;
@@ -297,6 +297,15 @@  int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
 	for (i = 0; i < d->nr_banks; ++i, ++bank) {
 		if (bank->eint_type != EINT_TYPE_GPIO)
 			continue;
+
+		bank->irq_chip = devm_kmemdup(dev, &exynos_gpio_irq_chip,
+					   sizeof(*bank->irq_chip), GFP_KERNEL);
+		if (!bank->irq_chip) {
+			ret = -ENOMEM;
+			goto err_domains;
+		}
+		bank->irq_chip->chip.name = bank->name;
+
 		bank->irq_domain = irq_domain_add_linear(bank->of_node,
 				bank->nr_pins, &exynos_eint_irqd_ops, bank);
 		if (!bank->irq_domain) {
@@ -313,7 +322,6 @@  int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
 			goto err_domains;
 		}
 
-		bank->irq_chip = &exynos_gpio_irq_chip;
 	}
 
 	return 0;
@@ -338,9 +346,9 @@  static int exynos_wkup_irq_set_wake(struct irq_data *irqd, unsigned int on)
 	pr_info("wake %s for irq %d\n", on ? "enabled" : "disabled", irqd->irq);
 
 	if (!on)
-		our_chip->eint_wake_mask_value |= bit;
+		*our_chip->eint_wake_mask_value |= bit;
 	else
-		our_chip->eint_wake_mask_value &= ~bit;
+		*our_chip->eint_wake_mask_value &= ~bit;
 
 	return 0;
 }
@@ -386,6 +394,7 @@  s5pv210_pinctrl_set_eint_wakeup_mask(struct samsung_pinctrl_drv_data *drvdata,
 		     clk_base + irq_chip->eint_wake_mask_reg);
 }
 
+static u32 eint_wake_mask_value = EXYNOS_EINT_WAKEUP_MASK_DISABLED;
 /*
  * irq_chip for wakeup interrupts
  */
@@ -403,7 +412,7 @@  static const struct exynos_irq_chip s5pv210_wkup_irq_chip __initconst = {
 	.eint_con = EXYNOS_WKUP_ECON_OFFSET,
 	.eint_mask = EXYNOS_WKUP_EMASK_OFFSET,
 	.eint_pend = EXYNOS_WKUP_EPEND_OFFSET,
-	.eint_wake_mask_value = EXYNOS_EINT_WAKEUP_MASK_DISABLED,
+	.eint_wake_mask_value = &eint_wake_mask_value,
 	/* Only differences with exynos4210_wkup_irq_chip: */
 	.eint_wake_mask_reg = S5PV210_EINT_WAKEUP_MASK,
 	.set_eint_wakeup_mask = s5pv210_pinctrl_set_eint_wakeup_mask,
@@ -423,7 +432,7 @@  static const struct exynos_irq_chip exynos4210_wkup_irq_chip __initconst = {
 	.eint_con = EXYNOS_WKUP_ECON_OFFSET,
 	.eint_mask = EXYNOS_WKUP_EMASK_OFFSET,
 	.eint_pend = EXYNOS_WKUP_EPEND_OFFSET,
-	.eint_wake_mask_value = EXYNOS_EINT_WAKEUP_MASK_DISABLED,
+	.eint_wake_mask_value = &eint_wake_mask_value,
 	.eint_wake_mask_reg = EXYNOS_EINT_WAKEUP_MASK,
 	.set_eint_wakeup_mask = exynos_pinctrl_set_eint_wakeup_mask,
 };
@@ -442,7 +451,7 @@  static const struct exynos_irq_chip exynos7_wkup_irq_chip __initconst = {
 	.eint_con = EXYNOS7_WKUP_ECON_OFFSET,
 	.eint_mask = EXYNOS7_WKUP_EMASK_OFFSET,
 	.eint_pend = EXYNOS7_WKUP_EPEND_OFFSET,
-	.eint_wake_mask_value = EXYNOS_EINT_WAKEUP_MASK_DISABLED,
+	.eint_wake_mask_value = &eint_wake_mask_value,
 	.eint_wake_mask_reg = EXYNOS5433_EINT_WAKEUP_MASK,
 	.set_eint_wakeup_mask = exynos_pinctrl_set_eint_wakeup_mask,
 };
@@ -513,7 +522,7 @@  static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
  * exynos_eint_wkup_init() - setup handling of external wakeup interrupts.
  * @d: driver data of samsung pinctrl driver.
  */
-int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
+__init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
 	struct device_node *wkup_np = NULL;
@@ -521,7 +530,7 @@  int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 	struct samsung_pin_bank *bank;
 	struct exynos_weint_data *weint_data;
 	struct exynos_muxed_weint_data *muxed_data;
-	struct exynos_irq_chip *irq_chip;
+	const struct exynos_irq_chip *irq_chip;
 	unsigned int muxed_banks = 0;
 	unsigned int i;
 	int idx, irq;
@@ -531,12 +540,7 @@  int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 
 		match = of_match_node(exynos_wkup_irq_ids, np);
 		if (match) {
-			irq_chip = kmemdup(match->data,
-				sizeof(*irq_chip), GFP_KERNEL);
-			if (!irq_chip) {
-				of_node_put(np);
-				return -ENOMEM;
-			}
+			irq_chip = match->data;
 			wkup_np = np;
 			break;
 		}
@@ -549,6 +553,14 @@  int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		if (bank->eint_type != EINT_TYPE_WKUP)
 			continue;
 
+		bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip),
+					      GFP_KERNEL);
+		if (!bank->irq_chip) {
+			of_node_put(wkup_np);
+			return -ENOMEM;
+		}
+		bank->irq_chip->chip.name = bank->name;
+
 		bank->irq_domain = irq_domain_add_linear(bank->of_node,
 				bank->nr_pins, &exynos_eint_irqd_ops, bank);
 		if (!bank->irq_domain) {
@@ -557,8 +569,6 @@  int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 			return -ENXIO;
 		}
 
-		bank->irq_chip = irq_chip;
-
 		if (!of_find_property(bank->of_node, "interrupts", NULL)) {
 			bank->eint_type = EINT_TYPE_WKUP_MUX;
 			++muxed_banks;
@@ -657,10 +667,6 @@  void exynos_pinctrl_suspend(struct samsung_pinctrl_drv_data *drvdata)
 				irq_chip = bank->irq_chip;
 				irq_chip->set_eint_wakeup_mask(drvdata,
 							       irq_chip);
-			} else if (bank->irq_chip != irq_chip) {
-				dev_warn(drvdata->dev,
-					 "More than one external wakeup interrupt chip configured (bank: %s). This is not supported by hardware nor by driver.\n",
-					 bank->name);
 			}
 		}
 	}