[1/3,media] coda: Call v4l2_device_unregister() from a single location

Message ID 1412451652-27220-1-git-send-email-festevam@gmail.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Fabio Estevam Oct. 4, 2014, 7:40 p.m. UTC
  From: Fabio Estevam <fabio.estevam@freescale.com>

Instead of calling v4l2_device_unregister() in multiple locations within the
error paths, let's call it from a single location to make the error handling
simpler.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/media/platform/coda/coda-common.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
  

Comments

Philipp Zabel Oct. 5, 2014, 7:32 a.m. UTC | #1
On Sat, Oct 04, 2014 at 04:40:50PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Instead of calling v4l2_device_unregister() in multiple locations within the
> error paths, let's call it from a single location to make the error handling
> simpler.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index ced4760..7cd82e8 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1926,8 +1926,8 @@  static int coda_probe(struct platform_device *pdev)
 	} else if (pdev_id) {
 		dev->devtype = &coda_devdata[pdev_id->driver_data];
 	} else {
-		v4l2_device_unregister(&dev->v4l2_dev);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_v4l2_register;
 	}
 
 	dev->debugfs_root = debugfs_create_dir("coda", NULL);
@@ -1941,8 +1941,7 @@  static int coda_probe(struct platform_device *pdev)
 					 dev->debugfs_root);
 		if (ret < 0) {
 			dev_err(&pdev->dev, "failed to allocate work buffer\n");
-			v4l2_device_unregister(&dev->v4l2_dev);
-			return ret;
+			goto err_v4l2_register;
 		}
 	}
 
@@ -1952,8 +1951,7 @@  static int coda_probe(struct platform_device *pdev)
 					 dev->debugfs_root);
 		if (ret < 0) {
 			dev_err(&pdev->dev, "failed to allocate temp buffer\n");
-			v4l2_device_unregister(&dev->v4l2_dev);
-			return ret;
+			goto err_v4l2_register;
 		}
 	}
 
@@ -1988,6 +1986,10 @@  static int coda_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	return coda_firmware_request(dev);
+
+err_v4l2_register:
+	v4l2_device_unregister(&dev->v4l2_dev);
+	return ret;
 }
 
 static int coda_remove(struct platform_device *pdev)