V4L/DVB: staging/lirc: fix non-CONFIG_MODULES build horkage
authorJarod Wilson <jarod@redhat.com>
Thu, 29 Jul 2010 21:20:44 +0000 (18:20 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 9 Aug 2010 02:42:57 +0000 (23:42 -0300)
Fix when CONFIG_MODULES is not enabled:

drivers/staging/lirc/lirc_parallel.c:243: error: implicit declaration of function 'module_refcount'
drivers/staging/lirc/lirc_it87.c:150: error: implicit declaration of function 'module_refcount'
drivers/built-in.o: In function `it87_probe':
lirc_it87.c:(.text+0x4079b0): undefined reference to `init_chrdev'
lirc_it87.c:(.text+0x4079cc): undefined reference to `drop_chrdev'
drivers/built-in.o: In function `lirc_it87_exit':
lirc_it87.c:(.exit.text+0x38a5): undefined reference to `drop_chrdev'

Its a quick hack and untested beyond building, since I don't have the
hardware, but it should do the trick.

Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/lirc/lirc_it87.c
drivers/staging/lirc/lirc_parallel.c

index 09f36961c6d29279f24aa350112df15c6e3678cc..ec11c0e949a059476ff252c6ac7daeff4e75d414 100644 (file)
@@ -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 */
index a1ebd071640f7fe3393d7dda28b6c6ea421d1730..6da4a8c6ebc3b3367d23af5c31d3129d8af6f118 100644 (file)
@@ -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);