[media] rc: Make probe cleanup goto labels more verbose
authorMatthijs Kooijman <matthijs@stdin.nl>
Fri, 2 Nov 2012 12:13:54 +0000 (09:13 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 21 Dec 2012 20:26:08 +0000 (18:26 -0200)
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.

[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
 merge conflicts]

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/rc/ati_remote.c
drivers/media/rc/ene_ir.c
drivers/media/rc/fintek-cir.c
drivers/media/rc/ite-cir.c
drivers/media/rc/nuvoton-cir.c

index 2d6fb26a017094a1fa23828b7ce5c546a2cdad80..4d6a63fe6c5e210f878b132c6f6ea386e185fa66 100644 (file)
@@ -872,11 +872,11 @@ static int ati_remote_probe(struct usb_interface *interface,
        ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
        rc_dev = rc_allocate_device();
        if (!ati_remote || !rc_dev)
-               goto fail1;
+               goto exit_free_dev_rdev;
 
        /* Allocate URB buffers, URBs */
        if (ati_remote_alloc_buffers(udev, ati_remote))
-               goto fail2;
+               goto exit_free_buffers;
 
        ati_remote->endpoint_in = endpoint_in;
        ati_remote->endpoint_out = endpoint_out;
@@ -924,12 +924,12 @@ static int ati_remote_probe(struct usb_interface *interface,
        /* Device Hardware Initialization - fills in ati_remote->idev from udev. */
        err = ati_remote_initialize(ati_remote);
        if (err)
-               goto fail3;
+               goto exit_kill_urbs;
 
        /* Set up and register rc device */
        err = rc_register_device(ati_remote->rdev);
        if (err)
-               goto fail3;
+               goto exit_kill_urbs;
 
        /* use our delay for rc_dev */
        ati_remote->rdev->input_dev->rep[REP_DELAY] = repeat_delay;
@@ -939,7 +939,7 @@ static int ati_remote_probe(struct usb_interface *interface,
                input_dev = input_allocate_device();
                if (!input_dev) {
                        err = -ENOMEM;
-                       goto fail4;
+                       goto exit_unregister_device;
                }
 
                ati_remote->idev = input_dev;
@@ -947,19 +947,24 @@ static int ati_remote_probe(struct usb_interface *interface,
                err = input_register_device(input_dev);
 
                if (err)
-                       goto fail5;
+                       goto exit_free_input_device;
        }
 
        usb_set_intfdata(interface, ati_remote);
        return 0;
 
- fail5:        input_free_device(input_dev);
- fail4:        rc_unregister_device(rc_dev);
+ exit_free_input_device:
+       input_free_device(input_dev);
+ exit_unregister_device:
+       rc_unregister_device(rc_dev);
        rc_dev = NULL;
- fail3:        usb_kill_urb(ati_remote->irq_urb);
+ exit_kill_urbs:
+       usb_kill_urb(ati_remote->irq_urb);
        usb_kill_urb(ati_remote->out_urb);
- fail2:        ati_remote_free_buffers(ati_remote);
- fail1:        rc_free_device(rc_dev);
+ exit_free_buffers:
+       ati_remote_free_buffers(ati_remote);
+ exit_free_dev_rdev:
+        rc_free_device(rc_dev);
        kfree(ati_remote);
        return err;
 }
index 22231dd4f62b9432039bc41fdf954c86d60415b0..f7fdfea49ab1c55a09e15ad1b1a1c0be006e70b9 100644 (file)
@@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
        dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
        rdev = rc_allocate_device();
        if (!dev || !rdev)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        /* validate resources */
        error = -ENODEV;
@@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
 
        if (!pnp_port_valid(pnp_dev, 0) ||
            pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        if (!pnp_irq_valid(pnp_dev, 0))
-               goto failure;
+               goto exit_free_dev_rdev;
 
        spin_lock_init(&dev->hw_lock);
 
@@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
        /* detect hardware version and features */
        error = ene_hw_detect(dev);
        if (error)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        if (!dev->hw_learning_and_tx_capable && txsim) {
                dev->hw_learning_and_tx_capable = true;
@@ -1078,27 +1078,27 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
        /* claim the resources */
        error = -EBUSY;
        if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        dev->irq = pnp_irq(pnp_dev, 0);
        if (request_irq(dev->irq, ene_isr,
                        IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
-               goto failure2;
+               goto exit_release_hw_io;
        }
 
        error = rc_register_device(rdev);
        if (error < 0)
-               goto failure3;
+               goto exit_free_irq;
 
        pr_notice("driver has been successfully loaded\n");
        return 0;
 
-failure3:
+exit_free_irq:
        free_irq(dev->irq, dev);
-failure2:
+exit_release_hw_io:
        release_region(dev->hw_io, ENE_IO_SIZE);
-failure:
+exit_free_dev_rdev:
        rc_free_device(rdev);
        kfree(dev);
        return error;
index 936c3f79b62cba500b8e53ba4adffb899bfda007..3d5e57cacf3157d3a7dc03d78c3ad0983ba9d38d 100644 (file)
@@ -500,18 +500,18 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
        /* input device for IR remote (and tx) */
        rdev = rc_allocate_device();
        if (!rdev)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        ret = -ENODEV;
        /* validate pnp resources */
        if (!pnp_port_valid(pdev, 0)) {
                dev_err(&pdev->dev, "IR PNP Port not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        if (!pnp_irq_valid(pdev, 0)) {
                dev_err(&pdev->dev, "IR PNP IRQ not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        fintek->cir_addr = pnp_port_start(pdev, 0);
@@ -528,7 +528,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
 
        ret = fintek_hw_detect(fintek);
        if (ret)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        /* Initialize CIR & CIR Wake Logical Devices */
        fintek_config_mode_enable(fintek);
@@ -561,15 +561,15 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
        /* now claim resources */
        if (!request_region(fintek->cir_addr,
                            fintek->cir_port_len, FINTEK_DRIVER_NAME))
-               goto failure;
+               goto exit_free_dev_rdev;
 
        if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED,
                        FINTEK_DRIVER_NAME, (void *)fintek))
-               goto failure2;
+               goto exit_free_cir_addr;
 
        ret = rc_register_device(rdev);
        if (ret)
-               goto failure3;
+               goto exit_free_irq;
 
        device_init_wakeup(&pdev->dev, true);
        fintek->rdev = rdev;
@@ -579,11 +579,11 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
 
        return 0;
 
-failure3:
+exit_free_irq:
        free_irq(fintek->cir_irq, fintek);
-failure2:
+exit_free_cir_addr:
        release_region(fintek->cir_addr, fintek->cir_port_len);
-failure:
+exit_free_dev_rdev:
        rc_free_device(rdev);
        kfree(fintek);
 
index 5e5a7f2b8184cc992fab2bf0e3e90cb09c65c154..8e0e661b5ef929db9fc461e713f9a3bbbd2d0f0f 100644 (file)
@@ -1472,7 +1472,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
        /* input device for IR remote (and tx) */
        rdev = rc_allocate_device();
        if (!rdev)
-               goto failure;
+               goto exit_free_dev_rdev;
        itdev->rdev = rdev;
 
        ret = -ENODEV;
@@ -1498,12 +1498,12 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
        if (!pnp_port_valid(pdev, io_rsrc_no) ||
            pnp_port_len(pdev, io_rsrc_no) != dev_desc->io_region_size) {
                dev_err(&pdev->dev, "IR PNP Port not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        if (!pnp_irq_valid(pdev, 0)) {
                dev_err(&pdev->dev, "PNP IRQ not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        /* store resource values */
@@ -1595,25 +1595,25 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
        /* now claim resources */
        if (!request_region(itdev->cir_addr,
                                dev_desc->io_region_size, ITE_DRIVER_NAME))
-               goto failure;
+               goto exit_free_dev_rdev;
 
        if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED,
                        ITE_DRIVER_NAME, (void *)itdev))
-               goto failure2;
+               goto exit_release_cir_addr;
 
        ret = rc_register_device(rdev);
        if (ret)
-               goto failure3;
+               goto exit_free_irq;
 
        ite_pr(KERN_NOTICE, "driver has been successfully loaded\n");
 
        return 0;
 
-failure3:
+exit_free_irq:
        free_irq(itdev->cir_irq, itdev);
-failure2:
+exit_release_cir_addr:
        release_region(itdev->cir_addr, itdev->params.io_region_size);
-failure:
+exit_free_dev_rdev:
        rc_free_device(rdev);
        kfree(itdev);
 
index e4ea89a11eed451efd967b36a41a4fbbf5a7edf0..3477e231c1822f6a396782811da1157cb286dd4e 100644 (file)
@@ -986,25 +986,25 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
        /* input device for IR remote (and tx) */
        rdev = rc_allocate_device();
        if (!rdev)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        ret = -ENODEV;
        /* validate pnp resources */
        if (!pnp_port_valid(pdev, 0) ||
            pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) {
                dev_err(&pdev->dev, "IR PNP Port not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        if (!pnp_irq_valid(pdev, 0)) {
                dev_err(&pdev->dev, "PNP IRQ not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        if (!pnp_port_valid(pdev, 1) ||
            pnp_port_len(pdev, 1) < CIR_IOREG_LENGTH) {
                dev_err(&pdev->dev, "Wake PNP Port not valid!\n");
-               goto failure;
+               goto exit_free_dev_rdev;
        }
 
        nvt->cir_addr = pnp_port_start(pdev, 0);
@@ -1027,7 +1027,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
 
        ret = nvt_hw_detect(nvt);
        if (ret)
-               goto failure;
+               goto exit_free_dev_rdev;
 
        /* Initialize CIR & CIR Wake Logical Devices */
        nvt_efm_enable(nvt);
@@ -1070,23 +1070,23 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
        /* now claim resources */
        if (!request_region(nvt->cir_addr,
                            CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
-               goto failure;
+               goto exit_free_dev_rdev;
 
        if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED,
                        NVT_DRIVER_NAME, (void *)nvt))
-               goto failure2;
+               goto exit_release_cir_addr;
 
        if (!request_region(nvt->cir_wake_addr,
                            CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
-               goto failure3;
+               goto exit_free_irq;
 
        if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED,
                        NVT_DRIVER_NAME, (void *)nvt))
-               goto failure4;
+               goto exit_release_cir_wake_addr;
 
        ret = rc_register_device(rdev);
        if (ret)
-               goto failure5;
+               goto exit_free_wake_irq;
 
        device_init_wakeup(&pdev->dev, true);
        nvt->rdev = rdev;
@@ -1098,15 +1098,15 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
 
        return 0;
 
-failure5:
+exit_free_wake_irq:
        free_irq(nvt->cir_wake_irq, nvt);
-failure4:
+exit_release_cir_wake_addr:
        release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
-failure3:
+exit_free_irq:
        free_irq(nvt->cir_irq, nvt);
-failure2:
+exit_release_cir_addr:
        release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
-failure:
+exit_free_dev_rdev:
        rc_free_device(rdev);
        kfree(nvt);