aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/ene_ir.c
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2012-10-15 06:13:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-28 14:28:58 -0400
commit56411c0f1eec7495bcf1fd6b83a51bb57be608d4 (patch)
tree682650b282526d9107c52578ff5c1363c2d144d1 /drivers/media/rc/ene_ir.c
parent895507c19f88b7bbf82f24737d86cca0398647cb (diff)
[media] ene-ir: Fix cleanup on probe failure
This makes the cleanup on probe failure more consistent with other drivers. This is similar to what commit f27b853ea24a9b70585f9251384d97929e6551c3 ("[media] rc: Fix invalid free_region and/or free_irq on probe failure") did for some other drivers. In addition to making the cleanup more consistent, this also fixes a case where (on a ene_hw_detect failure) free_region would be called on a region that was not requested yet. This last problem was probably introduced by the moving of code in commit b31b021988fed9e3741a46918f14ba9b063811db ("[media] ene_ir: Fix driver initialisation") and commit 9ef449c6b31bb6a8e6dedc24de475a3b8c79be20 ("[media] rc: Postpone ISR registration"). Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl> Cc: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/rc/ene_ir.c')
-rw-r--r--drivers/media/rc/ene_ir.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index dd3c510a6ae8..22231dd4f62b 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); 1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
1004 rdev = rc_allocate_device(); 1004 rdev = rc_allocate_device();
1005 if (!dev || !rdev) 1005 if (!dev || !rdev)
1006 goto error1; 1006 goto failure;
1007 1007
1008 /* validate resources */ 1008 /* validate resources */
1009 error = -ENODEV; 1009 error = -ENODEV;
@@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1014 1014
1015 if (!pnp_port_valid(pnp_dev, 0) || 1015 if (!pnp_port_valid(pnp_dev, 0) ||
1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) 1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE)
1017 goto error; 1017 goto failure;
1018 1018
1019 if (!pnp_irq_valid(pnp_dev, 0)) 1019 if (!pnp_irq_valid(pnp_dev, 0))
1020 goto error; 1020 goto failure;
1021 1021
1022 spin_lock_init(&dev->hw_lock); 1022 spin_lock_init(&dev->hw_lock);
1023 1023
@@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1033 /* detect hardware version and features */ 1033 /* detect hardware version and features */
1034 error = ene_hw_detect(dev); 1034 error = ene_hw_detect(dev);
1035 if (error) 1035 if (error)
1036 goto error; 1036 goto failure;
1037 1037
1038 if (!dev->hw_learning_and_tx_capable && txsim) { 1038 if (!dev->hw_learning_and_tx_capable && txsim) {
1039 dev->hw_learning_and_tx_capable = true; 1039 dev->hw_learning_and_tx_capable = true;
@@ -1078,30 +1078,27 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1078 /* claim the resources */ 1078 /* claim the resources */
1079 error = -EBUSY; 1079 error = -EBUSY;
1080 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { 1080 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
1081 dev->hw_io = -1; 1081 goto failure;
1082 dev->irq = -1;
1083 goto error;
1084 } 1082 }
1085 1083
1086 dev->irq = pnp_irq(pnp_dev, 0); 1084 dev->irq = pnp_irq(pnp_dev, 0);
1087 if (request_irq(dev->irq, ene_isr, 1085 if (request_irq(dev->irq, ene_isr,
1088 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { 1086 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
1089 dev->irq = -1; 1087 goto failure2;
1090 goto error;
1091 } 1088 }
1092 1089
1093 error = rc_register_device(rdev); 1090 error = rc_register_device(rdev);
1094 if (error < 0) 1091 if (error < 0)
1095 goto error; 1092 goto failure3;
1096 1093
1097 pr_notice("driver has been successfully loaded\n"); 1094 pr_notice("driver has been successfully loaded\n");
1098 return 0; 1095 return 0;
1099error: 1096
1100 if (dev && dev->irq >= 0) 1097failure3:
1101 free_irq(dev->irq, dev); 1098 free_irq(dev->irq, dev);
1102 if (dev && dev->hw_io >= 0) 1099failure2:
1103 release_region(dev->hw_io, ENE_IO_SIZE); 1100 release_region(dev->hw_io, ENE_IO_SIZE);
1104error1: 1101failure:
1105 rc_free_device(rdev); 1102 rc_free_device(rdev);
1106 kfree(dev); 1103 kfree(dev);
1107 return error; 1104 return error;