From patchwork Thu Jul 29 15:35:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 115211 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6TFkvLt001405 for ; Thu, 29 Jul 2010 15:46:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757870Ab0G2Pqf (ORCPT ); Thu, 29 Jul 2010 11:46:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57322 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757390Ab0G2Pqd (ORCPT ); Thu, 29 Jul 2010 11:46:33 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6TFkIJc028002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Jul 2010 11:46:18 -0400 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6TFkIMX003742; Thu, 29 Jul 2010 11:46:18 -0400 Received: by xavier.bos.redhat.com (Postfix, from userid 501) id A001021D59; Thu, 29 Jul 2010 11:35:35 -0400 (EDT) Date: Thu, 29 Jul 2010 11:35:35 -0400 From: Jarod Wilson To: Randy Dunlap Cc: sfr@canb.auug.org.au, lirc-list@lists.sourceforge.net, linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, mchehab@redhat.com Subject: [PATCH] staging/lirc: fix non-CONFIG_MODULES build horkage Message-ID: <20100729153535.GB7507@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100728101358.e0dcd54d.randy.dunlap@oracle.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 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.3 (demeter.kernel.org [140.211.167.41]); Thu, 29 Jul 2010 15:46:57 +0000 (UTC) diff --git a/drivers/staging/lirc/lirc_it87.c b/drivers/staging/lirc/lirc_it87.c index 781abc3..72f07f1 100644 --- a/drivers/staging/lirc/lirc_it87.c +++ b/drivers/staging/lirc/lirc_it87.c @@ -109,6 +109,7 @@ static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue); static DEFINE_SPINLOCK(hardware_lock); static DEFINE_SPINLOCK(dev_lock); +static bool device_open; static int rx_buf[RBUF_LEN]; unsigned int rx_tail, rx_head; @@ -147,10 +148,11 @@ static void drop_port(void); static int lirc_open(struct inode *inode, struct file *file) { spin_lock(&dev_lock); - if (module_refcount(THIS_MODULE)) { + if (device_open) { spin_unlock(&dev_lock); return -EBUSY; } + device_open = true; spin_unlock(&dev_lock); return 0; } @@ -158,6 +160,9 @@ static int lirc_open(struct inode *inode, struct file *file) static int lirc_close(struct inode *inode, struct file *file) { + spin_lock(&dev_lock); + device_open = false; + spin_unlock(&dev_lock); return 0; } @@ -363,7 +368,6 @@ static struct lirc_driver driver = { }; -#ifdef MODULE static int init_chrdev(void) { driver.minor = lirc_register_driver(&driver); @@ -380,7 +384,6 @@ static void drop_chrdev(void) { lirc_unregister_driver(driver.minor); } -#endif /* SECTION: Hardware */ diff --git a/drivers/staging/lirc/lirc_parallel.c b/drivers/staging/lirc/lirc_parallel.c index df12e7b..04ce97713 100644 --- a/drivers/staging/lirc/lirc_parallel.c +++ b/drivers/staging/lirc/lirc_parallel.c @@ -240,7 +240,7 @@ static void irq_handler(void *blah) unsigned int level, newlevel; unsigned int timeout; - if (!module_refcount(THIS_MODULE)) + if (!is_open) return; if (!is_claimed) @@ -515,7 +515,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) static int lirc_open(struct inode *node, struct file *filep) { - if (module_refcount(THIS_MODULE) || !lirc_claim()) + if (is_open || !lirc_claim()) return -EBUSY; parport_enable_irq(pport);