2023-11-21 12:49:15

by Lukas Funke

[permalink] [raw]
Subject: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree

From: Lukas Funke <[email protected]>

Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on
every interrupt controller (i.e. arm64 GIC). Replace flag by a
request that depends on the actual device-tree setting.

Signed-off-by: Lukas Funke <[email protected]>
---
drivers/extcon/extcon-usbc-tusb320.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
index 4d08c2123e59..f7d699a90f72 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -515,6 +515,8 @@ static int tusb320_probe(struct i2c_client *client)
const void *match_data;
unsigned int revision;
int ret;
+ int irq_pol;
+ struct irq_data *irq_d;

priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -568,9 +570,17 @@ static int tusb320_probe(struct i2c_client *client)
*/
tusb320_state_update_handler(priv, true);

+ irq_d = irq_get_irq_data(client->irq);
+ if (!irq_d) {
+ dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
+ return -ENODEV;
+ }
+
+ irq_pol = irqd_get_trigger_type(irq_d);
+
ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
tusb320_irq_handler,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ IRQF_ONESHOT | irq_pol,
client->name, priv);
if (ret)
tusb320_typec_remove(priv);
--
2.30.2


2023-11-22 00:55:22

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree

Hi Lukas,

kernel test robot noticed the following build warnings:

[auto build test WARNING on chanwoo-extcon/extcon-next]
[also build test WARNING on linus/master v6.7-rc2 next-20231121]
[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/Lukas-Funke/extcon-usbc-tusb320-Set-interrupt-polarity-based-on-device-tree/20231121-205141
base: https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git extcon-next
patch link: https://lore.kernel.org/r/20231121124844.872238-1-lukas.funke-oss%40weidmueller.com
patch subject: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20231122/[email protected]/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231122/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/extcon/extcon-usbc-tusb320.c: In function 'tusb320_probe':
drivers/extcon/extcon-usbc-tusb320.c:573:17: error: implicit declaration of function 'irq_get_irq_data'; did you mean 'irq_set_irq_wake'? [-Werror=implicit-function-declaration]
573 | irq_d = irq_get_irq_data(client->irq);
| ^~~~~~~~~~~~~~~~
| irq_set_irq_wake
>> drivers/extcon/extcon-usbc-tusb320.c:573:15: warning: assignment to 'struct irq_data *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
573 | irq_d = irq_get_irq_data(client->irq);
| ^
drivers/extcon/extcon-usbc-tusb320.c:579:19: error: implicit declaration of function 'irqd_get_trigger_type' [-Werror=implicit-function-declaration]
579 | irq_pol = irqd_get_trigger_type(irq_d);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +573 drivers/extcon/extcon-usbc-tusb320.c

511
512 static int tusb320_probe(struct i2c_client *client)
513 {
514 struct tusb320_priv *priv;
515 const void *match_data;
516 unsigned int revision;
517 int ret;
518 int irq_pol;
519 struct irq_data *irq_d;
520
521 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
522 if (!priv)
523 return -ENOMEM;
524
525 priv->dev = &client->dev;
526 i2c_set_clientdata(client, priv);
527
528 priv->regmap = devm_regmap_init_i2c(client, &tusb320_regmap_config);
529 if (IS_ERR(priv->regmap))
530 return PTR_ERR(priv->regmap);
531
532 ret = tusb320_check_signature(priv);
533 if (ret)
534 return ret;
535
536 match_data = device_get_match_data(&client->dev);
537 if (!match_data)
538 return -EINVAL;
539
540 priv->ops = (struct tusb320_ops*)match_data;
541
542 if (priv->ops->get_revision) {
543 ret = priv->ops->get_revision(priv, &revision);
544 if (ret)
545 dev_warn(priv->dev,
546 "failed to read revision register: %d\n", ret);
547 else
548 dev_info(priv->dev, "chip revision %d\n", revision);
549 }
550
551 ret = tusb320_extcon_probe(priv);
552 if (ret)
553 return ret;
554
555 ret = tusb320_typec_probe(client, priv);
556 if (ret)
557 return ret;
558
559 /* update initial state */
560 tusb320_state_update_handler(priv, true);
561
562 /* Reset chip to its default state */
563 ret = tusb320_reset(priv);
564 if (ret)
565 dev_warn(priv->dev, "failed to reset chip: %d\n", ret);
566 else
567 /*
568 * State and polarity might change after a reset, so update
569 * them again and make sure the interrupt status bit is cleared.
570 */
571 tusb320_state_update_handler(priv, true);
572
> 573 irq_d = irq_get_irq_data(client->irq);
574 if (!irq_d) {
575 dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
576 return -ENODEV;
577 }
578
579 irq_pol = irqd_get_trigger_type(irq_d);
580
581 ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
582 tusb320_irq_handler,
583 IRQF_ONESHOT | irq_pol,
584 client->name, priv);
585 if (ret)
586 tusb320_typec_remove(priv);
587
588 return ret;
589 }
590

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

