pcmcia: m32r_pcc: check return from request_irq
PATCH 1/3 pcmcia: m32r_pcc: check return from request_irq
While building m32r allmodconfig we were getting warning:
drivers/pcmcia/m32r_pcc.c:331:2:
warning: ignoring return value of 'request_irq',
declared with attribute warn_unused_result
request_irq() can fail and we should always be checking the result from it. Check the result and return it to the caller.
---
m32r allmodconfig build log is at:
https://travis-ci.org/sudipm-mukherjee/parport/jobs/160355863
drivers/pcmcia/m32r_pcc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/pcmcia/m32r_pcc.c +10 -4
@@ -296,10 +296,11 @@ static int __init is_alive(u_short sock)return 0 ; } -static void add_pcc_socket (ulong base,int irq,ulong mapaddr, -unsigned int ioaddr) +static int add_pcc_socket (ulong base,int irq,ulong mapaddr, +unsigned int ioaddr) {pcc_socket_t *t = &socket[pcc_sockets]; +int err;/* add sockets */ t->ioaddr = ioaddr;
@@ -328,11 +329,16 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, t->socket.irq_mask =0 ; t->socket.pci_irq =2 + pcc_sockets;/* XXX */ -request_irq (irq, pcc_interrupt,0 ,"m32r-pcc" , pcc_interrupt); + err =request_irq (irq, pcc_interrupt,0 ,"m32r-pcc" , pcc_interrupt); +if (err) { +if (t->base >0 ) +release_region (t->base,0x20 ); +return err; + } pcc_sockets++; -return ; +return 0 ; }
Signature · 1 line
1.9.1
PATCH 2/3 pcmcia: m32r_pcc: use common error path
Use a common error path for the failure.
--- drivers/pcmcia/m32r_pcc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/pcmcia/m32r_pcc.c +10 -7
@@ -689,10 +689,8 @@ static int __init init_m32r_pcc(void)return ret; ret =platform_device_register (&pcc_device); -if (ret){ -platform_driver_unregister (&pcc_driver); -return ret; - } +if (ret) + goto unreg_driv;printk (KERN_INFO "m32r PCC probe:\n" );
@@ -706,9 +704,8 @@ static int __init init_m32r_pcc(void)if (pcc_sockets ==0 ) {printk ("socket is not found.\n" ); -platform_device_unregister (&pcc_device); -platform_driver_unregister (&pcc_driver); -return -ENODEV ; + ret = -ENODEV ; + goto unreg_dev; }/* Set up interrupt handler(s) */
@@ -734,6 +731,12 @@ static int __init init_m32r_pcc(void) }return 0 ; + +unreg_dev: +platform_device_unregister (&pcc_device); +unreg_driv: +platform_driver_unregister (&pcc_driver); +return ret; }/* init_m32r_pcc */ static void __exit exit_m32r_pcc(void)
Signature · 1 line
1.9.1
PATCH 3/3 pcmcia: m32r_pcc: check return from add_pcc_socket
In reply to Sudip MukherjeeIf request_irq() fails it passes the error to the caller. The caller now checks it and jumps to the common error path on failure.
--- drivers/pcmcia/m32r_pcc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pcmcia/m32r_pcc.c +8 -2
@@ -696,10 +696,16 @@ static int __init init_m32r_pcc(void) pcc_sockets =0 ; -add_pcc_socket (M32R_PCC0_BASE ,PCC0_IRQ ,M32R_PCC0_MAPBASE ,0x1000 ); + ret =add_pcc_socket (M32R_PCC0_BASE ,PCC0_IRQ ,M32R_PCC0_MAPBASE , +0x1000 ); +if (ret) + goto unreg_dev;#ifdef CONFIG_M32RPCC_SLOT2 -add_pcc_socket (M32R_PCC1_BASE ,PCC1_IRQ ,M32R_PCC1_MAPBASE ,0x2000 ); + ret =add_pcc_socket (M32R_PCC1_BASE ,PCC1_IRQ ,M32R_PCC1_MAPBASE , +0x2000 ); +if (ret) + goto unreg_dev;#endif if (pcc_sockets ==0 ) {
Signature · 1 line
1.9.1
Quoted 11 lines · Sudip Mukherjee
While building m32r allmodconfig we were getting warning:
drivers/pcmcia/m32r_pcc.c:331:2:
warning: ignoring return value of 'request_irq', declared with attributewarn_unused_result
request_irq()can fail and we should always be checking the result from it. Check the result and return it to the caller.Signed-off-by Sudip Mukherjee <[email protected]>---
Hi Andrew,
A gentle ping.
Regards
Sudip