From patchwork Thu May 30 09:34:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 2634751 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 17D9BDF2A1 for ; Thu, 30 May 2013 09:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030387Ab3E3JgK (ORCPT ); Thu, 30 May 2013 05:36:10 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:49843 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030375Ab3E3JgA (ORCPT ); Thu, 30 May 2013 05:36:00 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4U9a0dN003383; Thu, 30 May 2013 04:36:00 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4U9a08d005809; Thu, 30 May 2013 04:36:00 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Thu, 30 May 2013 04:35:59 -0500 Received: from deskari.tieu.ti.com (h64-9.vpn.ti.com [172.24.64.9]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4U9ZJ23002669; Thu, 30 May 2013 04:35:59 -0500 From: Tomi Valkeinen To: , , Archit Taneja CC: Tomi Valkeinen Subject: [PATCH 29/32] OMAPDSS: add module_get/put to omap_dss_get/put_device() Date: Thu, 30 May 2013 12:34:50 +0300 Message-ID: <1369906493-27538-30-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1369906493-27538-1-git-send-email-tomi.valkeinen@ti.com> References: <1369906493-27538-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 --- drivers/video/omap2/dss/display.c | 13 +++++++++++-- include/video/omapdss.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index 8096764..0daf3e3 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c @@ -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); diff --git a/include/video/omapdss.h b/include/video/omapdss.h index c32d90e..b2e6160 100644 --- a/include/video/omapdss.h +++ b/include/video/omapdss.h @@ -766,7 +766,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);