diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2023-01-27 02:21:57 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-02-08 09:06:27 +0100 |
commit | 2c117550d70578b0b9eb183807b0984c11ecb44b (patch) | |
tree | fe93b26233ca4b6ac1d927ff9ff75677dda24645 /drivers/media | |
parent | 49a82584b87c385b267f4ca12674f08bd229ab57 (diff) | |
download | linux-stable-2c117550d70578b0b9eb183807b0984c11ecb44b.tar.gz linux-stable-2c117550d70578b0b9eb183807b0984c11ecb44b.tar.bz2 linux-stable-2c117550d70578b0b9eb183807b0984c11ecb44b.zip |
media: imx: imx7-media-csi: Cleanup errors in imx7_csi_async_register()
It's good practice for functions to perform error cleanup internally
when they fail, in order to not leave the device in a half-initialized
state. Move the async notifier cleanup from the probe error path to the
imx7_csi_async_register(), and drop the v4l2_async_nf_unregister() call
as there is no error path after the async notifier gets registered.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Adam Ford <aford173@gmail.com> #imx8mm-beacon-kit
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/nxp/imx7-media-csi.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 1adf5c3392d9..733e44700ff9 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -2177,7 +2177,7 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ret = PTR_ERR(asd); /* OK if asd already exists */ if (ret != -EEXIST) - return ret; + goto error; } } @@ -2185,9 +2185,13 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ret = v4l2_async_nf_register(&csi->v4l2_dev, &csi->notifier); if (ret) - return ret; + goto error; return 0; + +error: + v4l2_async_nf_cleanup(&csi->notifier); + return ret; } static void imx7_csi_media_cleanup(struct imx7_csi *csi) @@ -2329,13 +2333,10 @@ static int imx7_csi_probe(struct platform_device *pdev) ret = imx7_csi_async_register(csi); if (ret) - goto subdev_notifier_cleanup; + goto media_cleanup; return 0; -subdev_notifier_cleanup: - v4l2_async_nf_unregister(&csi->notifier); - v4l2_async_nf_cleanup(&csi->notifier); media_cleanup: imx7_csi_media_cleanup(csi); |