Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752038AbdHJXpy (ORCPT ); Thu, 10 Aug 2017 19:45:54 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:56978 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751388AbdHJXpw (ORCPT ); Thu, 10 Aug 2017 19:45:52 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Jonathan Corbet , Hans Verkuil , Sakari Ailus , Laurent Pinchart , Stanimir Varbanov , Tomasz Figa Subject: [PATCH 3/3] media: compat32: reimplement ctrl_is_pointer() Date: Thu, 10 Aug 2017 20:45:13 -0300 Message-Id: <69f3826e29c64fb9358ce6fb9146f9b4330c33f4.1502408518.git.mchehab@s-opensource.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3222 Lines: 98 The current way that this function works is subject to problems as new controls gets added. Move it to v4l2-ctrls and use the knowledge that v4l2_ctrl_fill() has about controls, in order to detect if a given control is a pointer. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 18 +----------------- drivers/media/v4l2-core/v4l2-ctrls.c | 18 ++++++++++++++++++ include/media/v4l2-ctrls.h | 8 ++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 6f52970f8b54..1105e04dec3d 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -19,6 +19,7 @@ #include #include #include +#include static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -665,23 +666,6 @@ struct v4l2_ext_control32 { }; } __attribute__ ((packed)); -/* The following function really belong in v4l2-common, but that causes - a circular dependency between modules. We need to think about this, but - for now this will do. */ - -/* Return non-zero if this control is a pointer type. Currently only - type STRING is a pointer type. */ -static inline int ctrl_is_pointer(u32 id) -{ - switch (id) { - case V4L2_CID_RDS_TX_PS_NAME: - case V4L2_CID_RDS_TX_RADIO_TEXT: - return 1; - default: - return 0; - } -} - static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up) { struct v4l2_ext_control32 __user *ucontrols; diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index c512b7539077..0d5dab485723 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1254,6 +1254,24 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, } EXPORT_SYMBOL(v4l2_ctrl_fill); +bool ctrl_is_pointer(u32 id) +{ + enum v4l2_ctrl_type type; + + v4l2_ctrl_fill(id, NULL, &type, NULL, NULL, NULL, NULL, NULL); + + switch (type) { + case V4L2_CTRL_TYPE_STRING: + case V4L2_CTRL_TYPE_U8: + case V4L2_CTRL_TYPE_U16: + case V4L2_CTRL_TYPE_U32: + return true; + default: + return false; + } +} +EXPORT_SYMBOL(ctrl_is_pointer); + static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) { memset(ev->reserved, 0, sizeof(ev->reserved)); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index e22dea218a4c..bc6772f50956 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -367,6 +367,14 @@ struct v4l2_ctrl_config { void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags); +/** + * ctrl_is_pointer - Returns non-zero if this control is a pointer type. + * + * @id: ID of the control + * + * Currently only STRING and compound types are pointers. + */ +bool ctrl_is_pointer(u32 id); /** * v4l2_ctrl_handler_init_class() - Initialize the control handler. -- 2.13.3