2023-11-22 07:19:58

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree

Hi Lukas,

kernel test robot noticed the following build errors:

[auto build test ERROR on chanwoo-extcon/extcon-next]
[also build test ERROR on linus/master v6.7-rc2 next-20231121]
[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/Lukas-Funke/extcon-usbc-tusb320-Set-interrupt-polarity-based-on-device-tree/20231121-205141
base: https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git extcon-next
patch link: https://lore.kernel.org/r/20231121124844.872238-1-lukas.funke-oss%40weidmueller.com
patch subject: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree
config: x86_64-randconfig-121-20231122 (https://download.01.org/0day-ci/archive/20231122/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231122/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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

drivers/extcon/extcon-usbc-tusb320.c: In function 'tusb320_probe':
>> drivers/extcon/extcon-usbc-tusb320.c:573:10: error: implicit declaration of function 'irq_get_irq_data'; did you mean 'irq_set_irq_wake'? [-Werror=implicit-function-declaration]
irq_d = irq_get_irq_data(client->irq);
^~~~~~~~~~~~~~~~
irq_set_irq_wake
>> drivers/extcon/extcon-usbc-tusb320.c:573:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
irq_d = irq_get_irq_data(client->irq);
^
>> drivers/extcon/extcon-usbc-tusb320.c:579:12: error: implicit declaration of function 'irqd_get_trigger_type'; did you mean 'irq_get_irqchip_state'? [-Werror=implicit-function-declaration]
irq_pol = irqd_get_trigger_type(irq_d);
^~~~~~~~~~~~~~~~~~~~~
irq_get_irqchip_state
cc1: some warnings being treated as errors


vim +573 drivers/extcon/extcon-usbc-tusb320.c

511
512 static int tusb320_probe(struct i2c_client *client)
513 {
514 struct tusb320_priv *priv;
515 const void *match_data;
516 unsigned int revision;
517 int ret;
518 int irq_pol;
519 struct irq_data *irq_d;
520
521 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
522 if (!priv)
523 return -ENOMEM;
524
525 priv->dev = &client->dev;
526 i2c_set_clientdata(client, priv);
527
528 priv->regmap = devm_regmap_init_i2c(client, &tusb320_regmap_config);
529 if (IS_ERR(priv->regmap))
530 return PTR_ERR(priv->regmap);
531
532 ret = tusb320_check_signature(priv);
533 if (ret)
534 return ret;
535
536 match_data = device_get_match_data(&client->dev);
537 if (!match_data)
538 return -EINVAL;
539
540 priv->ops = (struct tusb320_ops*)match_data;
541
542 if (priv->ops->get_revision) {
543 ret = priv->ops->get_revision(priv, &revision);
544 if (ret)
545 dev_warn(priv->dev,
546 "failed to read revision register: %d\n", ret);
547 else
548 dev_info(priv->dev, "chip revision %d\n", revision);
549 }
550
551 ret = tusb320_extcon_probe(priv);
552 if (ret)
553 return ret;
554
555 ret = tusb320_typec_probe(client, priv);
556 if (ret)
557 return ret;
558
559 /* update initial state */
560 tusb320_state_update_handler(priv, true);
561
562 /* Reset chip to its default state */
563 ret = tusb320_reset(priv);
564 if (ret)
565 dev_warn(priv->dev, "failed to reset chip: %d\n", ret);
566 else
567 /*
568 * State and polarity might change after a reset, so update
569 * them again and make sure the interrupt status bit is cleared.
570 */
571 tusb320_state_update_handler(priv, true);
572
> 573 irq_d = irq_get_irq_data(client->irq);
574 if (!irq_d) {
575 dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
576 return -ENODEV;
577 }
578
> 579 irq_pol = irqd_get_trigger_type(irq_d);
580
581 ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
582 tusb320_irq_handler,
583 IRQF_ONESHOT | irq_pol,
584 client->name, priv);
585 if (ret)
586 tusb320_typec_remove(priv);
587
588 return ret;
589 }
590

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

2023-11-22 08:08:47

by Lukas Funke

[permalink] [raw]
Subject: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based on device-tree

From: Lukas Funke <[email protected]>

Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on
every interrupt controller (i.e. arm64 GIC). Replace flag by a
request that depends on the actual device-tree setting.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Lukas Funke <[email protected]>
---
drivers/extcon/extcon-usbc-tusb320.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
index 4d08c2123e59..140ab28dbd36 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -17,6 +17,7 @@
#include <linux/usb/typec.h>
#include <linux/usb/typec_altmode.h>
#include <linux/usb/role.h>
+#include <linux/irq.h>

#define TUSB320_REG8 0x8
#define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
@@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client *client)
const void *match_data;
unsigned int revision;
int ret;
+ int irq_pol;
+ struct irq_data *irq_d;

priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -568,9 +571,17 @@ static int tusb320_probe(struct i2c_client *client)
*/
tusb320_state_update_handler(priv, true);

+ irq_d = irq_get_irq_data(client->irq);
+ if (!irq_d) {
+ dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
+ return -ENODEV;
+ }
+
+ irq_pol = irqd_get_trigger_type(irq_d);
+
ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
tusb320_irq_handler,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ IRQF_ONESHOT | irq_pol,
client->name, priv);
if (ret)
tusb320_typec_remove(priv);
--
2.30.2

2023-11-23 01:58:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree

Hi Lukas,

kernel test robot noticed the following build errors:

[auto build test ERROR on chanwoo-extcon/extcon-next]
[also build test ERROR on linus/master v6.7-rc2 next-20231122]
[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/Lukas-Funke/extcon-usbc-tusb320-Set-interrupt-polarity-based-on-device-tree/20231121-205141
base: https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git extcon-next
patch link: https://lore.kernel.org/r/20231121124844.872238-1-lukas.funke-oss%40weidmueller.com
patch subject: [PATCH] extcon: usbc-tusb320: Set interrupt polarity based on device-tree
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231123/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231123/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/extcon/extcon-usbc-tusb320.c:573:10: error: call to undeclared function 'irq_get_irq_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
irq_d = irq_get_irq_data(client->irq);
^
drivers/extcon/extcon-usbc-tusb320.c:573:10: note: did you mean 'irq_set_irq_wake'?
include/linux/interrupt.h:482:12: note: 'irq_set_irq_wake' declared here
extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
^
>> drivers/extcon/extcon-usbc-tusb320.c:573:8: error: incompatible integer to pointer conversion assigning to 'struct irq_data *' from 'int' [-Wint-conversion]
irq_d = irq_get_irq_data(client->irq);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/extcon/extcon-usbc-tusb320.c:579:12: error: call to undeclared function 'irqd_get_trigger_type'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
irq_pol = irqd_get_trigger_type(irq_d);
^
3 errors generated.


vim +/irq_get_irq_data +573 drivers/extcon/extcon-usbc-tusb320.c

511
512 static int tusb320_probe(struct i2c_client *client)
513 {
514 struct tusb320_priv *priv;
515 const void *match_data;
516 unsigned int revision;
517 int ret;
518 int irq_pol;
519 struct irq_data *irq_d;
520
521 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
522 if (!priv)
523 return -ENOMEM;
524
525 priv->dev = &client->dev;
526 i2c_set_clientdata(client, priv);
527
528 priv->regmap = devm_regmap_init_i2c(client, &tusb320_regmap_config);
529 if (IS_ERR(priv->regmap))
530 return PTR_ERR(priv->regmap);
531
532 ret = tusb320_check_signature(priv);
533 if (ret)
534 return ret;
535
536 match_data = device_get_match_data(&client->dev);
537 if (!match_data)
538 return -EINVAL;
539
540 priv->ops = (struct tusb320_ops*)match_data;
541
542 if (priv->ops->get_revision) {
543 ret = priv->ops->get_revision(priv, &revision);
544 if (ret)
545 dev_warn(priv->dev,
546 "failed to read revision register: %d\n", ret);
547 else
548 dev_info(priv->dev, "chip revision %d\n", revision);
549 }
550
551 ret = tusb320_extcon_probe(priv);
552 if (ret)
553 return ret;
554
555 ret = tusb320_typec_probe(client, priv);
556 if (ret)
557 return ret;
558
559 /* update initial state */
560 tusb320_state_update_handler(priv, true);
561
562 /* Reset chip to its default state */
563 ret = tusb320_reset(priv);
564 if (ret)
565 dev_warn(priv->dev, "failed to reset chip: %d\n", ret);
566 else
567 /*
568 * State and polarity might change after a reset, so update
569 * them again and make sure the interrupt status bit is cleared.
570 */
571 tusb320_state_update_handler(priv, true);
572
> 573 irq_d = irq_get_irq_data(client->irq);
574 if (!irq_d) {
575 dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
576 return -ENODEV;
577 }
578
> 579 irq_pol = irqd_get_trigger_type(irq_d);
580
581 ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
582 tusb320_irq_handler,
583 IRQF_ONESHOT | irq_pol,
584 client->name, priv);
585 if (ret)
586 tusb320_typec_remove(priv);
587
588 return ret;
589 }
590

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

2023-12-04 12:09:44

by Chanwoo Choi

[permalink] [raw]
Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based on device-tree



> -----Original Message-----
> From: Lukas Funke <[email protected]>
> Sent: Wednesday, November 22, 2023 5:08 PM
> To: [email protected]; MyungJoo Ham <[email protected]>; Chanwoo Choi
> <[email protected]>
> Cc: [email protected]; [email protected];
lukas.funke-
> [email protected]; [email protected]; Lukas Funke
> <[email protected]>
> Subject: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based on
> device-tree
>
> From: Lukas Funke <[email protected]>
>
> Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on every
> interrupt controller (i.e. arm64 GIC). Replace flag by a request that
> depends on the actual device-tree setting.
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/202311221355.yxYpTIw3-
> [email protected]/
> Signed-off-by: Lukas Funke <[email protected]>
> ---
> drivers/extcon/extcon-usbc-tusb320.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-
> usbc-tusb320.c
> index 4d08c2123e59..140ab28dbd36 100644
> --- a/drivers/extcon/extcon-usbc-tusb320.c
> +++ b/drivers/extcon/extcon-usbc-tusb320.c
> @@ -17,6 +17,7 @@
> #include <linux/usb/typec.h>
> #include <linux/usb/typec_altmode.h>
> #include <linux/usb/role.h>
> +#include <linux/irq.h>
>
> #define TUSB320_REG8 0x8
> #define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
> @@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client *client)
> const void *match_data;
> unsigned int revision;
> int ret;
> + int irq_pol;
> + struct irq_data *irq_d;
>
> priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> @@ -568,9 +571,17 @@ static int tusb320_probe(struct i2c_client *client)
> */
> tusb320_state_update_handler(priv, true);
>
> + irq_d = irq_get_irq_data(client->irq);
> + if (!irq_d) {
> + dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
> + return -ENODEV;
> + }
> +
> + irq_pol = irqd_get_trigger_type(irq_d);
> +
> ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
> tusb320_irq_handler,
> - IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> + IRQF_ONESHOT | irq_pol,
> client->name, priv);
> if (ret)
> tusb320_typec_remove(priv);
> --
> 2.30.2


Applied it. Thanks.


Best Regards,
Chanwoo Choi


2023-12-04 12:33:14

by Chanwoo Choi

[permalink] [raw]
Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based on device-tree



