From 25ac5039e7359c02afc5d8fd9c7106bf6904a225 Mon Sep 17 00:00:00 2001 From: David Lin Date: Sat, 14 Mar 2020 22:38:48 +0800 Subject: [PATCH] Update pwm.c rt_malloc -> rt_calloc --- bsp/fh8620/drivers/pwm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bsp/fh8620/drivers/pwm.c b/bsp/fh8620/drivers/pwm.c index 3eb5a8ccd2..6faa836edb 100644 --- a/bsp/fh8620/drivers/pwm.c +++ b/bsp/fh8620/drivers/pwm.c @@ -185,16 +185,14 @@ int fh_pwm_probe(void *priv_data) PWM_Enable(pwm_obj, RT_FALSE); - pwm_dev = rt_malloc(sizeof(struct rt_device)); + pwm_dev = rt_calloc(sizeof(struct rt_device)); if (pwm_dev == RT_NULL) { - rt_kprintf("ERROR: %s rt_device malloc failed\n", __func__); - return -RT_EIO; + rt_kprintf("ERROR: %s rt_device calloc failed\n", __func__); + return -RT_ENOMEM; } - rt_memset(pwm_dev, 0, sizeof(struct rt_device)); - pwm_dev->user_data = &pwm_drv; pwm_dev->open =fh_pwm_open; pwm_dev->close = fh_pwm_close;