Patchwork [U-Boot,1/2] spi: cf_qspi: Use DIV_ROUND_UP at appropriate place

login
register
mail settings
Submitter Axel Lin
Date June 14, 2013, 1:12 p.m.
Message ID <1371215539.3888.1.camel@phoenix>
Download mbox | patch
Permalink /patch/251425/
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Comments

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

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/cf_qspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Richard Retanubun - June 14, 2013, 1:15 p.m.
On 14/06/13 09:12 AM, Axel Lin wrote:
> This change slightly improves readability.
>
> Signed-off-by: Axel Lin<axel.lin@ingics.com>
> ---
>   drivers/spi/cf_qspi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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 */
ACK. Thanks for the cleanup.

Signed-off-by: Richard Retanubun<richardretanubun@ruggedcom.com>
Jagannadha Sutradharudu Teki - June 14, 2013, 3:10 p.m.
On 14-06-2013 18:45, Richard Retanubun wrote:
> On 14/06/13 09:12 AM, Axel Lin wrote:
>> This change slightly improves readability.
>>
>> Signed-off-by: Axel Lin<axel.lin@ingics.com>
>> ---
>>   drivers/spi/cf_qspi.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> 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 */
> ACK. Thanks for the cleanup.
>
> Signed-off-by: Richard Retanubun<richardretanubun@ruggedcom.com>

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

--
Thanks,
Jagan.
Jagannadha Sutradharudu Teki - June 14, 2013, 5:05 p.m.
On 14-06-2013 20:40, Jagan Teki wrote:
> On 14-06-2013 18:45, Richard Retanubun wrote:
>> On 14/06/13 09:12 AM, Axel Lin wrote:
>>> This change slightly improves readability.
>>>
>>> Signed-off-by: Axel Lin<axel.lin@ingics.com>
>>> ---
>>>   drivers/spi/cf_qspi.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> 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 */
>> ACK. Thanks for the cleanup.
>>
>> Signed-off-by: Richard Retanubun<richardretanubun@ruggedcom.com>
>
> Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>

Applied to u-boot-spi/master

--
Thanks,
Jagan.

Patch

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 */