From patchwork Mon Apr 7 13:16:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3945391 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C47D9F370 for ; Mon, 7 Apr 2014 13:16:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 238DE2022D for ; Mon, 7 Apr 2014 13:16:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECC95201F7 for ; Mon, 7 Apr 2014 13:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755342AbaDGNQ3 (ORCPT ); Mon, 7 Apr 2014 09:16:29 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:38056 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755277AbaDGNQ2 (ORCPT ); Mon, 7 Apr 2014 09:16:28 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3N006P7WVFCW60@mailout3.samsung.com> for linux-media@vger.kernel.org; Mon, 07 Apr 2014 22:16:27 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-dc-5342a52beb95 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 8F.D0.28157.B25A2435; Mon, 07 Apr 2014 22:16:27 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N3N00MSNWV2V030@mmp2.samsung.com>; Mon, 07 Apr 2014 22:16:27 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: s.nawrocki@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH 1/8] [media] s5p-jpeg: Add fmt_ver_flag field to the s5p_jpeg_variant structure Date: Mon, 07 Apr 2014 15:16:06 +0200 Message-id: <1396876573-15811-1-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFJMWRmVeSWpSXmKPExsVy+t9jQV3tpU7BBieOSFj0Xn3OaHG26Q27 Rc+GrawWh9+0szqwePRtWcXo8XmTXABTFJdNSmpOZllqkb5dAlfG4f1zmQu6RCpeHljL3MB4 R6CLkYNDQsBE4u1X1S5GTiBTTOLCvfVsXYxcHEIC0xklJu/+wgaSEBJoZ5L4+7IexGYTMJT4 +eI1E4gtIiAv8aT3BhvIHGaBEolD6xVBwsICiRIX97cxgtgsAqoSk16fYQaxeQU8JKZfWsoG sVZBYs4kmwmM3AsYGVYxiqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBPv4mfQOxlUNFocYBTgY lXh4Aw84BguxJpYVV+YeYpTgYFYS4TXscgoW4k1JrKxKLcqPLyrNSS0+xCjNwaIkznuw1TpQ SCA9sSQ1OzW1ILUIJsvEwSnVwGjvutnuyydzt1mlRx61ffiq3hbmmc8p+kn83Z2LsT9rb1Y9 eSX0meP/wfNzQ3tjW2oaFTvsj2S7t1UUCcjNePX1PLcY8zeuLIHdt6qSWBwlzyxIqXzKx8fs 23zt+JJjKkGJ8+e5V7i+/6MkuJRr4vmQs+peIs7GYnrMFiFhXzZdWvCT1/j7SyWW4oxEQy3m ouJEAHqV+ELtAQAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify the code by adding fmt_ver_flag field to the s5p_jpeg_variant structure which allows to avoid "if" statement in the s5p_jpeg_find_format function. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 11 ++++------- drivers/media/platform/s5p-jpeg/jpeg-core.h | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 6db4d5e..9b0102d 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -959,7 +959,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f) static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx, u32 pixelformat, unsigned int fmt_type) { - unsigned int k, fmt_flag, ver_flag; + unsigned int k, fmt_flag; if (ctx->mode == S5P_JPEG_ENCODE) fmt_flag = (fmt_type == FMT_TYPE_OUTPUT) ? @@ -970,16 +970,11 @@ static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx, SJPEG_FMT_FLAG_DEC_OUTPUT : SJPEG_FMT_FLAG_DEC_CAPTURE; - if (ctx->jpeg->variant->version == SJPEG_S5P) - ver_flag = SJPEG_FMT_FLAG_S5P; - else - ver_flag = SJPEG_FMT_FLAG_EXYNOS4; - for (k = 0; k < ARRAY_SIZE(sjpeg_formats); k++) { struct s5p_jpeg_fmt *fmt = &sjpeg_formats[k]; if (fmt->fourcc == pixelformat && fmt->flags & fmt_flag && - fmt->flags & ver_flag) { + fmt->flags & ctx->jpeg->variant->fmt_ver_flag) { return fmt; } } @@ -2103,11 +2098,13 @@ static const struct dev_pm_ops s5p_jpeg_pm_ops = { static struct s5p_jpeg_variant s5p_jpeg_drvdata = { .version = SJPEG_S5P, .jpeg_irq = s5p_jpeg_irq, + .fmt_ver_flag = SJPEG_FMT_FLAG_S5P, }; static struct s5p_jpeg_variant exynos4_jpeg_drvdata = { .version = SJPEG_EXYNOS4, .jpeg_irq = exynos4_jpeg_irq, + .fmt_ver_flag = SJPEG_FMT_FLAG_EXYNOS4, }; static const struct of_device_id samsung_jpeg_match[] = { diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h index f482dbf..c222436 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h @@ -118,6 +118,7 @@ struct s5p_jpeg { struct s5p_jpeg_variant { unsigned int version; + unsigned int fmt_ver_flag; irqreturn_t (*jpeg_irq)(int irq, void *priv); };