From patchwork Sun Mar 19 13:07:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arushi X-Patchwork-Id: 9632545 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 8F87A601E9 for ; Sun, 19 Mar 2017 13:07:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 763A428490 for ; Sun, 19 Mar 2017 13:07:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59A87284A3; Sun, 19 Mar 2017 13:07:53 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 E7D8528490 for ; Sun, 19 Mar 2017 13:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647AbdCSNHv (ORCPT ); Sun, 19 Mar 2017 09:07:51 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36785 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdCSNHu (ORCPT ); Sun, 19 Mar 2017 09:07:50 -0400 Received: by mail-pg0-f67.google.com with SMTP id 81so7908245pgh.3; Sun, 19 Mar 2017 06:07:49 -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 :user-agent; bh=CXrI0Uj+HcrOiy9ZX3Phyn49A679Hg5LyKl0lBQvu7I=; b=OM5gIa9f2r7JSryWo/un5JuPLY0LOYrVWxszA7O5vCsyehgnaGlBlGWyArhaNzYEdh cZznTvbGD/r8Hd3mLYZyf/42DqZ1fOv/UOj/jPnewG/dP96DBrYWJZw70fhA40Shrv+j rupvzmCiIv+r2YTadxhXRiE+Xc8U0ePVfDO9qS0GVQ/8hM4R4LnypobnjtWHnLNCn7AV boLkDzm3RzQoLthD25PoGuS9WtL6KbUVx6nT96Y6fK6qo12MWm863U06a+R6mQsg861i swMlYaOG2DCkJIsI52oo3UvMn2JFn2+NYC19Vt8+w1oWJfPc65J1KHVrSqO09QmctZ+c 5kDQ== 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:user-agent; bh=CXrI0Uj+HcrOiy9ZX3Phyn49A679Hg5LyKl0lBQvu7I=; b=RPZwJoHCgLVPWPBG4YA+/0nmZg8aujIRLgfo5NdBGkzsRmNrZgwjCxvPmfy0Rgfixm 8RvFbuTaFXm9oxNKsxdRTZji/LkhsGwxYI7nxkcL2X8qjzInpEnJPGAK277H6IY6OMPY a1+HGZgSyEpUh6cMckmQ1OOjS2EdutLxlE6jmp+nnIHc8ozrnqis30GmqKDqP3xp8jQQ C8g1Aue3y4LEuBdVBi9j1bRmodw362w3whZLgttCV5ABIu4tCB1Se/I37Z+r1NukFeua DeAr5C1FbAtoXWRnIxpCmmMn8D4/mbGaaNPqYxQAhnDXvu5hck9UnEw1M4+YECsvSW9s 07/Q== X-Gm-Message-State: AFeK/H2eXS9SznXr02ArltnG9tg3T3N5GRwvbxZTqkf7Zp0lGYkzs0yRZqmxVjnWuK6Fow== X-Received: by 10.84.231.193 with SMTP id g1mr20615145pln.1.1489928869150; Sun, 19 Mar 2017 06:07:49 -0700 (PDT) Received: from arushi-HP-Pavilion-Notebook ([14.139.82.6]) by smtp.gmail.com with ESMTPSA id v186sm27406363pgv.44.2017.03.19.06.07.46 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Mar 2017 06:07:47 -0700 (PDT) Date: Sun, 19 Mar 2017 18:37:44 +0530 From: Arushi Singhal To: sudipm.mukherjee@gmail.com Cc: Teddy Wang , Greg Kroah-Hartman , linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com Subject: [PATCH v3] staging: sm750fb: Code readability is improved Message-ID: <20170319130744.GA24605@arushi-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 New variables are added to make the code more readable. Signed-off-by: Arushi Singhal --- changes in v3 -try to make the code much more readable. drivers/staging/sm750fb/ddk750_mode.c | 61 ++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index eea5aef2956f..5f18ce4d10de 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value * if (pll->clockType == SECONDARY_PLL) { /* programe secondary pixel clock */ poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll)); - poke32(CRT_HORIZONTAL_TOTAL, - (((pModeParam->horizontal_total - 1) << - CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) & - CRT_HORIZONTAL_TOTAL_TOTAL_MASK) | - ((pModeParam->horizontal_display_end - 1) & - CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK)); - - poke32(CRT_HORIZONTAL_SYNC, - ((pModeParam->horizontal_sync_width << - CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) & - CRT_HORIZONTAL_SYNC_WIDTH_MASK) | - ((pModeParam->horizontal_sync_start - 1) & - CRT_HORIZONTAL_SYNC_START_MASK)); - poke32(CRT_VERTICAL_TOTAL, - (((pModeParam->vertical_total - 1) << - CRT_VERTICAL_TOTAL_TOTAL_SHIFT) & - CRT_VERTICAL_TOTAL_TOTAL_MASK) | - ((pModeParam->vertical_display_end - 1) & - CRT_VERTICAL_TOTAL_DISPLAY_END_MASK)); - - poke32(CRT_VERTICAL_SYNC, - ((pModeParam->vertical_sync_height << - CRT_VERTICAL_SYNC_HEIGHT_SHIFT) & - CRT_VERTICAL_SYNC_HEIGHT_MASK) | - ((pModeParam->vertical_sync_start - 1) & - CRT_VERTICAL_SYNC_START_MASK)); + unsigned int a = (pModeParam->horizontal_total - 1) << + CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT; + unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK; + unsigned int c = (pModeParam->horizontal_display_end - 1) & + CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK; + unsigned int temp = b | c; + + poke32(CRT_HORIZONTAL_TOTAL, temp); + + unsigned int a = (pModeParam->horizontal_sync_width << + CRT_HORIZONTAL_SYNC_WIDTH_SHIFT); + unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK; + unsigned int c = (pModeParam->horizontal_sync_start - 1) & + CRT_HORIZONTAL_SYNC_START_MASK; + unsigned int temp = b | c; + + poke32(CRT_HORIZONTAL_SYNC, temp); + + unsigned int a = (pModeParam->vertical_total - 1) << + CRT_VERTICAL_TOTAL_TOTAL_SHIFT; + unsigned int b = a & CRT_VERTICAL_TOTAL_TOTAL_MASK; + unsigned int c = (pModeParam->vertical_display_end - 1) & + CRT_VERTICAL_TOTAL_DISPLAY_END_MASK; + unsigned int temp = b | c; + + poke32(CRT_VERTICAL_TOTAL, temp); + + unsigned int a = pModeParam->vertical_sync_height << + CRT_VERTICAL_SYNC_HEIGHT_SHIFT; + unsigned int b = a & CRT_VERTICAL_SYNC_HEIGHT_MASK; + unsigned int c = (pModeParam->vertical_sync_start - 1) & + CRT_VERTICAL_SYNC_START_MASK; + unsigned int temp = b | c; + + poke32(CRT_VERTICAL_SYNC, temp); tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE; if (pModeParam->vertical_sync_polarity)