hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/media/usb/hackrf/hackrf.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * HackRF driver
34 *
45 * Copyright (C) 2014 Antti Palosaari <crope@iki.fi>
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/module.h>
....@@ -905,21 +896,15 @@
905896 {
906897 struct hackrf_dev *dev = video_drvdata(file);
907898 struct usb_interface *intf = dev->intf;
908
- struct video_device *vdev = video_devdata(file);
909899
910900 dev_dbg(&intf->dev, "\n");
911901
912
- cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
913
- if (vdev->vfl_dir == VFL_DIR_RX)
914
- cap->device_caps |= V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER;
915
- else
916
- cap->device_caps |= V4L2_CAP_SDR_OUTPUT | V4L2_CAP_MODULATOR;
917
-
918902 cap->capabilities = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER |
919903 V4L2_CAP_SDR_OUTPUT | V4L2_CAP_MODULATOR |
920
- V4L2_CAP_DEVICE_CAPS | cap->device_caps;
921
- strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
922
- strlcpy(cap->card, dev->rx_vdev.name, sizeof(cap->card));
904
+ V4L2_CAP_STREAMING | V4L2_CAP_READWRITE |
905
+ V4L2_CAP_DEVICE_CAPS;
906
+ strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
907
+ strscpy(cap->card, dev->rx_vdev.name, sizeof(cap->card));
923908 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
924909
925910 return 0;
....@@ -1041,14 +1026,14 @@
10411026 dev_dbg(dev->dev, "index=%d\n", v->index);
10421027
10431028 if (v->index == 0) {
1044
- strlcpy(v->name, "HackRF ADC", sizeof(v->name));
1029
+ strscpy(v->name, "HackRF ADC", sizeof(v->name));
10451030 v->type = V4L2_TUNER_SDR;
10461031 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
10471032 v->rangelow = bands_adc_dac[0].rangelow;
10481033 v->rangehigh = bands_adc_dac[0].rangehigh;
10491034 ret = 0;
10501035 } else if (v->index == 1) {
1051
- strlcpy(v->name, "HackRF RF", sizeof(v->name));
1036
+ strscpy(v->name, "HackRF RF", sizeof(v->name));
10521037 v->type = V4L2_TUNER_RF;
10531038 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
10541039 v->rangelow = bands_rx_tx[0].rangelow;
....@@ -1080,14 +1065,14 @@
10801065 dev_dbg(dev->dev, "index=%d\n", a->index);
10811066
10821067 if (a->index == 0) {
1083
- strlcpy(a->name, "HackRF DAC", sizeof(a->name));
1068
+ strscpy(a->name, "HackRF DAC", sizeof(a->name));
10841069 a->type = V4L2_TUNER_SDR;
10851070 a->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
10861071 a->rangelow = bands_adc_dac[0].rangelow;
10871072 a->rangehigh = bands_adc_dac[0].rangehigh;
10881073 ret = 0;
10891074 } else if (a->index == 1) {
1090
- strlcpy(a->name, "HackRF RF", sizeof(a->name));
1075
+ strscpy(a->name, "HackRF RF", sizeof(a->name));
10911076 a->type = V4L2_TUNER_RF;
10921077 a->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
10931078 a->rangelow = bands_rx_tx[0].rangelow;
....@@ -1496,6 +1481,8 @@
14961481 dev->rx_vdev.ctrl_handler = &dev->rx_ctrl_handler;
14971482 dev->rx_vdev.lock = &dev->v4l2_lock;
14981483 dev->rx_vdev.vfl_dir = VFL_DIR_RX;
1484
+ dev->rx_vdev.device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE |
1485
+ V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER;
14991486 video_set_drvdata(&dev->rx_vdev, dev);
15001487 ret = video_register_device(&dev->rx_vdev, VFL_TYPE_SDR, -1);
15011488 if (ret) {
....@@ -1514,6 +1501,8 @@
15141501 dev->tx_vdev.ctrl_handler = &dev->tx_ctrl_handler;
15151502 dev->tx_vdev.lock = &dev->v4l2_lock;
15161503 dev->tx_vdev.vfl_dir = VFL_DIR_TX;
1504
+ dev->tx_vdev.device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE |
1505
+ V4L2_CAP_SDR_OUTPUT | V4L2_CAP_MODULATOR;
15171506 video_set_drvdata(&dev->tx_vdev, dev);
15181507 ret = video_register_device(&dev->tx_vdev, VFL_TYPE_SDR, -1);
15191508 if (ret) {