From patchwork Fri Dec 19 02:00:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5516931 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F10CBEEA8 for ; Fri, 19 Dec 2014 02:02:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B8D22011B for ; Fri, 19 Dec 2014 02:02:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A595720115 for ; Fri, 19 Dec 2014 02:02:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751860AbaLSCBq (ORCPT ); Thu, 18 Dec 2014 21:01:46 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:46968 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752099AbaLSCBN (ORCPT ); Thu, 18 Dec 2014 21:01:13 -0500 Received: by mail-pd0-f177.google.com with SMTP id ft15so159863pdb.8; Thu, 18 Dec 2014 18:01:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pcuP5TJTTe/qoCHfVBVU8W1YzdxjJxMU0Ye8YLfNllw=; b=dcWlgijpcBEH7kfdbXAgHYgirJ4l3EEt1chiS8FaR63CEkUXnurTm7ASCqMrn31+Wt HRGi4ALvxjNMJ8/YqU+XVPrDOEu0ri44jgg1+wNzQA60xzN0Rm2C3j5ee8lUrvdYU7Iz VhBV7bToIrUpXWqak7ax6nn2W/wleHVNMa0//0ltD4GRRk9EhGtDp5IG2El8nqKwAjre ptBNUcP9dVEC/qitELFn3LA+XDC+qaYsTJpgKp8i0JVPm43frVwcxNffu8wFIgQ0ajBV 7r9n1fdo4pZxLwC+HwR4hSMa6nOfGdpfuvisz9i2C0akeVZ8qbyNbXb7gC0vh/tDWdZ1 S8lw== X-Received: by 10.70.23.99 with SMTP id l3mr8421419pdf.86.1418954472925; Thu, 18 Dec 2014 18:01:12 -0800 (PST) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id pd9sm7959386pdb.35.2014.12.18.18.01.11 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Dec 2014 18:01:12 -0800 (PST) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, David Airlie , Philipp Zabel , Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Russell King , Fabio Estevam , Shawn Guo , Denis Carikli , Jiada Wang , Steve Longerbeam Subject: [PATCH v2 7/7] gpu: ipu-di: Switch to DIV_ROUND_CLOSEST for DI clock divider calc Date: Thu, 18 Dec 2014 18:00:26 -0800 Message-Id: <1418954426-21909-8-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418954426-21909-1-git-send-email-steve_longerbeam@mentor.com> References: <1418954426-21909-1-git-send-email-steve_longerbeam@mentor.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We can use the DIV_ROUND_CLOSEST() macro when calculating the DI clock divider, rounded to nearest int. Suggested-by: Philipp Zabel Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-di.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c index d95fbd0..b61d6be 100644 --- a/drivers/gpu/ipu-v3/ipu-di.c +++ b/drivers/gpu/ipu-v3/ipu-di.c @@ -440,8 +440,7 @@ static void ipu_di_config_clock(struct ipu_di *di, clk_set_rate(clk, sig->mode.pixelclock); in_rate = clk_get_rate(clk); - div = (in_rate + sig->mode.pixelclock / 2) / - sig->mode.pixelclock; + div = DIV_ROUND_CLOSEST(in_rate, sig->mode.pixelclock); if (div == 0) div = 1; @@ -459,8 +458,7 @@ static void ipu_di_config_clock(struct ipu_di *di, unsigned div, error; clkrate = clk_get_rate(di->clk_ipu); - div = (clkrate + sig->mode.pixelclock / 2) / - sig->mode.pixelclock; + div = DIV_ROUND_CLOSEST(clkrate, sig->mode.pixelclock); rate = clkrate / div; error = rate / (sig->mode.pixelclock / 1000); @@ -482,8 +480,7 @@ static void ipu_di_config_clock(struct ipu_di *di, clk_set_rate(clk, sig->mode.pixelclock); in_rate = clk_get_rate(clk); - div = (in_rate + sig->mode.pixelclock / 2) / - sig->mode.pixelclock; + div = DIV_ROUND_CLOSEST(in_rate, sig->mode.pixelclock); if (div == 0) div = 1;