From patchwork Tue Apr 5 03:30:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Nieder X-Patchwork-Id: 686051 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 p353V02a002546 for ; Tue, 5 Apr 2011 03:31:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195Ab1DEDam (ORCPT ); Mon, 4 Apr 2011 23:30:42 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:62881 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751723Ab1DEDal (ORCPT ); Mon, 4 Apr 2011 23:30:41 -0400 Received: by yxs7 with SMTP id 7so2432324yxs.19 for ; Mon, 04 Apr 2011 20:30:41 -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=n8f6qs4bA213UbvEamCF5+/roSR91hnFwx4Mmw5Oxbk=; b=iKBUmCSICxekN16qZ1cM5aefkqx1IldyxExyRni/8UN4IU+4HwTnBoYbn8QWwzqStK OoNEz2JO0cHo3lF3BlCkv/zVYXYdiYsG1BlrXVpzNg52l/RnC236zr5Twb5R/PquIT0z M9JLXAOTIiDB3hNiHXVf5VRjmIw146npI25d4= 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=lPnroZ99P8HKU0bgR1e/hJou3JFUfnXHygAK3yq4uGNOl14ogKbkXHeU8bHMZt9Ifa YwUx3NBFAQGsCbFPCMMah5lqO0zHeW6j4XLQDSZSzVO25iagaiyk+luT2bIyXQK1XdYg cv6O8QlZKlJTbDm8jnhZihYuOTyJatnS/5QJw= Received: by 10.236.181.164 with SMTP id l24mr8649040yhm.101.1301974240947; Mon, 04 Apr 2011 20:30:40 -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 a12sm2673952yhk.27.2011.04.04.20.30.39 (version=SSLv3 cipher=OTHER); Mon, 04 Apr 2011 20:30:40 -0700 (PDT) Date: Mon, 4 Apr 2011 22:30:35 -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 6/7] [media] cx88: don't use atomic_t for core->mpeg_users Message-ID: <20110405033035.GG4498@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:00 +0000 (UTC) mpeg_users is always read or written with core->lock held except in mpeg_release (where it looks like a bug). A plain int is simpler and faster. Signed-off-by: Jonathan Nieder --- drivers/media/video/cx88/cx88-blackbird.c | 11 ++++++----- drivers/media/video/cx88/cx88.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index fa8e347..11e49bb 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1073,7 +1073,7 @@ static int mpeg_open(struct file *file) return err; } - if (!atomic_read(&dev->core->mpeg_users) && blackbird_initialize_codec(dev) < 0) { + if (!dev->core->mpeg_users && blackbird_initialize_codec(dev) < 0) { drv->request_release(drv); mutex_unlock(&dev->core->lock); return -EINVAL; @@ -1101,7 +1101,7 @@ static int mpeg_open(struct file *file) cx88_set_scale(dev->core, dev->width, dev->height, fh->mpegq.field); - atomic_inc(&dev->core->mpeg_users); + dev->core->mpeg_users++; mutex_unlock(&dev->core->lock); return 0; } @@ -1112,7 +1112,9 @@ static int mpeg_release(struct file *file) struct cx8802_dev *dev = fh->dev; struct cx8802_driver *drv = NULL; - if (dev->mpeg_active && atomic_read(&dev->core->mpeg_users) == 1) + mutex_lock(&dev->core->lock); + + if (dev->mpeg_active && dev->core->mpeg_users == 1) blackbird_stop_codec(dev); cx8802_cancel_buffers(fh->dev); @@ -1121,7 +1123,6 @@ static int mpeg_release(struct file *file) videobuf_mmap_free(&fh->mpegq); - mutex_lock(&dev->core->lock); file->private_data = NULL; kfree(fh); @@ -1131,7 +1132,7 @@ static int mpeg_release(struct file *file) if (drv) drv->request_release(drv); - atomic_dec(&dev->core->mpeg_users); + dev->core->mpeg_users--; mutex_unlock(&dev->core->lock); diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 3d32f4a..9e8176e 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -390,7 +390,7 @@ struct cx88_core { /* various v4l controls */ u32 freq; atomic_t users; - atomic_t mpeg_users; + int mpeg_users; /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ struct cx8802_dev *dvbdev;