From patchwork Fri Jun 14 07:59:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 251257 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 511FC2C008E for ; Fri, 14 Jun 2013 17:59:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 48FC44A103; Fri, 14 Jun 2013 09:59:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T1OPBqGfD78E; Fri, 14 Jun 2013 09:59:32 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8BEC44A0FD; Fri, 14 Jun 2013 09:59:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B24694A0FD for ; Fri, 14 Jun 2013 09:59:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f5KyLtE65pXY for ; Fri, 14 Jun 2013 09:59:16 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by theia.denx.de (Postfix) with ESMTPS id 321164A0FB for ; Fri, 14 Jun 2013 09:59:10 +0200 (CEST) Received: by mail-pa0-f46.google.com with SMTP id fa11so410834pad.33 for ; Fri, 14 Jun 2013 00:59:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :mime-version:content-transfer-encoding:x-gm-message-state; bh=PnIsCyvDlMjvEb8lS735OT05TCRROFhxg66WAcHGbXQ=; b=Xq85bG679FLFDeK+NXhOzL7D1kYydMg9DPsg3N/i0bGx6WIs5txRtlSSgUqYs4rjwG Y0MgLq6t+ZwqxDVKQ4G2jfrhOX84MJwfHBo+G0FDsHbNrYjTgvpXqlcBId+q5XzKttF3 esF5Sj4PBAPi3O//9QkluG4nLLPzvmzLoD1F5sa/eIByr7CqxL5w7mg/bCVjJ7F+Lggv R2TXKSWow8Asxrk+N8qHu3gefuIQBQ6lqLNfzTkOO2nvAELvl2aVJN4CzcTh2W6crbMX jbvK6HoHP0vIGFTXnHvrFTwyabZiZr4dMTHKw4blE3Vmube2muZpc7YHpBYOOJ3O0k1i QrJg== X-Received: by 10.66.160.101 with SMTP id xj5mr1374306pab.5.1371196747638; Fri, 14 Jun 2013 00:59:07 -0700 (PDT) Received: from [114.39.96.159] (114-39-96-159.dynamic.hinet.net. [114.39.96.159]) by mx.google.com with ESMTPSA id xu10sm1457188pab.3.2013.06.14.00.59.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Jun 2013 00:59:06 -0700 (PDT) Message-ID: <1371196742.20321.1.camel@phoenix> From: Axel Lin To: Jagannadha Sutradharudu Teki Date: Fri, 14 Jun 2013 15:59:02 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQmrvkuazEM1fheD+0nGBxbqUAxhegGyUdT9FyOwbt6CAE6WHeYq3ZuYLfL/d12fxguerOYN Cc: Fabio Estevam , Dirk Behme , u-boot@lists.denx.de Subject: [U-Boot] [PATCH] spi: Use DIV_ROUND_UP at appropriate places X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This change slightly improves readability. Signed-off-by: Axel Lin --- drivers/spi/cf_qspi.c | 2 +- drivers/spi/mxc_spi.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c index a37ac4e..06bcf91 100644 --- a/drivers/spi/cf_qspi.c +++ b/drivers/spi/cf_qspi.c @@ -171,7 +171,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, volatile qspi_t *qspi = dev->regs; u8 *txbuf = (u8 *)dout; u8 *rxbuf = (u8 *)din; - u32 count = ((bitlen / 8) + (bitlen % 8 ? 1 : 0)); + u32 count = DIV_ROUND_UP(bitlen, 8); u32 n, i = 0; /* Sanitize arguments */ diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index 5bed858..2ea3228 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -224,7 +224,7 @@ int spi_xchg_single(struct spi_slave *slave, unsigned int bitlen, const u8 *dout, u8 *din, unsigned long flags) { struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave); - int nbytes = (bitlen + 7) / 8; + int nbytes = DIV_ROUND_UP(bitlen, 8); u32 data, cnt, i; struct cspi_regs *regs = (struct cspi_regs *)mxcs->base; @@ -294,7 +294,7 @@ int spi_xchg_single(struct spi_slave *slave, unsigned int bitlen, /* Transfer completed, clear any pending request */ reg_write(®s->stat, MXC_CSPICTRL_TC | MXC_CSPICTRL_RXOVF); - nbytes = (bitlen + 7) / 8; + nbytes = DIV_ROUND_UP(bitlen, 8); cnt = nbytes % 32; @@ -330,7 +330,7 @@ int spi_xchg_single(struct spi_slave *slave, unsigned int bitlen, int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { - int n_bytes = (bitlen + 7) / 8; + int n_bytes = DIV_ROUND_UP(bitlen, 8); int n_bits; int ret; u32 blk_size;