From patchwork Mon Jul 27 11:47:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sifan Naeem X-Patchwork-Id: 500361 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 558F31402C9 for ; Mon, 27 Jul 2015 21:45:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751472AbbG0Lpa (ORCPT ); Mon, 27 Jul 2015 07:45:30 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:17968 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbbG0Lp3 (ORCPT ); Mon, 27 Jul 2015 07:45:29 -0400 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id E5FED30CF284F; Mon, 27 Jul 2015 12:45:24 +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; Mon, 27 Jul 2015 12:45:27 +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; Mon, 27 Jul 2015 12:45:27 +0100 From: Sifan Naeem To: Wolfram Sang , James Hogan , CC: Sifan Naeem , "Stable kernel (v3.19+)" Subject: [PATCH 3/8] i2c: img-scb: use DIV_ROUND_UP to round divisor values Date: Mon, 27 Jul 2015 12:47:16 +0100 Message-ID: <1437997641-32575-4-git-send-email-sifan.naeem@imgtec.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1437997641-32575-1-git-send-email-sifan.naeem@imgtec.com> References: <1437997641-32575-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: 27bce4 ("i2c: img-scb: Add Imagination Technologies I2C SCB driver") Signed-off-by: Sifan Naeem Cc: Stable kernel (v3.19+) Acked-by: James Hogan --- 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 0368d91..b4f59e1 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;