forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/media/pci/saa7164/saa7164-dvb.c
....@@ -1,18 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for the NXP SAA7164 PCIe bridge
34 *
45 * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- *
15
- * GNU General Public License for more details.
166 */
177
188 #include "saa7164.h"
....@@ -120,14 +110,14 @@
120110
121111 memset(&bi, 0, sizeof(bi));
122112
123
- strlcpy(bi.type, "si2157", I2C_NAME_SIZE);
113
+ strscpy(bi.type, "si2157", I2C_NAME_SIZE);
124114 bi.platform_data = cfg;
125115 bi.addr = addr8bit >> 1;
126116
127117 request_module(bi.type);
128118
129
- tuner = i2c_new_device(adapter, &bi);
130
- if (tuner == NULL || tuner->dev.driver == NULL)
119
+ tuner = i2c_new_client_device(adapter, &bi);
120
+ if (!i2c_client_has_driver(tuner))
131121 return -ENODEV;
132122
133123 if (!try_module_get(tuner->dev.driver->owner)) {
....@@ -347,8 +337,7 @@
347337
348338 dprintk(DBGLVL_DVB, "%s(port=%d)\n", __func__, port->nr);
349339
350
- if (port->type != SAA7164_MPEG_DVB)
351
- BUG();
340
+ BUG_ON(port->type != SAA7164_MPEG_DVB);
352341
353342 /* Sanity check that the PCI configuration space is active */
354343 if (port->hwcfg.BARLocation == 0) {
....@@ -489,8 +478,7 @@
489478
490479 dprintk(DBGLVL_DVB, "%s()\n", __func__);
491480
492
- if (port->type != SAA7164_MPEG_DVB)
493
- BUG();
481
+ BUG_ON(port->type != SAA7164_MPEG_DVB);
494482
495483 /* Remove any allocated buffers */
496484 mutex_lock(&port->dmaqueue_lock);
....@@ -529,7 +517,7 @@
529517 return 0;
530518 }
531519
532
-/* All the DVB attach calls go here, this function get's modified
520
+/* All the DVB attach calls go here, this function gets modified
533521 * for each new card.
534522 */
535523 int saa7164_dvb_register(struct saa7164_port *port)
....@@ -643,13 +631,12 @@
643631 si2168_config.fe = &port->dvb.frontend;
644632 si2168_config.ts_mode = SI2168_TS_SERIAL;
645633 memset(&info, 0, sizeof(struct i2c_board_info));
646
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
634
+ strscpy(info.type, "si2168", I2C_NAME_SIZE);
647635 info.addr = 0xc8 >> 1;
648636 info.platform_data = &si2168_config;
649637 request_module(info.type);
650
- client_demod = i2c_new_device(&dev->i2c_bus[2].i2c_adap,
651
- &info);
652
- if (!client_demod || !client_demod->dev.driver)
638
+ client_demod = i2c_new_client_device(&dev->i2c_bus[2].i2c_adap, &info);
639
+ if (!i2c_client_has_driver(client_demod))
653640 goto frontend_detach;
654641
655642 if (!try_module_get(client_demod->dev.driver->owner)) {
....@@ -663,13 +650,12 @@
663650 si2157_config.if_port = 1;
664651 si2157_config.fe = port->dvb.frontend;
665652 memset(&info, 0, sizeof(struct i2c_board_info));
666
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
653
+ strscpy(info.type, "si2157", I2C_NAME_SIZE);
667654 info.addr = 0xc0 >> 1;
668655 info.platform_data = &si2157_config;
669656 request_module(info.type);
670
- client_tuner = i2c_new_device(&dev->i2c_bus[0].i2c_adap,
671
- &info);
672
- if (!client_tuner || !client_tuner->dev.driver) {
657
+ client_tuner = i2c_new_client_device(&dev->i2c_bus[0].i2c_adap, &info);
658
+ if (!i2c_client_has_driver(client_tuner)) {
673659 module_put(client_demod->dev.driver->owner);
674660 i2c_unregister_device(client_demod);
675661 goto frontend_detach;
....@@ -688,13 +674,12 @@
688674 si2168_config.fe = &port->dvb.frontend;
689675 si2168_config.ts_mode = SI2168_TS_SERIAL;
690676 memset(&info, 0, sizeof(struct i2c_board_info));
691
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
677
+ strscpy(info.type, "si2168", I2C_NAME_SIZE);
692678 info.addr = 0xcc >> 1;
693679 info.platform_data = &si2168_config;
694680 request_module(info.type);
695
- client_demod = i2c_new_device(&dev->i2c_bus[2].i2c_adap,
696
- &info);
697
- if (!client_demod || !client_demod->dev.driver)
681
+ client_demod = i2c_new_client_device(&dev->i2c_bus[2].i2c_adap, &info);
682
+ if (!i2c_client_has_driver(client_demod))
698683 goto frontend_detach;
699684
700685 if (!try_module_get(client_demod->dev.driver->owner)) {
....@@ -708,13 +693,12 @@
708693 si2157_config.fe = port->dvb.frontend;
709694 si2157_config.if_port = 1;
710695 memset(&info, 0, sizeof(struct i2c_board_info));
711
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
696
+ strscpy(info.type, "si2157", I2C_NAME_SIZE);
712697 info.addr = 0xc0 >> 1;
713698 info.platform_data = &si2157_config;
714699 request_module(info.type);
715
- client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap,
716
- &info);
717
- if (!client_tuner || !client_tuner->dev.driver) {
700
+ client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap, &info);
701
+ if (!i2c_client_has_driver(client_tuner)) {
718702 module_put(client_demod->dev.driver->owner);
719703 i2c_unregister_device(client_demod);
720704 goto frontend_detach;
....@@ -754,4 +738,3 @@
754738 printk(KERN_ERR "%s() Frontend/I2C initialization failed\n", __func__);
755739 return -1;
756740 }
757
-