hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/media/rc/iguanair.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * IguanaWorks USB IR Transceiver support
34 *
45 * Copyright (C) 2012 Sean Young <sean@mess.org>
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
- * GNU General Public License for more details.
156 */
167
178 #include <linux/device.h>
....@@ -23,7 +14,6 @@
2314 #include <linux/completion.h>
2415 #include <media/rc-core.h>
2516
26
-#define DRIVER_NAME "iguanair"
2717 #define BUF_SIZE 152
2818
2919 struct iguanair {
....@@ -35,8 +25,6 @@
3525 uint16_t version;
3626 uint8_t bufsize;
3727 uint8_t cycle_overhead;
38
-
39
- struct mutex lock;
4028
4129 /* receiver support */
4230 bool receiver_on;
....@@ -71,7 +59,7 @@
7159 #define MAX_IN_PACKET 8u
7260 #define MAX_OUT_PACKET (sizeof(struct send_packet) + BUF_SIZE)
7361 #define TIMEOUT 1000
74
-#define RX_RESOLUTION 21333
62
+#define RX_RESOLUTION 21
7563
7664 struct packet {
7765 uint16_t start;
....@@ -85,7 +73,7 @@
8573 uint8_t channels;
8674 uint8_t busy7;
8775 uint8_t busy4;
88
- uint8_t payload[0];
76
+ uint8_t payload[];
8977 };
9078
9179 static void process_ir_data(struct iguanair *ir, unsigned len)
....@@ -113,7 +101,7 @@
113101 break;
114102 case CMD_TX_OVERFLOW:
115103 ir->tx_overflow = true;
116
- /* fall through */
104
+ fallthrough;
117105 case CMD_RECEIVER_OFF:
118106 case CMD_RECEIVER_ON:
119107 case CMD_SEND:
....@@ -129,16 +117,14 @@
129117 break;
130118 }
131119 } else if (len >= 7) {
132
- DEFINE_IR_RAW_EVENT(rawir);
120
+ struct ir_raw_event rawir = {};
133121 unsigned i;
134122 bool event = false;
135
-
136
- init_ir_raw_event(&rawir);
137123
138124 for (i = 0; i < 7; i++) {
139125 if (ir->buf_in[i] == 0x80) {
140126 rawir.pulse = false;
141
- rawir.duration = US_TO_NS(21845);
127
+ rawir.duration = 21845;
142128 } else {
143129 rawir.pulse = (ir->buf_in[i] & 0x80) == 0;
144130 rawir.duration = ((ir->buf_in[i] & 0x7f) + 1) *
....@@ -295,8 +281,6 @@
295281 if (carrier < 25000 || carrier > 150000)
296282 return -EINVAL;
297283
298
- mutex_lock(&ir->lock);
299
-
300284 if (carrier != ir->carrier) {
301285 uint32_t cycles, fours, sevens;
302286
....@@ -325,8 +309,6 @@
325309 ir->packet->busy4 = 110 - fours;
326310 }
327311
328
- mutex_unlock(&ir->lock);
329
-
330312 return 0;
331313 }
332314
....@@ -337,9 +319,7 @@
337319 if (mask > 15)
338320 return 4;
339321
340
- mutex_lock(&ir->lock);
341322 ir->packet->channels = mask << 4;
342
- mutex_unlock(&ir->lock);
343323
344324 return 0;
345325 }
....@@ -349,8 +329,6 @@
349329 struct iguanair *ir = dev->priv;
350330 unsigned int i, size, p, periods;
351331 int rc;
352
-
353
- mutex_lock(&ir->lock);
354332
355333 /* convert from us to carrier periods */
356334 for (i = size = 0; i < count; i++) {
....@@ -379,8 +357,6 @@
379357 rc = -EOVERFLOW;
380358
381359 out:
382
- mutex_unlock(&ir->lock);
383
-
384360 return rc ? rc : count;
385361 }
386362
....@@ -389,13 +365,9 @@
389365 struct iguanair *ir = rdev->priv;
390366 int rc;
391367
392
- mutex_lock(&ir->lock);
393
-
394368 rc = iguanair_receiver(ir, true);
395369 if (rc == 0)
396370 ir->receiver_on = true;
397
-
398
- mutex_unlock(&ir->lock);
399371
400372 return rc;
401373 }
....@@ -405,14 +377,10 @@
405377 struct iguanair *ir = rdev->priv;
406378 int rc;
407379
408
- mutex_lock(&ir->lock);
409
-
410380 rc = iguanair_receiver(ir, false);
411381 ir->receiver_on = false;
412382 if (rc && rc != -ENODEV)
413383 dev_warn(ir->dev, "failed to disable receiver: %d\n", rc);
414
-
415
- mutex_unlock(&ir->lock);
416384 }
417385
418386 static int iguanair_probe(struct usb_interface *intf,
....@@ -452,7 +420,6 @@
452420 ir->rc = rc;
453421 ir->dev = &intf->dev;
454422 ir->udev = udev;
455
- mutex_init(&ir->lock);
456423
457424 init_completion(&ir->completion);
458425 pipeout = usb_sndintpipe(udev,
....@@ -494,7 +461,7 @@
494461 rc->s_tx_mask = iguanair_set_tx_mask;
495462 rc->s_tx_carrier = iguanair_set_tx_carrier;
496463 rc->tx_ir = iguanair_tx;
497
- rc->driver_name = DRIVER_NAME;
464
+ rc->driver_name = KBUILD_MODNAME;
498465 rc->map_name = RC_MAP_RC6_MCE;
499466 rc->min_timeout = 1;
500467 rc->timeout = IR_DEFAULT_TIMEOUT;
....@@ -549,8 +516,6 @@
549516 struct iguanair *ir = usb_get_intfdata(intf);
550517 int rc = 0;
551518
552
- mutex_lock(&ir->lock);
553
-
554519 if (ir->receiver_on) {
555520 rc = iguanair_receiver(ir, false);
556521 if (rc)
....@@ -560,17 +525,13 @@
560525 usb_kill_urb(ir->urb_in);
561526 usb_kill_urb(ir->urb_out);
562527
563
- mutex_unlock(&ir->lock);
564
-
565528 return rc;
566529 }
567530
568531 static int iguanair_resume(struct usb_interface *intf)
569532 {
570533 struct iguanair *ir = usb_get_intfdata(intf);
571
- int rc = 0;
572
-
573
- mutex_lock(&ir->lock);
534
+ int rc;
574535
575536 rc = usb_submit_urb(ir->urb_in, GFP_KERNEL);
576537 if (rc)
....@@ -582,8 +543,6 @@
582543 dev_warn(ir->dev, "failed to enable receiver after resume\n");
583544 }
584545
585
- mutex_unlock(&ir->lock);
586
-
587546 return rc;
588547 }
589548
....@@ -593,7 +552,7 @@
593552 };
594553
595554 static struct usb_driver iguanair_driver = {
596
- .name = DRIVER_NAME,
555
+ .name = KBUILD_MODNAME,
597556 .probe = iguanair_probe,
598557 .disconnect = iguanair_disconnect,
599558 .suspend = iguanair_suspend,