From patchwork Fri Jan 23 15:52:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 5695021 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E3E14C058E for ; Fri, 23 Jan 2015 15:52:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36E5B20260 for ; Fri, 23 Jan 2015 15:52:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C11C20304 for ; Fri, 23 Jan 2015 15:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755765AbbAWPwn (ORCPT ); Fri, 23 Jan 2015 10:52:43 -0500 Received: from smtp-out-190.synserver.de ([212.40.185.190]:1095 "EHLO smtp-out-190.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755667AbbAWPwk (ORCPT ); Fri, 23 Jan 2015 10:52:40 -0500 Received: (qmail 16156 invoked by uid 0); 23 Jan 2015 15:52:38 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 15834 Received: from p4fc46056.dip0.t-ipconnect.de (HELO lars-adi-laptop.analog.com) [79.196.96.86] by 217.119.54.81 with SMTP; 23 Jan 2015 15:52:38 -0000 From: Lars-Peter Clausen To: Hans Verkuil Cc: Sergei Shtylyov , Vladimir Barinov , =?UTF-8?q?Richard=20R=C3=B6jfors?= , Federico Vaga , linux-media@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH v2 03/15] [media] adv7180: Use inline function instead of macro Date: Fri, 23 Jan 2015 16:52:22 +0100 Message-Id: <1422028354-31891-4-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1422028354-31891-1-git-send-email-lars@metafoo.de> References: <1422028354-31891-1-git-send-email-lars@metafoo.de> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Use a inline function instead of a macro for the container_of helper for getting the driver's state struct from a control. A inline function has the advantage that it is more typesafe and nicer in general. Signed-off-by: Lars-Peter Clausen Acked-by: Hans Verkuil --- drivers/media/i2c/adv7180.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index f424a4d..f2508abe 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -130,9 +130,11 @@ struct adv7180_state { bool powered; u8 input; }; -#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \ - struct adv7180_state, \ - ctrl_hdl)->sd) + +static struct adv7180_state *ctrl_to_adv7180(struct v4l2_ctrl *ctrl) +{ + return container_of(ctrl->handler, struct adv7180_state, ctrl_hdl); +} static v4l2_std_id adv7180_std_to_v4l2(u8 status1) { @@ -345,9 +347,8 @@ static int adv7180_s_power(struct v4l2_subdev *sd, int on) static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl) { - struct v4l2_subdev *sd = to_adv7180_sd(ctrl); - struct adv7180_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); + struct adv7180_state *state = ctrl_to_adv7180(ctrl); + struct i2c_client *client = v4l2_get_subdevdata(&state->sd); int ret = mutex_lock_interruptible(&state->mutex); int val;