diff mbox

[U-Boot,2/2] spi: mxc_spi: Use DIV_ROUND_UP at appropriate places

Message ID 1371215612.3888.2.camel@phoenix
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Axel Lin June 14, 2013, 1:13 p.m. UTC
This change slightly improves readability.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/mxc_spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jagan Teki June 14, 2013, 3:11 p.m. UTC | #1
On 14-06-2013 18:43, Axel Lin wrote:
> This change slightly improves readability.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>   drivers/spi/mxc_spi.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> 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(&regs->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;
>

Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>

--
Thanks,
Jagan.
Jagan Teki June 14, 2013, 5:05 p.m. UTC | #2
On 14-06-2013 20:41, Jagan Teki wrote:
> On 14-06-2013 18:43, Axel Lin wrote:
>> This change slightly improves readability.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>>   drivers/spi/mxc_spi.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> 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(&regs->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;
>>
>
> Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>

Applied to u-boot-spi/master

--
Thanks,
Jagan.
diff mbox

Patch

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(&regs->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;