From patchwork Sun Mar 12 02:34:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arushi X-Patchwork-Id: 9619209 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 7F3E2602C2 for ; Sun, 12 Mar 2017 02:34:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70CA628518 for ; Sun, 12 Mar 2017 02:34:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62E72285B6; Sun, 12 Mar 2017 02:34:10 +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 CE06C28518 for ; Sun, 12 Mar 2017 02:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755547AbdCLCeJ (ORCPT ); Sat, 11 Mar 2017 21:34:09 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33897 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755500AbdCLCeI (ORCPT ); Sat, 11 Mar 2017 21:34:08 -0500 Received: by mail-pf0-f194.google.com with SMTP id o126so15167719pfb.1; Sat, 11 Mar 2017 18:34:07 -0800 (PST) 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=kfQIIaa/liRaeYYeROMS9C5Cb5EcWcHOVolL0T5JMns=; b=fL3sjkX8PYSaw8cbEcQ4dYJct0lBKWKqjpRkBzE+e6Jpzw+9kxMMFjY6YnpXv3uG2y Ma44YuVd6+4pXUgzmo3v5zVilT2t+3e611w3A/hNcvtuGzE1LJtuWwGqvHUVV4bO+RDk Wd0xo1iiGKCjdaTw8mlYunQZ09htz2jJvFEH/pBeWwewwPNspJwLwv4iL+RV2K1ojvMS JNFFuyonrcujYzsHQ8445oJIeQfPZEGmRwhh2TMpK03Cr1j6n7NNl4ivIgSCZAWrCBLC tflFTw5tUeiBhvBcUzCQr25ZqEqi3WI6Z0YANJNihXDUPv2rMqzvbB2bZ4O67cBYUSCI zCLA== 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=kfQIIaa/liRaeYYeROMS9C5Cb5EcWcHOVolL0T5JMns=; b=oPn0gZF5CnhHGAH9ZW7Nin/JxHlm0HVyFAKIF80T7nq5RbbZaPq+7T6rOVTwpqHPfw 4NKKa90sLv9AiRC1aVdbVmhzVb9yPAtEh7Nw2k23I2quLdras5oTPflgW2s9zO5fk0F0 YRxn78HrT9ELzMV9zjVuP2kDIjAsLVUw9SIP0FDQy6wziU0tfSJPSXrN1s88YafndZRo 2NYYIsUA8bQaZEJHc9fofBsIzViCwqIABXu7RbaIh2McYZS3BNkIxZXJ/XaGk5sx39Y3 hjcU1nydqMXSmSCfoV9s5V/fJja0mLfGlK/s7bdom0shYe7WrMe4JbcakWDFszQqbcGo EiBw== X-Gm-Message-State: AMke39lymDrMBUH5qseFX/zPgcoLBn9+um9GbD637I0agJ/Ez8YUzvEmJCq3Ya0oMjFweQ== X-Received: by 10.99.109.138 with SMTP id i132mr28745934pgc.11.1489286047360; Sat, 11 Mar 2017 18:34:07 -0800 (PST) Received: from arushi-HP-Pavilion-Notebook ([14.139.82.6]) by smtp.gmail.com with ESMTPSA id d2sm26429229pgf.35.2017.03.11.18.34.04 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 11 Mar 2017 18:34:05 -0800 (PST) Date: Sun, 12 Mar 2017 08:04:02 +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] staging: sm750fb: Improved coding style Message-ID: <20170312023402.GA10352@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. Also fixed the checkpatch issue: "Alignment should match open parenthesis". Signed-off-by: Arushi Singhal --- drivers/staging/sm750fb/ddk750_mode.c | 112 ++++++++++++++++------------------ 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 45af806c8d55..7fd3c3f20c01 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -28,9 +28,9 @@ static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, poke32(CRT_AUTO_CENTERING_TL, 0); poke32(CRT_AUTO_CENTERING_BR, - (((y - 1) << CRT_AUTO_CENTERING_BR_BOTTOM_SHIFT) & - CRT_AUTO_CENTERING_BR_BOTTOM_MASK) | - ((x - 1) & CRT_AUTO_CENTERING_BR_RIGHT_MASK)); + (((y - 1) << CRT_AUTO_CENTERING_BR_BOTTOM_SHIFT) & + CRT_AUTO_CENTERING_BR_BOTTOM_MASK) | + ((x - 1) & CRT_AUTO_CENTERING_BR_RIGHT_MASK)); /* * Assume common fields in dispControl have been properly set before @@ -72,43 +72,39 @@ static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, } /* only timing related registers will be programed */ -static int programModeRegisters(mode_parameter_t *pModeParam, - struct pll_value *pll) +static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *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) @@ -129,36 +125,34 @@ static int programModeRegisters(mode_parameter_t *pModeParam, } 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 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)