V4L/DVB (9093): gspca: Cleanup code and small changes.
authorErik Andren <erik.andren@gmail.com>
Fri, 3 Oct 2008 11:46:50 +0000 (08:46 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 12 Oct 2008 11:37:13 +0000 (09:37 -0200)
- 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>
drivers/media/video/gspca/gspca.c
drivers/media/video/gspca/gspca.h
drivers/media/video/gspca/m5602/m5602_core.c

index 02824fc101d56c70acbb4ec79fe319e91a19eee1..9db3d899aa61bf602badea7a1e18fe03ba0a7adc 100644 (file)
@@ -237,7 +237,7 @@ static void bulk_irq(struct urb *urb
  * On LAST_PACKET, a new frame is returned.
  */
 struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
-                                   int packet_type,
+                                   enum gspca_packet_type packet_type,
                                    struct gspca_frame *frame,
                                    const __u8 *data,
                                    int len)
@@ -317,7 +317,6 @@ static void *rvmalloc(unsigned long size)
        void *mem;
        unsigned long adr;
 
-/*     size = PAGE_ALIGN(size);        (already done) */
        mem = vmalloc_32(size);
        if (mem != NULL) {
                adr = (unsigned long) mem;
@@ -937,7 +936,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
        memset(cap, 0, sizeof *cap);
        strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver);
-/*     strncpy(cap->card, gspca_dev->cam.dev_name, sizeof cap->card); */
        if (gspca_dev->dev->product != NULL) {
                strncpy(cap->card, gspca_dev->dev->product,
                        sizeof cap->card);
@@ -1571,7 +1569,6 @@ static int vidioc_qbuf(struct file *file, void *priv,
        }
 
        frame->v4l2_buf.flags |= V4L2_BUF_FLAG_QUEUED;
-/*     frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; */
 
        if (frame->v4l2_buf.memory == V4L2_MEMORY_USERPTR) {
                frame->v4l2_buf.m.userptr = v4l2_buf->m.userptr;
@@ -1836,22 +1833,21 @@ int gspca_dev_probe(struct usb_interface *intf,
        if (dev_size < sizeof *gspca_dev)
                dev_size = sizeof *gspca_dev;
        gspca_dev = kzalloc(dev_size, GFP_KERNEL);
-       if (gspca_dev == NULL) {
+       if (!gspca_dev) {
                err("couldn't kzalloc gspca struct");
-               return -EIO;
+               return -ENOMEM;
        }
        kref_init(&gspca_dev->kref);
        gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL);
        if (!gspca_dev->usb_buf) {
                err("out of memory");
-               ret = -EIO;
+               ret = -ENOMEM;
                goto out;
        }
        gspca_dev->dev = dev;
        gspca_dev->iface = interface->bInterfaceNumber;
        gspca_dev->nbalt = intf->num_altsetting;
        gspca_dev->sd_desc = sd_desc;
-/*     gspca_dev->users = 0;                   (done by kzalloc) */
        gspca_dev->nbufread = 2;
 
        /* configure the subdriver and initialize the USB device */
index f9006542c58f1b11aa76ffb59bd191c4da27e7ea..4779dd0b06da0145eeee191f4e0e2d3fe198446a 100644 (file)
@@ -106,10 +106,12 @@ struct sd_desc {
 };
 
 /* packet types when moving from iso buf to frame buf */
-#define DISCARD_PACKET 0
-#define FIRST_PACKET   1
-#define INTER_PACKET   2
-#define LAST_PACKET    3
+enum gspca_packet_type {
+       DISCARD_PACKET,
+       FIRST_PACKET,
+       INTER_PACKET,
+       LAST_PACKET
+};
 
 struct gspca_frame {
        __u8 *data;                     /* frame buffer */
@@ -175,7 +177,7 @@ int gspca_dev_probe(struct usb_interface *intf,
                struct module *module);
 void gspca_disconnect(struct usb_interface *intf);
 struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
-                                   int packet_type,
+                                   enum gspca_packet_type packet_type,
                                    struct gspca_frame *frame,
                                    const __u8 *data,
                                    int len);
index 559495e2d11ec77fdaf853ab76d95dd2addb4066..ac105ef4aa6af92beacb785fd793e8e7f8069086 100644 (file)
@@ -146,7 +146,6 @@ int m5602_probe_sensor(struct sd *sd)
                return 0;
        }
 
-
        /* More sensor probe function goes here */
        info("Failed to find a sensor");
        sd->sensor = NULL;