From patchwork Mon Mar 13 18:26:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arushi X-Patchwork-Id: 9621737 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 A9E4D60244 for ; Mon, 13 Mar 2017 18:27:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0D30277D9 for ; Mon, 13 Mar 2017 18:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9599727F89; Mon, 13 Mar 2017 18:27:01 +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 1902D277D9 for ; Mon, 13 Mar 2017 18:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752113AbdCMS1A (ORCPT ); Mon, 13 Mar 2017 14:27:00 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36840 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751248AbdCMS1A (ORCPT ); Mon, 13 Mar 2017 14:27:00 -0400 Received: by mail-pg0-f66.google.com with SMTP id 25so18911085pgy.3; Mon, 13 Mar 2017 11:26:59 -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=+jShk7lcZDW/NfjfRq6hm8EapEn8CnHjlizwgI2tuwc=; b=lRmw0nx7clrFx1oDG1aGdQx3cDi0BT6OyTHMdcHf71PL3/xRxO1J/2FMxeImyCIN5I +AJGtRIAgJAjhherwM3aLSn44+zc7trt/5ezjxeVLkNNmElY+kujmo9it6wxk/8X46uc viBQOrK/Y/rEauQE2KR+CpSsgvcjs7MVll6aVCzqZ/wthMzSq5l8QlRUljXN+k9n6Lan 5qCRyWuN82EslxJ4W4qeydSutfPblmrgjFFxyCamBSY500rXhmtYL1+vN0YGRoKaAXsW O8CJ94cFJ5djYEOXwmmMnV4aUk/noW/aHpjtrmKQu5gSHd/kg6ntH2R3HJrlaVSsyhQF BOCg== 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=+jShk7lcZDW/NfjfRq6hm8EapEn8CnHjlizwgI2tuwc=; b=RKOboOGvsdH3F76FIegHM3Np9VZw0cUoc3Fq1tphfRuKS5VhhLYEqogZ5zpQuDrLlF 3XXKJKO2EQWasSMXrAs87+MOGBpLvXa3FLdwbOZV39lHE1yHb4sGg1BcAKG/c6s1QyhZ 9aLam6UD4oCkwWVwManP3KShUfqFtTg8s63jFEjT0wAXJkN4BGpqq1YVyKayTgscNQwx rrG0KeXwuxnZjFBGrot4bQY3ibG6pIthj5lXth3SgrmtwoAm3v6zjFGxcbCbd6/uct2x mxKWwg0nmt4SxYrZvcADPfC1omPuGPIvcENTKEzCQjn/FRkid5REH7K+WPGW/FzyyS7O Ut/Q== X-Gm-Message-State: AMke39mOC6fxpIwFtRyzER6wWT8Xx4CLhImAAMdnoTFwhHL+PJWHFDAeOOiqCiMDlovodQ== X-Received: by 10.84.210.167 with SMTP id a36mr50149586pli.40.1489429618540; Mon, 13 Mar 2017 11:26:58 -0700 (PDT) Received: from arushi-HP-Pavilion-Notebook ([14.139.82.6]) by smtp.gmail.com with ESMTPSA id w20sm5442307pgc.18.2017.03.13.11.26.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Mar 2017 11:26:57 -0700 (PDT) Date: Mon, 13 Mar 2017 23:56:53 +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 v2] staging: sm750fb: Improved code readability Message-ID: <20170313182652.GA19882@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 v2 - removed the error. drivers/staging/sm750fb/ddk750_mode.c | 103 ++++++++++++++++------------------ 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 25da678179f7..6dd52b450367 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -77,37 +77,34 @@ static int programModeRegisters(struct _mode_parameter_t *pModeParam, struct pll int ret = 0; int cnt = 0; unsigned int tmp, reg; + unsigned int cht = CRT_HORIZONTAL_TOTAL; + unsigned int cvt = CRT_VERTICAL_TOTAL; + unsigned int chs = CRT_HORIZONTAL_SYNC; + unsigned int cvs = CRT_VERTICAL_SYNC; + unsigned int chssm = CRT_HORIZONTAL_SYNC_START_MASK; + unsigned int cvssm = CRT_VERTICAL_SYNC_START_MASK; + unsigned int chtdem = CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK; + unsigned int cvtdem = CRT_VERTICAL_TOTAL_DISPLAY_END_MASK; + unsigned int chttm = CRT_HORIZONTAL_TOTAL_TOTAL_MASK; + unsigned int cvttm = CRT_VERTICAL_TOTAL_TOTAL_MASK; + unsigned int chswm = CRT_HORIZONTAL_SYNC_WIDTH_MASK; + unsigned int cvshm = CRT_VERTICAL_SYNC_HEIGHT_MASK; + unsigned int phde = pModeParam->horizontal_display_end - 1; + unsigned int pvde = pModeParam->vertical_display_end - 1; + unsigned int phss = pModeParam->horizontal_sync_start - 1; + unsigned int pvss = pModeParam->vertical_sync_start - 1; 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)); + + poke32(cht, (((pModeParam->horizontal_total - 1) << CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) & chttm) | (phde & chtdem)); + + poke32(chs, ((pModeParam->horizontal_sync_width << CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) & chswm) | (phss & chssm)); + + poke32(cvt, (((pModeParam->vertical_total - 1) << CRT_VERTICAL_TOTAL_TOTAL_SHIFT) & cvttm) | (pvde & cvtdem)); + + poke32(cvs, ((pModeParam->vertical_sync_height << CRT_VERTICAL_SYNC_HEIGHT_SHIFT) & cvshm) | (pvss & cvssm)); tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE; if (pModeParam->vertical_sync_polarity) @@ -128,36 +125,34 @@ static int programModeRegisters(struct _mode_parameter_t *pModeParam, struct pll } else if (pll->clockType == PRIMARY_PLL) { unsigned int reserved; + unsigned int pht = PANEL_HORIZONTAL_TOTAL; + unsigned int pvt = PANEL_VERTICAL_TOTAL; + unsigned int phs = PANEL_HORIZONTAL_SYNC; + unsigned int pvs = PANEL_VERTICAL_SYNC; + unsigned int phssm = PANEL_HORIZONTAL_SYNC_START_MASK; + unsigned int pvssm = PANEL_VERTICAL_SYNC_START_MASK; + unsigned int phtdem = PANEL_HORIZONTAL_TOTAL_DISPLAY_END_MASK; + unsigned int pvtdem = PANEL_VERTICAL_TOTAL_DISPLAY_END_MASK; + unsigned int phttm = PANEL_HORIZONTAL_TOTAL_TOTAL_MASK; + unsigned int pvttm = PANEL_VERTICAL_TOTAL_TOTAL_MASK; + unsigned int phswm = PANEL_HORIZONTAL_SYNC_WIDTH_MASK; + unsigned int pvshm = PANEL_VERTICAL_SYNC_HEIGHT_MASK; + unsigned int phde = pModeParam->horizontal_display_end - 1; + unsigned int pvde = pModeParam->vertical_display_end - 1; + unsigned int phss = pModeParam->horizontal_sync_start - 1; + unsigned int pvss = pModeParam->vertical_sync_start - 1; poke32(PANEL_PLL_CTRL, sm750_format_pll_reg(pll)); - reg = ((pModeParam->horizontal_total - 1) << - PANEL_HORIZONTAL_TOTAL_TOTAL_SHIFT) & - PANEL_HORIZONTAL_TOTAL_TOTAL_MASK; - reg |= ((pModeParam->horizontal_display_end - 1) & - PANEL_HORIZONTAL_TOTAL_DISPLAY_END_MASK); - poke32(PANEL_HORIZONTAL_TOTAL, reg); - - poke32(PANEL_HORIZONTAL_SYNC, - ((pModeParam->horizontal_sync_width << - PANEL_HORIZONTAL_SYNC_WIDTH_SHIFT) & - PANEL_HORIZONTAL_SYNC_WIDTH_MASK) | - ((pModeParam->horizontal_sync_start - 1) & - PANEL_HORIZONTAL_SYNC_START_MASK)); - - poke32(PANEL_VERTICAL_TOTAL, - (((pModeParam->vertical_total - 1) << - PANEL_VERTICAL_TOTAL_TOTAL_SHIFT) & - PANEL_VERTICAL_TOTAL_TOTAL_MASK) | - ((pModeParam->vertical_display_end - 1) & - PANEL_VERTICAL_TOTAL_DISPLAY_END_MASK)); - - poke32(PANEL_VERTICAL_SYNC, - ((pModeParam->vertical_sync_height << - PANEL_VERTICAL_SYNC_HEIGHT_SHIFT) & - PANEL_VERTICAL_SYNC_HEIGHT_MASK) | - ((pModeParam->vertical_sync_start - 1) & - PANEL_VERTICAL_SYNC_START_MASK)); + reg = ((pModeParam->horizontal_total - 1) << PANEL_HORIZONTAL_TOTAL_TOTAL_SHIFT) & phttm; + reg |= (phde & phtdem); + poke32(pht, reg); + + poke32(phs, ((pModeParam->horizontal_sync_width << PANEL_HORIZONTAL_SYNC_WIDTH_SHIFT) & phswm) | (phss & phssm)); + + poke32(pvt, (((pModeParam->vertical_total - 1) << PANEL_VERTICAL_TOTAL_TOTAL_SHIFT) & pvttm) | (pvde & pvtdem)); + + poke32(pvs, ((pModeParam->vertical_sync_height << PANEL_VERTICAL_SYNC_HEIGHT_SHIFT) & pvshm) | (pvss & pvssm)); tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE; if (pModeParam->vertical_sync_polarity)