8e71918cf3f828610676010467577ea4d5faa0f8
[openwrt/staging/hauke.git] / package / kernel / mwlwifi / patches / 001-Fix-compilation-warning-with-64-bit-system.patch
1 From ed4422e98ababf956674da3438ac42b3aa32c66e Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Wed, 10 May 2023 00:41:06 +0200
4 Subject: [PATCH] Fix compilation warning with 64 bit system
5
6 Use %zu and %zd where possible for ssize_t and size_t.
7 Use PTR_ERR to correctly convert to negative error.
8 Use universal pointer to support both 32 and 64bit systems.
9
10 Fix compilation warning:
11 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/fwcmd.c: In function 'mwl_fwcmd_get_fw_core_dump':
12 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/fwcmd.c:3608:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
13 3608 | (const void *)((u32)pcmd +
14 | ^
15 In file included from ./include/linux/device.h:15,
16 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/device.h:3,
17 from ./include/linux/dma-mapping.h:7,
18 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/dma-mapping.h:3,
19 from ./include/linux/skbuff.h:31,
20 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/skbuff.h:3,
21 from ./include/linux/if_ether.h:19,
22 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/if_ether.h:3,
23 from ./include/linux/etherdevice.h:20,
24 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/etherdevice.h:3,
25 from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:20:
26 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c: In function 'pcie_tx_init_ndp':
27 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:38: error: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Werror=format=]
28 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
29 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 ./include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
31 110 | _p_func(dev, fmt, ##__VA_ARGS__); \
32 | ^~~
33 ./include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
34 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
35 | ^~~~~~~
36 /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err'
37 8828 | dev_err(&(wiphy)->dev, format, ##args)
38 | ^~~~~~~
39 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:17: note: in expansion of macro 'wiphy_err'
40 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
41 | ^~~~~~~~~
42 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:67: note: format string is defined here
43 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
44 | ~^
45 | |
46 | int
47 | %ld
48 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:38: error: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Werror=format=]
49 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
50 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51 ./include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
52 110 | _p_func(dev, fmt, ##__VA_ARGS__); \
53 | ^~~
54 ./include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
55 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
56 | ^~~~~~~
57 /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err'
58 8828 | dev_err(&(wiphy)->dev, format, ##args)
59 | ^~~~~~~
60 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:17: note: in expansion of macro 'wiphy_err'
61 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
62 | ^~~~~~~~~
63 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:71: note: format string is defined here
64 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
65 | ~^
66 | |
67 | int
68 | %ld
69 CC [M] /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.o
70 In file included from ./include/linux/device.h:15,
71 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/device.h:3,
72 from ./include/linux/dma-mapping.h:7,
73 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/dma-mapping.h:3,
74 from ./include/linux/skbuff.h:31,
75 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/skbuff.h:3,
76 from ./include/linux/if_ether.h:19,
77 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/if_ether.h:3,
78 from ./include/linux/etherdevice.h:20,
79 from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/etherdevice.h:3,
80 from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:19:
81 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c: In function 'pcie_bf_mimo_ctrl_decode':
82 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:1325:37: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
83 1325 | filename, (unsigned int)fp_data);
84 | ^
85 ./include/linux/dev_printk.h:110:37: note: in definition of macro 'dev_printk_index_wrap'
86 110 | _p_func(dev, fmt, ##__VA_ARGS__); \
87 | ^~~~~~~~~~~
88 /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err'
89 8828 | dev_err(&(wiphy)->dev, format, ##args)
90 | ^~~~~~~
91 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:1324:17: note: in expansion of macro 'wiphy_err'
92 1324 | wiphy_err(priv->hw->wiphy, "Error opening %s! %x\n",
93 | ^~~~~~~~~
94 cc1: all warnings being treated as errors
95 make[4]: *** [scripts/Makefile.build:289: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.o] Error 1
96 make[4]: *** Waiting for unfinished jobs....
97 cc1: all warnings being treated as errors
98 make[4]: *** [scripts/Makefile.build:289: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.o] Error 1
99 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.c: In function 'mwl_debugfs_regrdwr_read':
100 /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.c:1335:43: error: format '%d' expects argument of type 'int', but argument 4 has type 'ssize_t' {aka 'long int'} [-Werror=format=]
101 1335 | "error: %d(%u 0x%08x 0x%08x)\n",
102 | ~^
103 | |
104 | int
105 | %ld
106 1336 | ret, priv->reg_type, priv->reg_offset,
107 | ~~~
108 | |
109 | ssize_t {aka long int}
110 cc1: all warnings being treated as errors
111
112 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
113 ---
114 debugfs.c | 2 +-
115 hif/fwcmd.c | 2 +-
116 hif/pcie/pcie.c | 4 ++--
117 hif/pcie/tx_ndp.c | 2 +-
118 4 files changed, 5 insertions(+), 5 deletions(-)
119
120 diff --git a/debugfs.c b/debugfs.c
121 index 39b09fd..42efd28 100644
122 --- a/debugfs.c
123 +++ b/debugfs.c
124 @@ -1332,7 +1332,7 @@ done:
125 priv->reg_value);
126 else
127 len += scnprintf(p + len, size - len,
128 - "error: %d(%u 0x%08x 0x%08x)\n",
129 + "error: %zd(%u 0x%08x 0x%08x)\n",
130 ret, priv->reg_type, priv->reg_offset,
131 priv->reg_value);
132
133 diff --git a/hif/fwcmd.c b/hif/fwcmd.c
134 index 376b58f..582c8d2 100644
135 --- a/hif/fwcmd.c
136 +++ b/hif/fwcmd.c
137 @@ -3604,7 +3604,7 @@ int mwl_fwcmd_get_fw_core_dump(struct ieee80211_hw *hw,
138 core_dump->size_kb = pcmd->cmd_data.coredump.size_kb;
139 core_dump->flags = pcmd->cmd_data.coredump.flags;
140 memcpy(buff,
141 - (const void *)((u32)pcmd +
142 + (const void *)((uintptr_t)pcmd +
143 sizeof(struct hostcmd_cmd_get_fw_core_dump) -
144 sizeof(struct hostcmd_cmd_get_fw_core_dump_)),
145 MAX_CORE_DUMP_BUFFER);
146 diff --git a/hif/pcie/pcie.c b/hif/pcie/pcie.c
147 index 24453b6..5b6c633 100644
148 --- a/hif/pcie/pcie.c
149 +++ b/hif/pcie/pcie.c
150 @@ -1320,8 +1320,8 @@ static void pcie_bf_mimo_ctrl_decode(struct mwl_priv *priv,
151 &fp_data->f_pos);
152 filp_close(fp_data, current->files);
153 } else {
154 - wiphy_err(priv->hw->wiphy, "Error opening %s! %x\n",
155 - filename, (unsigned int)fp_data);
156 + wiphy_err(priv->hw->wiphy, "Error opening %s! %ld\n",
157 + filename, PTR_ERR(fp_data));
158 }
159
160 #if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
161 diff --git a/hif/pcie/tx_ndp.c b/hif/pcie/tx_ndp.c
162 index 6758cde..3140a2e 100644
163 --- a/hif/pcie/tx_ndp.c
164 +++ b/hif/pcie/tx_ndp.c
165 @@ -335,7 +335,7 @@ int pcie_tx_init_ndp(struct ieee80211_hw *hw)
166
167 if (sizeof(struct pcie_tx_ctrl_ndp) >
168 sizeof(tx_info->status.status_driver_data)) {
169 - wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
170 + wiphy_err(hw->wiphy, "driver data is not enough: %zu (%zu)\n",
171 sizeof(struct pcie_tx_ctrl_ndp),
172 sizeof(tx_info->status.status_driver_data));
173 return -ENOMEM;
174 --
175 2.39.2
176