From patchwork Wed Jul 18 13:58:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1211261 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 360B140071 for ; Wed, 18 Jul 2012 13:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754601Ab2GRN6g (ORCPT ); Wed, 18 Jul 2012 09:58:36 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:59150 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581Ab2GRN61 (ORCPT ); Wed, 18 Jul 2012 09:58:27 -0400 Received: from avalon.ideasonboard.com (unknown [91.178.171.146]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3DDAA35A8A; Wed, 18 Jul 2012 15:58:25 +0200 (CEST) From: Laurent Pinchart To: Guennadi Liakhovetski Cc: linux-media@vger.kernel.org Subject: [PATCH v2 5/9] ov772x: Make to_ov772x convert from v4l2_subdev to ov772x_priv Date: Wed, 18 Jul 2012 15:58:22 +0200 Message-Id: <1342619906-5820-6-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1342619906-5820-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1342619906-5820-1-git-send-email-laurent.pinchart@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Conversion from i2c_client to ov772x_priv is only needed in a single location, while conversion from v4l2_subdev to ov772x_priv is needed in several locations. Perform the former manually, and use to_ov772x for the later. Signed-off-by: Laurent Pinchart --- drivers/media/video/ov772x.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c index be3dfb5..2b95dd4 100644 --- a/drivers/media/video/ov772x.c +++ b/drivers/media/video/ov772x.c @@ -525,10 +525,9 @@ static const struct ov772x_win_size ov772x_win_sizes[] = { * general function */ -static struct ov772x_priv *to_ov772x(const struct i2c_client *client) +static struct ov772x_priv *to_ov772x(struct v4l2_subdev *sd) { - return container_of(i2c_get_clientdata(client), struct ov772x_priv, - subdev); + return container_of(sd, struct ov772x_priv, subdev); } static int ov772x_write_array(struct i2c_client *client, @@ -574,7 +573,7 @@ static int ov772x_reset(struct i2c_client *client) static int ov772x_s_stream(struct v4l2_subdev *sd, int enable) { struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); + struct ov772x_priv *priv = to_ov772x(sd); if (!enable) { ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE, SOFT_SLEEP_MODE); @@ -638,7 +637,7 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) static int ov772x_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id) { - struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); + struct ov772x_priv *priv = to_ov772x(sd); id->ident = priv->model; id->revision = 0; @@ -880,7 +879,7 @@ static int ov772x_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) static int ov772x_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { - struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); + struct ov772x_priv *priv = to_ov772x(sd); mf->width = priv->win->width; mf->height = priv->win->height; @@ -893,7 +892,7 @@ static int ov772x_g_fmt(struct v4l2_subdev *sd, static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { - struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); + struct ov772x_priv *priv = to_ov772x(sd); const struct ov772x_color_format *cfmt; const struct ov772x_win_size *win; int ret; @@ -933,9 +932,9 @@ static int ov772x_try_fmt(struct v4l2_subdev *sd, return 0; } -static int ov772x_video_probe(struct i2c_client *client) +static int ov772x_video_probe(struct ov772x_priv *priv) { - struct ov772x_priv *priv = to_ov772x(client); + struct i2c_client *client = v4l2_get_subdevdata(&priv->subdev); u8 pid, ver; const char *devname; int ret; @@ -1078,7 +1077,7 @@ static int ov772x_probe(struct i2c_client *client, goto done; } - ret = ov772x_video_probe(client); + ret = ov772x_video_probe(priv); if (ret < 0) goto done; @@ -1095,7 +1094,7 @@ done: static int ov772x_remove(struct i2c_client *client) { - struct ov772x_priv *priv = to_ov772x(client); + struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client)); v4l2_device_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl);