diff options
Diffstat (limited to 'drivers/media/radio/si470x/radio-si470x-usb.c')
| -rw-r--r-- | drivers/media/radio/si470x/radio-si470x-usb.c | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c index 571f29a34bf8..aa7a580dbecc 100644 --- a/drivers/media/radio/si470x/radio-si470x-usb.c +++ b/drivers/media/radio/si470x/radio-si470x-usb.c @@ -1,19 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * drivers/media/radio/si470x/radio-si470x-usb.c * * USB driver for radios with Silicon Labs Si470x FM Radio Receivers * * Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ @@ -25,7 +16,7 @@ /* driver definitions */ #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>" -#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" +#define DRIVER_CARD "Silicon Labs Si470x FM Radio" #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers" #define DRIVER_VERSION "1.0.10" @@ -38,7 +29,7 @@ /* USB Device ID List */ -static struct usb_device_id si470x_usb_driver_id_table[] = { +static const struct usb_device_id si470x_usb_driver_id_table[] = { /* Silicon Labs USB FM Radio Reference Design */ { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */ @@ -250,7 +241,7 @@ static int si470x_set_report(struct si470x_device *radio, void *buf, int size) /* * si470x_get_register - read register */ -int si470x_get_register(struct si470x_device *radio, int regnr) +static int si470x_get_register(struct si470x_device *radio, int regnr) { int retval; @@ -268,7 +259,7 @@ int si470x_get_register(struct si470x_device *radio, int regnr) /* * si470x_set_register - write register */ -int si470x_set_register(struct si470x_device *radio, int regnr) +static int si470x_set_register(struct si470x_device *radio, int regnr) { int retval; @@ -482,12 +473,12 @@ resubmit: } -int si470x_fops_open(struct file *file) +static int si470x_fops_open(struct file *file) { return v4l2_fh_open(file); } -int si470x_fops_release(struct file *file) +static int si470x_fops_release(struct file *file) { return v4l2_fh_release(file); } @@ -514,18 +505,15 @@ static void si470x_usb_release(struct v4l2_device *v4l2_dev) /* * si470x_vidioc_querycap - query device capabilities */ -int si470x_vidioc_querycap(struct file *file, void *priv, - struct v4l2_capability *capability) +static int si470x_vidioc_querycap(struct file *file, void *priv, + struct v4l2_capability *capability) { struct si470x_device *radio = video_drvdata(file); - strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); - strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); + strscpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); + strscpy(capability->card, DRIVER_CARD, sizeof(capability->card)); usb_make_path(radio->usbdev, capability->bus_info, sizeof(capability->bus_info)); - capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_READWRITE | - V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE; - capability->capabilities = capability->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } @@ -578,7 +566,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, struct si470x_device *radio; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; - int i, int_end_size, retval = 0; + int i, int_end_size, retval; unsigned char version_warning = 0; /* private data allocation and initialization */ @@ -598,6 +586,12 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, mutex_init(&radio->lock); init_completion(&radio->completion); + radio->get_register = si470x_get_register; + radio->set_register = si470x_set_register; + radio->fops_open = si470x_fops_open; + radio->fops_release = si470x_fops_release; + radio->vidioc_querycap = si470x_vidioc_querycap; + iface_desc = intf->cur_altsetting; /* Set up interrupt endpoint information. */ @@ -673,6 +667,9 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, radio->videodev.lock = &radio->lock; radio->videodev.v4l2_dev = &radio->v4l2_dev; radio->videodev.release = video_device_release_empty; + radio->videodev.device_caps = + V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_READWRITE | V4L2_CAP_TUNER | + V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE; video_set_drvdata(&radio->videodev, radio); /* get device and chip versions */ @@ -684,10 +681,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, radio->registers[DEVICEID], radio->registers[SI_CHIPID]); if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) { dev_warn(&intf->dev, - "This driver is known to work with firmware version %hu,\n", - RADIO_FW_VERSION); - dev_warn(&intf->dev, - "but the device has firmware version %hu.\n", + "This driver is known to work with firmware version %u, but the device has firmware version %u.\n", + RADIO_FW_VERSION, radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE); version_warning = 1; } @@ -701,10 +696,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, radio->software_version, radio->hardware_version); if (radio->hardware_version < RADIO_HW_VERSION) { dev_warn(&intf->dev, - "This driver is known to work with hardware version %hu,\n", - RADIO_HW_VERSION); - dev_warn(&intf->dev, - "but the device has hardware version %hu.\n", + "This driver is known to work with hardware version %u, but the device has hardware version %u.\n", + RADIO_HW_VERSION, radio->hardware_version); version_warning = 1; } @@ -712,9 +705,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, /* give out version warning */ if (version_warning == 1) { dev_warn(&intf->dev, - "If you have some trouble using this driver,\n"); - dev_warn(&intf->dev, - "please report to V4L ML at linux-media@vger.kernel.org\n"); + "If you have some trouble using this driver, please report to V4L ML at linux-media@vger.kernel.org\n"); } /* set led to connect state */ @@ -736,7 +727,9 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, /* start radio */ retval = si470x_start_usb(radio); - if (retval < 0) + if (retval < 0 && !radio->int_in_running) + goto err_buf; + else if (retval < 0) /* in case of radio->int_in_running == 1 */ goto err_all; /* set initial frequency */ @@ -752,6 +745,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, return 0; err_all: + usb_kill_urb(radio->int_in_urb); +err_buf: kfree(radio->buffer); err_ctrl: v4l2_ctrl_handler_free(&radio->hdl); @@ -825,6 +820,7 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf) mutex_lock(&radio->lock); v4l2_device_disconnect(&radio->v4l2_dev); video_unregister_device(&radio->videodev); + usb_kill_urb(radio->int_in_urb); usb_set_intfdata(intf, NULL); mutex_unlock(&radio->lock); v4l2_device_put(&radio->v4l2_dev); |
