This patch makes the timb-radio to use the unblocked_ioctl, to avoid BKL. Also an open function is introduced to really add the tuner and DSP to the I2C bus.
The first part is a proposed patch by Hans Verkuil, the second patch is a patch that I posted to linux-media earlier today. Signed-off-by: Richard Röjfors <[email protected]> --- diff -Naur linux-2.6.35/drivers/media/radio/radio-timb.c linux-2.6.35.new/drivers/media/radio/radio-timb.c --- linux-2.6.35/drivers/media/radio/radio-timb.c 2010-08-01 18:11:14.000000000 -0400 +++ linux-2.6.35.new/drivers/media/radio/radio-timb.c 2010-11-26 08:59:22.000000000 -0500 @@ -34,6 +34,7 @@ struct v4l2_subdev *sd_dsp; struct video_device video_dev; struct v4l2_device v4l2_dev; + struct mutex lock; }; @@ -140,9 +141,53 @@ .vidioc_s_ctrl = timbradio_vidioc_s_ctrl }; +static int timbradio_rds_fops_open(struct file *file) +{ + struct timbradio *tr = video_drvdata(file); + struct i2c_adapter *adapt; + int err = 0; + + mutex_lock(&tr->lock); + + /* Check if the DSP and tuner is not yet identified */ + + /* find the I2C bus */ + adapt = i2c_get_adapter(tr->pdata.i2c_adapter); + if (!adapt) { + printk(KERN_ERR DRIVER_NAME": No I2C bus\n"); + err = -ENODEV; + goto out; + } + + /* now find the tuner and dsp */ + if (!tr->sd_dsp) + tr->sd_dsp = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, adapt, + tr->pdata.dsp.module_name, tr->pdata.dsp.info, NULL, 0); + + if (!tr->sd_tuner) + tr->sd_tuner = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, adapt, + tr->pdata.tuner.module_name, tr->pdata.tuner.info, + NULL, 0); + + i2c_put_adapter(adapt); + + if (!tr->sd_tuner || !tr->sd_dsp) { + printk(KERN_ERR DRIVER_NAME + ": Failed to get tuner or DSP\n"); + err = -ENODEV; + goto out; + } + +out: + mutex_unlock(&tr->lock); + return err; +} + + static const struct v4l2_file_operations timbradio_fops = { .owner = THIS_MODULE, - .ioctl = video_ioctl2, + .unlocked_ioctl = video_ioctl2, + .open = timbradio_rds_fops_open, }; static int __devinit timbradio_probe(struct platform_device *pdev) @@ -164,6 +209,7 @@ } tr->pdata = *pdata; + mutex_init(&tr->lock); strlcpy(tr->video_dev.name, "Timberdale Radio", sizeof(tr->video_dev.name)); _______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
