{
struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = &go->v4l2_dev;
-
- if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL))
+ struct v4l2_subdev *sd;
+ struct i2c_board_info info;
+
+ memset(&info, 0, sizeof(info));
+ strlcpy(info.type, i2c->type, sizeof(info.type));
+ info.addr = i2c->addr;
+ info.flags = i2c->flags;
+
+ sd = v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, NULL);
+ if (sd) {
+ if (i2c->is_video)
+ go->sd_video = sd;
+ if (i2c->is_audio)
+ go->sd_audio = sd;
return 0;
- if (i2c_del_adapter(&go->i2c_adapter) == 0)
- go->i2c_adapter_online = 0;
- else
- v4l2_err(&go->v4l2_dev,
- "error removing I2C adapter!\n");
+ }
+
+ printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", i2c->type);
+ return -EINVAL;
+ }
+
+ /*
+ * Detach and unregister the encoder. The go7007 struct won't be freed
+ * until v4l2 finishes releasing its resources and all associated fds are
+ * closed by applications.
+ */
+ static void go7007_remove(struct v4l2_device *v4l2_dev)
+ {
+ struct go7007 *go = container_of(v4l2_dev, struct go7007, v4l2_dev);
+
+ v4l2_device_unregister(v4l2_dev);
+ if (go->hpi_ops->release)
+ go->hpi_ops->release(go);
+ if (go->i2c_adapter_online) {
++ i2c_del_adapter(&go->i2c_adapter);
++ go->i2c_adapter_online = 0;
+ }
- dev_info(&adapter->dev,
- "go7007: probing for module i2c:%s failed\n", type);
- return -1;
+ kfree(go->boot_fw);
+ go7007_v4l2_remove(go);
+ kfree(go);
}
/*