Skip to content

Commit 82bc898

Browse files
committed
优化
1 parent 21b0cd1 commit 82bc898

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

components/drivers/rtc/dev_soft_rtc.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,15 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
190190
struct tm time_temp;
191191

192192
RT_ASSERT(dev != RT_NULL);
193+
if (!args)
194+
return -RT_EINVAL;
195+
193196
rt_memset(&time_temp, 0, sizeof(struct tm));
194197

195198
switch (cmd)
196199
{
197200
case RT_DEVICE_CTRL_RTC_GET_TIME:
198201
{
199-
if (!args)
200-
return -RT_EINVAL;
201202
t = (time_t *)args;
202203
struct timespec ts;
203204
get_rtc_time(&ts);
@@ -206,30 +207,22 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
206207
}
207208
case RT_DEVICE_CTRL_RTC_SET_TIME:
208209
{
209-
if (!args)
210-
return -RT_EINVAL;
211210
t = (time_t *)args;
212211
struct timespec ts = { *t, 0 };
213212
set_rtc_time(&ts);
214213
break;
215214
}
216215
#ifdef RT_USING_ALARM
217216
case RT_DEVICE_CTRL_RTC_GET_ALARM:
218-
if (!args)
219-
return -RT_EINVAL;
220217
*((struct rt_rtc_wkalarm *)args) = wkalarm;
221218
break;
222219
case RT_DEVICE_CTRL_RTC_SET_ALARM:
223-
if (!args)
224-
return -RT_EINVAL;
225220
wkalarm = *((struct rt_rtc_wkalarm *)args);
226221
soft_rtc_alarm_update(&wkalarm);
227222
break;
228223
#endif
229224
case RT_DEVICE_CTRL_RTC_GET_TIMEVAL:
230225
{
231-
if (!args)
232-
return -RT_EINVAL;
233226
struct timeval *tv = (struct timeval *)args;
234227
struct timespec ts;
235228
get_rtc_time(&ts);
@@ -239,33 +232,25 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
239232
}
240233
case RT_DEVICE_CTRL_RTC_SET_TIMEVAL:
241234
{
242-
if (!args)
243-
return -RT_EINVAL;
244235
struct timeval *tv = (struct timeval *)args;
245236
struct timespec ts = { tv->tv_sec, tv->tv_usec * 1000 };
246237
set_rtc_time(&ts);
247238
break;
248239
}
249240
case RT_DEVICE_CTRL_RTC_GET_TIMESPEC:
250241
{
251-
if (!args)
252-
return -RT_EINVAL;
253242
struct timespec *ts = (struct timespec *)args;
254243
get_rtc_time(ts);
255244
break;
256245
}
257246
case RT_DEVICE_CTRL_RTC_SET_TIMESPEC:
258247
{
259-
if (!args)
260-
return -RT_EINVAL;
261248
struct timespec *ts = (struct timespec *)args;
262249
set_rtc_time(ts);
263250
break;
264251
}
265252
case RT_DEVICE_CTRL_RTC_GET_TIMERES:
266253
{
267-
if (!args)
268-
return -RT_EINVAL;
269254
struct timespec *ts = (struct timespec *)args;
270255
level = rt_spin_lock_irqsave(&_spinlock);
271256
ts->tv_sec = 0;

0 commit comments

Comments
 (0)