aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorErik Andren <erik.andren@gmail.com>2008-10-03 07:46:50 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:37:13 -0400
commite293e599524f74532b0add53ddf80f10ff854598 (patch)
treeec8306de58b273b79e507df183f0d9cec835ef5d /drivers
parentc109f8168f259ea1f1ab7009c6b99dbe8ea0e2b2 (diff)
V4L/DVB (9093): gspca: Cleanup code and small changes.
- convert some #define to enum. - remove some comments. - return ENOMEM on memory allocation failure. Signed-off-by: Erik Andren <erik.andren@gmail.com> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/gspca.c12
-rw-r--r--drivers/media/video/gspca/gspca.h12
-rw-r--r--drivers/media/video/gspca/m5602/m5602_core.c1
3 files changed, 11 insertions, 14 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 02824fc101d5..9db3d899aa61 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -237,7 +237,7 @@ static void bulk_irq(struct urb *urb
237 * On LAST_PACKET, a new frame is returned. 237 * On LAST_PACKET, a new frame is returned.
238 */ 238 */
239struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, 239struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
240 int packet_type, 240 enum gspca_packet_type packet_type,
241 struct gspca_frame *frame, 241 struct gspca_frame *frame,
242 const __u8 *data, 242 const __u8 *data,
243 int len) 243 int len)
@@ -317,7 +317,6 @@ static void *rvmalloc(unsigned long size)
317 void *mem; 317 void *mem;
318 unsigned long adr; 318 unsigned long adr;
319 319
320/* size = PAGE_ALIGN(size); (already done) */
321 mem = vmalloc_32(size); 320 mem = vmalloc_32(size);
322 if (mem != NULL) { 321 if (mem != NULL) {
323 adr = (unsigned long) mem; 322 adr = (unsigned long) mem;
@@ -937,7 +936,6 @@ static int vidioc_querycap(struct file *file, void *priv,
937 936
938 memset(cap, 0, sizeof *cap); 937 memset(cap, 0, sizeof *cap);
939 strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver); 938 strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver);
940/* strncpy(cap->card, gspca_dev->cam.dev_name, sizeof cap->card); */
941 if (gspca_dev->dev->product != NULL) { 939 if (gspca_dev->dev->product != NULL) {
942 strncpy(cap->card, gspca_dev->dev->product, 940 strncpy(cap->card, gspca_dev->dev->product,
943 sizeof cap->card); 941 sizeof cap->card);
@@ -1571,7 +1569,6 @@ static int vidioc_qbuf(struct file *file, void *priv,
1571 } 1569 }
1572 1570
1573 frame->v4l2_buf.flags |= V4L2_BUF_FLAG_QUEUED; 1571 frame->v4l2_buf.flags |= V4L2_BUF_FLAG_QUEUED;
1574/* frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; */
1575 1572
1576 if (frame->v4l2_buf.memory == V4L2_MEMORY_USERPTR) { 1573 if (frame->v4l2_buf.memory == V4L2_MEMORY_USERPTR) {
1577 frame->v4l2_buf.m.userptr = v4l2_buf->m.userptr; 1574 frame->v4l2_buf.m.userptr = v4l2_buf->m.userptr;
@@ -1836,22 +1833,21 @@ int gspca_dev_probe(struct usb_interface *intf,
1836 if (dev_size < sizeof *gspca_dev) 1833 if (dev_size < sizeof *gspca_dev)
1837 dev_size = sizeof *gspca_dev; 1834 dev_size = sizeof *gspca_dev;
1838 gspca_dev = kzalloc(dev_size, GFP_KERNEL); 1835 gspca_dev = kzalloc(dev_size, GFP_KERNEL);
1839 if (gspca_dev == NULL) { 1836 if (!gspca_dev) {
1840 err("couldn't kzalloc gspca struct"); 1837 err("couldn't kzalloc gspca struct");
1841 return -EIO; 1838 return -ENOMEM;
1842 } 1839 }
1843 kref_init(&gspca_dev->kref); 1840 kref_init(&gspca_dev->kref);
1844 gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL); 1841 gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL);
1845 if (!gspca_dev->usb_buf) { 1842 if (!gspca_dev->usb_buf) {
1846 err("out of memory"); 1843 err("out of memory");
1847 ret = -EIO; 1844 ret = -ENOMEM;
1848 goto out; 1845 goto out;
1849 } 1846 }
1850 gspca_dev->dev = dev; 1847 gspca_dev->dev = dev;
1851 gspca_dev->iface = interface->bInterfaceNumber; 1848 gspca_dev->iface = interface->bInterfaceNumber;
1852 gspca_dev->nbalt = intf->num_altsetting; 1849 gspca_dev->nbalt = intf->num_altsetting;
1853 gspca_dev->sd_desc = sd_desc; 1850 gspca_dev->sd_desc = sd_desc;
1854/* gspca_dev->users = 0; (done by kzalloc) */
1855 gspca_dev->nbufread = 2; 1851 gspca_dev->nbufread = 2;
1856 1852
1857 /* configure the subdriver and initialize the USB device */ 1853 /* configure the subdriver and initialize the USB device */
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index f9006542c58f..4779dd0b06da 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -106,10 +106,12 @@ struct sd_desc {
106}; 106};
107 107
108/* packet types when moving from iso buf to frame buf */ 108/* packet types when moving from iso buf to frame buf */
109#define DISCARD_PACKET 0 109enum gspca_packet_type {
110#define FIRST_PACKET 1 110 DISCARD_PACKET,
111#define INTER_PACKET 2 111 FIRST_PACKET,
112#define LAST_PACKET 3 112 INTER_PACKET,
113 LAST_PACKET
114};
113 115
114struct gspca_frame { 116struct gspca_frame {
115 __u8 *data; /* frame buffer */ 117 __u8 *data; /* frame buffer */
@@ -175,7 +177,7 @@ int gspca_dev_probe(struct usb_interface *intf,
175 struct module *module); 177 struct module *module);
176void gspca_disconnect(struct usb_interface *intf); 178void gspca_disconnect(struct usb_interface *intf);
177struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, 179struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
178 int packet_type, 180 enum gspca_packet_type packet_type,
179 struct gspca_frame *frame, 181 struct gspca_frame *frame,
180 const __u8 *data, 182 const __u8 *data,
181 int len); 183 int len);
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c
index 559495e2d11e..ac105ef4aa6a 100644
--- a/drivers/media/video/gspca/m5602/m5602_core.c
+++ b/drivers/media/video/gspca/m5602/m5602_core.c
@@ -146,7 +146,6 @@ int m5602_probe_sensor(struct sd *sd)
146 return 0; 146 return 0;
147 } 147 }
148 148
149
150 /* More sensor probe function goes here */ 149 /* More sensor probe function goes here */
151 info("Failed to find a sensor"); 150 info("Failed to find a sensor");
152 sd->sensor = NULL; 151 sd->sensor = NULL;