Skip to contentSkip to conversation

go7007: subdev conversion

PATCH In review Pete Eberlein 2 participants 2 messages Nov 10, 2009 – Nov 15, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 5/5 go7007: subdev conversion

From: Pete Eberlein <[email protected]>

Convert the go7007 driver to v4l2 subdev interface, using v4l2 i2c subdev functions instead of i2c functions directly. The v4l2 ioctl ops functions call subdev ops instead of i2c commands.

Priority: normal

linux/drivers/staging/go7007/go7007-driver.c +10 -8
diff -r a44341b7bf67 -r 76b500418fae linux/drivers/staging/go7007/go7007-driver.c
@@ -193,7 +193,8 @@
 static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
 			   int id, int addr)
 {
-	struct i2c_board_info info;
+	struct go7007 *go = i2c_get_adapdata(adapter);
+	struct v4l2_device *v4l2_dev = &go->v4l2_dev;
 	char *modname;
 
 	switch (id) {
@@ -225,14 +226,10 @@
 		modname = NULL;
 		break;
 	}
-	if (modname != NULL)
-		request_module(modname);
 
-	memset(&info, 0, sizeof(struct i2c_board_info));
-	info.addr = addr;
-	strlcpy(info.type, type, I2C_NAME_SIZE);
-	if (!i2c_new_device(adapter, &info))
+	if (v4l2_i2c_new_subdev(v4l2_dev, adapter, modname, type, addr, NULL))
 		return 0;
+
 	if (modname != NULL)
 		printk(KERN_INFO
 			"go7007: probing for module %s failed\n", modname);
@@ -262,6 +259,11 @@
 	if (ret < 0)
 		return -1;
 
+	/* v4l2 init must happen before i2c subdevs */
+	ret = go7007_v4l2_init(go);
+	if (ret < 0)
+		return ret;
+
 	if (!go->i2c_adapter_online &&
 			go->board_info->flags & GO7007_BOARD_USE_ONBOARD_I2C) {
 		if (go7007_i2c_init(go) < 0)
@@ -282,7 +284,7 @@
 		go->audio_enabled = 1;
 		go7007_snd_init(go);
 	}
-	return go7007_v4l2_init(go);
+	return 0;
 }
 EXPORT_SYMBOL(go7007_register_encoder);
 
linux/drivers/staging/go7007/go7007-v4l2.c +37 -63

209 lines not on this page · raw message

#1 lore raw
Quoted 9 lines · On Tuesday 10 November 2009 20:21:44 Pete Eberlein wrote:

From: Pete Eberlein <[email protected]>

Convert the go7007 driver to v4l2 subdev interface, using v4l2 i2c subdev functions instead of i2c functions directly. The v4l2 ioctl ops functions call subdev ops instead of i2c commands.

Priority: normal

Again, nice work!

It's in much better shape now.

When all this is in we need to take a good look at this and see what needs to be done to move this driver out of staging.

One thing that needs to be fixed before that can happen is that I noticed the use of lock_kernel in s2250-loader.c: this should be done differently. The BKL is slowly being removed throughout the kernel so it should be removed here as well.

Regards,

Hans

Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom