diff options
Diffstat (limited to 'drivers/media/usb/cx231xx/cx231xx-cards.c')
-rw-r--r-- | drivers/media/usb/cx231xx/cx231xx-cards.c | 125 |
1 files changed, 72 insertions, 53 deletions
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index d59f483102d2..2e8741314bce 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -26,7 +26,6 @@ #include <linux/slab.h> #include <linux/delay.h> #include <linux/i2c.h> -#include <linux/usb.h> #include <media/tuner.h> #include <media/tveeprom.h> #include <media/v4l2-common.h> @@ -856,8 +855,9 @@ int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) if (dev->tuner_type == TUNER_XC5000) { if (command == XC5000_TUNER_RESET) { - pr_debug("Tuner CB: RESET: cmd %d : tuner type %d \n", - command, dev->tuner_type); + dev_dbg(&dev->udev->dev, + "Tuner CB: RESET: cmd %d : tuner type %d\n", + command, dev->tuner_type); cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); msleep(10); @@ -915,7 +915,7 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) cx231xx_set_model(dev); - pr_info("Identified as %s (card=%d)\n", + dev_info(&dev->udev->dev, "Identified as %s (card=%d)\n", dev->board.name, dev->model); /* set the direction for GPIO pins */ @@ -989,7 +989,7 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, /* start reading at offset 0 */ ret = i2c_transfer(client->adapter, &msg_write, 1); if (ret < 0) { - pr_err("Can't read eeprom\n"); + dev_err(&dev->udev->dev, "Can't read eeprom\n"); return ret; } @@ -999,7 +999,7 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, ret = i2c_transfer(client->adapter, &msg_read, 1); if (ret < 0) { - pr_err("Can't read eeprom\n"); + dev_err(&dev->udev->dev, "Can't read eeprom\n"); return ret; } eedata_cur += msg_read.len; @@ -1007,7 +1007,8 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, } for (i = 0; i + 15 < len; i += 16) - pr_debug("i2c eeprom %02x: %*ph\n", i, 16, &eedata[i]); + dev_dbg(&dev->udev->dev, "i2c eeprom %02x: %*ph\n", + i, 16, &eedata[i]); return 0; } @@ -1027,7 +1028,8 @@ void cx231xx_card_setup(struct cx231xx *dev) cx231xx_get_i2c_adap(dev, I2C_0), "cx25840", 0x88 >> 1, NULL); if (dev->sd_cx25840 == NULL) - pr_err("cx25840 subdev registration failure\n"); + dev_err(&dev->udev->dev, + "cx25840 subdev registration failure\n"); cx25840_call(dev, core, load_fw); } @@ -1041,7 +1043,8 @@ void cx231xx_card_setup(struct cx231xx *dev) "tuner", dev->tuner_addr, NULL); if (dev->sd_tuner == NULL) - pr_err("tuner subdev registration failure\n"); + dev_err(&dev->udev->dev, + "tuner subdev registration failure\n"); else cx231xx_config_tuner(dev); } @@ -1147,7 +1150,7 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, /* Query cx231xx to find what pcb config it is related to */ retval = initialize_cx231xx(dev); if (retval < 0) { - pr_err("Failed to read PCB config\n"); + dev_err(&udev->dev, "Failed to read PCB config\n"); return retval; } @@ -1163,7 +1166,7 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, retval = cx231xx_config(dev); if (retval) { - pr_err("error configuring device\n"); + dev_err(&udev->dev, "error configuring device\n"); return -ENOMEM; } @@ -1173,8 +1176,9 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, /* register i2c bus */ retval = cx231xx_dev_init(dev); if (retval) { - pr_err("%s: cx231xx_i2c_register - errCode [%d]!\n", - __func__, retval); + dev_err(&udev->dev, + "%s: cx231xx_i2c_register - errCode [%d]!\n", + __func__, retval); goto err_dev_init; } @@ -1195,7 +1199,7 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, retval = cx231xx_config(dev); if (retval) { - pr_err("%s: cx231xx_config - errCode [%d]!\n", + dev_err(&udev->dev, "%s: cx231xx_config - errCode [%d]!\n", __func__, retval); goto err_dev_init; } @@ -1280,7 +1284,8 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, /* compute alternate max packet sizes for video */ idx = dev->current_pcb_config.hs_config_info[0].interface_info.video_index + 1; if (idx >= dev->max_iad_interface_count) { - pr_err("Video PCB interface #%d doesn't exist\n", idx); + dev_err(&dev->udev->dev, + "Video PCB interface #%d doesn't exist\n", idx); return -ENODEV; } @@ -1289,9 +1294,10 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, dev->video_mode.end_point_addr = uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress; dev->video_mode.num_alt = uif->num_altsetting; - pr_info("video EndPoint Addr 0x%x, Alternate settings: %i\n", - dev->video_mode.end_point_addr, - dev->video_mode.num_alt); + dev_info(&dev->udev->dev, + "video EndPoint Addr 0x%x, Alternate settings: %i\n", + dev->video_mode.end_point_addr, + dev->video_mode.num_alt); dev->video_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->video_mode.num_alt, GFP_KERNEL); if (dev->video_mode.alt_max_pkt_size == NULL) @@ -1300,15 +1306,17 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, for (i = 0; i < dev->video_mode.num_alt; i++) { u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.wMaxPacketSize); dev->video_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); - pr_debug("Alternate setting %i, max size= %i\n", i, - dev->video_mode.alt_max_pkt_size[i]); + dev_dbg(&dev->udev->dev, + "Alternate setting %i, max size= %i\n", i, + dev->video_mode.alt_max_pkt_size[i]); } /* VBI Init */ idx = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index + 1; if (idx >= dev->max_iad_interface_count) { - pr_err("VBI PCB interface #%d doesn't exist\n", idx); + dev_err(&dev->udev->dev, + "VBI PCB interface #%d doesn't exist\n", idx); return -ENODEV; } uif = udev->actconfig->interface[idx]; @@ -1318,9 +1326,10 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, bEndpointAddress; dev->vbi_mode.num_alt = uif->num_altsetting; - pr_info("VBI EndPoint Addr 0x%x, Alternate settings: %i\n", - dev->vbi_mode.end_point_addr, - dev->vbi_mode.num_alt); + dev_info(&dev->udev->dev, + "VBI EndPoint Addr 0x%x, Alternate settings: %i\n", + dev->vbi_mode.end_point_addr, + dev->vbi_mode.num_alt); /* compute alternate max packet sizes for vbi */ dev->vbi_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->vbi_mode.num_alt, GFP_KERNEL); @@ -1333,8 +1342,9 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, desc.wMaxPacketSize); dev->vbi_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); - pr_debug("Alternate setting %i, max size= %i\n", i, - dev->vbi_mode.alt_max_pkt_size[i]); + dev_dbg(&dev->udev->dev, + "Alternate setting %i, max size= %i\n", i, + dev->vbi_mode.alt_max_pkt_size[i]); } /* Sliced CC VBI init */ @@ -1342,7 +1352,8 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, /* compute alternate max packet sizes for sliced CC */ idx = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index + 1; if (idx >= dev->max_iad_interface_count) { - pr_err("Sliced CC PCB interface #%d doesn't exist\n", idx); + dev_err(&dev->udev->dev, + "Sliced CC PCB interface #%d doesn't exist\n", idx); return -ENODEV; } uif = udev->actconfig->interface[idx]; @@ -1352,9 +1363,10 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, bEndpointAddress; dev->sliced_cc_mode.num_alt = uif->num_altsetting; - pr_info("sliced CC EndPoint Addr 0x%x, Alternate settings: %i\n", - dev->sliced_cc_mode.end_point_addr, - dev->sliced_cc_mode.num_alt); + dev_info(&dev->udev->dev, + "sliced CC EndPoint Addr 0x%x, Alternate settings: %i\n", + dev->sliced_cc_mode.end_point_addr, + dev->sliced_cc_mode.num_alt); dev->sliced_cc_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->sliced_cc_mode.num_alt, GFP_KERNEL); if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) return -ENOMEM; @@ -1364,8 +1376,9 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, desc.wMaxPacketSize); dev->sliced_cc_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); - pr_debug("Alternate setting %i, max size= %i\n", i, - dev->sliced_cc_mode.alt_max_pkt_size[i]); + dev_dbg(&dev->udev->dev, + "Alternate setting %i, max size= %i\n", i, + dev->sliced_cc_mode.alt_max_pkt_size[i]); } return 0; @@ -1389,6 +1402,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, struct usb_interface_assoc_descriptor *assoc_desc; ifnum = interface->altsetting[0].desc.bInterfaceNumber; + udev = usb_get_dev(interface_to_usbdev(interface)); /* * Interface number 0 - IR interface (handled by mceusb driver) @@ -1402,13 +1416,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface, nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); if (nr >= CX231XX_MAXBOARDS) { /* No free device slots */ - pr_err("Supports only %i devices.\n", CX231XX_MAXBOARDS); + dev_err(&udev->dev, + "Supports only %i devices.\n", + CX231XX_MAXBOARDS); return -ENOMEM; } } while (test_and_set_bit(nr, &cx231xx_devused)); - udev = usb_get_dev(interface_to_usbdev(interface)); - /* allocate memory for our device state and initialize it */ dev = devm_kzalloc(&udev->dev, sizeof(*dev), GFP_KERNEL); if (dev == NULL) { @@ -1458,13 +1472,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface, speed = "unknown"; } - pr_info("New device %s %s @ %s Mbps (%04x:%04x) with %d interfaces\n", - udev->manufacturer ? udev->manufacturer : "", - udev->product ? udev->product : "", - speed, - le16_to_cpu(udev->descriptor.idVendor), - le16_to_cpu(udev->descriptor.idProduct), - dev->max_iad_interface_count); + dev_info(&udev->dev, + "New device %s %s @ %s Mbps (%04x:%04x) with %d interfaces\n", + udev->manufacturer ? udev->manufacturer : "", + udev->product ? udev->product : "", + speed, + le16_to_cpu(udev->descriptor.idVendor), + le16_to_cpu(udev->descriptor.idProduct), + dev->max_iad_interface_count); /* increment interface count */ dev->interface_count++; @@ -1474,12 +1489,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface, assoc_desc = udev->actconfig->intf_assoc[0]; if (assoc_desc->bFirstInterface != ifnum) { - pr_err("Not found matching IAD interface\n"); + dev_err(&udev->dev, "Not found matching IAD interface\n"); retval = -ENODEV; goto err_if; } - pr_debug("registering interface %d\n", ifnum); + dev_dbg(&udev->dev, "registering interface %d\n", ifnum); /* save our data pointer in this interface device */ usb_set_intfdata(interface, dev); @@ -1487,7 +1502,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, /* Create v4l2 device */ retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); if (retval) { - pr_err("v4l2_device_register failed\n"); + dev_err(&udev->dev, "v4l2_device_register failed\n"); goto err_v4l2; } @@ -1504,7 +1519,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface, /* compute alternate max packet sizes for TS1 */ idx = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index + 1; if (idx >= dev->max_iad_interface_count) { - pr_err("TS1 PCB interface #%d doesn't exist\n", idx); + dev_err(&udev->dev, + "TS1 PCB interface #%d doesn't exist\n", idx); retval = -ENODEV; goto err_video_alt; } @@ -1515,9 +1531,10 @@ static int cx231xx_usb_probe(struct usb_interface *interface, desc.bEndpointAddress; dev->ts1_mode.num_alt = uif->num_altsetting; - pr_info("TS EndPoint Addr 0x%x, Alternate settings: %i\n", - dev->ts1_mode.end_point_addr, - dev->ts1_mode.num_alt); + dev_info(&udev->dev, + "TS EndPoint Addr 0x%x, Alternate settings: %i\n", + dev->ts1_mode.end_point_addr, + dev->ts1_mode.num_alt); dev->ts1_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->ts1_mode.num_alt, GFP_KERNEL); if (dev->ts1_mode.alt_max_pkt_size == NULL) { @@ -1531,8 +1548,9 @@ static int cx231xx_usb_probe(struct usb_interface *interface, wMaxPacketSize); dev->ts1_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); - pr_debug("Alternate setting %i, max size= %i\n", i, - dev->ts1_mode.alt_max_pkt_size[i]); + dev_dbg(&udev->dev, + "Alternate setting %i, max size= %i\n", i, + dev->ts1_mode.alt_max_pkt_size[i]); } } @@ -1596,8 +1614,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) wake_up_interruptible_all(&dev->open); if (dev->users) { - pr_warn("device %s is open! Deregistration and memory deallocation are deferred on close.\n", - video_device_node_name(dev->vdev)); + dev_warn(&dev->udev->dev, + "device %s is open! Deregistration and memory deallocation are deferred on close.\n", + video_device_node_name(dev->vdev)); /* Even having users, it is safe to remove the RC i2c driver */ cx231xx_ir_exit(dev); |