Skip to content

Commit 5b88c8c

Browse files
unicornxRbb666
authored andcommitted
bsp: cvitek: fix build warnings for spi
See #10138. Signed-off-by: Chen Wang <[email protected]>
1 parent b583240 commit 5b88c8c

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

bsp/cvitek/drivers/drv_spi.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_config
7373
RT_ASSERT(device->bus->parent.user_data != RT_NULL);
7474
RT_ASSERT(cfg != RT_NULL);
7575

76-
rt_err_t ret = RT_EOK;
7776
struct _device_spi *spi = (struct _device_spi *)device->bus->parent.user_data;
7877
struct dw_spi *dws = &spi->dws;
7978

@@ -139,9 +138,6 @@ static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_config
139138

140139
static rt_err_t dw_spi_transfer_one(struct dw_spi *dws, const void *tx_buf, void *rx_buf, uint32_t len, enum transfer_type tran_type)
141140
{
142-
uint8_t imask = 0;
143-
uint16_t txlevel = 0;
144-
145141
dws->tx = NULL;
146142
dws->tx_end = NULL;
147143
dws->rx = NULL;
@@ -198,7 +194,7 @@ static rt_ssize_t spi_xfer(struct rt_spi_device *device, struct rt_spi_message *
198194

199195
struct _device_spi *spi = (struct _device_spi *)device->bus->parent.user_data;
200196
struct dw_spi *dws = &spi->dws;
201-
int32_t ret = 0;
197+
int32_t ret = RT_EOK;
202198

203199
if (message->send_buf && message->recv_buf)
204200
{
@@ -214,6 +210,14 @@ static rt_ssize_t spi_xfer(struct rt_spi_device *device, struct rt_spi_message *
214210
{
215211
ret = dw_spi_transfer_one(dws, RT_NULL, message->recv_buf, message->length, POLL_TRAN);
216212

213+
} else {
214+
return 0;
215+
}
216+
217+
if (ret != RT_EOK)
218+
{
219+
LOG_E("spi transfer error : %d", ret);
220+
return 0;
217221
}
218222

219223
return message->length;
@@ -329,13 +333,12 @@ static void rt_hw_spi_pinmux_config()
329333
int rt_hw_spi_init(void)
330334
{
331335
rt_err_t ret = RT_EOK;
332-
struct dw_spi *dws;
333336

334337
rt_hw_spi_pinmux_config();
335338

336339
for (rt_size_t i = 0; i < sizeof(_spi_obj) / sizeof(struct _device_spi); i++)
337340
{
338-
_spi_obj[i].dws.regs = (rt_ubase_t)DRV_IOREMAP((void *)_spi_obj[i].dws.regs, 0x1000);
341+
_spi_obj[i].dws.regs = (void *)DRV_IOREMAP((void *)_spi_obj[i].dws.regs, 0x1000);
339342

340343
_spi_obj[i].spi_bus.parent.user_data = (void *)&_spi_obj[i];
341344
ret = rt_spi_bus_register(&_spi_obj[i].spi_bus, _spi_obj[i].device_name, &_spi_ops);

bsp/cvitek/drivers/libraries/spi/dw_spi.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
#include <errno.h>
17+
#include <rtthread.h>
1718
#include <string.h>
1819
#include <stdio.h>
1920

@@ -23,9 +24,12 @@
2324
#include <rthw.h>
2425

2526
#ifdef SPI_DEBUG
26-
#define SP_DEBUG_LOG printf
27+
#define SP_DEBUG_LOG(fmt, ...) \
28+
do { \
29+
rt_kprintf(fmt, ##__VA_ARGS__); \
30+
} while(0)
2731
#else
28-
#define SP_DEBUG_LOG
32+
#define SP_DEBUG_LOG(fmt, ...)
2933
#endif
3034

3135
/* Restart the controller, disable all interrupts, clean rx fifo */

0 commit comments

Comments
 (0)