提交 e293e599 编写于 作者: E Erik Andren 提交者: 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: NErik Andren <erik.andren@gmail.com>
Signed-off-by: NJean-Francois Moine <moinejf@free.fr>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 c109f816
...@@ -237,7 +237,7 @@ static void bulk_irq(struct urb *urb ...@@ -237,7 +237,7 @@ static void bulk_irq(struct urb *urb
* On LAST_PACKET, a new frame is returned. * On LAST_PACKET, a new frame is returned.
*/ */
struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
int packet_type, enum gspca_packet_type packet_type,
struct gspca_frame *frame, struct gspca_frame *frame,
const __u8 *data, const __u8 *data,
int len) int len)
...@@ -317,7 +317,6 @@ static void *rvmalloc(unsigned long size) ...@@ -317,7 +317,6 @@ static void *rvmalloc(unsigned long size)
void *mem; void *mem;
unsigned long adr; unsigned long adr;
/* size = PAGE_ALIGN(size); (already done) */
mem = vmalloc_32(size); mem = vmalloc_32(size);
if (mem != NULL) { if (mem != NULL) {
adr = (unsigned long) mem; adr = (unsigned long) mem;
...@@ -937,7 +936,6 @@ static int vidioc_querycap(struct file *file, void *priv, ...@@ -937,7 +936,6 @@ static int vidioc_querycap(struct file *file, void *priv,
memset(cap, 0, sizeof *cap); memset(cap, 0, sizeof *cap);
strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver); 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) { if (gspca_dev->dev->product != NULL) {
strncpy(cap->card, gspca_dev->dev->product, strncpy(cap->card, gspca_dev->dev->product,
sizeof cap->card); sizeof cap->card);
...@@ -1571,7 +1569,6 @@ static int vidioc_qbuf(struct file *file, void *priv, ...@@ -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_QUEUED;
/* frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; */
if (frame->v4l2_buf.memory == V4L2_MEMORY_USERPTR) { if (frame->v4l2_buf.memory == V4L2_MEMORY_USERPTR) {
frame->v4l2_buf.m.userptr = v4l2_buf->m.userptr; frame->v4l2_buf.m.userptr = v4l2_buf->m.userptr;
...@@ -1836,22 +1833,21 @@ int gspca_dev_probe(struct usb_interface *intf, ...@@ -1836,22 +1833,21 @@ int gspca_dev_probe(struct usb_interface *intf,
if (dev_size < sizeof *gspca_dev) if (dev_size < sizeof *gspca_dev)
dev_size = sizeof *gspca_dev; dev_size = sizeof *gspca_dev;
gspca_dev = kzalloc(dev_size, GFP_KERNEL); gspca_dev = kzalloc(dev_size, GFP_KERNEL);
if (gspca_dev == NULL) { if (!gspca_dev) {
err("couldn't kzalloc gspca struct"); err("couldn't kzalloc gspca struct");
return -EIO; return -ENOMEM;
} }
kref_init(&gspca_dev->kref); kref_init(&gspca_dev->kref);
gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL); gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL);
if (!gspca_dev->usb_buf) { if (!gspca_dev->usb_buf) {
err("out of memory"); err("out of memory");
ret = -EIO; ret = -ENOMEM;
goto out; goto out;
} }
gspca_dev->dev = dev; gspca_dev->dev = dev;
gspca_dev->iface = interface->bInterfaceNumber; gspca_dev->iface = interface->bInterfaceNumber;
gspca_dev->nbalt = intf->num_altsetting; gspca_dev->nbalt = intf->num_altsetting;
gspca_dev->sd_desc = sd_desc; gspca_dev->sd_desc = sd_desc;
/* gspca_dev->users = 0; (done by kzalloc) */
gspca_dev->nbufread = 2; gspca_dev->nbufread = 2;
/* configure the subdriver and initialize the USB device */ /* configure the subdriver and initialize the USB device */
......
...@@ -106,10 +106,12 @@ struct sd_desc { ...@@ -106,10 +106,12 @@ struct sd_desc {
}; };
/* packet types when moving from iso buf to frame buf */ /* packet types when moving from iso buf to frame buf */
#define DISCARD_PACKET 0 enum gspca_packet_type {
#define FIRST_PACKET 1 DISCARD_PACKET,
#define INTER_PACKET 2 FIRST_PACKET,
#define LAST_PACKET 3 INTER_PACKET,
LAST_PACKET
};
struct gspca_frame { struct gspca_frame {
__u8 *data; /* frame buffer */ __u8 *data; /* frame buffer */
...@@ -175,7 +177,7 @@ int gspca_dev_probe(struct usb_interface *intf, ...@@ -175,7 +177,7 @@ int gspca_dev_probe(struct usb_interface *intf,
struct module *module); struct module *module);
void gspca_disconnect(struct usb_interface *intf); void gspca_disconnect(struct usb_interface *intf);
struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
int packet_type, enum gspca_packet_type packet_type,
struct gspca_frame *frame, struct gspca_frame *frame,
const __u8 *data, const __u8 *data,
int len); int len);
......
...@@ -146,7 +146,6 @@ int m5602_probe_sensor(struct sd *sd) ...@@ -146,7 +146,6 @@ int m5602_probe_sensor(struct sd *sd)
return 0; return 0;
} }
/* More sensor probe function goes here */ /* More sensor probe function goes here */
info("Failed to find a sensor"); info("Failed to find a sensor");
sd->sensor = NULL; sd->sensor = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册