Commit 0cf544a6 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[media] em28xx: rename some USB parameter fields in struct em28xx to clarify their role

Also improve the comments.
Signed-off-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent a950e4a7
...@@ -3183,9 +3183,10 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -3183,9 +3183,10 @@ static int em28xx_usb_probe(struct usb_interface *interface,
} }
/* compute alternate max packet sizes */ /* compute alternate max packet sizes */
dev->alt_max_pkt_size = kmalloc(sizeof(dev->alt_max_pkt_size[0]) * dev->alt_max_pkt_size_isoc =
kmalloc(sizeof(dev->alt_max_pkt_size_isoc[0]) *
interface->num_altsetting, GFP_KERNEL); interface->num_altsetting, GFP_KERNEL);
if (dev->alt_max_pkt_size == NULL) { if (dev->alt_max_pkt_size_isoc == NULL) {
em28xx_errdev("out of memory!\n"); em28xx_errdev("out of memory!\n");
kfree(dev); kfree(dev);
retval = -ENOMEM; retval = -ENOMEM;
...@@ -3216,13 +3217,14 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -3216,13 +3217,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
break; break;
case EM28XX_EP_ANALOG: case EM28XX_EP_ANALOG:
has_video = true; has_video = true;
dev->alt_max_pkt_size[i] = size; dev->alt_max_pkt_size_isoc[i] = size;
break; break;
case EM28XX_EP_DIGITAL: case EM28XX_EP_DIGITAL:
has_dvb = true; has_dvb = true;
if (size > dev->dvb_max_pkt_size) { if (size > dev->dvb_max_pkt_size_isoc) {
dev->dvb_max_pkt_size = size; dev->dvb_max_pkt_size_isoc =
dev->dvb_alt = i; size;
dev->dvb_alt_isoc = i;
} }
break; break;
} }
...@@ -3324,7 +3326,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -3324,7 +3326,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
/* pre-allocate DVB isoc transfer buffers */ /* pre-allocate DVB isoc transfer buffers */
retval = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE, 0, retval = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE, 0,
EM28XX_DVB_NUM_BUFS, EM28XX_DVB_NUM_BUFS,
dev->dvb_max_pkt_size, dev->dvb_max_pkt_size_isoc,
EM28XX_DVB_NUM_ISOC_PACKETS); EM28XX_DVB_NUM_ISOC_PACKETS);
if (retval) { if (retval) {
goto unlock_and_free; goto unlock_and_free;
...@@ -3344,7 +3346,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -3344,7 +3346,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
err_free: err_free:
kfree(dev->alt_max_pkt_size); kfree(dev->alt_max_pkt_size_isoc);
kfree(dev); kfree(dev);
err: err:
...@@ -3409,7 +3411,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) ...@@ -3409,7 +3411,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
em28xx_close_extension(dev); em28xx_close_extension(dev);
if (!dev->users) { if (!dev->users) {
kfree(dev->alt_max_pkt_size); kfree(dev->alt_max_pkt_size_isoc);
kfree(dev); kfree(dev);
} }
} }
......
...@@ -830,14 +830,14 @@ int em28xx_set_alternate(struct em28xx *dev) ...@@ -830,14 +830,14 @@ int em28xx_set_alternate(struct em28xx *dev)
for (i = 0; i < dev->num_alt; i++) { for (i = 0; i < dev->num_alt; i++) {
/* stop when the selected alt setting offers enough bandwidth */ /* stop when the selected alt setting offers enough bandwidth */
if (dev->alt_max_pkt_size[i] >= min_pkt_size) { if (dev->alt_max_pkt_size_isoc[i] >= min_pkt_size) {
dev->alt = i; dev->alt = i;
break; break;
/* otherwise make sure that we end up with the maximum bandwidth /* otherwise make sure that we end up with the maximum bandwidth
because the min_pkt_size equation might be wrong... because the min_pkt_size equation might be wrong...
*/ */
} else if (dev->alt_max_pkt_size[i] > } else if (dev->alt_max_pkt_size_isoc[i] >
dev->alt_max_pkt_size[dev->alt]) dev->alt_max_pkt_size_isoc[dev->alt])
dev->alt = i; dev->alt = i;
} }
...@@ -845,7 +845,7 @@ int em28xx_set_alternate(struct em28xx *dev) ...@@ -845,7 +845,7 @@ int em28xx_set_alternate(struct em28xx *dev)
if (dev->alt != prev_alt) { if (dev->alt != prev_alt) {
em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n",
min_pkt_size, dev->alt); min_pkt_size, dev->alt);
dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; dev->max_pkt_size = dev->alt_max_pkt_size_isoc[dev->alt];
em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
dev->alt, dev->max_pkt_size); dev->alt, dev->max_pkt_size);
errCode = usb_set_interface(dev->udev, 0, dev->alt); errCode = usb_set_interface(dev->udev, 0, dev->alt);
......
...@@ -178,12 +178,12 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb) ...@@ -178,12 +178,12 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
struct em28xx *dev = dvb->adapter.priv; struct em28xx *dev = dvb->adapter.priv;
int max_dvb_packet_size; int max_dvb_packet_size;
usb_set_interface(dev->udev, 0, dev->dvb_alt); usb_set_interface(dev->udev, 0, dev->dvb_alt_isoc);
rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
if (rc < 0) if (rc < 0)
return rc; return rc;
max_dvb_packet_size = dev->dvb_max_pkt_size; max_dvb_packet_size = dev->dvb_max_pkt_size_isoc;
if (max_dvb_packet_size < 0) if (max_dvb_packet_size < 0)
return max_dvb_packet_size; return max_dvb_packet_size;
dprintk(1, "Using %d buffers each with %d x %d bytes\n", dprintk(1, "Using %d buffers each with %d x %d bytes\n",
......
...@@ -2286,7 +2286,7 @@ static int em28xx_v4l2_close(struct file *filp) ...@@ -2286,7 +2286,7 @@ static int em28xx_v4l2_close(struct file *filp)
free the remaining resources */ free the remaining resources */
if (dev->state & DEV_DISCONNECTED) { if (dev->state & DEV_DISCONNECTED) {
em28xx_release_resources(dev); em28xx_release_resources(dev);
kfree(dev->alt_max_pkt_size); kfree(dev->alt_max_pkt_size_isoc);
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
kfree(dev); kfree(dev);
kfree(fh); kfree(fh);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com>
Ludovico Cavedon <cavedon@sssup.it> Ludovico Cavedon <cavedon@sssup.it>
Mauro Carvalho Chehab <mchehab@infradead.org> Mauro Carvalho Chehab <mchehab@infradead.org>
Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com>
Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de> Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de>
...@@ -583,12 +584,13 @@ struct em28xx { ...@@ -583,12 +584,13 @@ struct em28xx {
/* usb transfer */ /* usb transfer */
struct usb_device *udev; /* the usb device */ struct usb_device *udev; /* the usb device */
int alt; /* alternate */ int alt; /* alternate setting */
int max_pkt_size; /* max packet size of isoc transaction */ int max_pkt_size; /* max packet size of the selected ep at alt */
int num_alt; /* Number of alternative settings */ int num_alt; /* number of alternative settings */
unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ unsigned int *alt_max_pkt_size_isoc; /* array of isoc wMaxPacketSize */
int dvb_alt; /* alternate for DVB */ int dvb_alt_isoc; /* alternate setting for DVB isoc transfers */
unsigned int dvb_max_pkt_size; /* wMaxPacketSize for DVB */ unsigned int dvb_max_pkt_size_isoc; /* isoc max packet size of the
selected DVB ep at dvb_alt */
char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
/* helper funcs that call usb_control_msg */ /* helper funcs that call usb_control_msg */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment