Update pwm.c

rt_malloc -> rt_calloc
This commit is contained in:
David Lin 2020-03-14 22:38:48 +08:00 committed by GitHub
parent b2d33e9147
commit 25ac5039e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -185,16 +185,14 @@ int fh_pwm_probe(void *priv_data)
PWM_Enable(pwm_obj, RT_FALSE); 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) if (pwm_dev == RT_NULL)
{ {
rt_kprintf("ERROR: %s rt_device malloc failed\n", __func__); rt_kprintf("ERROR: %s rt_device calloc failed\n", __func__);
return -RT_EIO; return -RT_ENOMEM;
} }
rt_memset(pwm_dev, 0, sizeof(struct rt_device));
pwm_dev->user_data = &pwm_drv; pwm_dev->user_data = &pwm_drv;
pwm_dev->open =fh_pwm_open; pwm_dev->open =fh_pwm_open;
pwm_dev->close = fh_pwm_close; pwm_dev->close = fh_pwm_close;