bcm27xx: switch to kernel v6.1
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0671-misc-bcm2835_smi-Use-proper-enum-types-for-dma_-un-m.patch
1 From db1007fae024ae65b6f8a28988ce9d87c7d92995 Mon Sep 17 00:00:00 2001
2 From: Nathan Chancellor <nathan@kernel.org>
3 Date: Mon, 31 Jan 2022 17:12:10 -0700
4 Subject: [PATCH] misc: bcm2835_smi: Use proper enum types for
5 dma_{,un}map_single()
6
7 Clang warns:
8
9 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]
10 DMA_MEM_TO_DEV);
11 ^~~~~~~~~~~~~~~
12 ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
13 #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
14 ~~~~~~~~~~~~~~~~~~~~ ^
15 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]
16 (inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV);
17 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
18 ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
19 #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
20 ~~~~~~~~~~~~~~~~~~~~~~ ^
21 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]
22 DMA_DEV_TO_MEM);
23 ^~~~~~~~~~~~~~~
24 ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
25 #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
26 ~~~~~~~~~~~~~~~~~~~~ ^
27 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]
28 dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM);
29 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
30 ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
31 #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
32 ~~~~~~~~~~~~~~~~~~~~~~ ^
33 4 warnings generated.
34
35 Use the proper enumerated type to clear up the warning. There is not
36 actually a bug here because the enumerated types have the same integer
37 value:
38
39 DMA_MEM_TO_DEV = DMA_TO_DEVICE = 1
40 DMA_DEV_TO_MEM = DMA_FROM_DEVICE = 2
41
42 Fixes: 93254d0f7bc8 ("Add SMI driver")
43 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
44 ---
45 drivers/misc/bcm2835_smi.c | 8 ++++----
46 1 file changed, 4 insertions(+), 4 deletions(-)
47
48 --- a/drivers/misc/bcm2835_smi.c
49 +++ b/drivers/misc/bcm2835_smi.c
50 @@ -689,7 +689,7 @@ void bcm2835_smi_write_buf(
51 inst->dev,
52 (void *)buf,
53 n_bytes,
54 - DMA_MEM_TO_DEV);
55 + DMA_TO_DEVICE);
56 struct scatterlist *sgl =
57 smi_scatterlist_from_buffer(inst, phy_addr, n_bytes,
58 &inst->buffer_sgl);
59 @@ -702,7 +702,7 @@ void bcm2835_smi_write_buf(
60 smi_dma_write_sgl(inst, sgl, 1, n_bytes);
61
62 dma_unmap_single
63 - (inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV);
64 + (inst->dev, phy_addr, n_bytes, DMA_TO_DEVICE);
65 } else if (n_bytes) {
66 smi_write_fifo(inst, (uint32_t *) buf, n_bytes);
67 }
68 @@ -748,7 +748,7 @@ void bcm2835_smi_read_buf(struct bcm2835
69 if (n_bytes > DMA_THRESHOLD_BYTES) {
70 dma_addr_t phy_addr = dma_map_single(inst->dev,
71 buf, n_bytes,
72 - DMA_DEV_TO_MEM);
73 + DMA_FROM_DEVICE);
74 struct scatterlist *sgl = smi_scatterlist_from_buffer(
75 inst, phy_addr, n_bytes,
76 &inst->buffer_sgl);
77 @@ -758,7 +758,7 @@ void bcm2835_smi_read_buf(struct bcm2835
78 goto out;
79 }
80 smi_dma_read_sgl(inst, sgl, 1, n_bytes);
81 - dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM);
82 + dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_FROM_DEVICE);
83 } else if (n_bytes) {
84 smi_read_fifo(inst, (uint32_t *)buf, n_bytes);
85 }