Patchwork [U-Boot,3/3] spi: mpc8xxx_spi: Use DIV_ROUND_UP instead of open-coded

login
register
mail settings
Submitter Axel Lin
Date July 12, 2013, 9:42 a.m.
Message ID <1373622135.24016.5.camel@phoenix>
Download mbox | patch
Permalink /patch/258732/
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Comments

Axel Lin - July 12, 2013, 9:42 a.m.
Use DIV_ROUND_UP to simplify the code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/mpc8xxx_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Jagannadha Sutradharudu Teki - Aug. 6, 2013, 6:49 p.m.
On 12-07-2013 15:12, Axel Lin wrote:
> Use DIV_ROUND_UP to simplify the code.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>   drivers/spi/mpc8xxx_spi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c
> index 6b0e3b4..c90c0ce 100644
> --- a/drivers/spi/mpc8xxx_spi.c
> +++ b/drivers/spi/mpc8xxx_spi.c
> @@ -93,7 +93,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>   {
>   	volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
>   	unsigned int tmpdout, tmpdin, event;
> -	int numBlks = bitlen / 32 + (bitlen % 32 ? 1 : 0);
> +	int numBlks = DIV_ROUND_UP(bitlen, 32);
>   	int tm, isRead = 0;
>   	unsigned char charSize = 32;
>
>

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

--
Thanks,
Jagan.
Jagannadha Sutradharudu Teki - Aug. 6, 2013, 6:55 p.m.
On 07-08-2013 00:19, Jagan Teki wrote:
> On 12-07-2013 15:12, Axel Lin wrote:
>> Use DIV_ROUND_UP to simplify the code.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>>   drivers/spi/mpc8xxx_spi.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c
>> index 6b0e3b4..c90c0ce 100644
>> --- a/drivers/spi/mpc8xxx_spi.c
>> +++ b/drivers/spi/mpc8xxx_spi.c
>> @@ -93,7 +93,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int
>> bitlen, const void *dout,
>>   {
>>       volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
>>       unsigned int tmpdout, tmpdin, event;
>> -    int numBlks = bitlen / 32 + (bitlen % 32 ? 1 : 0);
>> +    int numBlks = DIV_ROUND_UP(bitlen, 32);
>>       int tm, isRead = 0;
>>       unsigned char charSize = 32;
>>
>>
>
> Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
>
> --
> Thanks,
> Jagan.

Applied to u-boot-spi/master

--
Thanks,
Jagan.

Patch

diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c
index 6b0e3b4..c90c0ce 100644
--- a/drivers/spi/mpc8xxx_spi.c
+++ b/drivers/spi/mpc8xxx_spi.c
@@ -93,7 +93,7 @@  int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 {
 	volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
 	unsigned int tmpdout, tmpdin, event;
-	int numBlks = bitlen / 32 + (bitlen % 32 ? 1 : 0);
+	int numBlks = DIV_ROUND_UP(bitlen, 32);
 	int tm, isRead = 0;
 	unsigned char charSize = 32;