From patchwork Sun Jul 2 14:27:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynn Lei X-Patchwork-Id: 9821167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F1B66035F for ; Sun, 2 Jul 2017 14:27:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33B1F26E39 for ; Sun, 2 Jul 2017 14:27:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 130E728294; Sun, 2 Jul 2017 14:27:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9668F26E39 for ; Sun, 2 Jul 2017 14:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751760AbdGBO1u (ORCPT ); Sun, 2 Jul 2017 10:27:50 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34412 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751759AbdGBO1t (ORCPT ); Sun, 2 Jul 2017 10:27:49 -0400 Received: by mail-pg0-f65.google.com with SMTP id j186so20435658pge.1; Sun, 02 Jul 2017 07:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=uTysITOEI2HpC0MOIwLB1lN3NkR9vCzn2/4geifkHZM=; b=XOnz0XZDY1q8b+YzRENBPrXZQzzN9ZFnLruP7rT4wCtFwlsTQSU2K8Ocu6ZKq/QIux ZekJJ8XylO3SagzjyZXJKFXqHaYPL2qO/ZVlRXr9hUnw295nMplhRg8YcamXaeADrsZE DKdywnHwG308QbmxNvsysbAPSpJ0ygoaU3ADlOb+UqVuAs56bTtFX5Y7mJxHLJS/aJRz VcziYjJawKQMCMy86ig6bzw2cxdHm6ykhTBvtGOeoxpBKWCfqWA1Uj/h1JJRwgrXF6hp qDmH8vfJul+0GoVu08NM1gPkFzneORWno6qti2ZdV/qfrSlzz3ovMXd0xFUAXViDlN4T kiLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=uTysITOEI2HpC0MOIwLB1lN3NkR9vCzn2/4geifkHZM=; b=p2yJ130+CaUqdP5eyqGF3Jia4ov8a7tbZtmN81iwHGHXg6Z3jGWurSzUJ7S5MZYU8q X5tPOon1YSmV1EmvjnZqdpYNcCt/+GM3tUO99t1W4QaEv50MFin6VagwiKcP/0gAxpad Mj8R/Jb4G/dmkVVCcgYgLi3gMP5IYYVGlCoxFz3LirsGarbGPYxgED5YvrwNumdjMGUi /+FSx9QDSWzJXT4Jta8gQqEhyi2qFGbXukZQtihNviooaM3fBqJ1acuegZTHlxgMHOYA ZPvPwMPLWZ+I8K/gdTWHuYX6MPaEgLoUgqgNsO2J7OdqJ6CXDFMgzdy5M30GMO8oXRQs Hy+A== X-Gm-Message-State: AIVw111Lix+cVF+Cu8VKJQX+/GOS9+7JaIUauul5bTdjDNLA5S4J7Agj ZxEkKmkbCt1ZTA== X-Received: by 10.98.65.76 with SMTP id o73mr5267470pfa.88.1499005668472; Sun, 02 Jul 2017 07:27:48 -0700 (PDT) Received: from lynnl.wit ([112.64.217.90]) by smtp.gmail.com with ESMTPSA id g79sm29403487pfg.121.2017.07.02.07.27.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Jul 2017 07:27:47 -0700 (PDT) Date: Sun, 2 Jul 2017 22:27:40 +0800 From: Lynn Lei To: sudipm.mukherjee@gmail.com Cc: teddy.wang@siliconmotion.com, gregkh@linuxfoundation.org, linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: sm750fb: refactor method and fix potential type inconsistence Message-ID: <20170702142335.GA9915@lynnl.wit> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP make reg variable typed `u32' not `unsigned int' this can fix potential type inconsistence in some platforms refactor swPanelPowerSequence() make the code less redundant a early check for disp to skip unnecessary delay Signed-off-by: Lynn Lei --- drivers/staging/sm750fb/ddk750_display.c | 36 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_display.c b/drivers/staging/sm750fb/ddk750_display.c index 9b116ed6ecc7..0f666dc2729a 100644 --- a/drivers/staging/sm750fb/ddk750_display.c +++ b/drivers/staging/sm750fb/ddk750_display.c @@ -86,28 +86,24 @@ static void primary_wait_vertical_sync(int delay) static void swPanelPowerSequence(int disp, int delay) { - unsigned int reg; + u32 reg; + u32 opt[] = { + PANEL_DISPLAY_CTRL_FPEN, PANEL_DISPLAY_CTRL_DATA, + PANEL_DISPLAY_CTRL_VBIASEN, PANEL_DISPLAY_CTRL_FPEN, + }; + u32 size, i; + + if (disp == 0) + return; + + size = sizeof(opt) / sizeof(u32); /* disp should be 1 to open sequence */ - reg = peek32(PANEL_DISPLAY_CTRL); - reg |= (disp ? PANEL_DISPLAY_CTRL_FPEN : 0); - poke32(PANEL_DISPLAY_CTRL, reg); - primary_wait_vertical_sync(delay); - - reg = peek32(PANEL_DISPLAY_CTRL); - reg |= (disp ? PANEL_DISPLAY_CTRL_DATA : 0); - poke32(PANEL_DISPLAY_CTRL, reg); - primary_wait_vertical_sync(delay); - - reg = peek32(PANEL_DISPLAY_CTRL); - reg |= (disp ? PANEL_DISPLAY_CTRL_VBIASEN : 0); - poke32(PANEL_DISPLAY_CTRL, reg); - primary_wait_vertical_sync(delay); - - reg = peek32(PANEL_DISPLAY_CTRL); - reg |= (disp ? PANEL_DISPLAY_CTRL_FPEN : 0); - poke32(PANEL_DISPLAY_CTRL, reg); - primary_wait_vertical_sync(delay); + for (i = 0; i < size; i++) { + reg = peek32(PANEL_DISPLAY_CTRL) | opt[i]; + poke32(PANEL_DISPLAY_CTRL, reg); + primary_wait_vertical_sync(delay); + } } void ddk750_setLogicalDispOut(disp_output_t output)