From patchwork Mon Dec 12 11:16:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 38579 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGObT-0000TK-TL; Mon, 12 Dec 2016 11:17:07 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-6) with esmtp id 1cGObR-0003MA-5j; Mon, 12 Dec 2016 12:17:07 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752372AbcLLLRD (ORCPT + 1 other); Mon, 12 Dec 2016 06:17:03 -0500 Received: from mout.gmx.net ([212.227.15.15]:62839 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751792AbcLLLRB (ORCPT ); Mon, 12 Dec 2016 06:17:01 -0500 Received: from axis700.grange ([89.0.199.8]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LkPBT-1cmzGC2z6p-00cNQH for ; Mon, 12 Dec 2016 12:16:59 +0100 Received: from 200r.grange (200r.grange [192.168.1.16]) by axis700.grange (Postfix) with ESMTP id 9EC808B11A for ; Mon, 12 Dec 2016 12:17:05 +0100 (CET) Received: from lyakh (uid 1000) (envelope-from g.liakhovetski@gmx.de) id 801cd2 by 200r.grange (DragonFly Mail Agent v0.9); Mon, 12 Dec 2016 12:16:52 +0100 From: Guennadi Liakhovetski To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Hans Verkuil , Guennadi Liakhovetski Subject: [PATCH v3 1/4] uvcvideo: (cosmetic) add and use an inline function Date: Mon, 12 Dec 2016 12:16:49 +0100 Message-Id: <1481541412-1186-2-git-send-email-guennadi.liakhovetski@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1481541412-1186-1-git-send-email-guennadi.liakhovetski@intel.com> References: <1481541412-1186-1-git-send-email-guennadi.liakhovetski@intel.com> X-Provags-ID: V03:K0:wTAXzpdJKfOzREXIHW9v0Yb7xtmSmKUoBtKY08vIStoqtNdxN7t D3sv/vvLBjM19uC73Fbq6Ub/4uTXdY8gyA1UtAK2QwYrMMWklq/HzdSahwpD5TSc4QF9ZhO CP2loxIqzurMijkFjsc6KQF7I+DFHoRR+W0AAFYzrln/6FuV9e69QhoucFZjM+TmxkM+zWE hZJbCxoTJ2ua0imJwq4Lg== X-UI-Out-Filterresults: notjunk:1; V01:K0:soTowAQkibw=:Xr4WWUE9gWDR9h5dVzvDZi Um53+QIIq1ZDcsM1zJiDjkErIwrVav7sh8tmN98yLi/6NsUVk2Nxmo0zfN31lHNCXg37BnJOw 9fg1mnWka1gjiWEwg46OI7LvmseAE93qL74JYkYH1MdnjBK/OR5hbR87N40XQ8dpxnAE0lalI 56gtiykARBtveNMlfqBATiRsWq9J8w/6C0xlRHAOTAj4jSr3I+BkO7YJ4pbzOwwxwENIGuRQo 0lm/OT68u4lZ2EDMuTlfaqDhilzodFyA7JBTHYCR/ubPlWk/mnAqEU8h4x6kdz0MuSYQvabxj AdiSOrNfOrKs4oRlr4gfhF0Suyu0mV0Q7Xf/WBGhlz/UWKHg//0JCB8GYfcFWUQwnMBhKKeSz vSY3bMk6kPZfEcz6uxhPPccVDt8pP6Gx9//ouu6Fz8mNLrDlUr5sTdbOg/IVptE8NL0hT6gdW g4e9mUhsAnAREErJY+TLW8V0FJiBaFO9QSTTcRwh+b3231YT8xTHAwwf1bzvyppFWKO+HZWrO xz+iIKrr9J7LrfRqZpwuSvk2yLUgy2HTg01D6TcU4RiGOwOirSMhNZXznHEvgI9tOy02zAjja edZBDMtRCRS1D56xBJ1EIis04R+7Dl+Ey/dNn8lFgqLPelGvsAw1d9AALdF8nvyOxyTflft53 yFmEqQi76L/MtjOEdz/cr9Tw93L/kFe1Inm5wyav8diZQFZjN6cDJ2bjIjcXcyhHiA0iooK/L itz/pQzB5DYVGBY1Y5SL0CKtUu6P+USRFoTXKyrHDxyDcTZChiC/d2j7c9Q= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.12.12.110920 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, IN_REP_TO 0, LEGITIMATE_NEGATE 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0' From: Guennadi Liakhovetski Add an inline function to obtain a struct uvc_buffer pointer from a struct vb2_v4l2_buffer one. Signed-off-by: Guennadi Liakhovetski Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_queue.c | 6 +++--- drivers/media/usb/uvc/uvcvideo.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index 77edd20..c119551 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c @@ -89,7 +89,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); - struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); + struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf); if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { @@ -116,7 +116,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); - struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); + struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf); unsigned long flags; spin_lock_irqsave(&queue->irqlock, flags); @@ -138,7 +138,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); struct uvc_streaming *stream = uvc_queue_to_stream(queue); - struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); + struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf); if (vb->state == VB2_BUF_STATE_DONE) uvc_video_clock_update(stream, vbuf, buf); diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 3d6cc62..a1e6a19 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -679,6 +679,10 @@ static inline int uvc_queue_streaming(struct uvc_video_queue *queue) { return vb2_is_streaming(&queue->queue); } +static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *vbuf) +{ + return container_of(vbuf, struct uvc_buffer, buf); +} /* V4L2 interface */ extern const struct v4l2_ioctl_ops uvc_ioctl_ops;