From: Alexey Klimov <klimov.linux@gmail.com>
To: Douglas Schilling Landgraf <dougsland@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: [patch review 6/6] radio-mr800: redesign radio->users counter
Date: Sat, 08 Aug 2009 21:46:16 +0400 [thread overview]
Message-ID: <1249753576.15160.251.camel@tux.localhost> (raw)
Redesign radio->users counter. Don't allow more that 5 users on radio in
usb_amradio_open() and don't stop radio device if other userspace
application uses it in usb_amradio_close().
Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
--
diff -r c2dd9da28106 linux/drivers/media/radio/radio-mr800.c
--- a/linux/drivers/media/radio/radio-mr800.c Sat Aug 08 17:28:18 2009 +0400
+++ b/linux/drivers/media/radio/radio-mr800.c Sat Aug 08 18:12:01 2009 +0400
@@ -540,7 +540,13 @@
{
struct amradio_device *radio = video_get_drvdata(video_devdata(file));
- radio->users = 1;
+ /* don't allow more than 5 users on radio */
+ if (radio->users > 4)
+ return -EBUSY;
+
+ mutex_lock(&radio->lock);
+ radio->users++;
+ mutex_unlock(&radio->lock);
return 0;
}
@@ -554,9 +560,20 @@
return -ENODEV;
mutex_lock(&radio->lock);
- radio->users = 0;
+ radio->users--;
mutex_unlock(&radio->lock);
+ /* In case several userspace applications opened the radio
+ * and one of them closes and stops it,
+ * we check if others use it and if they do we start the radio again. */
+ if (radio->users && radio->status == AMRADIO_STOP) {
+ int retval;
+ retval = amradio_set_mute(radio, AMRADIO_START);
+ if (retval < 0)
+ dev_warn(&radio->videodev->dev,
+ "amradio_start failed\n");
+ }
+
return 0;
}
--
Best regards, Klimov Alexey
next reply other threads:[~2009-08-08 17:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-08 17:46 Alexey Klimov [this message]
2009-08-08 18:01 ` [patch review 6/6] radio-mr800: redesign radio->users counter Trent Piepho
2009-08-08 19:08 ` Alexey Klimov
2009-08-08 20:16 ` wk
2009-08-09 8:19 ` Hans Verkuil
2009-08-09 11:04 ` Alexey Klimov
2009-08-10 22:24 ` David Ellingsworth
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=1249753576.15160.251.camel@tux.localhost \
--to=klimov.linux@gmail.com \
--cc=dougsland@gmail.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