Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1608844 > unrolled thread
| Started by | Bin Liu <b-liu@ti.com> |
|---|---|
| First post | 2017-03-24 19:30 +0100 |
| Last post | 2017-03-27 17:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() Bin Liu <b-liu@ti.com> - 2017-03-24 19:30 +0100
[PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() Ivan Safonov <insafonov@gmail.com> - 2017-03-25 08:00 +0100
Re: [PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() Bin Liu <b-liu@ti.com> - 2017-03-27 17:50 +0200
| From | Bin Liu <b-liu@ti.com> |
|---|---|
| Date | 2017-03-24 19:30 +0100 |
| Subject | Re: [PATCH] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() |
| Message-ID | <toC8k-5sk-67@gated-at.bofh.it> |
On Wed, Feb 15, 2017 at 11:12:36AM +0300, Ivan Safonov wrote:
> DIV_ROUND_UP is bit useful than series of "/" and "%" operations.
> Replace "/%" sequence with DIV_ROUND_UP macro.
>
> Signed-off-by: Ivan Safonov <insafonov@gmail.com>
> ---
> drivers/usb/musb/cppi_dma.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
> index 1ae48e6..d376188 100644
> --- a/drivers/usb/musb/cppi_dma.c
> +++ b/drivers/usb/musb/cppi_dma.c
> @@ -582,9 +582,9 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
> maxpacket = length;
> n_bds = 1;
> } else {
> - n_bds = length / maxpacket;
> - if (!length || (length % maxpacket))
> - n_bds++;
> + n_bds = DIV_ROUND_UP(length, maxpacket);
> + if (length == 0)
> + n_bds = 1;
Is it a little better logically if
+ if (length)
+ n_bds = DIV_ROUND_UP(length, maxpacket);
+ else
+ n_bds = 1;
or
+ n_bds = length ? DIV_ROUND_UP(length, maxpacket) : 1;
Regards,
-Bin.
[toc] | [next] | [standalone]
| From | Ivan Safonov <insafonov@gmail.com> |
|---|---|
| Date | 2017-03-25 08:00 +0100 |
| Subject | [PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() |
| Message-ID | <toNQ5-5sZ-1@gated-at.bofh.it> |
| In reply to | #1608844 |
DIV_ROUND_UP is bit useful than series of "/" and "%" operations.
Replace "/%" sequence with DIV_ROUND_UP macro.
Signed-off-by: Ivan Safonov <insafonov@gmail.com>
---
Changes in v2:
- little style fix
drivers/usb/musb/cppi_dma.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index c4fabe95..a13bd36 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -582,9 +582,10 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
maxpacket = length;
n_bds = 1;
} else {
- n_bds = length / maxpacket;
- if (!length || (length % maxpacket))
- n_bds++;
+ if (length)
+ n_bds = DIV_ROUND_UP(length, maxpacket);
+ else
+ n_bds = 1;
n_bds = min(n_bds, (unsigned) NUM_TXCHAN_BD);
length = min(n_bds * maxpacket, length);
}
@@ -790,9 +791,7 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
n_bds = 0xffff / maxpacket;
length = n_bds * maxpacket;
} else {
- n_bds = length / maxpacket;
- if (length % maxpacket)
- n_bds++;
+ n_bds = DIV_ROUND_UP(length, maxpacket);
}
if (n_bds == 1)
onepacket = 1;
--
2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Bin Liu <b-liu@ti.com> |
|---|---|
| Date | 2017-03-27 17:50 +0200 |
| Subject | Re: [PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() |
| Message-ID | <tpF45-1SO-5@gated-at.bofh.it> |
| In reply to | #1609110 |
On Sat, Mar 25, 2017 at 12:52:58PM +0300, Ivan Safonov wrote:
> DIV_ROUND_UP is bit useful than series of "/" and "%" operations.
> Replace "/%" sequence with DIV_ROUND_UP macro.
>
> Signed-off-by: Ivan Safonov <insafonov@gmail.com>
Applied. Thanks.
-Bin.
> ---
> Changes in v2:
> - little style fix
>
> drivers/usb/musb/cppi_dma.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
> index c4fabe95..a13bd36 100644
> --- a/drivers/usb/musb/cppi_dma.c
> +++ b/drivers/usb/musb/cppi_dma.c
> @@ -582,9 +582,10 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
> maxpacket = length;
> n_bds = 1;
> } else {
> - n_bds = length / maxpacket;
> - if (!length || (length % maxpacket))
> - n_bds++;
> + if (length)
> + n_bds = DIV_ROUND_UP(length, maxpacket);
> + else
> + n_bds = 1;
> n_bds = min(n_bds, (unsigned) NUM_TXCHAN_BD);
> length = min(n_bds * maxpacket, length);
> }
> @@ -790,9 +791,7 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
> n_bds = 0xffff / maxpacket;
> length = n_bds * maxpacket;
> } else {
> - n_bds = length / maxpacket;
> - if (length % maxpacket)
> - n_bds++;
> + n_bds = DIV_ROUND_UP(length, maxpacket);
> }
> if (n_bds == 1)
> onepacket = 1;
> --
> 2.10.2
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web