From patchwork Tue Apr 5 03:31:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Nieder X-Patchwork-Id: 686061 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p353VlZu002932 for ; Tue, 5 Apr 2011 03:31:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483Ab1DEDb0 (ORCPT ); Mon, 4 Apr 2011 23:31:26 -0400 Received: from mail-yi0-f46.google.com ([209.85.218.46]:33263 "EHLO mail-yi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739Ab1DEDbY (ORCPT ); Mon, 4 Apr 2011 23:31:24 -0400 Received: by yia27 with SMTP id 27so2432609yia.19 for ; Mon, 04 Apr 2011 20:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=12EbtgBmWjYcedu780huWTF4PYGkM+aKDKMo3fLwZxY=; b=qcmwx/P1w12mZprsIbfYOLSI0IhuAwzbn85rJNjIU7AEWnHz5RAnbexq2wnTUHQSRR 249Qzxrv5gi+h0eC0CbRfmjhzfyQBPaeUw6kUs3dytBtU6W9AjXNdOZi1BwZ+0qV+DeT e3ehjT8FHMZCzoXsLyz+kE4e7WCHPWZecBKoM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=Rix8M1gwhz2MFOPF5Y84OIJIPumLcccAprq/7mwH4xRphnYzg2jsIkG/ySyXcPM64I zG15fmYkgR3gr9Q3PEu7lrupVm9dyuk7Nu5+timGn7hGal7PYWNPfEGi2p2itAAd4j9k S5YlBse79UkiWQY/BrbNrUjdQtpVk3MiDgDK8= Received: by 10.91.50.6 with SMTP id c6mr9784agk.66.1301974280787; Mon, 04 Apr 2011 20:31:20 -0700 (PDT) Received: from elie (adsl-69-209-53-77.dsl.chcgil.ameritech.net [69.209.53.77]) by mx.google.com with ESMTPS id b3sm6068675ana.24.2011.04.04.20.31.18 (version=SSLv3 cipher=OTHER); Mon, 04 Apr 2011 20:31:19 -0700 (PDT) Date: Mon, 4 Apr 2011 22:31:15 -0500 From: Jonathan Nieder To: linux-media@vger.kernel.org Cc: Huber Andreas , Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, Ben Hutchings , Steven Toth Subject: [PATCH 7/7] [mpeg] cx88: don't use atomic_t for core->users Message-ID: <20110405033114.GH4498@elie> References: <20110327150610.4029.95961.reportbug@xen.corax.at> <20110327152810.GA32106@elie> <20110402093856.GA17015@elie> <20110405032014.GA4498@elie> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110405032014.GA4498@elie> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Apr 2011 03:31:47 +0000 (UTC) users is always read or written with core->lock held. A plain int is simpler and faster. Signed-off-by: Jonathan Nieder --- Thanks for reading. drivers/media/video/cx88/cx88-video.c | 5 +++-- drivers/media/video/cx88/cx88.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 287a41e..d719d12 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -824,7 +824,7 @@ static int video_open(struct file *file) call_all(core, tuner, s_radio); } - atomic_inc(&core->users); + core->users++; mutex_unlock(&core->lock); return 0; @@ -922,7 +922,8 @@ static int video_release(struct file *file) file->private_data = NULL; kfree(fh); - if(atomic_dec_and_test(&dev->core->users)) + dev->core->users--; + if (!dev->core->users) call_all(dev->core, core, s_power, 0); mutex_unlock(&dev->core->lock); diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 9e8176e..a399a8b 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -389,7 +389,7 @@ struct cx88_core { struct mutex lock; /* various v4l controls */ u32 freq; - atomic_t users; + int users; int mpeg_users; /* cx88-video needs to access cx8802 for hybrid tuner pll access. */