From patchwork Tue Jun 16 10:16:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 6617051 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 82FFC9F972 for ; Tue, 16 Jun 2015 10:17:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8DB8F205C6 for ; Tue, 16 Jun 2015 10:17:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E39F207AF for ; Tue, 16 Jun 2015 10:17:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932902AbbFPKRN (ORCPT ); Tue, 16 Jun 2015 06:17:13 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:34965 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932881AbbFPKRK (ORCPT ); Tue, 16 Jun 2015 06:17:10 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t5GAGjXZ010000; Tue, 16 Jun 2015 05:16:45 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5GAGjji005961; Tue, 16 Jun 2015 05:16:45 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Tue, 16 Jun 2015 05:16:44 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5GAGVrf016197; Tue, 16 Jun 2015 05:16:43 -0500 From: Tomi Valkeinen To: Laurent Pinchart , , , CC: Tomi Valkeinen Subject: [PATCH 7/7] OMAPDSS: simplify submodule reg/unreg code Date: Tue, 16 Jun 2015 13:16:29 +0300 Message-ID: <1434449789-13812-8-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434449789-13812-1-git-send-email-tomi.valkeinen@ti.com> References: <1434449789-13812-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 X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we are using components in omapdss, there's no need for separate handling of dss and dispc driver init. Thus we can move the dss and dispc init and unit func pointers to the lists we use for the other dss submodules. We can now also handle errors returned by the registration functions properly: if registering a driver fails, we can stop processing and return the error. Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/omap2/dss/core.c | 46 ++++++++++++------------------------ 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/drivers/video/fbdev/omap2/dss/core.c b/drivers/video/fbdev/omap2/dss/core.c index 5c64515de818..54eeb507f9b3 100644 --- a/drivers/video/fbdev/omap2/dss/core.c +++ b/drivers/video/fbdev/omap2/dss/core.c @@ -245,6 +245,8 @@ static struct platform_driver omap_dss_driver = { /* INIT */ static int (*dss_output_drv_reg_funcs[])(void) __initdata = { + dss_init_platform_driver, + dispc_init_platform_driver, #ifdef CONFIG_OMAP2_DSS_DSI dsi_init_platform_driver, #endif @@ -268,7 +270,7 @@ static int (*dss_output_drv_reg_funcs[])(void) __initdata = { #endif }; -static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = { +static void (*dss_output_drv_unreg_funcs[])(void) = { #ifdef CONFIG_OMAP5_DSS_HDMI hdmi5_uninit_platform_driver, #endif @@ -290,10 +292,10 @@ static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = { #ifdef CONFIG_OMAP2_DSS_DSI dsi_uninit_platform_driver, #endif + dispc_uninit_platform_driver, + dss_uninit_platform_driver, }; -static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)]; - static int __init omap_dss_init(void) { int r; @@ -303,33 +305,20 @@ static int __init omap_dss_init(void) if (r) return r; - r = dss_init_platform_driver(); - if (r) { - DSSERR("Failed to initialize DSS platform driver\n"); - goto err_dss; - } - - r = dispc_init_platform_driver(); - if (r) { - DSSERR("Failed to initialize dispc platform driver\n"); - goto err_dispc; - } - - /* - * It's ok if the output-driver register fails. It happens, for example, - * when there is no output-device (e.g. SDI for OMAP4). - */ for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) { r = dss_output_drv_reg_funcs[i](); - if (r == 0) - dss_output_drv_loaded[i] = true; + if (r) + goto err_reg; } return 0; -err_dispc: - dss_uninit_platform_driver(); -err_dss: +err_reg: + for (i = ARRAY_SIZE(dss_output_drv_reg_funcs) - i; + i < ARRAY_SIZE(dss_output_drv_reg_funcs); + ++i) + dss_output_drv_unreg_funcs[i](); + platform_driver_unregister(&omap_dss_driver); return r; @@ -339,13 +328,8 @@ static void __exit omap_dss_exit(void) { int i; - for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) { - if (dss_output_drv_loaded[i]) - dss_output_drv_unreg_funcs[i](); - } - - dispc_uninit_platform_driver(); - dss_uninit_platform_driver(); + for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) + dss_output_drv_unreg_funcs[i](); platform_driver_unregister(&omap_dss_driver); }