From patchwork Fri Feb 18 01:15:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Walls X-Patchwork-Id: 572731 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 p1I1FPAY022669 for ; Fri, 18 Feb 2011 01:15:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758158Ab1BRBPM (ORCPT ); Thu, 17 Feb 2011 20:15:12 -0500 Received: from proofpoint-cluster.metrocast.net ([65.175.128.136]:11607 "EHLO proofpoint-cluster.metrocast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758091Ab1BRBPJ (ORCPT ); Thu, 17 Feb 2011 20:15:09 -0500 Received: from [192.168.1.2] (d-216-36-28-191.cpe.metrocast.net [216.36.28.191]) (authenticated bits=0) by mango.metrocast.net (8.13.8/8.13.8) with ESMTP id p1I1F7kR017768 for ; Fri, 18 Feb 2011 01:15:08 GMT Subject: [PATCH 04/13] lirc_zilog: Convert the instance open count to an atomic_t From: Andy Walls To: linux-media@vger.kernel.org In-Reply-To: <1297991502.9399.16.camel@localhost> References: <1297991502.9399.16.camel@localhost> Date: Thu, 17 Feb 2011 20:15:20 -0500 Message-ID: <1297991720.9399.20.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15, 1.0.148, 0.0.0000 definitions=2011-02-18_01:2011-02-17, 2011-02-18, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=5.0.0-1012030000 definitions=main-1102170207 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]); Fri, 18 Feb 2011 01:15:25 +0000 (UTC) diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c index 39f7b53..c857b99 100644 --- a/drivers/staging/lirc/lirc_zilog.c +++ b/drivers/staging/lirc/lirc_zilog.c @@ -94,7 +94,7 @@ struct IR { struct lirc_driver l; struct mutex ir_lock; - int open; + atomic_t open_count; struct i2c_adapter *adapter; struct IR_rx *rx; @@ -279,7 +279,7 @@ static int lirc_thread(void *arg) set_current_state(TASK_INTERRUPTIBLE); /* if device not opened, we can sleep half a second */ - if (!ir->open) { + if (atomic_read(&ir->open_count) == 0) { schedule_timeout(HZ/2); continue; } @@ -1094,10 +1094,7 @@ static int open(struct inode *node, struct file *filep) if (ir == NULL) return -ENODEV; - /* increment in use count */ - mutex_lock(&ir->ir_lock); - ++ir->open; - mutex_unlock(&ir->ir_lock); + atomic_inc(&ir->open_count); /* stash our IR struct */ filep->private_data = ir; @@ -1115,10 +1112,7 @@ static int close(struct inode *node, struct file *filep) return -ENODEV; } - /* decrement in use count */ - mutex_lock(&ir->ir_lock); - --ir->open; - mutex_unlock(&ir->ir_lock); + atomic_dec(&ir->open_count); return 0; } @@ -1294,6 +1288,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) ir->adapter = adap; mutex_init(&ir->ir_lock); + atomic_set(&ir->open_count, 0); /* set lirc_dev stuff */ memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));