v4l: rcar-fcp: Don't get/put module reference
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 16 May 2017 23:20:03 +0000 (02:20 +0300)
committerKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Fri, 9 Jun 2017 11:25:36 +0000 (12:25 +0100)
Direct callers of the FCP API hold a reference to the FCP module due to
module linkage, there's no need to take another one manually. Take a
reference to the device instead to ensure that it won't disappear behind
the caller's back.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Acked-by: Mauro Cavalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/rcar-fcp.c

index 7146fc5ef168774a0f232ef70e46260df76e2826..e9f609edf513110dace35503eb5b9b2d917084bb 100644 (file)
@@ -53,14 +53,7 @@ struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np)
                if (fcp->dev->of_node != np)
                        continue;
 
-               /*
-                * Make sure the module won't be unloaded behind our back. This
-                * is a poor man's safety net, the module should really not be
-                * unloaded while FCP users can be active.
-                */
-               if (!try_module_get(fcp->dev->driver->owner))
-                       fcp = NULL;
-
+               get_device(fcp->dev);
                goto done;
        }
 
@@ -81,7 +74,7 @@ EXPORT_SYMBOL_GPL(rcar_fcp_get);
 void rcar_fcp_put(struct rcar_fcp_device *fcp)
 {
        if (fcp)
-               module_put(fcp->dev->driver->owner);
+               put_device(fcp->dev);
 }
 EXPORT_SYMBOL_GPL(rcar_fcp_put);