Skip to content

Commit 2360497

Browse files
lixuzhaJiri Kosina
authored andcommitted
HID: intel-ish-hid: Fix build error for COMPILE_TEST
kernel test robot reported build error due to a pointer type mismatch: .../ishtp/loader.c:172:8: error: incompatible pointer types passing '__le64 *' (aka 'unsigned long long *') to parameter of type 'dma_addr_t *' (aka 'unsigned int *') The issue arises because the driver, which is primarily intended for x86-64, is also built for i386 when COMPILE_TEST is enabled. Resolve type mismatch by using a temporary dma_addr_t variable to hold the DMA address. Populate this temporary variable in dma_alloc_coherent() function, and then convert and store the address in the fragment->fragment_tbl[i].ddr_adrs field in the correct format. Similarly, convert the ddr_adrs field back to dma_addr_t when freeing the DMA buffer with dma_free_coherent(). Fixes: 579a267 ("HID: intel-ish-hid: Implement loading firmware from host feature") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202405201313.SAStVPrT-lkp@intel.com/ Signed-off-by: Zhang Lixu <lixu.zhang@intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 70ec81c commit 2360497

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/hid/intel-ish-hid/ishtp/loader.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ static void release_dma_bufs(struct ishtp_device *dev,
138138
struct loader_xfer_dma_fragment *fragment,
139139
void **dma_bufs, u32 fragment_size)
140140
{
141+
dma_addr_t dma_addr;
141142
int i;
142143

143144
for (i = 0; i < FRAGMENT_MAX_NUM; i++) {
144145
if (dma_bufs[i]) {
145-
dma_free_coherent(dev->devc, fragment_size, dma_bufs[i],
146-
fragment->fragment_tbl[i].ddr_adrs);
146+
dma_addr = le64_to_cpu(fragment->fragment_tbl[i].ddr_adrs);
147+
dma_free_coherent(dev->devc, fragment_size, dma_bufs[i], dma_addr);
147148
dma_bufs[i] = NULL;
148149
}
149150
}
@@ -164,15 +165,16 @@ static int prepare_dma_bufs(struct ishtp_device *dev,
164165
struct loader_xfer_dma_fragment *fragment,
165166
void **dma_bufs, u32 fragment_size)
166167
{
168+
dma_addr_t dma_addr;
167169
u32 offset = 0;
168170
int i;
169171

170172
for (i = 0; i < fragment->fragment_cnt && offset < ish_fw->size; i++) {
171-
dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size,
172-
&fragment->fragment_tbl[i].ddr_adrs, GFP_KERNEL);
173+
dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size, &dma_addr, GFP_KERNEL);
173174
if (!dma_bufs[i])
174175
return -ENOMEM;
175176

177+
fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);
176178
fragment->fragment_tbl[i].length = clamp(ish_fw->size - offset, 0, fragment_size);
177179
fragment->fragment_tbl[i].fw_off = offset;
178180
memcpy(dma_bufs[i], ish_fw->data + offset, fragment->fragment_tbl[i].length);

0 commit comments

Comments
 (0)