Commit e293e599 authored by Erik Andren's avatar Erik Andren Committed by Mauro Carvalho Chehab

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: default avatarErik Andren <erik.andren@gmail.com>
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c109f816
......@@ -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 */
......
......@@ -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);
......
......@@ -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;
......
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