> -----Original Message-----
> From: Chanwoo Choi <[email protected]>
> Sent: Monday, December 4, 2023 9:09 PM
> To: 'Lukas Funke' <[email protected]>; '[email protected]'
> <[email protected]>; 'MyungJoo Ham' <[email protected]>
> Cc: '[email protected]' <[email protected]>; 'linux-
> [email protected]' <[email protected]>; 'oe-kbuild-
> [email protected]' <[email protected]>; 'Lukas Funke'
> <[email protected]>
> Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based
> on device-tree
>
>
>
> > -----Original Message-----
> > From: Lukas Funke <[email protected]>
> > Sent: Wednesday, November 22, 2023 5:08 PM
> > To: [email protected]; MyungJoo Ham <[email protected]>; Chanwoo
> > Choi <[email protected]>
> > Cc: [email protected]; [email protected];
> > lukas.funke- [email protected]; [email protected]; Lukas
> > Funke <[email protected]>
> > Subject: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based
> > on device-tree
> >
> > From: Lukas Funke <[email protected]>
> >
> > Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on every
> > interrupt controller (i.e. arm64 GIC). Replace flag by a request that
> > depends on the actual device-tree setting.
> >
> > Reported-by: kernel test robot <[email protected]>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202311221355.yxYpTIw3-
> > [email protected]/
> > Signed-off-by: Lukas Funke <[email protected]>
> > ---
> > drivers/extcon/extcon-usbc-tusb320.c | 13 ++++++++++++-
> > 1 file changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/extcon/extcon-usbc-tusb320.c
> > b/drivers/extcon/extcon- usbc-tusb320.c index
> > 4d08c2123e59..140ab28dbd36 100644
> > --- a/drivers/extcon/extcon-usbc-tusb320.c
> > +++ b/drivers/extcon/extcon-usbc-tusb320.c
> > @@ -17,6 +17,7 @@
> > #include <linux/usb/typec.h>
> > #include <linux/usb/typec_altmode.h>
> > #include <linux/usb/role.h>
> > +#include <linux/irq.h>
> >
> > #define TUSB320_REG8 0x8
> > #define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
> > @@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client *client)
> > const void *match_data;
> > unsigned int revision;
> > int ret;
> > + int irq_pol;
> > + struct irq_data *irq_d;
> >
> > priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
> > if (!priv)
> > @@ -568,9 +571,17 @@ static int tusb320_probe(struct i2c_client *client)
> > */
> > tusb320_state_update_handler(priv, true);
> >
> > + irq_d = irq_get_irq_data(client->irq);
> > + if (!irq_d) {
> > + dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
> > + return -ENODEV;
> > + }
> > +
> > + irq_pol = irqd_get_trigger_type(irq_d);
> > +
> > ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
> > tusb320_irq_handler,
> > - IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> > + IRQF_ONESHOT | irq_pol,
> > client->name, priv);
> > if (ret)
> > tusb320_typec_remove(priv);
> > --
> > 2.30.2
>
>
> Applied it. Thanks.
>
>
> Best Regards,
> Chanwoo Choi


In order to remove the build warning, I changed the variable type
of 'irq_pol' as following:


index 140ab28dbd36..cec1889549a6 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -516,7 +516,7 @@ static int tusb320_probe(struct i2c_client *client)
const void *match_data;
unsigned int revision;
int ret;
- int irq_pol;
+ u32 irq_pol;
struct irq_data *irq_d;

priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);

Best Regards,
Chanwoo Choi

2023-12-04 12:49:49

by Chanwoo Choi

[permalink] [raw]
Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based on device-tree



