forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 *
3
- *
44 * Copyright (C) 2005 Mike Isely <isely@pobox.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
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
155 */
166
177 #include <linux/i2c.h>
....@@ -478,8 +468,7 @@
478468 unsigned int idx,offs,cnt;
479469 for (idx = 0; idx < num; idx++) {
480470 cnt = msgs[idx].len;
481
- printk(KERN_INFO
482
- "pvrusb2 i2c xfer %u/%u: addr=0x%x len=%d %s",
471
+ pr_info("pvrusb2 i2c xfer %u/%u: addr=0x%x len=%d %s",
483472 idx+1,num,
484473 msgs[idx].addr,
485474 cnt,
....@@ -487,22 +476,21 @@
487476 "read" : "write"));
488477 if ((ret > 0) || !(msgs[idx].flags & I2C_M_RD)) {
489478 if (cnt > 8) cnt = 8;
490
- printk(KERN_CONT " [");
479
+ pr_cont(" [");
491480 for (offs = 0; offs < cnt; offs++) {
492
- if (offs) printk(KERN_CONT " ");
493
- printk(KERN_CONT "%02x",msgs[idx].buf[offs]);
481
+ if (offs) pr_cont(" ");
482
+ pr_cont("%02x", msgs[idx].buf[offs]);
494483 }
495
- if (offs < cnt) printk(KERN_CONT " ...");
496
- printk(KERN_CONT "]");
484
+ if (offs < cnt) pr_cont(" ...");
485
+ pr_cont("]");
497486 }
498487 if (idx+1 == num) {
499
- printk(KERN_CONT " result=%d",ret);
488
+ pr_cont(" result=%d", ret);
500489 }
501
- printk(KERN_CONT "\n");
490
+ pr_cont("\n");
502491 }
503492 if (!num) {
504
- printk(KERN_INFO
505
- "pvrusb2 i2c xfer null transfer result=%d\n",
493
+ pr_info("pvrusb2 i2c xfer null transfer result=%d\n",
506494 ret);
507495 }
508496 }
....@@ -542,14 +530,14 @@
542530 static void do_i2c_scan(struct pvr2_hdw *hdw)
543531 {
544532 int i;
545
- printk(KERN_INFO "%s: i2c scan beginning\n", hdw->name);
533
+ pr_info("%s: i2c scan beginning\n", hdw->name);
546534 for (i = 0; i < 128; i++) {
547535 if (do_i2c_probe(hdw, i)) {
548
- printk(KERN_INFO "%s: i2c scan: found device @ 0x%x\n",
536
+ pr_info("%s: i2c scan: found device @ 0x%x\n",
549537 hdw->name, i);
550538 }
551539 }
552
- printk(KERN_INFO "%s: i2c scan done.\n", hdw->name);
540
+ pr_info("%s: i2c scan done.\n", hdw->name);
553541 }
554542
555543 static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
....@@ -573,10 +561,10 @@
573561 /* IR Receiver */
574562 info.addr = 0x18;
575563 info.platform_data = init_data;
576
- strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
564
+ strscpy(info.type, "ir_video", I2C_NAME_SIZE);
577565 pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
578566 info.type, info.addr);
579
- i2c_new_device(&hdw->i2c_adap, &info);
567
+ i2c_new_client_device(&hdw->i2c_adap, &info);
580568 break;
581569 case PVR2_IR_SCHEME_ZILOG: /* HVR-1950 style */
582570 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */
....@@ -588,10 +576,10 @@
588576 /* IR Transceiver */
589577 info.addr = 0x71;
590578 info.platform_data = init_data;
591
- strlcpy(info.type, "ir_z8f0811_haup", I2C_NAME_SIZE);
579
+ strscpy(info.type, "ir_z8f0811_haup", I2C_NAME_SIZE);
592580 pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
593581 info.type, info.addr);
594
- i2c_new_device(&hdw->i2c_adap, &info);
582
+ i2c_new_client_device(&hdw->i2c_adap, &info);
595583 break;
596584 default:
597585 /* The device either doesn't support I2C-based IR or we
....@@ -612,7 +600,7 @@
612600
613601 /* However, deal with various special cases for 24xxx hardware. */
614602 if (ir_mode[hdw->unit_number] == 0) {
615
- printk(KERN_INFO "%s: IR disabled\n",hdw->name);
603
+ pr_info("%s: IR disabled\n", hdw->name);
616604 hdw->i2c_func[0x18] = i2c_black_hole;
617605 } else if (ir_mode[hdw->unit_number] == 1) {
618606 if (hdw->ir_scheme_active == PVR2_IR_SCHEME_24XXX) {
....@@ -631,7 +619,7 @@
631619 // Configure the adapter and set up everything else related to it.
632620 hdw->i2c_adap = pvr2_i2c_adap_template;
633621 hdw->i2c_algo = pvr2_i2c_algo_template;
634
- strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name));
622
+ strscpy(hdw->i2c_adap.name, hdw->name, sizeof(hdw->i2c_adap.name));
635623 hdw->i2c_adap.dev.parent = &hdw->usb_dev->dev;
636624 hdw->i2c_adap.algo = &hdw->i2c_algo;
637625 hdw->i2c_adap.algo_data = hdw;