From patchwork Sat Sep 12 14:50:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ellingsworth X-Patchwork-Id: 47079 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8CEoCuA027624 for ; Sat, 12 Sep 2009 14:50:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754644AbZILOuI (ORCPT ); Sat, 12 Sep 2009 10:50:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754637AbZILOuI (ORCPT ); Sat, 12 Sep 2009 10:50:08 -0400 Received: from mail-qy0-f172.google.com ([209.85.221.172]:50386 "EHLO mail-qy0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754626AbZILOuG (ORCPT ); Sat, 12 Sep 2009 10:50:06 -0400 Received: by mail-qy0-f172.google.com with SMTP id 2so1629968qyk.21 for ; Sat, 12 Sep 2009 07:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :reply-to:user-agent:mime-version:to:subject:content-type; bh=P6gG5bQV5Sm9AwyodFrT+gQ/BroQxMu9aPRg4nPb/EI=; b=tgAS7veWhVWfJQIMk1Io762fdJ9UGWXPXrOv5gtDOCPMW9oqQe8E8BfDwdhdzrjqoR K0Z1WH+74bmh9QnpJ0Vhf7Wbl9UQBLNLBqenUsFbRaYRyfLnMk/EKXHI2X9dp/ot/9br KU3cLYwuM72Nu2PJcYEHsn20cUM2RCBl9vEX8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:content-type; b=bCKNQT/QnnmzcZYDyeJRXU/USRuqu3Ze/dMwEUAXgMdwuHiy/rwtpdznxgPFpZRad2 Qk7CN2qfVWVZWXwsSDgcmW0XHU422ogs9+oAPt32yr4VGZu0uEf+N14dhKYnVsxYQ31H whKOZInd6oTMhkfgBljUBZot+Hv8GxI6MwgKE= Received: by 10.224.117.133 with SMTP id r5mr3751038qaq.133.1252767009662; Sat, 12 Sep 2009 07:50:09 -0700 (PDT) Received: from ?192.168.10.110? (cpe-71-72-62-249.neo.res.rr.com [71.72.62.249]) by mx.google.com with ESMTPS id 5sm2231124qwg.22.2009.09.12.07.50.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 12 Sep 2009 07:50:08 -0700 (PDT) Message-ID: <4AABB518.8090804@gmail.com> Date: Sat, 12 Sep 2009 10:50:00 -0400 From: David Ellingsworth Reply-To: david@identd.dyndns.org User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: linux-media@vger.kernel.org, klimov.linux@gmail.com Subject: [RFC/RFT 08/10] radio-mr800: turn radio on during first open and off during last close Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From 46c7d395e4ed2df431b21b6c07fb02a075a15e43 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 01:57:36 -0400 Subject: [PATCH 08/10] mr800: turn radio on during first open and off during last close Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) From 46c7d395e4ed2df431b21b6c07fb02a075a15e43 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 01:57:36 -0400 Subject: [PATCH 08/10] mr800: turn radio on during first open and off during last close Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 9fd2342..11db6ea 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -493,15 +493,14 @@ static int usb_amradio_open(struct file *file) } file->private_data = radio; - radio->users = 1; - radio->muted = 1; - retval = amradio_set_mute(radio, AMRADIO_START); - if (retval < 0) { - amradio_dev_warn(&radio->videodev.dev, - "radio did not start up properly\n"); - radio->users = 0; - goto unlock; + if (radio->users == 0) { + retval = amradio_set_mute(radio, AMRADIO_START); + if (retval < 0) { + amradio_dev_warn(&radio->videodev.dev, + "radio did not start up properly\n"); + goto unlock; + } } retval = amradio_set_stereo(radio, WANT_STEREO); @@ -514,6 +513,8 @@ static int usb_amradio_open(struct file *file) amradio_dev_warn(&radio->videodev.dev, "set frequency failed\n"); + radio->users++; + unlock: mutex_unlock(&radio->lock); return retval; @@ -526,18 +527,19 @@ static int usb_amradio_close(struct file *file) int retval = 0; mutex_lock(&radio->lock); + radio->users--; if (!radio->usbdev) { retval = -EIO; goto unlock; } - radio->users = 0; - - retval = amradio_set_mute(radio, AMRADIO_STOP); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, - "amradio_stop failed\n"); + if (radio->users == 0 && !radio->muted) { + retval = amradio_set_mute(radio, AMRADIO_STOP); + if (retval < 0) + amradio_dev_warn(&radio->videodev.dev, + "amradio_stop failed\n"); + } unlock: mutex_unlock(&radio->lock); @@ -674,6 +676,7 @@ static int usb_amradio_probe(struct usb_interface *intf, radio->usbdev = interface_to_usbdev(intf); radio->curfreq = 95.16 * FREQ_MUL; radio->stereo = -1; + radio->muted = 1; mutex_init(&radio->lock); -- 1.6.3.3