From ba390f005573bdf6ab7fd78bb05119036c2ed539 Mon Sep 17 00:00:00 2001
From: Hans Verkuil <hverkuil@xs4all.nl>
Date: Thu, 15 Jan 2009 05:37:14 -0300
Subject: [PATCH] V4L/DVB (10250): cx25840: fix regression: fw not loaded on
 first use

With the conversion to v4l2_subdev one bit of code was accidentally dropped:
on receiving the first command the driver has to load the fw. A new init()
command was introduced to do that explicitly for bridge drivers that are
converted to use v4l2_subdev, but old drivers that are not yet converted
no longer worked.

This patch fixes this regression for these old drivers.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/video/cx25840/cx25840-core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 88f2fd32bfe..b3b5b17dc8e 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -1382,6 +1382,14 @@ static int cx25840_log_status(struct v4l2_subdev *sd)
 
 static int cx25840_command(struct i2c_client *client, unsigned cmd, void *arg)
 {
+	/* ignore this command */
+	if (cmd == TUNER_SET_TYPE_ADDR)
+		return 0;
+
+	/* Old-style drivers rely on initialization on first use, so
+	   call the init whenever a command is issued to this driver.
+	   New-style drivers using v4l2_subdev should call init explicitly. */
+	cx25840_init(i2c_get_clientdata(client), 0);
 	return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg);
 }
 
-- 
2.41.3