From patchwork Thu May 28 20:44:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 26788 X-Patchwork-Delegate: dougsland@redhat.com 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 n4SKj2pV000761 for ; Thu, 28 May 2009 20:45:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759180AbZE1Uow (ORCPT ); Thu, 28 May 2009 16:44:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760302AbZE1Uow (ORCPT ); Thu, 28 May 2009 16:44:52 -0400 Received: from mail-fx0-f168.google.com ([209.85.220.168]:51647 "EHLO mail-fx0-f168.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759180AbZE1Uov (ORCPT ); Thu, 28 May 2009 16:44:51 -0400 Received: by fxm12 with SMTP id 12so3977963fxm.37 for ; Thu, 28 May 2009 13:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=8eAA9yKuaiYp+QEwxEW3QFkU2fGjfLJIqNmCa1W89J0=; b=w1n0mToR2OH2+hWW76rLZNa5I363JyBUo7g4XRF1/q0KeNDhK6t4VVHrkxgGexMOCd xz1xE51qMBpeDCWg9eSDuvZie5tBpBtiGvNTQCJ+p4zzhkZrG4g2zE+81i+ifTLFXWX7 tS1WnyaSE55hopT8DI2xxvJa9RqR4GJHNMMuU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=ZCjkTDgxAFTKipbu5uEN4HtBJrafruyYm9O79EHJ6yUoCBEmtOZmvmNHmKI/ss4oA2 MeOeSsnX1wiEKw875mZzEE0UP+ptPWsAAT4PeHQWt13YGmXhu8A58KqQ9+kvnbToiOSx mG/23qP3g292XgVrKlOgGX4QW7hWZACGjKuN0= Received: by 10.86.59.18 with SMTP id h18mr1935751fga.71.1243543492347; Thu, 28 May 2009 13:44:52 -0700 (PDT) Received: from ?192.168.1.102? (gw.zunet.ru [217.67.117.64]) by mx.google.com with ESMTPS id l19sm6250156fgb.17.2009.05.28.13.44.49 (version=SSLv3 cipher=RC4-MD5); Thu, 28 May 2009 13:44:50 -0700 (PDT) Subject: [patch review 4/4] dsbr100: change radio->muted to radio->status, update suspend/resume From: Alexey Klimov To: Linux Media Cc: Douglas Schilling Landgraf Date: Fri, 29 May 2009 00:44:48 +0400 Message-Id: <1243543488.6713.44.camel@tux.localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.26.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Patch renames radio->muted to radio->status, add defines for that variable, and fixes suspend/resume procedure. Radio->status set to STOPPED in usb_dsbr100_probe because of removing open call. Also, patch increases driver version. Signed-off-by: Alexey Klimov diff -r 8046021e508e linux/drivers/media/radio/dsbr100.c --- a/linux/drivers/media/radio/dsbr100.c Tue May 19 15:59:49 2009 +0400 +++ b/linux/drivers/media/radio/dsbr100.c Tue May 19 17:55:35 2009 +0400 @@ -33,6 +33,10 @@ History: + Version 0.46: + Removed usb_dsbr100_open/close calls and radio->users counter. Also, + radio->muted changed to radio->status and suspend/resume calls updated. + Version 0.45: Converted to v4l2_device. @@ -101,8 +105,8 @@ */ #include /* for KERNEL_VERSION MACRO */ -#define DRIVER_VERSION "v0.45" -#define RADIO_VERSION KERNEL_VERSION(0, 4, 5) +#define DRIVER_VERSION "v0.46" +#define RADIO_VERSION KERNEL_VERSION(0, 4, 6) #define DRIVER_AUTHOR "Markus Demleitner " #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" @@ -122,6 +126,10 @@ #define FREQ_MAX 108.0 #define FREQ_MUL 16000 +/* defines for radio->status */ +#define STARTED 0 +#define STOPPED 1 + #define videodev_to_radio(d) container_of(d, struct dsbr100_device, videodev) static int usb_dsbr100_probe(struct usb_interface *intf, @@ -145,7 +153,7 @@ int curfreq; int stereo; int removed; - int muted; + int status; }; static struct usb_device_id usb_dsbr100_device_table [] = { @@ -201,7 +209,7 @@ goto usb_control_msg_failed; } - radio->muted = 0; + radio->status = STARTED; mutex_unlock(&radio->lock); return (radio->transfer_buffer)[0]; @@ -244,7 +252,7 @@ goto usb_control_msg_failed; } - radio->muted = 1; + radio->status = STOPPED; mutex_unlock(&radio->lock); return (radio->transfer_buffer)[0]; @@ -473,7 +481,7 @@ switch (ctrl->id) { case V4L2_CID_AUDIO_MUTE: - ctrl->value = radio->muted; + ctrl->value = radio->status; return 0; } return -EINVAL; @@ -549,9 +557,21 @@ struct dsbr100_device *radio = usb_get_intfdata(intf); int retval; - retval = dsbr100_stop(radio); - if (retval < 0) - dev_warn(&intf->dev, "dsbr100_stop failed\n"); + if (radio->status == STARTED) { + retval = dsbr100_stop(radio); + if (retval < 0) + dev_warn(&intf->dev, "dsbr100_stop failed\n"); + + /* After dsbr100_stop() status set to STOPPED. + * If we want driver to start radio on resume + * we set status equal to STARTED. + * On resume we will check status and run radio if needed. + */ + + mutex_lock(&radio->lock); + radio->status = STARTED; + mutex_unlock(&radio->lock); + } dev_info(&intf->dev, "going into suspend..\n"); @@ -564,9 +584,11 @@ struct dsbr100_device *radio = usb_get_intfdata(intf); int retval; - retval = dsbr100_start(radio); - if (retval < 0) - dev_warn(&intf->dev, "dsbr100_start failed\n"); + if (radio->status == STARTED) { + retval = dsbr100_start(radio); + if (retval < 0) + dev_warn(&intf->dev, "dsbr100_start failed\n"); + } dev_info(&intf->dev, "coming out of suspend..\n"); @@ -645,6 +667,7 @@ radio->removed = 0; radio->usbdev = interface_to_usbdev(intf); radio->curfreq = FREQ_MIN * FREQ_MUL; + radio->status = STOPPED; video_set_drvdata(&radio->videodev, radio);