aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-07-18 09:58:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-15 16:10:49 -0400
commit47de502b04612824e9293ed0474882b461be49d9 (patch)
tree036ab9a0579c21506a2b4ddbe1ed921f55454a7d /drivers/media
parent9f717e9022d60fb653bad47a320bf0499c6fb549 (diff)
[media] ov772x: Make to_ov772x convert from v4l2_subdev to ov772x_priv
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 <laurent.pinchart@ideasonboard.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/i2c/soc_camera/ov772x.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
index c02676b023f2..2b68f04578d2 100644
--- a/drivers/media/i2c/soc_camera/ov772x.c
+++ b/drivers/media/i2c/soc_camera/ov772x.c
@@ -525,10 +525,9 @@ static const struct ov772x_win_size ov772x_win_sizes[] = {
525 * general function 525 * general function
526 */ 526 */
527 527
528static struct ov772x_priv *to_ov772x(const struct i2c_client *client) 528static struct ov772x_priv *to_ov772x(struct v4l2_subdev *sd)
529{ 529{
530 return container_of(i2c_get_clientdata(client), struct ov772x_priv, 530 return container_of(sd, struct ov772x_priv, subdev);
531 subdev);
532} 531}
533 532
534static int ov772x_write_array(struct i2c_client *client, 533static int ov772x_write_array(struct i2c_client *client,
@@ -574,7 +573,7 @@ static int ov772x_reset(struct i2c_client *client)
574static int ov772x_s_stream(struct v4l2_subdev *sd, int enable) 573static int ov772x_s_stream(struct v4l2_subdev *sd, int enable)
575{ 574{
576 struct i2c_client *client = v4l2_get_subdevdata(sd); 575 struct i2c_client *client = v4l2_get_subdevdata(sd);
577 struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); 576 struct ov772x_priv *priv = to_ov772x(sd);
578 577
579 if (!enable) { 578 if (!enable) {
580 ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE, SOFT_SLEEP_MODE); 579 ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE, SOFT_SLEEP_MODE);
@@ -638,7 +637,7 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
638static int ov772x_g_chip_ident(struct v4l2_subdev *sd, 637static int ov772x_g_chip_ident(struct v4l2_subdev *sd,
639 struct v4l2_dbg_chip_ident *id) 638 struct v4l2_dbg_chip_ident *id)
640{ 639{
641 struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); 640 struct ov772x_priv *priv = to_ov772x(sd);
642 641
643 id->ident = priv->model; 642 id->ident = priv->model;
644 id->revision = 0; 643 id->revision = 0;
@@ -880,7 +879,7 @@ static int ov772x_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
880static int ov772x_g_fmt(struct v4l2_subdev *sd, 879static int ov772x_g_fmt(struct v4l2_subdev *sd,
881 struct v4l2_mbus_framefmt *mf) 880 struct v4l2_mbus_framefmt *mf)
882{ 881{
883 struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); 882 struct ov772x_priv *priv = to_ov772x(sd);
884 883
885 mf->width = priv->win->width; 884 mf->width = priv->win->width;
886 mf->height = priv->win->height; 885 mf->height = priv->win->height;
@@ -893,7 +892,7 @@ static int ov772x_g_fmt(struct v4l2_subdev *sd,
893 892
894static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) 893static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
895{ 894{
896 struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); 895 struct ov772x_priv *priv = to_ov772x(sd);
897 const struct ov772x_color_format *cfmt; 896 const struct ov772x_color_format *cfmt;
898 const struct ov772x_win_size *win; 897 const struct ov772x_win_size *win;
899 int ret; 898 int ret;
@@ -933,9 +932,9 @@ static int ov772x_try_fmt(struct v4l2_subdev *sd,
933 return 0; 932 return 0;
934} 933}
935 934
936static int ov772x_video_probe(struct i2c_client *client) 935static int ov772x_video_probe(struct ov772x_priv *priv)
937{ 936{
938 struct ov772x_priv *priv = to_ov772x(client); 937 struct i2c_client *client = v4l2_get_subdevdata(&priv->subdev);
939 u8 pid, ver; 938 u8 pid, ver;
940 const char *devname; 939 const char *devname;
941 int ret; 940 int ret;
@@ -1078,7 +1077,7 @@ static int ov772x_probe(struct i2c_client *client,
1078 goto done; 1077 goto done;
1079 } 1078 }
1080 1079
1081 ret = ov772x_video_probe(client); 1080 ret = ov772x_video_probe(priv);
1082 if (ret < 0) 1081 if (ret < 0)
1083 goto done; 1082 goto done;
1084 1083
@@ -1095,7 +1094,7 @@ done:
1095 1094
1096static int ov772x_remove(struct i2c_client *client) 1095static int ov772x_remove(struct i2c_client *client)
1097{ 1096{
1098 struct ov772x_priv *priv = to_ov772x(client); 1097 struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client));
1099 1098
1100 v4l2_device_unregister_subdev(&priv->subdev); 1099 v4l2_device_unregister_subdev(&priv->subdev);
1101 v4l2_ctrl_handler_free(&priv->hdl); 1100 v4l2_ctrl_handler_free(&priv->hdl);