From patchwork Tue Mar 26 13:33:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 2336501 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2E2353FD40 for ; Tue, 26 Mar 2013 13:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934333Ab3CZNeo (ORCPT ); Tue, 26 Mar 2013 09:34:44 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:45932 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934241Ab3CZNen (ORCPT ); Tue, 26 Mar 2013 09:34:43 -0400 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2QDYg4q027066; Tue, 26 Mar 2013 08:34:42 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2QDYgst015485; Tue, 26 Mar 2013 08:34:42 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Tue, 26 Mar 2013 08:34:42 -0500 Received: from deskari.tieu.ti.com (h64-3.vpn.ti.com [172.24.64.3]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2QDYUc0025381; Tue, 26 Mar 2013 08:34:41 -0500 From: Tomi Valkeinen To: , , Archit Taneja CC: Tomi Valkeinen Subject: [PATCH 08/26] OMAPDSS: use the panel list in omap_dss_get_next_device Date: Tue, 26 Mar 2013 15:33:38 +0200 Message-ID: <1364304836-18134-9-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364304836-18134-1-git-send-email-tomi.valkeinen@ti.com> References: <1364304836-18134-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org omap_dss_get_next_device() uses the dss bus to iterate over the displays. This patch changes omap_dss_get_next_device() to use the new panel list instead. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/display.c | 63 +++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index e785694..50792bf 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c @@ -189,27 +189,51 @@ void omap_dss_put_device(struct omap_dss_device *dssdev) } EXPORT_SYMBOL(omap_dss_put_device); -/* ref count of the found device is incremented. ref count - * of from-device is decremented. */ +/* + * ref count of the found device is incremented. + * ref count of from-device is decremented. + */ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from) { - struct device *dev; - struct device *dev_start = NULL; - struct omap_dss_device *dssdev = NULL; + struct list_head *l; + struct omap_dss_device *dssdev; + + mutex_lock(&panel_list_mutex); + + if (list_empty(&panel_list)) { + dssdev = NULL; + goto out; + } - int match(struct device *dev, void *data) - { - return 1; + if (from == NULL) { + dssdev = list_first_entry(&panel_list, struct omap_dss_device, + panel_list); + omap_dss_get_device(dssdev); + goto out; } - if (from) - dev_start = &from->dev; - dev = bus_find_device(dss_get_bus(), dev_start, NULL, match); - if (dev) - dssdev = to_dss_device(dev); - if (from) - put_device(&from->dev); + omap_dss_put_device(from); + + list_for_each(l, &panel_list) { + dssdev = list_entry(l, struct omap_dss_device, panel_list); + if (dssdev == from) { + if (list_is_last(l, &panel_list)) { + dssdev = NULL; + goto out; + } + + dssdev = list_entry(l->next, struct omap_dss_device, + panel_list); + omap_dss_get_device(dssdev); + goto out; + } + } + + WARN(1, "'from' dssdev not found\n"); + dssdev = NULL; +out: + mutex_unlock(&panel_list_mutex); return dssdev; } EXPORT_SYMBOL(omap_dss_get_next_device); @@ -219,12 +243,17 @@ struct omap_dss_device *omap_dss_find_device(void *data, { struct omap_dss_device *dssdev = NULL; + mutex_lock(&panel_list_mutex); + while ((dssdev = omap_dss_get_next_device(dssdev)) != NULL) { if (match(dssdev, data)) - return dssdev; + goto out; } - return NULL; + dssdev = NULL; +out: + mutex_unlock(&panel_list_mutex); + return dssdev; } EXPORT_SYMBOL(omap_dss_find_device);