drm/bridge: lontium-lt9611uxc: use irq as optional parameter
Subsystems (3)
PATCH 1/1 drm/bridge: lontium-lt9611uxc: use irq as optional parameter
On some systems the interrupt pin may not be used.
In this case we exclude DRM_BRIDGE_OP_HPD from supported operations, after which a polling thread is started to detect the connection. (the default polling period for DRM is 10 seconds)
--- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +17 -9
@@ -851,19 +851,25 @@ static int lt9611uxc_probe(struct i2c_client *client)init_waitqueue_head (<9611uxc->wq);INIT_WORK (<9611uxc->work, lt9611uxc_hpd_work); - ret =request_threaded_irq (client->irq,NULL , - lt9611uxc_irq_thread_handler, -IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); -if (ret) { -dev_err (dev,"failed to request irq\n" ); - goto err_disable_regulators; +if (client->irq) { + ret =request_threaded_irq (client->irq,NULL , + lt9611uxc_irq_thread_handler, +IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); +if (ret) { +dev_err (dev,"failed to request irq\n" ); + goto err_disable_regulators; + } +dev_dbg (dev,"Uses IRQ\n" ); + }else { +dev_warn (dev,"The interrupt (IRQ) is not specified in the DTS.\n" ); +dev_warn (dev,"Check the interrupt (IRQ) or polling will be used!!!\n" ); }i2c_set_clientdata (client, lt9611uxc); lt9611uxc->bridge.of_node = client->dev.of_node; lt9611uxc->bridge.ops =DRM_BRIDGE_OP_DETECT |DRM_BRIDGE_OP_EDID ; -if (lt9611uxc->hpd_supported) +if (lt9611uxc->hpd_supported && client->irq) lt9611uxc->bridge.ops |=DRM_BRIDGE_OP_HPD ; lt9611uxc->bridge.type =DRM_MODE_CONNECTOR_HDMIA ;
@@ -892,7 +898,8 @@ static int lt9611uxc_probe(struct i2c_client *client)return 0 ; err_remove_bridge: -free_irq (client->irq, lt9611uxc); +if (client->irq) +free_irq (client->irq, lt9611uxc);cancel_work_sync (<9611uxc->work);drm_bridge_remove (<9611uxc->bridge);
@@ -910,7 +917,8 @@ static void lt9611uxc_remove(struct i2c_client *client) {struct lt9611uxc *lt9611uxc =i2c_get_clientdata (client); -free_irq (client->irq, lt9611uxc); +if (client->irq) +free_irq (client->irq, lt9611uxc);cancel_work_sync (<9611uxc->work);lt9611uxc_audio_exit (lt9611uxc);drm_bridge_remove (<9611uxc->bridge);
Signature · 1 line
2.34.1
Luca Ceresoli
reviewerHello,
Quoted 18 lines · Vladimir Yakovlev
On some systems the interrupt pin may not be used.
In this case we excludeDRM_BRIDGE_OP_HPDfrom supported operations, after which a polling thread is started to detect the connection. (the default polling period for DRM is 10 seconds)Signed-off-by Vladimir Yakovlev <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611uxc.c +0
-0@@ -851,19 +851,25 @@ static int lt9611uxc_probe(struct i2c_client *client)init_waitqueue_head (<9611uxc->wq);INIT_WORK (<9611uxc->work, lt9611uxc_hpd_work);
drivers/gpu/drm/bridge/lontium-lt9611uxc.c static int lt9611uxc_probe(struct i2c_client *client) · line 857
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +4
-6- ret =request_threaded_irq (client->irq,NULL , - lt9611uxc_irq_thread_handler, -IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); -if (ret) { -dev_err (dev,"failed to request irq\n" ); - goto err_disable_regulators; +if (client->irq) { + ret =request_threaded_irq (client->irq,NULL , + lt9611uxc_irq_thread_handler, +IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc);
This is per se correct, but while you're touching this it's a good opportunity to switch to devm_request_threaded_irq(). This would simplify the removal code too (see below).
drivers/gpu/drm/bridge/lontium-lt9611uxc.c static int lt9611uxc_probe(struct i2c_client *client) · line 865
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +8
-0+if (ret) { +dev_err (dev,"failed to request irq\n" ); + goto err_disable_regulators; + } +dev_dbg (dev,"Uses IRQ\n" ); + }else { +dev_warn (dev,"The interrupt (IRQ) is not specified in the DTS.\n" ); +dev_warn (dev,"Check the interrupt (IRQ) or polling will be used!!!\n" );
If hardware without this IRQ is supported, there is no reason to warn. You can have a dev_dbg() at most, or even nothing at all.
Quoted 12 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +1
-1}i2c_set_clientdata (client, lt9611uxc); lt9611uxc->bridge.of_node = client->dev.of_node; lt9611uxc->bridge.ops =DRM_BRIDGE_OP_DETECT |DRM_BRIDGE_OP_EDID ; -if (lt9611uxc->hpd_supported) +if (lt9611uxc->hpd_supported && client->irq) lt9611uxc->bridge.ops |=DRM_BRIDGE_OP_HPD ; lt9611uxc->bridge.type =DRM_MODE_CONNECTOR_HDMIA ;
drivers/gpu/drm/bridge/lontium-lt9611uxc.c static int lt9611uxc_probe(struct i2c_client *client) · line 902
Quoted 6 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +2
-1@@ -892,7 +898,8 @@ static int lt9611uxc_probe(struct i2c_client *client)return 0 ; err_remove_bridge: -free_irq (client->irq, lt9611uxc); +if (client->irq) +free_irq (client->irq, lt9611uxc);
With devm_request_threaded_irq() you can remove entirely the free_irq() here...
drivers/gpu/drm/bridge/lontium-lt9611uxc.c static void lt9611uxc_remove(struct i2c_client *client) · line 921
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +2
-1cancel_work_sync (<9611uxc->work);drm_bridge_remove (<9611uxc->bridge);@@ -910,7 +917,8 @@ static void lt9611uxc_remove(struct i2c_client *client) {struct lt9611uxc *lt9611uxc =i2c_get_clientdata (client); -free_irq (client->irq, lt9611uxc); +if (client->irq) +free_irq (client->irq, lt9611uxc);
...as well as here.
So I'd suggest to add a new patch to switch to devm_request_threaded_irq(), followed by this one, which will be a simpler.
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
PATCH 1/1 drm/bridge: lontium-lt9611uxc: change to use devm_request_threaded_irq
It's better to use devm_request_threaded_irq because resources will be freed automatically and no additional checks are needed.
--- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +3 -5
@@ -851,9 +851,9 @@ static int lt9611uxc_probe(struct i2c_client *client)init_waitqueue_head (<9611uxc->wq);INIT_WORK (<9611uxc->work, lt9611uxc_hpd_work); - ret =request_threaded_irq (client->irq,NULL , - lt9611uxc_irq_thread_handler, -IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); + ret =devm_request_threaded_irq (dev, client->irq,NULL , + lt9611uxc_irq_thread_handler, +IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc);if (ret) {dev_err (dev,"failed to request irq\n" ); goto err_disable_regulators;
@@ -892,7 +892,6 @@ static int lt9611uxc_probe(struct i2c_client *client)return 0 ; err_remove_bridge: -free_irq (client->irq, lt9611uxc);cancel_work_sync (<9611uxc->work);drm_bridge_remove (<9611uxc->bridge);
@@ -910,7 +909,6 @@ static void lt9611uxc_remove(struct i2c_client *client) {struct lt9611uxc *lt9611uxc =i2c_get_clientdata (client); -free_irq (client->irq, lt9611uxc);cancel_work_sync (<9611uxc->work);lt9611uxc_audio_exit (lt9611uxc);drm_bridge_remove (<9611uxc->bridge);
Signature · 1 line
2.34.1
Re: [PATCH] drm/bridge: lontium-lt9611uxc: change to use devm_request_threaded_irq
Quoted 4 lines · Vladimir Yakovlev
It's better to use
devm_request_threaded_irqbecause resources will be freed automatically and no additional checks are needed.Signed-off-by Vladimir Yakovlev <[email protected]>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH] drm/bridge: lontium-lt9611uxc: change to use devm_request_threaded_irq
In reply to Vladimir YakovlevQuoted 13 lines · Vladimir Yakovlev
It's better to use
devm_request_threaded_irqbecause resources will be freed automatically and no additional checks are needed.Signed-off-by Vladimir Yakovlev <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611uxc.c +0
-0
drivers/gpu/drm/bridge/lontium-lt9611uxc.c static int lt9611uxc_probe(struct i2c_client *client) · line 856
Quoted 9 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +3
-3@@ -851,9 +851,9 @@ static int lt9611uxc_probe(struct i2c_client *client)init_waitqueue_head (<9611uxc->wq);INIT_WORK (<9611uxc->work, lt9611uxc_hpd_work); - ret =request_threaded_irq (client->irq,NULL , - lt9611uxc_irq_thread_handler, -IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); + ret =devm_request_threaded_irq (dev, client->irq,NULL , + lt9611uxc_irq_thread_handler, +IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc);
This makes interrupt being registered until the _end_ of the lt9611uxc_remove() (or lt9611uxc_probe() in case of probe error). Are you sure that the code can cope with the stray IRQs being delivered during or right after lt9611uxc_remove()?
Quoted 22 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +0
-2if (ret) {dev_err (dev,"failed to request irq\n" ); goto err_disable_regulators;@@ -892,7 +892,6 @@ static int lt9611uxc_probe(struct i2c_client *client)return 0 ; err_remove_bridge: -free_irq (client->irq, lt9611uxc);cancel_work_sync (<9611uxc->work);drm_bridge_remove (<9611uxc->bridge);@@ -910,7 +909,6 @@ static void lt9611uxc_remove(struct i2c_client *client) {struct lt9611uxc *lt9611uxc =i2c_get_clientdata (client); -free_irq (client->irq, lt9611uxc);cancel_work_sync (<9611uxc->work);lt9611uxc_audio_exit (lt9611uxc);drm_bridge_remove (<9611uxc->bridge);Signature · 1 line
2.34.1
Signature · 2 lines
With best wishes Dmitry
v2 cover drm/bridge: lontium-lt9611uxc: use irq as optional
In reply to Luca CeresoliHello!
This patch add support IRQ as optional for lt9611uxc
Changes in v2:
- As Luca Ceresoli recommended earlier, I added a patch to replace
- request_threaded_irq with devm_request_threaded_irq before making
- these changes.
-
- Since the updates only affected this patch, and the previous patch
- was new, I made v2 just for this one. I apologize if this is incorrect.
Thanks
Vladimir Yakovlev (1):
drm/bridge: lontium-lt9611uxc: use irq as optional parameter
drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
Luca Ceresoli
reviewerRe: [PATCH v2 0/1] drm/bridge: lontium-lt9611uxc: use irq as optional
Quoted 11 lines · Vladimir Yakovlev
Hello!
This patch add support IRQ as optional for lt9611uxc
Changes in v2:
- As Luca Ceresoli recommended earlier, I added a patch to replace
-request_threaded_irqwithdevm_request_threaded_irqbefore making
- these changes.
-
- Since the updates only affected this patch, and the previous patch
- was new, I made v2 just for this one. I apologize if this is incorrect.
This series depends on "[PATCH] drm/bridge: lontium-lt9611uxc: change to use devm_request_threaded_irq" which you have sent separately, so it cannot be applied as-is. The best thing to do would have been sending a v2 series with 2 patches: first the devm conversion, then this one.
However no need to send again just for this, it can be handled while applying.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
PATCH v2 1/1 drm/bridge: lontium-lt9611uxc: use irq as optional parameter
In reply to Luca CeresoliOn some systems the interrupt pin may not be used.
In this case we exclude DRM_BRIDGE_OP_HPD from supported operations, after which a polling thread is started to detect the connection. (the default polling period for DRM is 10 seconds)
--- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +13 -7
@@ -851,19 +851,25 @@ static int lt9611uxc_probe(struct i2c_client *client)init_waitqueue_head (<9611uxc->wq);INIT_WORK (<9611uxc->work, lt9611uxc_hpd_work); - ret =devm_request_threaded_irq (dev, client->irq,NULL , - lt9611uxc_irq_thread_handler, -IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); -if (ret) { -dev_err (dev,"failed to request irq\n" ); - goto err_disable_regulators; +if (client->irq) { + ret =devm_request_threaded_irq (dev, client->irq,NULL , + lt9611uxc_irq_thread_handler, +IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); +if (ret) { +dev_err (dev,"failed to request irq\n" ); + goto err_disable_regulators; + } +dev_dbg (dev,"Uses IRQ\n" ); + }else { +dev_dbg (dev,"The interrupt (IRQ) is not specified in the DTS.\n" ); +dev_dbg (dev,"Check the interrupt (IRQ) or polling will be used!!!\n" ); }i2c_set_clientdata (client, lt9611uxc); lt9611uxc->bridge.of_node = client->dev.of_node; lt9611uxc->bridge.ops =DRM_BRIDGE_OP_DETECT |DRM_BRIDGE_OP_EDID ; -if (lt9611uxc->hpd_supported) +if (lt9611uxc->hpd_supported && client->irq) lt9611uxc->bridge.ops |=DRM_BRIDGE_OP_HPD ; lt9611uxc->bridge.type =DRM_MODE_CONNECTOR_HDMIA ;
Signature · 1 line
2.34.1
Luca Ceresoli
reviewerQuoted 27 lines · Vladimir Yakovlev
On some systems the interrupt pin may not be used.
In this case we excludeDRM_BRIDGE_OP_HPDfrom supported operations, after which a polling thread is started to detect the connection. (the default polling period for DRM is 10 seconds)Signed-off-by Vladimir Yakovlev <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611uxc.c +3
-6@@ -851,19 +851,25 @@ static int lt9611uxc_probe(struct i2c_client *client)init_waitqueue_head (<9611uxc->wq);INIT_WORK (<9611uxc->work, lt9611uxc_hpd_work); - ret =devm_request_threaded_irq (dev, client->irq,NULL , - lt9611uxc_irq_thread_handler, -IRQF_ONESHOT ,"lt9611uxc" , lt9611uxc); -if (ret) { -dev_err (dev,"failed to request irq\n" ); - goto err_disable_regulators; +if (client->irq) { + ret = devm_request_threaded_irq(dev, client->irq, NULL, + lt9611uxc_irq_thread_handler,
drivers/gpu/drm/bridge/lontium-lt9611uxc.c static int lt9611uxc_probe(struct i2c_client *client) · line 866
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611uxc.c +9
-0+ IRQF_ONESHOT, "lt9611uxc", lt9611uxc); +if (ret) { +dev_err (dev,"failed to request irq\n" ); + goto err_disable_regulators; + } +dev_dbg (dev,"Uses IRQ\n" ); + }else { +dev_dbg (dev,"The interrupt (IRQ) is not specified in the DTS.\n" ); +dev_dbg (dev,"Check the interrupt (IRQ) or polling will be used!!!\n" ); }
Thanks for having moved form a warning to a dbg. However these 2 lines are overly verbose and that's not really needed. I would prefer to see all those 3 dev_dbg() disappear honestly, being polling a perfectly supported use case here. But if you really really want to keep them, at least replace these 2 lines with just a "Uses polling\n" which gives the same info. Also the 2 consecutive dev_dbg() may mix with other logging, making it awkward to read in the logs.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com