> -----Original Message-----
> From: Chanwoo Choi <[email protected]>
> Sent: Monday, December 4, 2023 9:33 PM
> To: 'Lukas Funke' <[email protected]>; '[email protected]'
> <[email protected]>; 'MyungJoo Ham' <[email protected]>
> Cc: '[email protected]' <[email protected]>; 'linux-
> [email protected]' <[email protected]>; 'oe-kbuild-
> [email protected]' <[email protected]>; 'Lukas Funke'
> <[email protected]>
> Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based
> on device-tree
>
>
>
> > -----Original Message-----
> > From: Chanwoo Choi <[email protected]>
> > Sent: Monday, December 4, 2023 9:09 PM
> > To: 'Lukas Funke' <[email protected]>; '[email protected]'
> > <[email protected]>; 'MyungJoo Ham' <[email protected]>
> > Cc: '[email protected]' <[email protected]>;
> > 'linux- [email protected]' <[email protected]>;
> > 'oe-kbuild- [email protected]' <[email protected]>; 'Lukas
> Funke'
> > <[email protected]>
> > Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity
> > based on device-tree
> >
> >
> >
> > > -----Original Message-----
> > > From: Lukas Funke <[email protected]>
> > > Sent: Wednesday, November 22, 2023 5:08 PM
> > > To: [email protected]; MyungJoo Ham <[email protected]>; Chanwoo
> > > Choi <[email protected]>
> > > Cc: [email protected]; [email protected];
> > > lukas.funke- [email protected]; [email protected];
> > > Lukas Funke <[email protected]>
> > > Subject: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity
> > > based on device-tree
> > >
> > > From: Lukas Funke <[email protected]>
> > >
> > > Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on every
> > > interrupt controller (i.e. arm64 GIC). Replace flag by a request
> > > that depends on the actual device-tree setting.
> > >
> > > Reported-by: kernel test robot <[email protected]>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202311221355.yxYpTIw3-
> > > [email protected]/
> > > Signed-off-by: Lukas Funke <[email protected]>
> > > ---
> > > drivers/extcon/extcon-usbc-tusb320.c | 13 ++++++++++++-
> > > 1 file changed, 12 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/extcon/extcon-usbc-tusb320.c
> > > b/drivers/extcon/extcon- usbc-tusb320.c index
> > > 4d08c2123e59..140ab28dbd36 100644
> > > --- a/drivers/extcon/extcon-usbc-tusb320.c
> > > +++ b/drivers/extcon/extcon-usbc-tusb320.c
> > > @@ -17,6 +17,7 @@
> > > #include <linux/usb/typec.h>
> > > #include <linux/usb/typec_altmode.h> #include <linux/usb/role.h>
> > > +#include <linux/irq.h>
> > >
> > > #define TUSB320_REG8 0x8
> > > #define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
> > > @@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client
*client)
> > > const void *match_data;
> > > unsigned int revision;
> > > int ret;
> > > + int irq_pol;
> > > + struct irq_data *irq_d;
> > >
> > > priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
> > > if (!priv)
> > > @@ -568,9 +571,17 @@ static int tusb320_probe(struct i2c_client
*client)
> > > */
> > > tusb320_state_update_handler(priv, true);
> > >
> > > + irq_d = irq_get_irq_data(client->irq);
> > > + if (!irq_d) {
> > > + dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
> > > + return -ENODEV;
> > > + }
> > > +
> > > + irq_pol = irqd_get_trigger_type(irq_d);
> > > +
> > > ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
> > > tusb320_irq_handler,
> > > - IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> > > + IRQF_ONESHOT | irq_pol,
> > > client->name, priv);
> > > if (ret)
> > > tusb320_typec_remove(priv);
> > > --
> > > 2.30.2
> >
> >
> > Applied it. Thanks.
> >
> >
> > Best Regards,
> > Chanwoo Choi
>
>
> In order to remove the build warning, I changed the variable type
> of 'irq_pol' as following:
>
>
> index 140ab28dbd36..cec1889549a6 100644
> --- a/drivers/extcon/extcon-usbc-tusb320.c
> +++ b/drivers/extcon/extcon-usbc-tusb320.c
> @@ -516,7 +516,7 @@ static int tusb320_probe(struct i2c_client *client)
> const void *match_data;
> unsigned int revision;
> int ret;
> - int irq_pol;
> + u32 irq_pol;
> struct irq_data *irq_d;
>
> priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
>
> Best Regards,
> Chanwoo Choi


How about changing this patch as following?
When irq_getg_irq_data returns NULL, just use the IRQF_TRIGGER_FALLING flag
to support previous version. Because I didn't' check the all use-case
of this driver on DT. I think that better to keep the IRQF_TRIGGER_FALLING
flag
when irq_d is NULL.


