bsp: cvitek: remove warning when building wdt driver

```
./bsp/cvitek/drivers/drv_wdt.c: In function '_wdt_control':
warning: assignment to 'void *' from 'unsigned int' makes pointer
from integer without a cast [-Wint-conversion]
  119 |         wdt_device->parent.user_data = (rt_uint32_t)(*(rt_uint32_t *)arg);
      |                                      ^
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  122 |         *(rt_uint32_t *)arg = (rt_uint32_t)wdt_device->parent.user_data;
      |                               ^
```

Rootcasue: It's not portable to store integar in a pointer.

Solution: use global _wdt_dev to store the timeout value.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
Chen Wang 2024-06-13 11:04:39 +08:00
parent 1d78d11567
commit 2d5eb2669f
1 changed files with 4 additions and 3 deletions

View File

@ -23,6 +23,7 @@ struct _cvi_wdt_dev
struct rt_watchdog_device device; struct rt_watchdog_device device;
const char *name; const char *name;
rt_uint32_t base; rt_uint32_t base;
rt_uint32_t timeout;
}; };
static struct _cvi_wdt_dev _wdt_dev[] = static struct _cvi_wdt_dev _wdt_dev[] =
@ -113,11 +114,11 @@ static rt_err_t _wdt_control(rt_watchdog_t *wdt_device, int cmd, void *arg)
cvi_wdt_feed_en(reg_base); cvi_wdt_feed_en(reg_base);
break; break;
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT: case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
csi_wdt_set_timeout(reg_base, *(rt_uint32_t *)arg); wdt->timeout = *(rt_uint32_t *)arg;
wdt_device->parent.user_data = (rt_uint32_t)(*(rt_uint32_t *)arg); csi_wdt_set_timeout(reg_base, wdt->timeout);
break; break;
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT: case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
*(rt_uint32_t *)arg = (rt_uint32_t)wdt_device->parent.user_data; *(rt_uint32_t *)arg = wdt->timeout;
break; break;
case RT_DEVICE_CTRL_WDT_GET_TIMELEFT: case RT_DEVICE_CTRL_WDT_GET_TIMELEFT:
*(rt_uint32_t *)arg = (cvi_wdt_get_counter_value(reg_base) / (WDT_FREQ_DEFAULT / 1000U)); *(rt_uint32_t *)arg = (cvi_wdt_get_counter_value(reg_base) / (WDT_FREQ_DEFAULT / 1000U));