aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.15/950-0671-misc-bcm2835_smi-Use-proper-enum-types-for-dma_-un-m.patch
blob: ff669aab38adc97b4565bb55e3ef0bcb5c7bd8dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From db1007fae024ae65b6f8a28988ce9d87c7d92995 Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <nathan@kernel.org>
Date: Mon, 31 Jan 2022 17:12:10 -0700
Subject: [PATCH] misc: bcm2835_smi: Use proper enum types for
 dma_{,un}map_single()

Clang warns:

  drivers/misc/bcm2835_smi.c:692:4: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                          DMA_MEM_TO_DEV);
                          ^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
  #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
                                     ~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:705:35: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                          (inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
  #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
                                       ~~~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:751:12: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                                                       DMA_DEV_TO_MEM);
                                                       ^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
  #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
                                     ~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:761:50: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                  dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM);
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
  #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
                                       ~~~~~~~~~~~~~~~~~~~~~~          ^
  4 warnings generated.

Use the proper enumerated type to clear up the warning. There is not
actually a bug here because the enumerated types have the same integer
value:

DMA_MEM_TO_DEV = DMA_TO_DEVICE = 1
DMA_DEV_TO_MEM = DMA_FROM_DEVICE = 2

Fixes: 93254d0f7bc8 ("Add SMI driver")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/misc/bcm2835_smi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/misc/bcm2835_smi.c
+++ b/drivers/misc/bcm2835_smi.c
@@ -689,7 +689,7 @@ void bcm2835_smi_write_buf(
 			inst->dev,
 			(void *)buf,
 			n_bytes,
-			DMA_MEM_TO_DEV);
+			DMA_TO_DEVICE);
 		struct scatterlist *sgl =
 			smi_scatterlist_from_buffer(inst, phy_addr, n_bytes,
 				&inst->buffer_sgl);
@@ -702,7 +702,7 @@ void bcm2835_smi_write_buf(
 		smi_dma_write_sgl(inst, sgl, 1, n_bytes);
 
 		dma_unmap_single
-			(inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV);
+			(inst->dev, phy_addr, n_bytes, DMA_TO_DEVICE);
 	} else if (n_bytes) {
 		smi_write_fifo(inst, (uint32_t *) buf, n_bytes);
 	}
@@ -748,7 +748,7 @@ void bcm2835_smi_read_buf(struct bcm2835
 	if (n_bytes > DMA_THRESHOLD_BYTES) {
 		dma_addr_t phy_addr = dma_map_single(inst->dev,
 						     buf, n_bytes,
-						     DMA_DEV_TO_MEM);
+						     DMA_FROM_DEVICE);
 		struct scatterlist *sgl = smi_scatterlist_from_buffer(
 			inst, phy_addr, n_bytes,
 			&inst->buffer_sgl);
@@ -758,7 +758,7 @@ void bcm2835_smi_read_buf(struct bcm2835
 			goto out;
 		}
 		smi_dma_read_sgl(inst, sgl, 1, n_bytes);
-		dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM);
+		dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_FROM_DEVICE);
 	} else if (n_bytes) {
 		smi_read_fifo(inst, (uint32_t *)buf, n_bytes);
 	}