Patchwork [2/5] dma: tegra: make byte counters unsigned int

login
register
mail settings
Submitter Ben Dooks
Date Nov. 21, 2018, 4:13 p.m.
Message ID <20181121161323.20226-3-ben.dooks@codethink.co.uk>
Download mbox | patch
Permalink /patch/661921/
State New
Headers show

Comments

Ben Dooks - Nov. 21, 2018, 4:13 p.m.
The buffer byte request length and counter are declared as signed integers
but the values should never be below zero, so make these unsigned integers
instead.

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/dma/tegra20-apb-dma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Jon Hunter - Nov. 22, 2018, 9:19 a.m.
On Wed, Nov 21, 2018 at 4:15 PM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> The buffer byte request length and counter are declared as signed integers
> but the values should never be below zero, so make these unsigned integers
> instead.
>
> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  drivers/dma/tegra20-apb-dma.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> index 8219ab88a507..adfd918baedc 100644
> --- a/drivers/dma/tegra20-apb-dma.c
> +++ b/drivers/dma/tegra20-apb-dma.c
> @@ -155,7 +155,7 @@ struct tegra_dma_channel_regs {
>   */
>  struct tegra_dma_sg_req {
>         struct tegra_dma_channel_regs   ch_regs;
> -       int                             req_len;
> +       unsigned int                    req_len;
>         bool                            configured;
>         bool                            last_sg;
>         struct list_head                node;
> @@ -169,8 +169,8 @@ struct tegra_dma_sg_req {
>   */
>  struct tegra_dma_desc {
>         struct dma_async_tx_descriptor  txd;
> -       int                             bytes_requested;
> -       int                             bytes_transferred;
> +       unsigned int                    bytes_requested;
> +       unsigned int                    bytes_transferred;
>         enum dma_status                 dma_status;
>         struct list_head                node;
>         struct list_head                tx_list;
> --
> 2.19.1
>

For some reason, I did not receive this one at work, so replying from
personal email ...

Anyway, for consistency with the DMA engine APIs, I wonder if we
should just use size_t here instead of unsigned int (although it
should be the same).

Cheers
Jon

Patch

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 8219ab88a507..adfd918baedc 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -155,7 +155,7 @@  struct tegra_dma_channel_regs {
  */
 struct tegra_dma_sg_req {
 	struct tegra_dma_channel_regs	ch_regs;
-	int				req_len;
+	unsigned int			req_len;
 	bool				configured;
 	bool				last_sg;
 	struct list_head		node;
@@ -169,8 +169,8 @@  struct tegra_dma_sg_req {
  */
 struct tegra_dma_desc {
 	struct dma_async_tx_descriptor	txd;
-	int				bytes_requested;
-	int				bytes_transferred;
+	unsigned int			bytes_requested;
+	unsigned int			bytes_transferred;
 	enum dma_status			dma_status;
 	struct list_head		node;
 	struct list_head		tx_list;