@@ -360,8 +360,12 @@ __subsystem struct video_driver_api {
360
360
*/
361
361
static inline int video_set_format (const struct device * dev , struct video_format * fmt )
362
362
{
363
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
363
+ const struct video_driver_api * api ;
364
+
365
+ __ASSERT_NO_MSG (dev != NULL );
366
+ __ASSERT_NO_MSG (fmt != NULL );
364
367
368
+ api = (const struct video_driver_api * )dev -> api ;
365
369
if (api -> set_format == NULL ) {
366
370
return - ENOSYS ;
367
371
}
@@ -381,8 +385,12 @@ static inline int video_set_format(const struct device *dev, struct video_format
381
385
*/
382
386
static inline int video_get_format (const struct device * dev , struct video_format * fmt )
383
387
{
384
- const struct video_driver_api * api = ( const struct video_driver_api * ) dev -> api ;
388
+ const struct video_driver_api * api ;
385
389
390
+ __ASSERT_NO_MSG (dev != NULL );
391
+ __ASSERT_NO_MSG (fmt != NULL );
392
+
393
+ api = (const struct video_driver_api * )dev -> api ;
386
394
if (api -> get_format == NULL ) {
387
395
return - ENOSYS ;
388
396
}
@@ -408,8 +416,12 @@ static inline int video_get_format(const struct device *dev, struct video_format
408
416
*/
409
417
static inline int video_set_frmival (const struct device * dev , struct video_frmival * frmival )
410
418
{
411
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
419
+ const struct video_driver_api * api ;
420
+
421
+ __ASSERT_NO_MSG (dev != NULL );
422
+ __ASSERT_NO_MSG (frmival != NULL );
412
423
424
+ api = (const struct video_driver_api * )dev -> api ;
413
425
if (api -> set_frmival == NULL ) {
414
426
return - ENOSYS ;
415
427
}
@@ -432,8 +444,12 @@ static inline int video_set_frmival(const struct device *dev, struct video_frmiv
432
444
*/
433
445
static inline int video_get_frmival (const struct device * dev , struct video_frmival * frmival )
434
446
{
435
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
447
+ const struct video_driver_api * api ;
448
+
449
+ __ASSERT_NO_MSG (dev != NULL );
450
+ __ASSERT_NO_MSG (frmival != NULL );
436
451
452
+ api = (const struct video_driver_api * )dev -> api ;
437
453
if (api -> get_frmival == NULL ) {
438
454
return - ENOSYS ;
439
455
}
@@ -460,8 +476,13 @@ static inline int video_get_frmival(const struct device *dev, struct video_frmiv
460
476
*/
461
477
static inline int video_enum_frmival (const struct device * dev , struct video_frmival_enum * fie )
462
478
{
463
- const struct video_driver_api * api = ( const struct video_driver_api * ) dev -> api ;
479
+ const struct video_driver_api * api ;
464
480
481
+ __ASSERT_NO_MSG (dev != NULL );
482
+ __ASSERT_NO_MSG (fie != NULL );
483
+ __ASSERT_NO_MSG (fie -> format != NULL );
484
+
485
+ api = (const struct video_driver_api * )dev -> api ;
465
486
if (api -> enum_frmival == NULL ) {
466
487
return - ENOSYS ;
467
488
}
@@ -486,6 +507,11 @@ static inline int video_enqueue(const struct device *dev, struct video_buffer *b
486
507
{
487
508
const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
488
509
510
+ __ASSERT_NO_MSG (dev != NULL );
511
+ __ASSERT_NO_MSG (buf != NULL );
512
+ __ASSERT_NO_MSG (buf -> buffer != NULL );
513
+
514
+ api = (const struct video_driver_api * )dev -> api ;
489
515
if (api -> enqueue == NULL ) {
490
516
return - ENOSYS ;
491
517
}
@@ -510,8 +536,12 @@ static inline int video_enqueue(const struct device *dev, struct video_buffer *b
510
536
static inline int video_dequeue (const struct device * dev , struct video_buffer * * buf ,
511
537
k_timeout_t timeout )
512
538
{
513
- const struct video_driver_api * api = ( const struct video_driver_api * ) dev -> api ;
539
+ const struct video_driver_api * api ;
514
540
541
+ __ASSERT_NO_MSG (dev != NULL );
542
+ __ASSERT_NO_MSG (buf != NULL );
543
+
544
+ api = (const struct video_driver_api * )dev -> api ;
515
545
if (api -> dequeue == NULL ) {
516
546
return - ENOSYS ;
517
547
}
@@ -534,8 +564,11 @@ static inline int video_dequeue(const struct device *dev, struct video_buffer **
534
564
*/
535
565
static inline int video_flush (const struct device * dev , bool cancel )
536
566
{
537
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
567
+ const struct video_driver_api * api ;
568
+
569
+ __ASSERT_NO_MSG (dev != NULL );
538
570
571
+ api = (const struct video_driver_api * )dev -> api ;
539
572
if (api -> flush == NULL ) {
540
573
return - ENOSYS ;
541
574
}
@@ -560,8 +593,11 @@ static inline int video_flush(const struct device *dev, bool cancel)
560
593
*/
561
594
static inline int video_stream_start (const struct device * dev , enum video_buf_type type )
562
595
{
563
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
596
+ const struct video_driver_api * api ;
597
+
598
+ __ASSERT_NO_MSG (dev != NULL );
564
599
600
+ api = (const struct video_driver_api * )dev -> api ;
565
601
if (api -> set_stream == NULL ) {
566
602
return - ENOSYS ;
567
603
}
@@ -583,9 +619,12 @@ static inline int video_stream_start(const struct device *dev, enum video_buf_ty
583
619
*/
584
620
static inline int video_stream_stop (const struct device * dev , enum video_buf_type type )
585
621
{
586
- const struct video_driver_api * api = ( const struct video_driver_api * ) dev -> api ;
622
+ const struct video_driver_api * api ;
587
623
int ret ;
588
624
625
+ __ASSERT_NO_MSG (dev != NULL );
626
+
627
+ api = (const struct video_driver_api * )dev -> api ;
589
628
if (api -> set_stream == NULL ) {
590
629
return - ENOSYS ;
591
630
}
@@ -606,8 +645,12 @@ static inline int video_stream_stop(const struct device *dev, enum video_buf_typ
606
645
*/
607
646
static inline int video_get_caps (const struct device * dev , struct video_caps * caps )
608
647
{
609
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
648
+ const struct video_driver_api * api ;
649
+
650
+ __ASSERT_NO_MSG (dev != NULL );
651
+ __ASSERT_NO_MSG (caps != NULL );
610
652
653
+ api = (const struct video_driver_api * )dev -> api ;
611
654
if (api -> get_caps == NULL ) {
612
655
return - ENOSYS ;
613
656
}
@@ -696,8 +739,12 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
696
739
*/
697
740
static inline int video_set_signal (const struct device * dev , struct k_poll_signal * sig )
698
741
{
699
- const struct video_driver_api * api = (const struct video_driver_api * )dev -> api ;
742
+ const struct video_driver_api * api ;
743
+
744
+ __ASSERT_NO_MSG (dev != NULL );
745
+ __ASSERT_NO_MSG (sig != NULL );
700
746
747
+ api = (const struct video_driver_api * )dev -> api ;
701
748
if (api -> set_signal == NULL ) {
702
749
return - ENOSYS ;
703
750
}
@@ -755,6 +802,8 @@ int video_format_caps_index(const struct video_format_cap *fmts, const struct vi
755
802
*/
756
803
static inline uint64_t video_frmival_nsec (const struct video_frmival * frmival )
757
804
{
805
+ __ASSERT_NO_MSG (frmival != NULL );
806
+
758
807
return (uint64_t )NSEC_PER_SEC * frmival -> numerator / frmival -> denominator ;
759
808
}
760
809
0 commit comments