forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/media/dvb-core/dvbdev.c
....@@ -479,7 +479,7 @@
479479 return -ENOMEM;
480480 }
481481
482
- dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
482
+ dvbdevfops = kmemdup(template->fops, sizeof(*dvbdevfops), GFP_KERNEL);
483483
484484 if (!dvbdevfops){
485485 kfree (dvbdev);
....@@ -495,7 +495,6 @@
495495 dvbdev->fops = dvbdevfops;
496496 init_waitqueue_head (&dvbdev->wait_queue);
497497
498
- memcpy(dvbdevfops, template->fops, sizeof(struct file_operations));
499498 dvbdevfops->owner = adap->module;
500499
501500 list_add_tail (&dvbdev->list_head, &adap->device_list);
....@@ -529,7 +528,6 @@
529528 dvb_media_device_free(dvbdev);
530529 kfree(dvbdevfops);
531530 kfree(dvbdev);
532
- up_write(&minor_rwsem);
533531 mutex_unlock(&dvbdev_register_lock);
534532 return ret;
535533 }
....@@ -624,7 +622,7 @@
624622 unsigned demux_pad = 0;
625623 unsigned dvr_pad = 0;
626624 unsigned ntuner = 0, ndemod = 0;
627
- int ret;
625
+ int ret, pad_source, pad_sink;
628626 static const char *connector_name = "Television";
629627
630628 if (!mdev)
....@@ -684,7 +682,7 @@
684682 if (ret)
685683 return ret;
686684
687
- if (!ntuner)
685
+ if (!ntuner) {
688686 ret = media_create_pad_links(mdev,
689687 MEDIA_ENT_F_CONN_RF,
690688 conn, 0,
....@@ -692,22 +690,32 @@
692690 demod, 0,
693691 MEDIA_LNK_FL_ENABLED,
694692 false);
695
- else
693
+ } else {
694
+ pad_sink = media_get_pad_index(tuner, true,
695
+ PAD_SIGNAL_ANALOG);
696
+ if (pad_sink < 0)
697
+ return -EINVAL;
696698 ret = media_create_pad_links(mdev,
697699 MEDIA_ENT_F_CONN_RF,
698700 conn, 0,
699701 MEDIA_ENT_F_TUNER,
700
- tuner, TUNER_PAD_RF_INPUT,
702
+ tuner, pad_sink,
701703 MEDIA_LNK_FL_ENABLED,
702704 false);
705
+ }
703706 if (ret)
704707 return ret;
705708 }
706709
707710 if (ntuner && ndemod) {
711
+ /* NOTE: first found tuner source pad presumed correct */
712
+ pad_source = media_get_pad_index(tuner, false,
713
+ PAD_SIGNAL_ANALOG);
714
+ if (pad_source < 0)
715
+ return -EINVAL;
708716 ret = media_create_pad_links(mdev,
709717 MEDIA_ENT_F_TUNER,
710
- tuner, TUNER_PAD_OUTPUT,
718
+ tuner, pad_source,
711719 MEDIA_ENT_F_DTV_DEMOD,
712720 demod, 0, MEDIA_LNK_FL_ENABLED,
713721 false);
....@@ -892,7 +900,7 @@
892900
893901 /* if the miracle happens and "generic_usercopy()" is included into
894902 the kernel, then this can vanish. please don't make the mistake and
895
- define this as video_usercopy(). this will introduce a dependecy
903
+ define this as video_usercopy(). this will introduce a dependency
896904 to the v4l "videodev.o" module, which is unnecessary for some
897905 cards (ie. the budget dvb-cards don't need the v4l module...) */
898906 int dvb_usercopy(struct file *file,
....@@ -970,15 +978,15 @@
970978 return NULL;
971979
972980 if (name)
973
- strlcpy(board_info->type, name, I2C_NAME_SIZE);
981
+ strscpy(board_info->type, name, I2C_NAME_SIZE);
974982 else
975
- strlcpy(board_info->type, module_name, I2C_NAME_SIZE);
983
+ strscpy(board_info->type, module_name, I2C_NAME_SIZE);
976984
977985 board_info->addr = addr;
978986 board_info->platform_data = platform_data;
979987 request_module(module_name);
980
- client = i2c_new_device(adap, board_info);
981
- if (client == NULL || client->dev.driver == NULL) {
988
+ client = i2c_new_client_device(adap, board_info);
989
+ if (!i2c_client_has_driver(client)) {
982990 kfree(board_info);
983991 return NULL;
984992 }