diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-02-14 05:01:51 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:32:00 -0400 |
commit | 121ec13267fabcf2c81e4584f1505069e234b30d (patch) | |
tree | 3ec419067d994be255f9b64a46682e5760b10a8f | |
parent | b618726414f3eb7b0b122e459efe3c5edc36b2fc (diff) |
[media] cx88: Don't allow opening a device while it is not ready
After registering the cdev, it would be possible do have an open on it.
In a matter of fact, some versions of udev do this. So, move registration
to the end and protect it with a mutex.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/cx88/cx88-video.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index e2fc45509b03..f814886ccd17 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -1882,6 +1882,15 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1882 | request_module("ir-kbd-i2c"); | 1882 | request_module("ir-kbd-i2c"); |
1883 | } | 1883 | } |
1884 | 1884 | ||
1885 | /* Sets device info at pci_dev */ | ||
1886 | pci_set_drvdata(pci_dev, dev); | ||
1887 | |||
1888 | /* initial device configuration */ | ||
1889 | mutex_lock(&core->lock); | ||
1890 | cx88_set_tvnorm(core, core->tvnorm); | ||
1891 | init_controls(core); | ||
1892 | cx88_video_mux(core, 0); | ||
1893 | |||
1885 | /* register v4l devices */ | 1894 | /* register v4l devices */ |
1886 | dev->video_dev = cx88_vdev_init(core,dev->pci, | 1895 | dev->video_dev = cx88_vdev_init(core,dev->pci, |
1887 | &cx8800_video_template,"video"); | 1896 | &cx8800_video_template,"video"); |
@@ -1923,16 +1932,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1923 | core->name, video_device_node_name(dev->radio_dev)); | 1932 | core->name, video_device_node_name(dev->radio_dev)); |
1924 | } | 1933 | } |
1925 | 1934 | ||
1926 | /* everything worked */ | ||
1927 | pci_set_drvdata(pci_dev,dev); | ||
1928 | |||
1929 | /* initial device configuration */ | ||
1930 | mutex_lock(&core->lock); | ||
1931 | cx88_set_tvnorm(core,core->tvnorm); | ||
1932 | init_controls(core); | ||
1933 | cx88_video_mux(core,0); | ||
1934 | mutex_unlock(&core->lock); | ||
1935 | |||
1936 | /* start tvaudio thread */ | 1935 | /* start tvaudio thread */ |
1937 | if (core->board.tuner_type != TUNER_ABSENT) { | 1936 | if (core->board.tuner_type != TUNER_ABSENT) { |
1938 | core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); | 1937 | core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); |
@@ -1942,11 +1941,14 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1942 | core->name, err); | 1941 | core->name, err); |
1943 | } | 1942 | } |
1944 | } | 1943 | } |
1944 | mutex_unlock(&core->lock); | ||
1945 | |||
1945 | return 0; | 1946 | return 0; |
1946 | 1947 | ||
1947 | fail_unreg: | 1948 | fail_unreg: |
1948 | cx8800_unregister_video(dev); | 1949 | cx8800_unregister_video(dev); |
1949 | free_irq(pci_dev->irq, dev); | 1950 | free_irq(pci_dev->irq, dev); |
1951 | mutex_unlock(&core->lock); | ||
1950 | fail_core: | 1952 | fail_core: |
1951 | cx88_core_put(core,dev->pci); | 1953 | cx88_core_put(core,dev->pci); |
1952 | fail_free: | 1954 | fail_free: |