From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: mchehab@redhat.com
Cc: linux-media@vger.kernel.org,
"Frank Schäfer" <fschaefer.oss@googlemail.com>
Subject: [PATCH 1/9] em28xx: refactor get_next_buf() and use it for vbi data, too
Date: Sat, 8 Dec 2012 16:31:24 +0100 [thread overview]
Message-ID: <1354980692-3791-2-git-send-email-fschaefer.oss@googlemail.com> (raw)
In-Reply-To: <1354980692-3791-1-git-send-email-fschaefer.oss@googlemail.com>
get_next_buf() and vbi_get_next_buf() do exactly the same just with a
different dma queue and buffer. Saving the new buffer pointer back to the
device struct in em28xx_urb_data_copy() instead of doing this from inside
these functions makes it possible to get rid of one of them.
Also refactor the function parameters and return type:
- pass a pointer to struct em28xx as parameter (instead of obtaining the
pointer from the dma queue pointer with the container_of macro) like we do
it in all other functions
- instead of using a pointer-pointer, return the pointer to the new buffer
as return value of the function
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
drivers/media/usb/em28xx/em28xx-video.c | 58 ++++++++-----------------------
1 Datei geändert, 15 Zeilen hinzugefügt(+), 43 Zeilen entfernt(-)
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 6282d48..6acdfea 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -358,57 +358,26 @@ static inline void print_err_status(struct em28xx *dev,
}
/*
- * video-buf generic routine to get the next available buffer
+ * get the next available buffer from dma queue
*/
-static inline void get_next_buf(struct em28xx_dmaqueue *dma_q,
- struct em28xx_buffer **buf)
+static inline struct em28xx_buffer *get_next_buf(struct em28xx *dev,
+ struct em28xx_dmaqueue *dma_q)
{
- struct em28xx *dev = container_of(dma_q, struct em28xx, vidq);
+ struct em28xx_buffer *buf;
char *outp;
if (list_empty(&dma_q->active)) {
em28xx_usbdbg("No active queue to serve\n");
- dev->usb_ctl.vid_buf = NULL;
- *buf = NULL;
- return;
- }
-
- /* Get the next buffer */
- *buf = list_entry(dma_q->active.next, struct em28xx_buffer, vb.queue);
- /* Cleans up buffer - Useful for testing for frame/URB loss */
- outp = videobuf_to_vmalloc(&(*buf)->vb);
- memset(outp, 0, (*buf)->vb.size);
-
- dev->usb_ctl.vid_buf = *buf;
-
- return;
-}
-
-/*
- * video-buf generic routine to get the next available VBI buffer
- */
-static inline void vbi_get_next_buf(struct em28xx_dmaqueue *dma_q,
- struct em28xx_buffer **buf)
-{
- struct em28xx *dev = container_of(dma_q, struct em28xx, vbiq);
- char *outp;
-
- if (list_empty(&dma_q->active)) {
- em28xx_usbdbg("No active queue to serve\n");
- dev->usb_ctl.vbi_buf = NULL;
- *buf = NULL;
- return;
+ return NULL;
}
/* Get the next buffer */
- *buf = list_entry(dma_q->active.next, struct em28xx_buffer, vb.queue);
+ buf = list_entry(dma_q->active.next, struct em28xx_buffer, vb.queue);
/* Cleans up buffer - Useful for testing for frame/URB loss */
- outp = videobuf_to_vmalloc(&(*buf)->vb);
- memset(outp, 0x00, (*buf)->vb.size);
-
- dev->usb_ctl.vbi_buf = *buf;
+ outp = videobuf_to_vmalloc(&buf->vb);
+ memset(outp, 0, buf->vb.size);
- return;
+ return buf;
}
/* Processes and copies the URB data content (video and VBI data) */
@@ -518,7 +487,8 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
vbi_buffer_filled(dev,
vbi_dma_q,
vbi_buf);
- vbi_get_next_buf(vbi_dma_q, &vbi_buf);
+ vbi_buf = get_next_buf(dev, vbi_dma_q);
+ dev->usb_ctl.vbi_buf = vbi_buf;
if (vbi_buf == NULL)
vbioutp = NULL;
else
@@ -529,7 +499,8 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
if (dev->vbi_read == 0) {
vbi_dma_q->pos = 0;
if (vbi_buf != NULL)
- vbi_buf->top_field = dev->top_field;
+ vbi_buf->top_field
+ = dev->top_field;
}
dev->vbi_read += len;
@@ -553,7 +524,8 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
if (dev->progressive || dev->top_field) {
if (buf != NULL)
buffer_filled(dev, dma_q, buf);
- get_next_buf(dma_q, &buf);
+ buf = get_next_buf(dev, dma_q);
+ dev->usb_ctl.vid_buf = buf;
if (buf == NULL)
outp = NULL;
else
--
1.7.10.4
next prev parent reply other threads:[~2012-12-08 15:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-08 15:31 [PATCH 0/9] em28xx: refactor the frame data processing code Frank Schäfer
2012-12-08 15:31 ` Frank Schäfer [this message]
2012-12-08 15:31 ` [PATCH 2/9] em28xx: use common function for video and vbi buffer completion Frank Schäfer
2012-12-08 15:31 ` [PATCH 3/9] em28xx: remove obsolete field 'frame' from struct em28xx_buffer Frank Schäfer
2012-12-08 15:31 ` [PATCH 4/9] em28xx: move field 'pos' from struct em28xx_dmaqueue to " Frank Schäfer
2012-12-08 15:31 ` [PATCH 5/9] em28xx: refactor VBI data processing code in em28xx_urb_data_copy() Frank Schäfer
2012-12-08 15:31 ` [PATCH 6/9] em28xx: move caching of pointer to vmalloc memory in videobuf to struct em28xx_buffer Frank Schäfer
2012-12-08 15:31 ` [PATCH 7/9] em28xx: em28xx_urb_data_copy(): move duplicate code for capture_type=0 and capture_type=2 to a function Frank Schäfer
2012-12-08 15:31 ` [PATCH 8/9] em28xx: move the em2710/em2750/em28xx specific frame data processing code to a separate function Frank Schäfer
2012-12-08 15:31 ` [PATCH 9/9] em28xx: clean up and unify functions em28xx_copy_vbi() em28xx_copy_video() Frank Schäfer
[not found] ` <CAGoCfiw1wN+KgvNLqDSmbz5AwswPT9K48XOM4RnfKvHkmmR59g@mail.gmail.com>
2012-12-13 17:56 ` [PATCH 0/9] em28xx: refactor the frame data processing code Frank Schäfer
2012-12-13 18:16 ` Devin Heitmueller
2012-12-14 15:24 ` Frank Schäfer
2012-12-14 15:29 ` Devin Heitmueller
2012-12-14 15:45 ` Frank Schäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354980692-3791-2-git-send-email-fschaefer.oss@googlemail.com \
--to=fschaefer.oss@googlemail.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.