Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] typhoon: convert to unlocked_ioctl

Convert the typhoon driver from ioctl to unlocked_ioctl.

When doing this I noticed a bug where curfreq was not initialized correctly
to mutefreq (it wasn't multiplied by 16).

The initialization is now also done before the device node is created.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
d2c998f7 725ea8cf

+8 -8
+8 -8
drivers/media/radio/radio-typhoon.c
··· 317 317 318 318 static const struct v4l2_file_operations typhoon_fops = { 319 319 .owner = THIS_MODULE, 320 - .ioctl = video_ioctl2, 320 + .unlocked_ioctl = video_ioctl2, 321 321 }; 322 322 323 323 static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { ··· 344 344 345 345 strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name)); 346 346 dev->io = io; 347 - dev->curfreq = dev->mutefreq = mutefreq; 348 347 349 348 if (dev->io == -1) { 350 349 v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n"); 351 350 return -EINVAL; 352 351 } 353 352 354 - if (dev->mutefreq < 87000 || dev->mutefreq > 108500) { 353 + if (mutefreq < 87000 || mutefreq > 108500) { 355 354 v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n"); 356 355 v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n"); 357 356 return -EINVAL; 358 357 } 358 + dev->curfreq = dev->mutefreq = mutefreq << 4; 359 359 360 360 mutex_init(&dev->lock); 361 361 if (!request_region(dev->io, 8, "typhoon")) { ··· 378 378 dev->vdev.ioctl_ops = &typhoon_ioctl_ops; 379 379 dev->vdev.release = video_device_release_empty; 380 380 video_set_drvdata(&dev->vdev, dev); 381 + 382 + /* mute card - prevents noisy bootups */ 383 + typhoon_mute(dev); 384 + 381 385 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 382 386 v4l2_device_unregister(&dev->v4l2_dev); 383 387 release_region(dev->io, 8); 384 388 return -EINVAL; 385 389 } 386 390 v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io); 387 - v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", dev->mutefreq); 388 - dev->mutefreq <<= 4; 389 - 390 - /* mute card - prevents noisy bootups */ 391 - typhoon_mute(dev); 391 + v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", mutefreq); 392 392 393 393 return 0; 394 394 }