diff --git a/drivers/extcon/extcon-usbc-tusb320.c
b/drivers/extcon/extcon-usbc-tusb320.c
index 4d08c2123e59..bd5ed8dd8fdd 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -17,6 +17,7 @@
#include <linux/usb/typec.h>
#include <linux/usb/typec_altmode.h>
#include <linux/usb/role.h>
+#include <linux/irq.h>

#define TUSB320_REG8 0x8
#define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
@@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client *client)
const void *match_data;
unsigned int revision;
int ret;
+ u32 irq_trigger_type;
+ struct irq_data *irq_d;

priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -568,9 +571,15 @@ static int tusb320_probe(struct i2c_client *client)
*/
tusb320_state_update_handler(priv, true);

+ irq_d = irq_get_irq_data(client->irq);
+ if (irq_d)
+ irq_trigger_type = irqd_get_trigger_type(irq_d);
+ else
+ irq_trigger_type = IRQF_TRIGGER_FALLING;
+
ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
tusb320_irq_handler,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ IRQF_ONESHOT | irq_trigger_type,
client->name, priv);
if (ret)
tusb320_typec_remove(priv);
--
2.25.1

2023-12-04 13:23:10

by Lukas Funke

[permalink] [raw]
Subject: Re: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based on device-tree

Hi Chanwoo,

On 04.12.2023 13:49, Chanwoo Choi wrote:
>
>
>> -----Original Message-----
>> From: Chanwoo Choi <[email protected]>
>> Sent: Monday, December 4, 2023 9:33 PM
>> To: 'Lukas Funke' <[email protected]>; '[email protected]'
>> <[email protected]>; 'MyungJoo Ham' <[email protected]>
>> Cc: '[email protected]' <[email protected]>; 'linux-
>> [email protected]' <[email protected]>; 'oe-kbuild-
>> [email protected]' <[email protected]>; 'Lukas Funke'
>> <[email protected]>
>> Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity based
>> on device-tree
>>
>>
>>
>>> -----Original Message-----
>>> From: Chanwoo Choi <[email protected]>
>>> Sent: Monday, December 4, 2023 9:09 PM
>>> To: 'Lukas Funke' <[email protected]>; '[email protected]'
>>> <[email protected]>; 'MyungJoo Ham' <[email protected]>
>>> Cc: '[email protected]' <[email protected]>;
>>> 'linux- [email protected]' <[email protected]>;
>>> 'oe-kbuild- [email protected]' <[email protected]>; 'Lukas
>> Funke'
>>> <[email protected]>
>>> Subject: RE: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity
>>> based on device-tree
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Lukas Funke <[email protected]>
>>>> Sent: Wednesday, November 22, 2023 5:08 PM
>>>> To: [email protected]; MyungJoo Ham <[email protected]>; Chanwoo
>>>> Choi <[email protected]>
>>>> Cc: [email protected]; [email protected];
>>>> lukas.funke- [email protected]; [email protected];
>>>> Lukas Funke <[email protected]>
>>>> Subject: [PATCH v2] extcon: usbc-tusb320: Set interrupt polarity
>>>> based on device-tree
>>>>
>>>> From: Lukas Funke <[email protected]>
>>>>
>>>> Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on every
>>>> interrupt controller (i.e. arm64 GIC). Replace flag by a request
>>>> that depends on the actual device-tree setting.
>>>>
>>>> Reported-by: kernel test robot <[email protected]>
>>>> Closes: https://lore.kernel.org/oe-kbuild-all/202311221355.yxYpTIw3-
>>>> [email protected]/
>>>> Signed-off-by: Lukas Funke <[email protected]>
>>>> ---
>>>> drivers/extcon/extcon-usbc-tusb320.c | 13 ++++++++++++-
>>>> 1 file changed, 12 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/extcon/extcon-usbc-tusb320.c
>>>> b/drivers/extcon/extcon- usbc-tusb320.c index
>>>> 4d08c2123e59..140ab28dbd36 100644
>>>> --- a/drivers/extcon/extcon-usbc-tusb320.c
>>>> +++ b/drivers/extcon/extcon-usbc-tusb320.c
>>>> @@ -17,6 +17,7 @@
>>>> #include <linux/usb/typec.h>
>>>> #include <linux/usb/typec_altmode.h> #include <linux/usb/role.h>
>>>> +#include <linux/irq.h>
>>>>
>>>> #define TUSB320_REG8 0x8
>>>> #define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
>>>> @@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client
> *client)
>>>> const void *match_data;
>>>> unsigned int revision;
>>>> int ret;
>>>> + int irq_pol;
>>>> + struct irq_data *irq_d;
>>>>
>>>> priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
>>>> if (!priv)
>>>> @@ -568,9 +571,17 @@ static int tusb320_probe(struct i2c_client
> *client)
>>>> */
>>>> tusb320_state_update_handler(priv, true);
>>>>
>>>> + irq_d = irq_get_irq_data(client->irq);
>>>> + if (!irq_d) {
>>>> + dev_err(&client->dev, "Invalid IRQ: %d\n", client->irq);
>>>> + return -ENODEV;
>>>> + }
>>>> +
>>>> + irq_pol = irqd_get_trigger_type(irq_d);
>>>> +
>>>> ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
>>>> tusb320_irq_handler,
>>>> - IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
>>>> + IRQF_ONESHOT | irq_pol,
>>>> client->name, priv);
>>>> if (ret)
>>>> tusb320_typec_remove(priv);
>>>> --
>>>> 2.30.2
>>>
>>>
>>> Applied it. Thanks.
>>>
>>>
>>> Best Regards,
>>> Chanwoo Choi
>>
>>
>> In order to remove the build warning, I changed the variable type
>> of 'irq_pol' as following:
>>
>>
>> index 140ab28dbd36..cec1889549a6 100644
>> --- a/drivers/extcon/extcon-usbc-tusb320.c
>> +++ b/drivers/extcon/extcon-usbc-tusb320.c
>> @@ -516,7 +516,7 @@ static int tusb320_probe(struct i2c_client *client)
>> const void *match_data;
>> unsigned int revision;
>> int ret;
>> - int irq_pol;
>> + u32 irq_pol;
>> struct irq_data *irq_d;
>>
>> priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
>>
>> Best Regards,
>> Chanwoo Choi
>
>
> How about changing this patch as following?
> When irq_getg_irq_data returns NULL, just use the IRQF_TRIGGER_FALLING flag
> to support previous version. Because I didn't' check the all use-case
> of this driver on DT. I think that better to keep the IRQF_TRIGGER_FALLING
> flag
> when irq_d is NULL.

Good call. Just one minor change to make the 'else' obsolete (see below).

Best regards
Lukas Funke

>
>
> diff --git a/drivers/extcon/extcon-usbc-tusb320.c
> b/drivers/extcon/extcon-usbc-tusb320.c
> index 4d08c2123e59..bd5ed8dd8fdd 100644
> --- a/drivers/extcon/extcon-usbc-tusb320.c
> +++ b/drivers/extcon/extcon-usbc-tusb320.c
> @@ -17,6 +17,7 @@
> #include <linux/usb/typec.h>
> #include <linux/usb/typec_altmode.h>
> #include <linux/usb/role.h>
> +#include <linux/irq.h>
>
> #define TUSB320_REG8 0x8
> #define TUSB320_REG8_CURRENT_MODE_ADVERTISE GENMASK(7, 6)
> @@ -515,6 +516,8 @@ static int tusb320_probe(struct i2c_client *client)
> const void *match_data;
> unsigned int revision;
> int ret;
+ u32 irq_trigger_type = IRQF_TRIGGER_FALLING;
> + struct irq_data *irq_d;
>
> priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> @@ -568,9 +571,15 @@ static int tusb320_probe(struct i2c_client *client)
> */
> tusb320_state_update_handler(priv, true);
>
> + irq_d = irq_get_irq_data(client->irq);
> + if (irq_d)
> + irq_trigger_type = irqd_get_trigger_type(irq_d);
> +
> ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
> tusb320_irq_handler,
> - IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> + IRQF_ONESHOT | irq_trigger_type,
> client->name, priv);
> if (ret)
> tusb320_typec_remove(priv);