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.
Showing the changes to drivers/staging/lirc/lirc_it87.c (1 of 2 files). Show all
Unified · Split
| @@ -109,6 +109,7 @@ static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue); · 108 unmodified lines | ||
| 109 | 109 | |
| 110 | 110 | static DEFINE_SPINLOCK(hardware_lock); |
| 111 | 111 | static DEFINE_SPINLOCK(dev_lock); |
| 112 | +static bool device_open; | |
| 112 | 113 | |
| 113 | 114 | static int rx_buf[RBUF_LEN]; |
| 114 | 115 | unsigned int rx_tail, rx_head; |
| @@ -147,10 +148,11 @@ static void drop_port(void); · 32 unmodified lines | ||
| 147 | 148 | static int lirc_open(struct inode *inode, struct file *file) |
| 148 | 149 | { |
| 149 | 150 | spin_lock(&dev_lock); |
| 150 | − if (module_refcount(THIS_MODULE)) { | |
| 151 | + if (device_open) { | |
| 151 | 152 | spin_unlock(&dev_lock); |
| 152 | 153 | return -EBUSY; |
| 153 | 154 | } |
| 155 | + device_open = true; | |
| 154 | 156 | spin_unlock(&dev_lock); |
| 155 | 157 | return 0; |
| 156 | 158 | } |
| @@ -158,6 +160,9 @@ static int lirc_open(struct inode *inode, struct file *file) · 1 unmodified line | ||
| 158 | 160 | |
| 159 | 161 | static int lirc_close(struct inode *inode, struct file *file) |
| 160 | 162 | { |
| 163 | + spin_lock(&dev_lock); | |
| 164 | + device_open = false; | |
| 165 | + spin_unlock(&dev_lock); | |
| 161 | 166 | return 0; |
| 162 | 167 | } |
| 163 | 168 | |
| @@ -363,7 +368,6 @@ static struct lirc_driver driver = { · 199 unmodified lines | ||
| 363 | 368 | }; |
| 364 | 369 | |
| 365 | 370 | |
| 366 | −#ifdef MODULE | |
| 367 | 371 | static int init_chrdev(void) |
| 368 | 372 | { |
| 369 | 373 | driver.minor = lirc_register_driver(&driver); |
| @@ -380,7 +384,6 @@ static void drop_chrdev(void) · 10 unmodified lines | ||
| 380 | 384 | { |
| 381 | 385 | lirc_unregister_driver(driver.minor); |
| 382 | 386 | } |
| 383 | −#endif | |
| 384 | 387 | |
| 385 | 388 | |
| 386 | 389 | /* SECTION: Hardware */ |