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: 5517031 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 31EA99F54F for ; Fri, 19 Dec 2014 02:11:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 709722011E for ; Fri, 19 Dec 2014 02:11:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 38F892013D for ; Fri, 19 Dec 2014 02:11:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 804296EACC; Thu, 18 Dec 2014 18:11:18 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by gabe.freedesktop.org (Postfix) with ESMTP id 308A96EACC for ; Thu, 18 Dec 2014 18:01:13 -0800 (PST) Received: by mail-pa0-f50.google.com with SMTP id bj1so151248pad.23 for ; 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 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> X-Mailman-Approved-At: Thu, 18 Dec 2014 18:11:13 -0800 Cc: Fabio Estevam , Steve Longerbeam , Denis Carikli , Russell King X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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;