From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: unlisted-recipients:; (no To-header on input)@casper.infradead.org
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH 02/14] [media] cx88: Don't allow opening a device while it is not ready
Date: Mon, 14 Feb 2011 19:03:20 -0200 [thread overview]
Message-ID: <20110214190320.288e9b34@pedra> (raw)
In-Reply-To: <cover.1297716906.git.mchehab@redhat.com>
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>
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index e2fc455..f814886 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,
request_module("ir-kbd-i2c");
}
+ /* Sets device info at pci_dev */
+ pci_set_drvdata(pci_dev, dev);
+
+ /* initial device configuration */
+ mutex_lock(&core->lock);
+ cx88_set_tvnorm(core, core->tvnorm);
+ init_controls(core);
+ cx88_video_mux(core, 0);
+
/* register v4l devices */
dev->video_dev = cx88_vdev_init(core,dev->pci,
&cx8800_video_template,"video");
@@ -1923,16 +1932,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
core->name, video_device_node_name(dev->radio_dev));
}
- /* everything worked */
- pci_set_drvdata(pci_dev,dev);
-
- /* initial device configuration */
- mutex_lock(&core->lock);
- cx88_set_tvnorm(core,core->tvnorm);
- init_controls(core);
- cx88_video_mux(core,0);
- mutex_unlock(&core->lock);
-
/* start tvaudio thread */
if (core->board.tuner_type != TUNER_ABSENT) {
core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio");
@@ -1942,11 +1941,14 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
core->name, err);
}
}
+ mutex_unlock(&core->lock);
+
return 0;
fail_unreg:
cx8800_unregister_video(dev);
free_irq(pci_dev->irq, dev);
+ mutex_unlock(&core->lock);
fail_core:
cx88_core_put(core,dev->pci);
fail_free:
--
1.7.1
next prev parent reply other threads:[~2011-02-14 21:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1297716906.git.mchehab@redhat.com>
2011-02-14 21:03 ` [PATCH 03/14] [media] tuner-core: Remove V4L1/V4L2 API switch Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 04/14] [media] tuner-core: remove the legacy is_stereo() call Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 05/14] [media] tuner-core: move some messages to the proper place Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 06/14] [media] tuner-core: Reorganize the functions internally Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 07/14] [media] tuner-core: Some cleanups at check_mode/set_mode Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 09/14] [media] tuner-core: do the right thing for suspend/resume Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 08/14] [media] tuner-core: Better implement standby mode Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 10/14] [media] tuner-core: CodingStyle cleanups Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 11/14] [media] tuner-core: Don't use a static var for xc5000_cfg Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 01/14] [media] cx88: use unlocked_ioctl for cx88-video Mauro Carvalho Chehab
2011-02-14 21:03 ` Mauro Carvalho Chehab [this message]
2011-02-14 21:03 ` [PATCH 14/14] [media] Remove the remaining usages for T_STANDBY Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 12/14] [media] tuner-core: dead code removal Mauro Carvalho Chehab
2011-02-14 21:03 ` [PATCH 13/14] [media] tuner-core: Fix a few comments on it Mauro Carvalho Chehab
2011-02-14 21:49 ` [PATCH 01/14] [media] cx88: use unlocked_ioctl for cx88-video Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110214190320.288e9b34@pedra \
--to=mchehab@redhat.com \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox