linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lynn Lei <lynnl.wit@gmail.com>
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
Date: Sun, 02 Jul 2017 14:27:40 +0000	[thread overview]
Message-ID: <20170702142335.GA9915@lynnl.wit> (raw)

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 <lynnl.wit@gmail.com>
---
 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)
-- 
2.13.2


             reply	other threads:[~2017-07-02 14:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-02 14:27 Lynn Lei [this message]
2017-07-03  6:22 ` [PATCH] staging: sm750fb: refactor method and fix potential type inconsistence Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170702142335.GA9915@lynnl.wit \
    --to=lynnl.wit@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=teddy.wang@siliconmotion.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).