From patchwork Fri Aug 14 15:50:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sifan Naeem X-Patchwork-Id: 507473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3877B140293 for ; Sat, 15 Aug 2015 01:47:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755225AbbHNPry (ORCPT ); Fri, 14 Aug 2015 11:47:54 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:47411 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755324AbbHNPrx (ORCPT ); Fri, 14 Aug 2015 11:47:53 -0400 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id BACB42A56050F; Fri, 14 Aug 2015 16:47:49 +0100 (IST) Received: from hhmail02.hh.imgtec.org (10.100.10.20) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 14 Aug 2015 16:47:52 +0100 Received: from iw-build-3.kl.imgtec.org (192.168.167.63) by hhmail02.hh.imgtec.org (10.100.10.20) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 14 Aug 2015 16:47:51 +0100 From: Sifan Naeem To: Wolfram Sang , James Hogan , , Ezequiel Garcia CC: Ionela Voinescu , Sifan Naeem Subject: [PATCH v2 3/7] i2c: img-scb: use DIV_ROUND_UP to round divisor values Date: Fri, 14 Aug 2015 16:50:20 +0100 Message-ID: <1439567424-8094-4-git-send-email-sifan.naeem@imgtec.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1439567424-8094-1-git-send-email-sifan.naeem@imgtec.com> References: <1439567424-8094-1-git-send-email-sifan.naeem@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.167.63] Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Using % can be slow depending on the architecture. Using DIV_ROUND_UP is nicer and more efficient way to do it. Fixes: commit 27bce457d588 ("i2c: img-scb: Add Imagination Technologies I2C SCB driver") Signed-off-by: Sifan Naeem Acked-by: James Hogan Reviewed-by: James Hartley --- drivers/i2c/busses/i2c-img-scb.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c index 0368d91b6805..b4f59e1a5cac 100644 --- a/drivers/i2c/busses/i2c-img-scb.c +++ b/drivers/i2c/busses/i2c-img-scb.c @@ -1179,9 +1179,7 @@ static int img_i2c_init(struct img_i2c *i2c) int_bitrate++; /* Setup TCKH value */ - tckh = timing.tckh / clk_period; - if (timing.tckh % clk_period) - tckh++; + tckh = DIV_ROUND_UP(timing.tckh, clk_period); if (tckh > 0) data = tckh - 1; @@ -1201,9 +1199,7 @@ static int img_i2c_init(struct img_i2c *i2c) img_i2c_writel(i2c, SCB_TIME_TCKL_REG, data); /* Setup TSDH value */ - tsdh = timing.tsdh / clk_period; - if (timing.tsdh % clk_period) - tsdh++; + tsdh = DIV_ROUND_UP(timing.tsdh, clk_period); if (tsdh > 1) data = tsdh - 1;