OMAPDSS: add module_get/put to omap_dss_get/put_device()
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 3 May 2013 08:40:54 +0000 (11:40 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 17 Jun 2013 11:00:52 +0000 (14:00 +0300)
omap_dss_get_device() should be called for omap_dss_device before it is
used to increase its refcount. Currently we only increase the refcount
for the underlying device.

This patch adds managing the ref count to the underlying module also,
which contains the ops for the omap_dss_device.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/omap2/dss/display.c
include/video/omapdss.h

index 809676473a99e308349d09622b6b94909054cad9..0daf3e37d5979037812bb6497c6e23a467b2e484 100644 (file)
@@ -158,15 +158,24 @@ void omapdss_unregister_display(struct omap_dss_device *dssdev)
 }
 EXPORT_SYMBOL(omapdss_unregister_display);
 
-void omap_dss_get_device(struct omap_dss_device *dssdev)
+struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
 {
-       get_device(dssdev->dev);
+       if (!try_module_get(dssdev->owner))
+               return NULL;
+
+       if (get_device(dssdev->dev) == NULL) {
+               module_put(dssdev->owner);
+               return NULL;
+       }
+
+       return dssdev;
 }
 EXPORT_SYMBOL(omap_dss_get_device);
 
 void omap_dss_put_device(struct omap_dss_device *dssdev)
 {
        put_device(dssdev->dev);
+       module_put(dssdev->owner);
 }
 EXPORT_SYMBOL(omap_dss_put_device);
 
index d667a4a78a4936c69e04a72389299635d29abc58..80d7eb6358ae546dc0defb54a81b7323960d556f 100644 (file)
@@ -767,7 +767,7 @@ void omap_dss_unregister_driver(struct omap_dss_driver *);
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
 
-void omap_dss_get_device(struct omap_dss_device *dssdev);
+struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
 #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);