aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/Kconfig2
-rw-r--r--drivers/char/agp/amd64-agp.c39
-rw-r--r--drivers/char/agp/generic.c4
-rw-r--r--drivers/char/apm-emulation.c12
-rw-r--r--drivers/char/applicom.c9
-rw-r--r--drivers/char/bfin-otp.c1
-rw-r--r--drivers/char/briq_panel.c1
-rw-r--r--drivers/char/bsr.c1
-rw-r--r--drivers/char/cs5535_gpio.c3
-rw-r--r--drivers/char/ds1302.c16
-rw-r--r--drivers/char/ds1620.c9
-rw-r--r--drivers/char/dsp56k.c28
-rw-r--r--drivers/char/dtlk.c9
-rw-r--r--drivers/char/generic_nvram.c7
-rw-r--r--drivers/char/genrtc.c14
-rw-r--r--drivers/char/hpet.c98
-rw-r--r--drivers/char/hw_random/core.c1
-rw-r--r--drivers/char/i8k.c7
-rw-r--r--drivers/char/ip2/ip2main.c9
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c15
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c9
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/lp.c16
-rw-r--r--drivers/char/mbcs.c8
-rw-r--r--drivers/char/mem.c3
-rw-r--r--drivers/char/misc.c1
-rw-r--r--drivers/char/mmtimer.c8
-rw-r--r--drivers/char/mspec.c9
-rw-r--r--drivers/char/mwave/mwavedd.c47
-rw-r--r--drivers/char/nvram.c11
-rw-r--r--drivers/char/nwbutton.c1
-rw-r--r--drivers/char/nwflash.c12
-rw-r--r--drivers/char/pc8736x_gpio.c1
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c42
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c47
-rw-r--r--drivers/char/pcmcia/ipwireless/main.c117
-rw-r--r--drivers/char/pcmcia/ipwireless/main.h5
-rw-r--r--drivers/char/pcmcia/ipwireless/tty.h1
-rw-r--r--drivers/char/pcmcia/synclink_cs.c46
-rw-r--r--drivers/char/ppdev.c8
-rw-r--r--drivers/char/random.c2
-rw-r--r--drivers/char/raw.c245
-rw-r--r--drivers/char/rio/rio_linux.c8
-rw-r--r--drivers/char/scx200_gpio.c1
-rw-r--r--drivers/char/snsc.c10
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c1
-rw-r--r--drivers/char/sysrq.c1
-rw-r--r--drivers/char/tb0219.c1
-rw-r--r--drivers/char/tlclk.c7
-rw-r--r--drivers/char/toshiba.c10
-rw-r--r--drivers/char/tpm/tpm.c22
-rw-r--r--drivers/char/uv_mmtimer.c1
-rw-r--r--drivers/char/viotape.c12
-rw-r--r--drivers/char/virtio_console.c240
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c7
56 files changed, 724 insertions, 523 deletions
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 4b66c69eaf57..5ddf67e76f8b 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -57,7 +57,7 @@ config AGP_AMD
57 57
58config AGP_AMD64 58config AGP_AMD64
59 tristate "AMD Opteron/Athlon64 on-CPU GART support" 59 tristate "AMD Opteron/Athlon64 on-CPU GART support"
60 depends on AGP && X86 && K8_NB 60 depends on AGP && X86 && AMD_NB
61 help 61 help
62 This option gives you AGP support for the GLX component of 62 This option gives you AGP support for the GLX component of
63 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. 63 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 70312da4c968..42396df55556 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -15,7 +15,7 @@
15#include <linux/mmzone.h> 15#include <linux/mmzone.h>
16#include <asm/page.h> /* PAGE_SIZE */ 16#include <asm/page.h> /* PAGE_SIZE */
17#include <asm/e820.h> 17#include <asm/e820.h>
18#include <asm/k8.h> 18#include <asm/amd_nb.h>
19#include <asm/gart.h> 19#include <asm/gart.h>
20#include "agp.h" 20#include "agp.h"
21 21
@@ -124,7 +124,7 @@ static int amd64_fetch_size(void)
124 u32 temp; 124 u32 temp;
125 struct aper_size_info_32 *values; 125 struct aper_size_info_32 *values;
126 126
127 dev = k8_northbridges[0]; 127 dev = k8_northbridges.nb_misc[0];
128 if (dev==NULL) 128 if (dev==NULL)
129 return 0; 129 return 0;
130 130
@@ -181,10 +181,14 @@ static int amd_8151_configure(void)
181 unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real); 181 unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real);
182 int i; 182 int i;
183 183
184 if (!k8_northbridges.gart_supported)
185 return 0;
186
184 /* Configure AGP regs in each x86-64 host bridge. */ 187 /* Configure AGP regs in each x86-64 host bridge. */
185 for (i = 0; i < num_k8_northbridges; i++) { 188 for (i = 0; i < k8_northbridges.num; i++) {
186 agp_bridge->gart_bus_addr = 189 agp_bridge->gart_bus_addr =
187 amd64_configure(k8_northbridges[i], gatt_bus); 190 amd64_configure(k8_northbridges.nb_misc[i],
191 gatt_bus);
188 } 192 }
189 k8_flush_garts(); 193 k8_flush_garts();
190 return 0; 194 return 0;
@@ -195,11 +199,15 @@ static void amd64_cleanup(void)
195{ 199{
196 u32 tmp; 200 u32 tmp;
197 int i; 201 int i;
198 for (i = 0; i < num_k8_northbridges; i++) { 202
199 struct pci_dev *dev = k8_northbridges[i]; 203 if (!k8_northbridges.gart_supported)
204 return;
205
206 for (i = 0; i < k8_northbridges.num; i++) {
207 struct pci_dev *dev = k8_northbridges.nb_misc[i];
200 /* disable gart translation */ 208 /* disable gart translation */
201 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp); 209 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp);
202 tmp &= ~AMD64_GARTEN; 210 tmp &= ~GARTEN;
203 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp); 211 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp);
204 } 212 }
205} 213}
@@ -313,22 +321,25 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
313 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) 321 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order))
314 return -1; 322 return -1;
315 323
316 pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); 324 gart_set_size_and_enable(nb, order);
317 pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25); 325 pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25);
318 326
319 return 0; 327 return 0;
320} 328}
321 329
322static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) 330static __devinit int cache_nbs(struct pci_dev *pdev, u32 cap_ptr)
323{ 331{
324 int i; 332 int i;
325 333
326 if (cache_k8_northbridges() < 0) 334 if (cache_k8_northbridges() < 0)
327 return -ENODEV; 335 return -ENODEV;
328 336
337 if (!k8_northbridges.gart_supported)
338 return -ENODEV;
339
329 i = 0; 340 i = 0;
330 for (i = 0; i < num_k8_northbridges; i++) { 341 for (i = 0; i < k8_northbridges.num; i++) {
331 struct pci_dev *dev = k8_northbridges[i]; 342 struct pci_dev *dev = k8_northbridges.nb_misc[i];
332 if (fix_northbridge(dev, pdev, cap_ptr) < 0) { 343 if (fix_northbridge(dev, pdev, cap_ptr) < 0) {
333 dev_err(&dev->dev, "no usable aperture found\n"); 344 dev_err(&dev->dev, "no usable aperture found\n");
334#ifdef __x86_64__ 345#ifdef __x86_64__
@@ -405,7 +416,8 @@ static int __devinit uli_agp_init(struct pci_dev *pdev)
405 } 416 }
406 417
407 /* shadow x86-64 registers into ULi registers */ 418 /* shadow x86-64 registers into ULi registers */
408 pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &httfea); 419 pci_read_config_dword (k8_northbridges.nb_misc[0], AMD64_GARTAPERTUREBASE,
420 &httfea);
409 421
410 /* if x86-64 aperture base is beyond 4G, exit here */ 422 /* if x86-64 aperture base is beyond 4G, exit here */
411 if ((httfea & 0x7fff) >> (32 - 25)) { 423 if ((httfea & 0x7fff) >> (32 - 25)) {
@@ -472,7 +484,8 @@ static int nforce3_agp_init(struct pci_dev *pdev)
472 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); 484 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp);
473 485
474 /* shadow x86-64 registers into NVIDIA registers */ 486 /* shadow x86-64 registers into NVIDIA registers */
475 pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &apbase); 487 pci_read_config_dword (k8_northbridges.nb_misc[0], AMD64_GARTAPERTUREBASE,
488 &apbase);
476 489
477 /* if x86-64 aperture base is beyond 4G, exit here */ 490 /* if x86-64 aperture base is beyond 4G, exit here */
478 if ( (apbase & 0x7fff) >> (32 - 25) ) { 491 if ( (apbase & 0x7fff) >> (32 - 25) ) {
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index d2abf5143983..64255cef8a7d 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -984,7 +984,9 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
984 984
985 bridge->driver->cache_flush(); 985 bridge->driver->cache_flush();
986#ifdef CONFIG_X86 986#ifdef CONFIG_X86
987 set_memory_uc((unsigned long)table, 1 << page_order); 987 if (set_memory_uc((unsigned long)table, 1 << page_order))
988 printk(KERN_WARNING "Could not set GATT table memory to UC!");
989
988 bridge->gatt_table = (void *)table; 990 bridge->gatt_table = (void *)table;
989#else 991#else
990 bridge->gatt_table = ioremap_nocache(virt_to_phys(table), 992 bridge->gatt_table = ioremap_nocache(virt_to_phys(table),
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 033e1505fca9..3022801669b1 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -13,7 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/poll.h> 14#include <linux/poll.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/smp_lock.h> 16#include <linux/mutex.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
@@ -126,6 +126,7 @@ struct apm_user {
126/* 126/*
127 * Local variables 127 * Local variables
128 */ 128 */
129static DEFINE_MUTEX(apm_mutex);
129static atomic_t suspend_acks_pending = ATOMIC_INIT(0); 130static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
130static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); 131static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
131static int apm_disabled; 132static int apm_disabled;
@@ -274,7 +275,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
274 if (!as->suser || !as->writer) 275 if (!as->suser || !as->writer)
275 return -EPERM; 276 return -EPERM;
276 277
277 lock_kernel(); 278 mutex_lock(&apm_mutex);
278 switch (cmd) { 279 switch (cmd) {
279 case APM_IOC_SUSPEND: 280 case APM_IOC_SUSPEND:
280 mutex_lock(&state_lock); 281 mutex_lock(&state_lock);
@@ -335,7 +336,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
335 mutex_unlock(&state_lock); 336 mutex_unlock(&state_lock);
336 break; 337 break;
337 } 338 }
338 unlock_kernel(); 339 mutex_unlock(&apm_mutex);
339 340
340 return err; 341 return err;
341} 342}
@@ -370,7 +371,7 @@ static int apm_open(struct inode * inode, struct file * filp)
370{ 371{
371 struct apm_user *as; 372 struct apm_user *as;
372 373
373 lock_kernel(); 374 mutex_lock(&apm_mutex);
374 as = kzalloc(sizeof(*as), GFP_KERNEL); 375 as = kzalloc(sizeof(*as), GFP_KERNEL);
375 if (as) { 376 if (as) {
376 /* 377 /*
@@ -390,7 +391,7 @@ static int apm_open(struct inode * inode, struct file * filp)
390 391
391 filp->private_data = as; 392 filp->private_data = as;
392 } 393 }
393 unlock_kernel(); 394 mutex_unlock(&apm_mutex);
394 395
395 return as ? 0 : -ENOMEM; 396 return as ? 0 : -ENOMEM;
396} 397}
@@ -402,6 +403,7 @@ static const struct file_operations apm_bios_fops = {
402 .unlocked_ioctl = apm_ioctl, 403 .unlocked_ioctl = apm_ioctl,
403 .open = apm_open, 404 .open = apm_open,
404 .release = apm_release, 405 .release = apm_release,
406 .llseek = noop_llseek,
405}; 407};
406 408
407static struct miscdevice apm_device = { 409static struct miscdevice apm_device = {
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index f4ae0e0fb631..e7ba774beda6 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -26,7 +26,7 @@
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/smp_lock.h> 29#include <linux/mutex.h>
30#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/wait.h> 32#include <linux/wait.h>
@@ -60,6 +60,7 @@
60#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 60#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003
61#endif 61#endif
62 62
63static DEFINE_MUTEX(ac_mutex);
63static char *applicom_pci_devnames[] = { 64static char *applicom_pci_devnames[] = {
64 "PCI board", 65 "PCI board",
65 "PCI2000IBS / PCI2000CAN", 66 "PCI2000IBS / PCI2000CAN",
@@ -707,7 +708,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
707 if (IS_ERR(adgl)) 708 if (IS_ERR(adgl))
708 return PTR_ERR(adgl); 709 return PTR_ERR(adgl);
709 710
710 lock_kernel(); 711 mutex_lock(&ac_mutex);
711 IndexCard = adgl->num_card-1; 712 IndexCard = adgl->num_card-1;
712 713
713 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { 714 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
@@ -717,7 +718,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
717 warncount--; 718 warncount--;
718 } 719 }
719 kfree(adgl); 720 kfree(adgl);
720 unlock_kernel(); 721 mutex_unlock(&ac_mutex);
721 return -EINVAL; 722 return -EINVAL;
722 } 723 }
723 724
@@ -835,7 +836,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
835 } 836 }
836 Dummy = readb(apbs[IndexCard].RamIO + VERS); 837 Dummy = readb(apbs[IndexCard].RamIO + VERS);
837 kfree(adgl); 838 kfree(adgl);
838 unlock_kernel(); 839 mutex_unlock(&ac_mutex);
839 return 0; 840 return 0;
840} 841}
841 842
diff --git a/drivers/char/bfin-otp.c b/drivers/char/bfin-otp.c
index 836d4f0a876f..44660f1c4849 100644
--- a/drivers/char/bfin-otp.c
+++ b/drivers/char/bfin-otp.c
@@ -222,6 +222,7 @@ static const struct file_operations bfin_otp_fops = {
222 .unlocked_ioctl = bfin_otp_ioctl, 222 .unlocked_ioctl = bfin_otp_ioctl,
223 .read = bfin_otp_read, 223 .read = bfin_otp_read,
224 .write = bfin_otp_write, 224 .write = bfin_otp_write,
225 .llseek = default_llseek,
225}; 226};
226 227
227static struct miscdevice bfin_otp_misc_device = { 228static struct miscdevice bfin_otp_misc_device = {
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
index d5fa113afe37..f6718f05dad4 100644
--- a/drivers/char/briq_panel.c
+++ b/drivers/char/briq_panel.c
@@ -186,6 +186,7 @@ static const struct file_operations briq_panel_fops = {
186 .write = briq_panel_write, 186 .write = briq_panel_write,
187 .open = briq_panel_open, 187 .open = briq_panel_open,
188 .release = briq_panel_release, 188 .release = briq_panel_release,
189 .llseek = noop_llseek,
189}; 190};
190 191
191static struct miscdevice briq_panel_miscdev = { 192static struct miscdevice briq_panel_miscdev = {
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 91917133ae0a..a4a6c2f044b5 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -155,6 +155,7 @@ static const struct file_operations bsr_fops = {
155 .owner = THIS_MODULE, 155 .owner = THIS_MODULE,
156 .mmap = bsr_mmap, 156 .mmap = bsr_mmap,
157 .open = bsr_open, 157 .open = bsr_open,
158 .llseek = noop_llseek,
158}; 159};
159 160
160static void bsr_cleanup_devs(void) 161static void bsr_cleanup_devs(void)
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c
index 4d830dc482ef..0cf1e5fad9ab 100644
--- a/drivers/char/cs5535_gpio.c
+++ b/drivers/char/cs5535_gpio.c
@@ -169,7 +169,8 @@ static const struct file_operations cs5535_gpio_fops = {
169 .owner = THIS_MODULE, 169 .owner = THIS_MODULE,
170 .write = cs5535_gpio_write, 170 .write = cs5535_gpio_write,
171 .read = cs5535_gpio_read, 171 .read = cs5535_gpio_read,
172 .open = cs5535_gpio_open 172 .open = cs5535_gpio_open,
173 .llseek = no_llseek,
173}; 174};
174 175
175static int __init cs5535_gpio_init(void) 176static int __init cs5535_gpio_init(void)
diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c
index 170693c93c73..ed8303f9890c 100644
--- a/drivers/char/ds1302.c
+++ b/drivers/char/ds1302.c
@@ -20,7 +20,7 @@
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/bcd.h> 22#include <linux/bcd.h>
23#include <linux/smp_lock.h> 23#include <linux/mutex.h>
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/io.h> 25#include <linux/io.h>
26 26
@@ -32,6 +32,7 @@
32 32
33#define RTC_MAJOR_NR 121 /* local major, change later */ 33#define RTC_MAJOR_NR 121 /* local major, change later */
34 34
35static DEFINE_MUTEX(rtc_mutex);
35static const char ds1302_name[] = "ds1302"; 36static const char ds1302_name[] = "ds1302";
36 37
37/* Send 8 bits. */ 38/* Send 8 bits. */
@@ -164,9 +165,9 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
164 struct rtc_time rtc_tm; 165 struct rtc_time rtc_tm;
165 166
166 memset(&rtc_tm, 0, sizeof (struct rtc_time)); 167 memset(&rtc_tm, 0, sizeof (struct rtc_time));
167 lock_kernel(); 168 mutex_lock(&rtc_mutex);
168 get_rtc_time(&rtc_tm); 169 get_rtc_time(&rtc_tm);
169 unlock_kernel(); 170 mutex_unlock(&rtc_mutex);
170 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) 171 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
171 return -EFAULT; 172 return -EFAULT;
172 return 0; 173 return 0;
@@ -218,7 +219,7 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
218 mon = bin2bcd(mon); 219 mon = bin2bcd(mon);
219 yrs = bin2bcd(yrs); 220 yrs = bin2bcd(yrs);
220 221
221 lock_kernel(); 222 mutex_lock(&rtc_mutex);
222 local_irq_save(flags); 223 local_irq_save(flags);
223 CMOS_WRITE(yrs, RTC_YEAR); 224 CMOS_WRITE(yrs, RTC_YEAR);
224 CMOS_WRITE(mon, RTC_MONTH); 225 CMOS_WRITE(mon, RTC_MONTH);
@@ -227,7 +228,7 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
227 CMOS_WRITE(min, RTC_MINUTES); 228 CMOS_WRITE(min, RTC_MINUTES);
228 CMOS_WRITE(sec, RTC_SECONDS); 229 CMOS_WRITE(sec, RTC_SECONDS);
229 local_irq_restore(flags); 230 local_irq_restore(flags);
230 unlock_kernel(); 231 mutex_unlock(&rtc_mutex);
231 232
232 /* Notice that at this point, the RTC is updated but 233 /* Notice that at this point, the RTC is updated but
233 * the kernel is still running with the old time. 234 * the kernel is still running with the old time.
@@ -247,10 +248,10 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
247 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) 248 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int)))
248 return -EFAULT; 249 return -EFAULT;
249 250
250 lock_kernel(); 251 mutex_lock(&rtc_mutex);
251 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); 252 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F);
252 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); 253 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val);
253 unlock_kernel(); 254 mutex_unlock(&rtc_mutex);
254 return 0; 255 return 0;
255 } 256 }
256 default: 257 default:
@@ -288,6 +289,7 @@ get_rtc_status(char *buf)
288static const struct file_operations rtc_fops = { 289static const struct file_operations rtc_fops = {
289 .owner = THIS_MODULE, 290 .owner = THIS_MODULE,
290 .unlocked_ioctl = rtc_ioctl, 291 .unlocked_ioctl = rtc_ioctl,
292 .llseek = noop_llseek,
291}; 293};
292 294
293/* Probe for the chip by writing something to its RAM and try reading it back. */ 295/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index dbee8688f75c..aab9605f0b43 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -8,7 +8,7 @@
8#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
9#include <linux/capability.h> 9#include <linux/capability.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/smp_lock.h> 11#include <linux/mutex.h>
12 12
13#include <mach/hardware.h> 13#include <mach/hardware.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
@@ -34,6 +34,7 @@
34#define CFG_CPU 2 34#define CFG_CPU 2
35#define CFG_1SHOT 1 35#define CFG_1SHOT 1
36 36
37static DEFINE_MUTEX(ds1620_mutex);
37static const char *fan_state[] = { "off", "on", "on (hardwired)" }; 38static const char *fan_state[] = { "off", "on", "on (hardwired)" };
38 39
39/* 40/*
@@ -210,7 +211,6 @@ static void ds1620_read_state(struct therm *therm)
210 211
211static int ds1620_open(struct inode *inode, struct file *file) 212static int ds1620_open(struct inode *inode, struct file *file)
212{ 213{
213 cycle_kernel_lock();
214 return nonseekable_open(inode, file); 214 return nonseekable_open(inode, file);
215} 215}
216 216
@@ -321,9 +321,9 @@ ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
321{ 321{
322 int ret; 322 int ret;
323 323
324 lock_kernel(); 324 mutex_lock(&ds1620_mutex);
325 ret = ds1620_ioctl(file, cmd, arg); 325 ret = ds1620_ioctl(file, cmd, arg);
326 unlock_kernel(); 326 mutex_unlock(&ds1620_mutex);
327 327
328 return ret; 328 return ret;
329} 329}
@@ -357,6 +357,7 @@ static const struct file_operations ds1620_fops = {
357 .open = ds1620_open, 357 .open = ds1620_open,
358 .read = ds1620_read, 358 .read = ds1620_read,
359 .unlocked_ioctl = ds1620_unlocked_ioctl, 359 .unlocked_ioctl = ds1620_unlocked_ioctl,
360 .llseek = no_llseek,
360}; 361};
361 362
362static struct miscdevice ds1620_miscdev = { 363static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 8a1b28a10ef0..052797b32bd3 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -32,7 +32,7 @@
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/smp_lock.h> 35#include <linux/mutex.h>
36#include <linux/firmware.h> 36#include <linux/firmware.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/uaccess.h> /* For put_user and get_user */ 38#include <linux/uaccess.h> /* For put_user and get_user */
@@ -94,6 +94,7 @@
94 } \ 94 } \
95} 95}
96 96
97static DEFINE_MUTEX(dsp56k_mutex);
97static struct dsp56k_device { 98static struct dsp56k_device {
98 unsigned long in_use; 99 unsigned long in_use;
99 long maxio, timeout; 100 long maxio, timeout;
@@ -330,9 +331,9 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
330 if (len > DSP56K_MAX_BINARY_LENGTH) { 331 if (len > DSP56K_MAX_BINARY_LENGTH) {
331 return -EINVAL; 332 return -EINVAL;
332 } 333 }
333 lock_kernel(); 334 mutex_lock(&dsp56k_mutex);
334 r = dsp56k_upload(bin, len); 335 r = dsp56k_upload(bin, len);
335 unlock_kernel(); 336 mutex_unlock(&dsp56k_mutex);
336 if (r < 0) { 337 if (r < 0) {
337 return r; 338 return r;
338 } 339 }
@@ -342,16 +343,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
342 case DSP56K_SET_TX_WSIZE: 343 case DSP56K_SET_TX_WSIZE:
343 if (arg > 4 || arg < 1) 344 if (arg > 4 || arg < 1)
344 return -EINVAL; 345 return -EINVAL;
345 lock_kernel(); 346 mutex_lock(&dsp56k_mutex);
346 dsp56k.tx_wsize = (int) arg; 347 dsp56k.tx_wsize = (int) arg;
347 unlock_kernel(); 348 mutex_unlock(&dsp56k_mutex);
348 break; 349 break;
349 case DSP56K_SET_RX_WSIZE: 350 case DSP56K_SET_RX_WSIZE:
350 if (arg > 4 || arg < 1) 351 if (arg > 4 || arg < 1)
351 return -EINVAL; 352 return -EINVAL;
352 lock_kernel(); 353 mutex_lock(&dsp56k_mutex);
353 dsp56k.rx_wsize = (int) arg; 354 dsp56k.rx_wsize = (int) arg;
354 unlock_kernel(); 355 mutex_unlock(&dsp56k_mutex);
355 break; 356 break;
356 case DSP56K_HOST_FLAGS: 357 case DSP56K_HOST_FLAGS:
357 { 358 {
@@ -363,7 +364,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
363 if(get_user(out, &hf->out) < 0) 364 if(get_user(out, &hf->out) < 0)
364 return -EFAULT; 365 return -EFAULT;
365 366
366 lock_kernel(); 367 mutex_lock(&dsp56k_mutex);
367 if ((dir & 0x1) && (out & 0x1)) 368 if ((dir & 0x1) && (out & 0x1))
368 dsp56k_host_interface.icr |= DSP56K_ICR_HF0; 369 dsp56k_host_interface.icr |= DSP56K_ICR_HF0;
369 else if (dir & 0x1) 370 else if (dir & 0x1)
@@ -378,16 +379,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
378 if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; 379 if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2;
379 if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; 380 if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4;
380 if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; 381 if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8;
381 unlock_kernel(); 382 mutex_unlock(&dsp56k_mutex);
382 return put_user(status, &hf->status); 383 return put_user(status, &hf->status);
383 } 384 }
384 case DSP56K_HOST_CMD: 385 case DSP56K_HOST_CMD:
385 if (arg > 31 || arg < 0) 386 if (arg > 31 || arg < 0)
386 return -EINVAL; 387 return -EINVAL;
387 lock_kernel(); 388 mutex_lock(&dsp56k_mutex);
388 dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | 389 dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) |
389 DSP56K_CVR_HC); 390 DSP56K_CVR_HC);
390 unlock_kernel(); 391 mutex_unlock(&dsp56k_mutex);
391 break; 392 break;
392 default: 393 default:
393 return -EINVAL; 394 return -EINVAL;
@@ -427,7 +428,7 @@ static int dsp56k_open(struct inode *inode, struct file *file)
427 int dev = iminor(inode) & 0x0f; 428 int dev = iminor(inode) & 0x0f;
428 int ret = 0; 429 int ret = 0;
429 430
430 lock_kernel(); 431 mutex_lock(&dsp56k_mutex);
431 switch(dev) 432 switch(dev)
432 { 433 {
433 case DSP56K_DEV_56001: 434 case DSP56K_DEV_56001:
@@ -454,7 +455,7 @@ static int dsp56k_open(struct inode *inode, struct file *file)
454 ret = -ENODEV; 455 ret = -ENODEV;
455 } 456 }
456out: 457out:
457 unlock_kernel(); 458 mutex_unlock(&dsp56k_mutex);
458 return ret; 459 return ret;
459} 460}
460 461
@@ -482,6 +483,7 @@ static const struct file_operations dsp56k_fops = {
482 .unlocked_ioctl = dsp56k_ioctl, 483 .unlocked_ioctl = dsp56k_ioctl,
483 .open = dsp56k_open, 484 .open = dsp56k_open,
484 .release = dsp56k_release, 485 .release = dsp56k_release,
486 .llseek = noop_llseek,
485}; 487};
486 488
487 489
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index e3859d4eaead..85156dd0caee 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -57,7 +57,7 @@
57#include <linux/ioport.h> /* for request_region */ 57#include <linux/ioport.h> /* for request_region */
58#include <linux/delay.h> /* for loops_per_jiffy */ 58#include <linux/delay.h> /* for loops_per_jiffy */
59#include <linux/sched.h> 59#include <linux/sched.h>
60#include <linux/smp_lock.h> /* cycle_kernel_lock() */ 60#include <linux/mutex.h>
61#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ 61#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */
62#include <asm/uaccess.h> /* for get_user, etc. */ 62#include <asm/uaccess.h> /* for get_user, etc. */
63#include <linux/wait.h> /* for wait_queue */ 63#include <linux/wait.h> /* for wait_queue */
@@ -73,6 +73,7 @@
73#define TRACE_RET ((void) 0) 73#define TRACE_RET ((void) 0)
74#endif /* TRACING */ 74#endif /* TRACING */
75 75
76static DEFINE_MUTEX(dtlk_mutex);
76static void dtlk_timer_tick(unsigned long data); 77static void dtlk_timer_tick(unsigned long data);
77 78
78static int dtlk_major; 79static int dtlk_major;
@@ -105,6 +106,7 @@ static const struct file_operations dtlk_fops =
105 .unlocked_ioctl = dtlk_ioctl, 106 .unlocked_ioctl = dtlk_ioctl,
106 .open = dtlk_open, 107 .open = dtlk_open,
107 .release = dtlk_release, 108 .release = dtlk_release,
109 .llseek = no_llseek,
108}; 110};
109 111
110/* local prototypes */ 112/* local prototypes */
@@ -275,9 +277,9 @@ static long dtlk_ioctl(struct file *file,
275 switch (cmd) { 277 switch (cmd) {
276 278
277 case DTLK_INTERROGATE: 279 case DTLK_INTERROGATE:
278 lock_kernel(); 280 mutex_lock(&dtlk_mutex);
279 sp = dtlk_interrogate(); 281 sp = dtlk_interrogate();
280 unlock_kernel(); 282 mutex_unlock(&dtlk_mutex);
281 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) 283 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
282 return -EINVAL; 284 return -EINVAL;
283 return 0; 285 return 0;
@@ -296,7 +298,6 @@ static int dtlk_open(struct inode *inode, struct file *file)
296{ 298{
297 TRACE_TEXT("(dtlk_open"); 299 TRACE_TEXT("(dtlk_open");
298 300
299 cycle_kernel_lock();
300 nonseekable_open(inode, file); 301 nonseekable_open(inode, file);
301 switch (iminor(inode)) { 302 switch (iminor(inode)) {
302 case DTLK_MINOR: 303 case DTLK_MINOR:
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index 82b5a88a82d7..0e941b57482e 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -19,7 +19,7 @@
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/fcntl.h> 20#include <linux/fcntl.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/smp_lock.h> 22#include <linux/mutex.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <asm/nvram.h> 24#include <asm/nvram.h>
25#ifdef CONFIG_PPC_PMAC 25#ifdef CONFIG_PPC_PMAC
@@ -28,6 +28,7 @@
28 28
29#define NVRAM_SIZE 8192 29#define NVRAM_SIZE 8192
30 30
31static DEFINE_MUTEX(nvram_mutex);
31static ssize_t nvram_len; 32static ssize_t nvram_len;
32 33
33static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 34static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
@@ -120,9 +121,9 @@ static long nvram_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned l
120{ 121{
121 int ret; 122 int ret;
122 123
123 lock_kernel(); 124 mutex_lock(&nvram_mutex);
124 ret = nvram_ioctl(file, cmd, arg); 125 ret = nvram_ioctl(file, cmd, arg);
125 unlock_kernel(); 126 mutex_unlock(&nvram_mutex);
126 127
127 return ret; 128 return ret;
128} 129}
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index b6c2cc167c11..f773a9dd14f3 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -52,7 +52,7 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/poll.h> 53#include <linux/poll.h>
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/smp_lock.h> 55#include <linux/mutex.h>
56#include <linux/workqueue.h> 56#include <linux/workqueue.h>
57 57
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
@@ -66,6 +66,7 @@
66 * ioctls. 66 * ioctls.
67 */ 67 */
68 68
69static DEFINE_MUTEX(gen_rtc_mutex);
69static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); 70static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait);
70 71
71/* 72/*
@@ -337,9 +338,9 @@ static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
337{ 338{
338 int ret; 339 int ret;
339 340
340 lock_kernel(); 341 mutex_lock(&gen_rtc_mutex);
341 ret = gen_rtc_ioctl(file, cmd, arg); 342 ret = gen_rtc_ioctl(file, cmd, arg);
342 unlock_kernel(); 343 mutex_unlock(&gen_rtc_mutex);
343 344
344 return ret; 345 return ret;
345} 346}
@@ -352,16 +353,16 @@ static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
352 353
353static int gen_rtc_open(struct inode *inode, struct file *file) 354static int gen_rtc_open(struct inode *inode, struct file *file)
354{ 355{
355 lock_kernel(); 356 mutex_lock(&gen_rtc_mutex);
356 if (gen_rtc_status & RTC_IS_OPEN) { 357 if (gen_rtc_status & RTC_IS_OPEN) {
357 unlock_kernel(); 358 mutex_unlock(&gen_rtc_mutex);
358 return -EBUSY; 359 return -EBUSY;
359 } 360 }
360 361
361 gen_rtc_status |= RTC_IS_OPEN; 362 gen_rtc_status |= RTC_IS_OPEN;
362 gen_rtc_irq_data = 0; 363 gen_rtc_irq_data = 0;
363 irq_active = 0; 364 irq_active = 0;
364 unlock_kernel(); 365 mutex_unlock(&gen_rtc_mutex);
365 366
366 return 0; 367 return 0;
367} 368}
@@ -497,6 +498,7 @@ static const struct file_operations gen_rtc_fops = {
497 .unlocked_ioctl = gen_rtc_unlocked_ioctl, 498 .unlocked_ioctl = gen_rtc_unlocked_ioctl,
498 .open = gen_rtc_open, 499 .open = gen_rtc_open,
499 .release = gen_rtc_release, 500 .release = gen_rtc_release,
501 .llseek = noop_llseek,
500}; 502};
501 503
502static struct miscdevice rtc_gen_dev = 504static struct miscdevice rtc_gen_dev =
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index a0a1829d3198..a4eee324eb1e 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -30,6 +30,7 @@
30#include <linux/bcd.h> 30#include <linux/bcd.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/bitops.h> 32#include <linux/bitops.h>
33#include <linux/compat.h>
33#include <linux/clocksource.h> 34#include <linux/clocksource.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35 36
@@ -67,6 +68,7 @@
67#define read_counter(MC) readl(MC) 68#define read_counter(MC) readl(MC)
68#endif 69#endif
69 70
71static DEFINE_MUTEX(hpet_mutex); /* replaces BKL */
70static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ; 72static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ;
71 73
72/* This clocksource driver currently only works on ia64 */ 74/* This clocksource driver currently only works on ia64 */
@@ -250,7 +252,7 @@ static int hpet_open(struct inode *inode, struct file *file)
250 if (file->f_mode & FMODE_WRITE) 252 if (file->f_mode & FMODE_WRITE)
251 return -EINVAL; 253 return -EINVAL;
252 254
253 lock_kernel(); 255 mutex_lock(&hpet_mutex);
254 spin_lock_irq(&hpet_lock); 256 spin_lock_irq(&hpet_lock);
255 257
256 for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) 258 for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
@@ -264,7 +266,7 @@ static int hpet_open(struct inode *inode, struct file *file)
264 266
265 if (!devp) { 267 if (!devp) {
266 spin_unlock_irq(&hpet_lock); 268 spin_unlock_irq(&hpet_lock);
267 unlock_kernel(); 269 mutex_unlock(&hpet_mutex);
268 return -EBUSY; 270 return -EBUSY;
269 } 271 }
270 272
@@ -272,7 +274,7 @@ static int hpet_open(struct inode *inode, struct file *file)
272 devp->hd_irqdata = 0; 274 devp->hd_irqdata = 0;
273 devp->hd_flags |= HPET_OPEN; 275 devp->hd_flags |= HPET_OPEN;
274 spin_unlock_irq(&hpet_lock); 276 spin_unlock_irq(&hpet_lock);
275 unlock_kernel(); 277 mutex_unlock(&hpet_mutex);
276 278
277 hpet_timer_set_irq(devp); 279 hpet_timer_set_irq(devp);
278 280
@@ -429,22 +431,6 @@ static int hpet_release(struct inode *inode, struct file *file)
429 return 0; 431 return 0;
430} 432}
431 433
432static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);
433
434static long hpet_ioctl(struct file *file, unsigned int cmd,
435 unsigned long arg)
436{
437 struct hpet_dev *devp;
438 int ret;
439
440 devp = file->private_data;
441 lock_kernel();
442 ret = hpet_ioctl_common(devp, cmd, arg, 0);
443 unlock_kernel();
444
445 return ret;
446}
447
448static int hpet_ioctl_ieon(struct hpet_dev *devp) 434static int hpet_ioctl_ieon(struct hpet_dev *devp)
449{ 435{
450 struct hpet_timer __iomem *timer; 436 struct hpet_timer __iomem *timer;
@@ -553,7 +539,8 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
553} 539}
554 540
555static int 541static int
556hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) 542hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
543 struct hpet_info *info)
557{ 544{
558 struct hpet_timer __iomem *timer; 545 struct hpet_timer __iomem *timer;
559 struct hpet __iomem *hpet; 546 struct hpet __iomem *hpet;
@@ -594,23 +581,15 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
594 break; 581 break;
595 case HPET_INFO: 582 case HPET_INFO:
596 { 583 {
597 struct hpet_info info;
598
599 if (devp->hd_ireqfreq) 584 if (devp->hd_ireqfreq)
600 info.hi_ireqfreq = 585 info->hi_ireqfreq =
601 hpet_time_div(hpetp, devp->hd_ireqfreq); 586 hpet_time_div(hpetp, devp->hd_ireqfreq);
602 else 587 else
603 info.hi_ireqfreq = 0; 588 info->hi_ireqfreq = 0;
604 info.hi_flags = 589 info->hi_flags =
605 readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK; 590 readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK;
606 info.hi_hpet = hpetp->hp_which; 591 info->hi_hpet = hpetp->hp_which;
607 info.hi_timer = devp - hpetp->hp_dev; 592 info->hi_timer = devp - hpetp->hp_dev;
608 if (kernel)
609 memcpy((void *)arg, &info, sizeof(info));
610 else
611 if (copy_to_user((void __user *)arg, &info,
612 sizeof(info)))
613 err = -EFAULT;
614 break; 593 break;
615 } 594 }
616 case HPET_EPI: 595 case HPET_EPI:
@@ -636,7 +615,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
636 devp->hd_flags &= ~HPET_PERIODIC; 615 devp->hd_flags &= ~HPET_PERIODIC;
637 break; 616 break;
638 case HPET_IRQFREQ: 617 case HPET_IRQFREQ:
639 if (!kernel && (arg > hpet_max_freq) && 618 if ((arg > hpet_max_freq) &&
640 !capable(CAP_SYS_RESOURCE)) { 619 !capable(CAP_SYS_RESOURCE)) {
641 err = -EACCES; 620 err = -EACCES;
642 break; 621 break;
@@ -653,12 +632,63 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
653 return err; 632 return err;
654} 633}
655 634
635static long
636hpet_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
637{
638 struct hpet_info info;
639 int err;
640
641 mutex_lock(&hpet_mutex);
642 err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
643 mutex_unlock(&hpet_mutex);
644
645 if ((cmd == HPET_INFO) && !err &&
646 (copy_to_user((void __user *)arg, &info, sizeof(info))))
647 err = -EFAULT;
648
649 return err;
650}
651
652#ifdef CONFIG_COMPAT
653struct compat_hpet_info {
654 compat_ulong_t hi_ireqfreq; /* Hz */
655 compat_ulong_t hi_flags; /* information */
656 unsigned short hi_hpet;
657 unsigned short hi_timer;
658};
659
660static long
661hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
662{
663 struct hpet_info info;
664 int err;
665
666 mutex_lock(&hpet_mutex);
667 err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
668 mutex_unlock(&hpet_mutex);
669
670 if ((cmd == HPET_INFO) && !err) {
671 struct compat_hpet_info __user *u = compat_ptr(arg);
672 if (put_user(info.hi_ireqfreq, &u->hi_ireqfreq) ||
673 put_user(info.hi_flags, &u->hi_flags) ||
674 put_user(info.hi_hpet, &u->hi_hpet) ||
675 put_user(info.hi_timer, &u->hi_timer))
676 err = -EFAULT;
677 }
678
679 return err;
680}
681#endif
682
656static const struct file_operations hpet_fops = { 683static const struct file_operations hpet_fops = {
657 .owner = THIS_MODULE, 684 .owner = THIS_MODULE,
658 .llseek = no_llseek, 685 .llseek = no_llseek,
659 .read = hpet_read, 686 .read = hpet_read,
660 .poll = hpet_poll, 687 .poll = hpet_poll,
661 .unlocked_ioctl = hpet_ioctl, 688 .unlocked_ioctl = hpet_ioctl,
689#ifdef CONFIG_COMPAT
690 .compat_ioctl = hpet_compat_ioctl,
691#endif
662 .open = hpet_open, 692 .open = hpet_open,
663 .release = hpet_release, 693 .release = hpet_release,
664 .fasync = hpet_fasync, 694 .fasync = hpet_fasync,
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 3d9c61e5acbf..788da05190cc 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -170,6 +170,7 @@ static const struct file_operations rng_chrdev_ops = {
170 .owner = THIS_MODULE, 170 .owner = THIS_MODULE,
171 .open = rng_dev_open, 171 .open = rng_dev_open,
172 .read = rng_dev_read, 172 .read = rng_dev_read,
173 .llseek = noop_llseek,
173}; 174};
174 175
175static struct miscdevice rng_miscdev = { 176static struct miscdevice rng_miscdev = {
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 4cd8b227c11f..3bc0eef88717 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -23,7 +23,7 @@
23#include <linux/seq_file.h> 23#include <linux/seq_file.h>
24#include <linux/dmi.h> 24#include <linux/dmi.h>
25#include <linux/capability.h> 25#include <linux/capability.h>
26#include <linux/smp_lock.h> 26#include <linux/mutex.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <asm/io.h> 28#include <asm/io.h>
29 29
@@ -56,6 +56,7 @@
56 56
57#define I8K_TEMPERATURE_BUG 1 57#define I8K_TEMPERATURE_BUG 1
58 58
59static DEFINE_MUTEX(i8k_mutex);
59static char bios_version[4]; 60static char bios_version[4];
60 61
61MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); 62MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)");
@@ -399,9 +400,9 @@ static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
399{ 400{
400 long ret; 401 long ret;
401 402
402 lock_kernel(); 403 mutex_lock(&i8k_mutex);
403 ret = i8k_ioctl_unlocked(fp, cmd, arg); 404 ret = i8k_ioctl_unlocked(fp, cmd, arg);
404 unlock_kernel(); 405 mutex_unlock(&i8k_mutex);
405 406
406 return ret; 407 return ret;
407} 408}
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index d4b71e8d0d23..64a439ce2f89 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -98,7 +98,7 @@
98#include <linux/major.h> 98#include <linux/major.h>
99#include <linux/wait.h> 99#include <linux/wait.h>
100#include <linux/device.h> 100#include <linux/device.h>
101#include <linux/smp_lock.h> 101#include <linux/mutex.h>
102#include <linux/firmware.h> 102#include <linux/firmware.h>
103#include <linux/platform_device.h> 103#include <linux/platform_device.h>
104 104
@@ -138,6 +138,7 @@
138#include <linux/proc_fs.h> 138#include <linux/proc_fs.h>
139#include <linux/seq_file.h> 139#include <linux/seq_file.h>
140 140
141static DEFINE_MUTEX(ip2_mutex);
141static const struct file_operations ip2mem_proc_fops; 142static const struct file_operations ip2mem_proc_fops;
142static const struct file_operations ip2_proc_fops; 143static const struct file_operations ip2_proc_fops;
143 144
@@ -236,6 +237,7 @@ static const struct file_operations ip2_ipl = {
236 .write = ip2_ipl_write, 237 .write = ip2_ipl_write,
237 .unlocked_ioctl = ip2_ipl_ioctl, 238 .unlocked_ioctl = ip2_ipl_ioctl,
238 .open = ip2_ipl_open, 239 .open = ip2_ipl_open,
240 .llseek = noop_llseek,
239}; 241};
240 242
241static unsigned long irq_counter; 243static unsigned long irq_counter;
@@ -2897,7 +2899,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg )
2897 printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); 2899 printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg );
2898#endif 2900#endif
2899 2901
2900 lock_kernel(); 2902 mutex_lock(&ip2_mutex);
2901 2903
2902 switch ( iplminor ) { 2904 switch ( iplminor ) {
2903 case 0: // IPL device 2905 case 0: // IPL device
@@ -2961,7 +2963,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg )
2961 rc = -ENODEV; 2963 rc = -ENODEV;
2962 break; 2964 break;
2963 } 2965 }
2964 unlock_kernel(); 2966 mutex_unlock(&ip2_mutex);
2965 return rc; 2967 return rc;
2966} 2968}
2967 2969
@@ -2982,7 +2984,6 @@ ip2_ipl_open( struct inode *pInode, struct file *pFile )
2982#ifdef IP2DEBUG_IPL 2984#ifdef IP2DEBUG_IPL
2983 printk (KERN_DEBUG "IP2IPL: open\n" ); 2985 printk (KERN_DEBUG "IP2IPL: open\n" );
2984#endif 2986#endif
2985 cycle_kernel_lock();
2986 return 0; 2987 return 0;
2987} 2988}
2988 2989
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index d8ec92a38980..1fc8876af1f5 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -44,7 +44,6 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/device.h> 45#include <linux/device.h>
46#include <linux/compat.h> 46#include <linux/compat.h>
47#include <linux/smp_lock.h>
48 47
49struct ipmi_file_private 48struct ipmi_file_private
50{ 49{
@@ -59,6 +58,7 @@ struct ipmi_file_private
59 unsigned int default_retry_time_ms; 58 unsigned int default_retry_time_ms;
60}; 59};
61 60
61static DEFINE_MUTEX(ipmi_mutex);
62static void file_receive_handler(struct ipmi_recv_msg *msg, 62static void file_receive_handler(struct ipmi_recv_msg *msg,
63 void *handler_data) 63 void *handler_data)
64{ 64{
@@ -102,9 +102,9 @@ static int ipmi_fasync(int fd, struct file *file, int on)
102 struct ipmi_file_private *priv = file->private_data; 102 struct ipmi_file_private *priv = file->private_data;
103 int result; 103 int result;
104 104
105 lock_kernel(); /* could race against open() otherwise */ 105 mutex_lock(&ipmi_mutex); /* could race against open() otherwise */
106 result = fasync_helper(fd, file, on, &priv->fasync_queue); 106 result = fasync_helper(fd, file, on, &priv->fasync_queue);
107 unlock_kernel(); 107 mutex_unlock(&ipmi_mutex);
108 108
109 return (result); 109 return (result);
110} 110}
@@ -125,7 +125,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
125 if (!priv) 125 if (!priv)
126 return -ENOMEM; 126 return -ENOMEM;
127 127
128 lock_kernel(); 128 mutex_lock(&ipmi_mutex);
129 priv->file = file; 129 priv->file = file;
130 130
131 rv = ipmi_create_user(if_num, 131 rv = ipmi_create_user(if_num,
@@ -150,7 +150,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
150 priv->default_retry_time_ms = 0; 150 priv->default_retry_time_ms = 0;
151 151
152out: 152out:
153 unlock_kernel(); 153 mutex_unlock(&ipmi_mutex);
154 return rv; 154 return rv;
155} 155}
156 156
@@ -639,9 +639,9 @@ static long ipmi_unlocked_ioctl(struct file *file,
639{ 639{
640 int ret; 640 int ret;
641 641
642 lock_kernel(); 642 mutex_lock(&ipmi_mutex);
643 ret = ipmi_ioctl(file, cmd, data); 643 ret = ipmi_ioctl(file, cmd, data);
644 unlock_kernel(); 644 mutex_unlock(&ipmi_mutex);
645 645
646 return ret; 646 return ret;
647} 647}
@@ -850,6 +850,7 @@ static const struct file_operations ipmi_fops = {
850 .release = ipmi_release, 850 .release = ipmi_release,
851 .fasync = ipmi_fasync, 851 .fasync = ipmi_fasync,
852 .poll = ipmi_poll, 852 .poll = ipmi_poll,
853 .llseek = noop_llseek,
853}; 854};
854 855
855#define DEVICE_NAME "ipmidev" 856#define DEVICE_NAME "ipmidev"
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 654d566ca57c..f4d334f2536e 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -35,7 +35,7 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/ipmi.h> 36#include <linux/ipmi.h>
37#include <linux/ipmi_smi.h> 37#include <linux/ipmi_smi.h>
38#include <linux/smp_lock.h> 38#include <linux/mutex.h>
39#include <linux/watchdog.h> 39#include <linux/watchdog.h>
40#include <linux/miscdevice.h> 40#include <linux/miscdevice.h>
41#include <linux/init.h> 41#include <linux/init.h>
@@ -149,6 +149,7 @@
149#define WDIOC_GET_PRETIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 22, int) 149#define WDIOC_GET_PRETIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 22, int)
150#endif 150#endif
151 151
152static DEFINE_MUTEX(ipmi_watchdog_mutex);
152static int nowayout = WATCHDOG_NOWAYOUT; 153static int nowayout = WATCHDOG_NOWAYOUT;
153 154
154static ipmi_user_t watchdog_user; 155static ipmi_user_t watchdog_user;
@@ -748,9 +749,9 @@ static long ipmi_unlocked_ioctl(struct file *file,
748{ 749{
749 int ret; 750 int ret;
750 751
751 lock_kernel(); 752 mutex_lock(&ipmi_watchdog_mutex);
752 ret = ipmi_ioctl(file, cmd, arg); 753 ret = ipmi_ioctl(file, cmd, arg);
753 unlock_kernel(); 754 mutex_unlock(&ipmi_watchdog_mutex);
754 755
755 return ret; 756 return ret;
756} 757}
@@ -844,7 +845,6 @@ static int ipmi_open(struct inode *ino, struct file *filep)
844 if (test_and_set_bit(0, &ipmi_wdog_open)) 845 if (test_and_set_bit(0, &ipmi_wdog_open))
845 return -EBUSY; 846 return -EBUSY;
846 847
847 cycle_kernel_lock();
848 848
849 /* 849 /*
850 * Don't start the timer now, let it start on the 850 * Don't start the timer now, let it start on the
@@ -909,6 +909,7 @@ static const struct file_operations ipmi_wdog_fops = {
909 .open = ipmi_open, 909 .open = ipmi_open,
910 .release = ipmi_close, 910 .release = ipmi_close,
911 .fasync = ipmi_fasync, 911 .fasync = ipmi_fasync,
912 .llseek = no_llseek,
912}; 913};
913 914
914static struct miscdevice ipmi_wdog_miscdev = { 915static struct miscdevice ipmi_wdog_miscdev = {
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index be28391adb79..667abd23ad6a 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -704,6 +704,7 @@ static const struct file_operations stli_fsiomem = {
704 .read = stli_memread, 704 .read = stli_memread,
705 .write = stli_memwrite, 705 .write = stli_memwrite,
706 .unlocked_ioctl = stli_memioctl, 706 .unlocked_ioctl = stli_memioctl,
707 .llseek = default_llseek,
707}; 708};
708 709
709/*****************************************************************************/ 710/*****************************************************************************/
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 938a3a273886..97c3edb95ae7 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -126,7 +126,7 @@
126#include <linux/device.h> 126#include <linux/device.h>
127#include <linux/wait.h> 127#include <linux/wait.h>
128#include <linux/jiffies.h> 128#include <linux/jiffies.h>
129#include <linux/smp_lock.h> 129#include <linux/mutex.h>
130#include <linux/compat.h> 130#include <linux/compat.h>
131 131
132#include <linux/parport.h> 132#include <linux/parport.h>
@@ -140,6 +140,7 @@
140/* if you have more than 8 printers, remember to increase LP_NO */ 140/* if you have more than 8 printers, remember to increase LP_NO */
141#define LP_NO 8 141#define LP_NO 8
142 142
143static DEFINE_MUTEX(lp_mutex);
143static struct lp_struct lp_table[LP_NO]; 144static struct lp_struct lp_table[LP_NO];
144 145
145static unsigned int lp_count = 0; 146static unsigned int lp_count = 0;
@@ -493,7 +494,7 @@ static int lp_open(struct inode * inode, struct file * file)
493 unsigned int minor = iminor(inode); 494 unsigned int minor = iminor(inode);
494 int ret = 0; 495 int ret = 0;
495 496
496 lock_kernel(); 497 mutex_lock(&lp_mutex);
497 if (minor >= LP_NO) { 498 if (minor >= LP_NO) {
498 ret = -ENXIO; 499 ret = -ENXIO;
499 goto out; 500 goto out;
@@ -554,7 +555,7 @@ static int lp_open(struct inode * inode, struct file * file)
554 lp_release_parport (&lp_table[minor]); 555 lp_release_parport (&lp_table[minor]);
555 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; 556 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT;
556out: 557out:
557 unlock_kernel(); 558 mutex_unlock(&lp_mutex);
558 return ret; 559 return ret;
559} 560}
560 561
@@ -680,7 +681,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd,
680 int ret; 681 int ret;
681 682
682 minor = iminor(file->f_path.dentry->d_inode); 683 minor = iminor(file->f_path.dentry->d_inode);
683 lock_kernel(); 684 mutex_lock(&lp_mutex);
684 switch (cmd) { 685 switch (cmd) {
685 case LPSETTIMEOUT: 686 case LPSETTIMEOUT:
686 if (copy_from_user(&par_timeout, (void __user *)arg, 687 if (copy_from_user(&par_timeout, (void __user *)arg,
@@ -694,7 +695,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd,
694 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); 695 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg);
695 break; 696 break;
696 } 697 }
697 unlock_kernel(); 698 mutex_unlock(&lp_mutex);
698 699
699 return ret; 700 return ret;
700} 701}
@@ -709,7 +710,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
709 int ret; 710 int ret;
710 711
711 minor = iminor(file->f_path.dentry->d_inode); 712 minor = iminor(file->f_path.dentry->d_inode);
712 lock_kernel(); 713 mutex_lock(&lp_mutex);
713 switch (cmd) { 714 switch (cmd) {
714 case LPSETTIMEOUT: 715 case LPSETTIMEOUT:
715 tc = compat_ptr(arg); 716 tc = compat_ptr(arg);
@@ -730,7 +731,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
730 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); 731 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg));
731 break; 732 break;
732 } 733 }
733 unlock_kernel(); 734 mutex_unlock(&lp_mutex);
734 735
735 return ret; 736 return ret;
736} 737}
@@ -748,6 +749,7 @@ static const struct file_operations lp_fops = {
748#ifdef CONFIG_PARPORT_1284 749#ifdef CONFIG_PARPORT_1284
749 .read = lp_read, 750 .read = lp_read,
750#endif 751#endif
752 .llseek = noop_llseek,
751}; 753};
752 754
753/* --- support for console on the line printer ----------------- */ 755/* --- support for console on the line printer ----------------- */
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 83bef4efe376..1aeaaba680d2 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -25,7 +25,6 @@
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/uio.h> 26#include <linux/uio.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/smp_lock.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <asm/io.h> 29#include <asm/io.h>
31#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -42,6 +41,7 @@
42#else 41#else
43#define DBG(fmt...) 42#define DBG(fmt...)
44#endif 43#endif
44static DEFINE_MUTEX(mbcs_mutex);
45static int mbcs_major; 45static int mbcs_major;
46 46
47static LIST_HEAD(soft_list); 47static LIST_HEAD(soft_list);
@@ -385,19 +385,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
385 struct mbcs_soft *soft; 385 struct mbcs_soft *soft;
386 int minor; 386 int minor;
387 387
388 lock_kernel(); 388 mutex_lock(&mbcs_mutex);
389 minor = iminor(ip); 389 minor = iminor(ip);
390 390
391 /* Nothing protects access to this list... */ 391 /* Nothing protects access to this list... */
392 list_for_each_entry(soft, &soft_list, list) { 392 list_for_each_entry(soft, &soft_list, list) {
393 if (soft->nasid == minor) { 393 if (soft->nasid == minor) {
394 fp->private_data = soft->cxdev; 394 fp->private_data = soft->cxdev;
395 unlock_kernel(); 395 mutex_unlock(&mbcs_mutex);
396 return 0; 396 return 0;
397 } 397 }
398 } 398 }
399 399
400 unlock_kernel(); 400 mutex_unlock(&mbcs_mutex);
401 return -ENODEV; 401 return -ENODEV;
402} 402}
403 403
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 1f528fad3516..e985b1c2730e 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -805,6 +805,7 @@ static const struct file_operations full_fops = {
805static const struct file_operations oldmem_fops = { 805static const struct file_operations oldmem_fops = {
806 .read = read_oldmem, 806 .read = read_oldmem,
807 .open = open_oldmem, 807 .open = open_oldmem,
808 .llseek = default_llseek,
808}; 809};
809#endif 810#endif
810 811
@@ -831,6 +832,7 @@ static ssize_t kmsg_write(struct file *file, const char __user *buf,
831 832
832static const struct file_operations kmsg_fops = { 833static const struct file_operations kmsg_fops = {
833 .write = kmsg_write, 834 .write = kmsg_write,
835 .llseek = noop_llseek,
834}; 836};
835 837
836static const struct memdev { 838static const struct memdev {
@@ -882,6 +884,7 @@ static int memory_open(struct inode *inode, struct file *filp)
882 884
883static const struct file_operations memory_fops = { 885static const struct file_operations memory_fops = {
884 .open = memory_open, 886 .open = memory_open,
887 .llseek = noop_llseek,
885}; 888};
886 889
887static char *mem_devnode(struct device *dev, mode_t *mode) 890static char *mem_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index abdafd488980..778273c93242 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -162,6 +162,7 @@ static struct class *misc_class;
162static const struct file_operations misc_fops = { 162static const struct file_operations misc_fops = {
163 .owner = THIS_MODULE, 163 .owner = THIS_MODULE,
164 .open = misc_open, 164 .open = misc_open,
165 .llseek = noop_llseek,
165}; 166};
166 167
167/** 168/**
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index ea7c99fa978f..c070b53984e4 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -32,7 +32,7 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/time.h> 33#include <linux/time.h>
34#include <linux/math64.h> 34#include <linux/math64.h>
35#include <linux/smp_lock.h> 35#include <linux/mutex.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37 37
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
@@ -59,6 +59,7 @@ extern unsigned long sn_rtc_cycles_per_second;
59 59
60#define rtc_time() (*RTC_COUNTER_ADDR) 60#define rtc_time() (*RTC_COUNTER_ADDR)
61 61
62static DEFINE_MUTEX(mmtimer_mutex);
62static long mmtimer_ioctl(struct file *file, unsigned int cmd, 63static long mmtimer_ioctl(struct file *file, unsigned int cmd,
63 unsigned long arg); 64 unsigned long arg);
64static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); 65static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma);
@@ -72,6 +73,7 @@ static const struct file_operations mmtimer_fops = {
72 .owner = THIS_MODULE, 73 .owner = THIS_MODULE,
73 .mmap = mmtimer_mmap, 74 .mmap = mmtimer_mmap,
74 .unlocked_ioctl = mmtimer_ioctl, 75 .unlocked_ioctl = mmtimer_ioctl,
76 .llseek = noop_llseek,
75}; 77};
76 78
77/* 79/*
@@ -371,7 +373,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd,
371{ 373{
372 int ret = 0; 374 int ret = 0;
373 375
374 lock_kernel(); 376 mutex_lock(&mmtimer_mutex);
375 377
376 switch (cmd) { 378 switch (cmd) {
377 case MMTIMER_GETOFFSET: /* offset of the counter */ 379 case MMTIMER_GETOFFSET: /* offset of the counter */
@@ -414,7 +416,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd,
414 ret = -ENOTTY; 416 ret = -ENOTTY;
415 break; 417 break;
416 } 418 }
417 unlock_kernel(); 419 mutex_unlock(&mmtimer_mutex);
418 return ret; 420 return ret;
419} 421}
420 422
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index ecb89d798e35..966a95bc974b 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -316,7 +316,8 @@ uncached_mmap(struct file *file, struct vm_area_struct *vma)
316 316
317static const struct file_operations fetchop_fops = { 317static const struct file_operations fetchop_fops = {
318 .owner = THIS_MODULE, 318 .owner = THIS_MODULE,
319 .mmap = fetchop_mmap 319 .mmap = fetchop_mmap,
320 .llseek = noop_llseek,
320}; 321};
321 322
322static struct miscdevice fetchop_miscdev = { 323static struct miscdevice fetchop_miscdev = {
@@ -327,7 +328,8 @@ static struct miscdevice fetchop_miscdev = {
327 328
328static const struct file_operations cached_fops = { 329static const struct file_operations cached_fops = {
329 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
330 .mmap = cached_mmap 331 .mmap = cached_mmap,
332 .llseek = noop_llseek,
331}; 333};
332 334
333static struct miscdevice cached_miscdev = { 335static struct miscdevice cached_miscdev = {
@@ -338,7 +340,8 @@ static struct miscdevice cached_miscdev = {
338 340
339static const struct file_operations uncached_fops = { 341static const struct file_operations uncached_fops = {
340 .owner = THIS_MODULE, 342 .owner = THIS_MODULE,
341 .mmap = uncached_mmap 343 .mmap = uncached_mmap,
344 .llseek = noop_llseek,
342}; 345};
343 346
344static struct miscdevice uncached_miscdev = { 347static struct miscdevice uncached_miscdev = {
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c
index a4ec50c95072..1d82d5838f0c 100644
--- a/drivers/char/mwave/mwavedd.c
+++ b/drivers/char/mwave/mwavedd.c
@@ -56,7 +56,7 @@
56#include <linux/serial.h> 56#include <linux/serial.h>
57#include <linux/sched.h> 57#include <linux/sched.h>
58#include <linux/spinlock.h> 58#include <linux/spinlock.h>
59#include <linux/smp_lock.h> 59#include <linux/mutex.h>
60#include <linux/delay.h> 60#include <linux/delay.h>
61#include <linux/serial_8250.h> 61#include <linux/serial_8250.h>
62#include "smapi.h" 62#include "smapi.h"
@@ -73,6 +73,7 @@ MODULE_LICENSE("GPL");
73* checks are made against other devices (ie. superio) for conflicts. 73* checks are made against other devices (ie. superio) for conflicts.
74* We'll depend on users using the tpctl utility to do that for now 74* We'll depend on users using the tpctl utility to do that for now
75*/ 75*/
76static DEFINE_MUTEX(mwave_mutex);
76int mwave_debug = 0; 77int mwave_debug = 0;
77int mwave_3780i_irq = 0; 78int mwave_3780i_irq = 0;
78int mwave_3780i_io = 0; 79int mwave_3780i_io = 0;
@@ -101,7 +102,6 @@ static int mwave_open(struct inode *inode, struct file *file)
101 PRINTK_2(TRACE_MWAVE, 102 PRINTK_2(TRACE_MWAVE,
102 "mwavedd::mwave_open, exit return retval %x\n", retval); 103 "mwavedd::mwave_open, exit return retval %x\n", retval);
103 104
104 cycle_kernel_lock();
105 return retval; 105 return retval;
106} 106}
107 107
@@ -136,9 +136,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
136 PRINTK_1(TRACE_MWAVE, 136 PRINTK_1(TRACE_MWAVE,
137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET"
138 " calling tp3780I_ResetDSP\n"); 138 " calling tp3780I_ResetDSP\n");
139 lock_kernel(); 139 mutex_lock(&mwave_mutex);
140 retval = tp3780I_ResetDSP(&pDrvData->rBDData); 140 retval = tp3780I_ResetDSP(&pDrvData->rBDData);
141 unlock_kernel(); 141 mutex_unlock(&mwave_mutex);
142 PRINTK_2(TRACE_MWAVE, 142 PRINTK_2(TRACE_MWAVE,
143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET"
144 " retval %x from tp3780I_ResetDSP\n", 144 " retval %x from tp3780I_ResetDSP\n",
@@ -149,9 +149,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
149 PRINTK_1(TRACE_MWAVE, 149 PRINTK_1(TRACE_MWAVE,
150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN"
151 " calling tp3780I_StartDSP\n"); 151 " calling tp3780I_StartDSP\n");
152 lock_kernel(); 152 mutex_lock(&mwave_mutex);
153 retval = tp3780I_StartDSP(&pDrvData->rBDData); 153 retval = tp3780I_StartDSP(&pDrvData->rBDData);
154 unlock_kernel(); 154 mutex_unlock(&mwave_mutex);
155 PRINTK_2(TRACE_MWAVE, 155 PRINTK_2(TRACE_MWAVE,
156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN"
157 " retval %x from tp3780I_StartDSP\n", 157 " retval %x from tp3780I_StartDSP\n",
@@ -165,10 +165,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
165 "mwavedd::mwave_ioctl," 165 "mwavedd::mwave_ioctl,"
166 " IOCTL_MW_DSP_ABILITIES calling" 166 " IOCTL_MW_DSP_ABILITIES calling"
167 " tp3780I_QueryAbilities\n"); 167 " tp3780I_QueryAbilities\n");
168 lock_kernel(); 168 mutex_lock(&mwave_mutex);
169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData,
170 &rAbilities); 170 &rAbilities);
171 unlock_kernel(); 171 mutex_unlock(&mwave_mutex);
172 PRINTK_2(TRACE_MWAVE, 172 PRINTK_2(TRACE_MWAVE,
173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES"
174 " retval %x from tp3780I_QueryAbilities\n", 174 " retval %x from tp3780I_QueryAbilities\n",
@@ -199,13 +199,13 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA,"
200 " size %lx, ioarg %lx pusBuffer %p\n", 200 " size %lx, ioarg %lx pusBuffer %p\n",
201 rReadData.ulDataLength, ioarg, pusBuffer); 201 rReadData.ulDataLength, ioarg, pusBuffer);
202 lock_kernel(); 202 mutex_lock(&mwave_mutex);
203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
204 iocmd, 204 iocmd,
205 pusBuffer, 205 pusBuffer,
206 rReadData.ulDataLength, 206 rReadData.ulDataLength,
207 rReadData.usDspAddress); 207 rReadData.usDspAddress);
208 unlock_kernel(); 208 mutex_unlock(&mwave_mutex);
209 } 209 }
210 break; 210 break;
211 211
@@ -223,12 +223,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
223 " size %lx, ioarg %lx pusBuffer %p\n", 223 " size %lx, ioarg %lx pusBuffer %p\n",
224 rReadData.ulDataLength / 2, ioarg, 224 rReadData.ulDataLength / 2, ioarg,
225 pusBuffer); 225 pusBuffer);
226 lock_kernel(); 226 mutex_lock(&mwave_mutex);
227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
228 iocmd, pusBuffer, 228 iocmd, pusBuffer,
229 rReadData.ulDataLength / 2, 229 rReadData.ulDataLength / 2,
230 rReadData.usDspAddress); 230 rReadData.usDspAddress);
231 unlock_kernel(); 231 mutex_unlock(&mwave_mutex);
232 } 232 }
233 break; 233 break;
234 234
@@ -246,12 +246,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
246 " size %lx, ioarg %lx pusBuffer %p\n", 246 " size %lx, ioarg %lx pusBuffer %p\n",
247 rWriteData.ulDataLength, ioarg, 247 rWriteData.ulDataLength, ioarg,
248 pusBuffer); 248 pusBuffer);
249 lock_kernel(); 249 mutex_lock(&mwave_mutex);
250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
251 iocmd, pusBuffer, 251 iocmd, pusBuffer,
252 rWriteData.ulDataLength, 252 rWriteData.ulDataLength,
253 rWriteData.usDspAddress); 253 rWriteData.usDspAddress);
254 unlock_kernel(); 254 mutex_unlock(&mwave_mutex);
255 } 255 }
256 break; 256 break;
257 257
@@ -269,12 +269,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
269 " size %lx, ioarg %lx pusBuffer %p\n", 269 " size %lx, ioarg %lx pusBuffer %p\n",
270 rWriteData.ulDataLength, ioarg, 270 rWriteData.ulDataLength, ioarg,
271 pusBuffer); 271 pusBuffer);
272 lock_kernel(); 272 mutex_lock(&mwave_mutex);
273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData,
274 iocmd, pusBuffer, 274 iocmd, pusBuffer,
275 rWriteData.ulDataLength, 275 rWriteData.ulDataLength,
276 rWriteData.usDspAddress); 276 rWriteData.usDspAddress);
277 unlock_kernel(); 277 mutex_unlock(&mwave_mutex);
278 } 278 }
279 break; 279 break;
280 280
@@ -295,10 +295,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
295 ipcnum, 295 ipcnum,
296 pDrvData->IPCs[ipcnum].usIntCount); 296 pDrvData->IPCs[ipcnum].usIntCount);
297 297
298 lock_kernel(); 298 mutex_lock(&mwave_mutex);
299 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 299 pDrvData->IPCs[ipcnum].bIsHere = FALSE;
300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; 300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE;
301 unlock_kernel(); 301 mutex_unlock(&mwave_mutex);
302 302
303 PRINTK_2(TRACE_MWAVE, 303 PRINTK_2(TRACE_MWAVE,
304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
@@ -323,7 +323,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
323 ipcnum, 323 ipcnum,
324 pDrvData->IPCs[ipcnum].usIntCount); 324 pDrvData->IPCs[ipcnum].usIntCount);
325 325
326 lock_kernel(); 326 mutex_lock(&mwave_mutex);
327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) {
328 DECLARE_WAITQUEUE(wait, current); 328 DECLARE_WAITQUEUE(wait, current);
329 329
@@ -364,7 +364,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
364 " processing\n", 364 " processing\n",
365 ipcnum); 365 ipcnum);
366 } 366 }
367 unlock_kernel(); 367 mutex_unlock(&mwave_mutex);
368 } 368 }
369 break; 369 break;
370 370
@@ -383,14 +383,14 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
383 ipcnum); 383 ipcnum);
384 return -EINVAL; 384 return -EINVAL;
385 } 385 }
386 lock_kernel(); 386 mutex_lock(&mwave_mutex);
387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) {
388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE;
389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) {
390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue);
391 } 391 }
392 } 392 }
393 unlock_kernel(); 393 mutex_unlock(&mwave_mutex);
394 } 394 }
395 break; 395 break;
396 396
@@ -479,7 +479,8 @@ static const struct file_operations mwave_fops = {
479 .write = mwave_write, 479 .write = mwave_write,
480 .unlocked_ioctl = mwave_ioctl, 480 .unlocked_ioctl = mwave_ioctl,
481 .open = mwave_open, 481 .open = mwave_open,
482 .release = mwave_close 482 .release = mwave_close,
483 .llseek = default_llseek,
483}; 484};
484 485
485 486
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 66d2917b003f..166f1e7aaa7e 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -109,10 +109,11 @@
109#include <linux/spinlock.h> 109#include <linux/spinlock.h>
110#include <linux/io.h> 110#include <linux/io.h>
111#include <linux/uaccess.h> 111#include <linux/uaccess.h>
112#include <linux/smp_lock.h> 112#include <linux/mutex.h>
113 113
114#include <asm/system.h> 114#include <asm/system.h>
115 115
116static DEFINE_MUTEX(nvram_mutex);
116static DEFINE_SPINLOCK(nvram_state_lock); 117static DEFINE_SPINLOCK(nvram_state_lock);
117static int nvram_open_cnt; /* #times opened */ 118static int nvram_open_cnt; /* #times opened */
118static int nvram_open_mode; /* special open modes */ 119static int nvram_open_mode; /* special open modes */
@@ -308,7 +309,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
308 if (!capable(CAP_SYS_ADMIN)) 309 if (!capable(CAP_SYS_ADMIN))
309 return -EACCES; 310 return -EACCES;
310 311
311 lock_kernel(); 312 mutex_lock(&nvram_mutex);
312 spin_lock_irq(&rtc_lock); 313 spin_lock_irq(&rtc_lock);
313 314
314 for (i = 0; i < NVRAM_BYTES; ++i) 315 for (i = 0; i < NVRAM_BYTES; ++i)
@@ -316,7 +317,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
316 __nvram_set_checksum(); 317 __nvram_set_checksum();
317 318
318 spin_unlock_irq(&rtc_lock); 319 spin_unlock_irq(&rtc_lock);
319 unlock_kernel(); 320 mutex_unlock(&nvram_mutex);
320 return 0; 321 return 0;
321 322
322 case NVRAM_SETCKS: 323 case NVRAM_SETCKS:
@@ -325,11 +326,11 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
325 if (!capable(CAP_SYS_ADMIN)) 326 if (!capable(CAP_SYS_ADMIN))
326 return -EACCES; 327 return -EACCES;
327 328
328 lock_kernel(); 329 mutex_lock(&nvram_mutex);
329 spin_lock_irq(&rtc_lock); 330 spin_lock_irq(&rtc_lock);
330 __nvram_set_checksum(); 331 __nvram_set_checksum();
331 spin_unlock_irq(&rtc_lock); 332 spin_unlock_irq(&rtc_lock);
332 unlock_kernel(); 333 mutex_unlock(&nvram_mutex);
333 return 0; 334 return 0;
334 335
335 default: 336 default:
diff --git a/drivers/char/nwbutton.c b/drivers/char/nwbutton.c
index 2604246501e4..8994ce32e6c7 100644
--- a/drivers/char/nwbutton.c
+++ b/drivers/char/nwbutton.c
@@ -182,6 +182,7 @@ static int button_read (struct file *filp, char __user *buffer,
182static const struct file_operations button_fops = { 182static const struct file_operations button_fops = {
183 .owner = THIS_MODULE, 183 .owner = THIS_MODULE,
184 .read = button_read, 184 .read = button_read,
185 .llseek = noop_llseek,
185}; 186};
186 187
187/* 188/*
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index 043a1c7b86be..a12f52400dbc 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -25,7 +25,6 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/rwsem.h> 26#include <linux/rwsem.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/smp_lock.h>
29#include <linux/mutex.h> 28#include <linux/mutex.h>
30#include <linux/jiffies.h> 29#include <linux/jiffies.h>
31 30
@@ -41,6 +40,7 @@
41 40
42#define NWFLASH_VERSION "6.4" 41#define NWFLASH_VERSION "6.4"
43 42
43static DEFINE_MUTEX(flash_mutex);
44static void kick_open(void); 44static void kick_open(void);
45static int get_flash_id(void); 45static int get_flash_id(void);
46static int erase_block(int nBlock); 46static int erase_block(int nBlock);
@@ -96,7 +96,7 @@ static int get_flash_id(void)
96 96
97static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) 97static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
98{ 98{
99 lock_kernel(); 99 mutex_lock(&flash_mutex);
100 switch (cmd) { 100 switch (cmd) {
101 case CMD_WRITE_DISABLE: 101 case CMD_WRITE_DISABLE:
102 gbWriteBase64Enable = 0; 102 gbWriteBase64Enable = 0;
@@ -114,10 +114,10 @@ static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
114 default: 114 default:
115 gbWriteBase64Enable = 0; 115 gbWriteBase64Enable = 0;
116 gbWriteEnable = 0; 116 gbWriteEnable = 0;
117 unlock_kernel(); 117 mutex_unlock(&flash_mutex);
118 return -EINVAL; 118 return -EINVAL;
119 } 119 }
120 unlock_kernel(); 120 mutex_unlock(&flash_mutex);
121 return 0; 121 return 0;
122} 122}
123 123
@@ -282,7 +282,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
282{ 282{
283 loff_t ret; 283 loff_t ret;
284 284
285 lock_kernel(); 285 mutex_lock(&flash_mutex);
286 if (flashdebug) 286 if (flashdebug)
287 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n", 287 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n",
288 (unsigned int) offset, orig); 288 (unsigned int) offset, orig);
@@ -317,7 +317,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
317 default: 317 default:
318 ret = -EINVAL; 318 ret = -EINVAL;
319 } 319 }
320 unlock_kernel(); 320 mutex_unlock(&flash_mutex);
321 return ret; 321 return ret;
322} 322}
323 323
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index 8ecbcc174c15..b304ec052501 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -234,6 +234,7 @@ static const struct file_operations pc8736x_gpio_fileops = {
234 .open = pc8736x_gpio_open, 234 .open = pc8736x_gpio_open,
235 .write = nsc_gpio_write, 235 .write = nsc_gpio_write,
236 .read = nsc_gpio_read, 236 .read = nsc_gpio_read,
237 .llseek = no_llseek,
237}; 238};
238 239
239static void __init pc8736x_init_shadow(void) 240static void __init pc8736x_init_shadow(void)
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index ec73d9f6d9ed..6835c23e9a51 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -30,11 +30,10 @@
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/bitrev.h> 32#include <linux/bitrev.h>
33#include <linux/smp_lock.h> 33#include <linux/mutex.h>
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35#include <linux/io.h> 35#include <linux/io.h>
36 36
37#include <pcmcia/cs.h>
38#include <pcmcia/cistpl.h> 37#include <pcmcia/cistpl.h>
39#include <pcmcia/cisreg.h> 38#include <pcmcia/cisreg.h>
40#include <pcmcia/ciscode.h> 39#include <pcmcia/ciscode.h>
@@ -55,7 +54,7 @@
55 __func__ , ## args); \ 54 __func__ , ## args); \
56 } while (0) 55 } while (0)
57 56
58static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte"; 57static DEFINE_MUTEX(cmm_mutex);
59 58
60#define T_1SEC (HZ) 59#define T_1SEC (HZ)
61#define T_10MSEC msecs_to_jiffies(10) 60#define T_10MSEC msecs_to_jiffies(10)
@@ -1418,7 +1417,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1418 iminor(inode), ioctl_names[_IOC_NR(cmd)]); 1417 iminor(inode), ioctl_names[_IOC_NR(cmd)]);
1419#endif 1418#endif
1420 1419
1421 lock_kernel(); 1420 mutex_lock(&cmm_mutex);
1422 rc = -ENODEV; 1421 rc = -ENODEV;
1423 link = dev_table[iminor(inode)]; 1422 link = dev_table[iminor(inode)];
1424 if (!pcmcia_dev_present(link)) { 1423 if (!pcmcia_dev_present(link)) {
@@ -1626,7 +1625,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1626 rc = -ENOTTY; 1625 rc = -ENOTTY;
1627 } 1626 }
1628out: 1627out:
1629 unlock_kernel(); 1628 mutex_unlock(&cmm_mutex);
1630 return rc; 1629 return rc;
1631} 1630}
1632 1631
@@ -1640,7 +1639,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
1640 if (minor >= CM4000_MAX_DEV) 1639 if (minor >= CM4000_MAX_DEV)
1641 return -ENODEV; 1640 return -ENODEV;
1642 1641
1643 lock_kernel(); 1642 mutex_lock(&cmm_mutex);
1644 link = dev_table[minor]; 1643 link = dev_table[minor];
1645 if (link == NULL || !pcmcia_dev_present(link)) { 1644 if (link == NULL || !pcmcia_dev_present(link)) {
1646 ret = -ENODEV; 1645 ret = -ENODEV;
@@ -1685,7 +1684,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
1685 DEBUGP(2, dev, "<- cmm_open\n"); 1684 DEBUGP(2, dev, "<- cmm_open\n");
1686 ret = nonseekable_open(inode, filp); 1685 ret = nonseekable_open(inode, filp);
1687out: 1686out:
1688 unlock_kernel(); 1687 mutex_unlock(&cmm_mutex);
1689 return ret; 1688 return ret;
1690} 1689}
1691 1690
@@ -1742,20 +1741,8 @@ static void cmm_cm4000_release(struct pcmcia_device * link)
1742 1741
1743/*==== Interface to PCMCIA Layer =======================================*/ 1742/*==== Interface to PCMCIA Layer =======================================*/
1744 1743
1745static int cm4000_config_check(struct pcmcia_device *p_dev, 1744static int cm4000_config_check(struct pcmcia_device *p_dev, void *priv_data)
1746 cistpl_cftable_entry_t *cfg,
1747 cistpl_cftable_entry_t *dflt,
1748 unsigned int vcc,
1749 void *priv_data)
1750{ 1745{
1751 if (!cfg->io.nwin)
1752 return -ENODEV;
1753
1754 p_dev->resource[0]->start = cfg->io.win[0].base;
1755 p_dev->resource[0]->end = cfg->io.win[0].len;
1756 p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags);
1757 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK;
1758
1759 return pcmcia_request_io(p_dev); 1746 return pcmcia_request_io(p_dev);
1760} 1747}
1761 1748
@@ -1763,13 +1750,13 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
1763{ 1750{
1764 struct cm4000_dev *dev; 1751 struct cm4000_dev *dev;
1765 1752
1753 link->config_flags |= CONF_AUTO_SET_IO;
1754
1766 /* read the config-tuples */ 1755 /* read the config-tuples */
1767 if (pcmcia_loop_config(link, cm4000_config_check, NULL)) 1756 if (pcmcia_loop_config(link, cm4000_config_check, NULL))
1768 goto cs_release; 1757 goto cs_release;
1769 1758
1770 link->conf.IntType = 00000002; 1759 if (pcmcia_enable_device(link))
1771
1772 if (pcmcia_request_configuration(link, &link->conf))
1773 goto cs_release; 1760 goto cs_release;
1774 1761
1775 dev = link->priv; 1762 dev = link->priv;
@@ -1829,7 +1816,6 @@ static int cm4000_probe(struct pcmcia_device *link)
1829 1816
1830 dev->p_dev = link; 1817 dev->p_dev = link;
1831 link->priv = dev; 1818 link->priv = dev;
1832 link->conf.IntType = INT_MEMORY_AND_IO;
1833 dev_table[i] = link; 1819 dev_table[i] = link;
1834 1820
1835 init_waitqueue_head(&dev->devq); 1821 init_waitqueue_head(&dev->devq);
@@ -1880,6 +1866,7 @@ static const struct file_operations cm4000_fops = {
1880 .unlocked_ioctl = cmm_ioctl, 1866 .unlocked_ioctl = cmm_ioctl,
1881 .open = cmm_open, 1867 .open = cmm_open,
1882 .release= cmm_close, 1868 .release= cmm_close,
1869 .llseek = no_llseek,
1883}; 1870};
1884 1871
1885static struct pcmcia_device_id cm4000_ids[] = { 1872static struct pcmcia_device_id cm4000_ids[] = {
@@ -1891,9 +1878,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4000_ids);
1891 1878
1892static struct pcmcia_driver cm4000_driver = { 1879static struct pcmcia_driver cm4000_driver = {
1893 .owner = THIS_MODULE, 1880 .owner = THIS_MODULE,
1894 .drv = { 1881 .name = "cm4000_cs",
1895 .name = "cm4000_cs",
1896 },
1897 .probe = cm4000_probe, 1882 .probe = cm4000_probe,
1898 .remove = cm4000_detach, 1883 .remove = cm4000_detach,
1899 .suspend = cm4000_suspend, 1884 .suspend = cm4000_suspend,
@@ -1905,8 +1890,6 @@ static int __init cmm_init(void)
1905{ 1890{
1906 int rc; 1891 int rc;
1907 1892
1908 printk(KERN_INFO "%s\n", version);
1909
1910 cmm_class = class_create(THIS_MODULE, "cardman_4000"); 1893 cmm_class = class_create(THIS_MODULE, "cardman_4000");
1911 if (IS_ERR(cmm_class)) 1894 if (IS_ERR(cmm_class))
1912 return PTR_ERR(cmm_class); 1895 return PTR_ERR(cmm_class);
@@ -1931,7 +1914,6 @@ static int __init cmm_init(void)
1931 1914
1932static void __exit cmm_exit(void) 1915static void __exit cmm_exit(void)
1933{ 1916{
1934 printk(KERN_INFO MODULE_NAME ": unloading\n");
1935 pcmcia_unregister_driver(&cm4000_driver); 1917 pcmcia_unregister_driver(&cm4000_driver);
1936 unregister_chrdev(major, DEVICE_NAME); 1918 unregister_chrdev(major, DEVICE_NAME);
1937 class_destroy(cmm_class); 1919 class_destroy(cmm_class);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 815cde1d0570..5d8d59e865f4 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -24,12 +24,11 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/smp_lock.h> 27#include <linux/mutex.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <asm/uaccess.h> 29#include <asm/uaccess.h>
30#include <asm/io.h> 30#include <asm/io.h>
31 31
32#include <pcmcia/cs.h>
33#include <pcmcia/cistpl.h> 32#include <pcmcia/cistpl.h>
34#include <pcmcia/cisreg.h> 33#include <pcmcia/cisreg.h>
35#include <pcmcia/ciscode.h> 34#include <pcmcia/ciscode.h>
@@ -49,8 +48,7 @@
49 __func__ , ## args); \ 48 __func__ , ## args); \
50 } while (0) 49 } while (0)
51 50
52static char *version = 51static DEFINE_MUTEX(cm4040_mutex);
53"OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte";
54 52
55#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) 53#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
56#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) 54#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
@@ -444,7 +442,7 @@ static int cm4040_open(struct inode *inode, struct file *filp)
444 if (minor >= CM_MAX_DEV) 442 if (minor >= CM_MAX_DEV)
445 return -ENODEV; 443 return -ENODEV;
446 444
447 lock_kernel(); 445 mutex_lock(&cm4040_mutex);
448 link = dev_table[minor]; 446 link = dev_table[minor];
449 if (link == NULL || !pcmcia_dev_present(link)) { 447 if (link == NULL || !pcmcia_dev_present(link)) {
450 ret = -ENODEV; 448 ret = -ENODEV;
@@ -473,7 +471,7 @@ static int cm4040_open(struct inode *inode, struct file *filp)
473 DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); 471 DEBUGP(2, dev, "<- cm4040_open (successfully)\n");
474 ret = nonseekable_open(inode, filp); 472 ret = nonseekable_open(inode, filp);
475out: 473out:
476 unlock_kernel(); 474 mutex_unlock(&cm4040_mutex);
477 return ret; 475 return ret;
478} 476}
479 477
@@ -516,26 +514,9 @@ static void cm4040_reader_release(struct pcmcia_device *link)
516 return; 514 return;
517} 515}
518 516
519static int cm4040_config_check(struct pcmcia_device *p_dev, 517static int cm4040_config_check(struct pcmcia_device *p_dev, void *priv_data)
520 cistpl_cftable_entry_t *cfg,
521 cistpl_cftable_entry_t *dflt,
522 unsigned int vcc,
523 void *priv_data)
524{ 518{
525 int rc; 519 return pcmcia_request_io(p_dev);
526 if (!cfg->io.nwin)
527 return -ENODEV;
528
529 /* Get the IOaddr */
530 p_dev->resource[0]->start = cfg->io.win[0].base;
531 p_dev->resource[0]->end = cfg->io.win[0].len;
532 p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags);
533 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK;
534 rc = pcmcia_request_io(p_dev);
535
536 dev_printk(KERN_INFO, &p_dev->dev,
537 "pcmcia_request_io returned 0x%x\n", rc);
538 return rc;
539} 520}
540 521
541 522
@@ -544,15 +525,15 @@ static int reader_config(struct pcmcia_device *link, int devno)
544 struct reader_dev *dev; 525 struct reader_dev *dev;
545 int fail_rc; 526 int fail_rc;
546 527
528 link->config_flags |= CONF_AUTO_SET_IO;
529
547 if (pcmcia_loop_config(link, cm4040_config_check, NULL)) 530 if (pcmcia_loop_config(link, cm4040_config_check, NULL))
548 goto cs_release; 531 goto cs_release;
549 532
550 link->conf.IntType = 00000002; 533 fail_rc = pcmcia_enable_device(link);
551
552 fail_rc = pcmcia_request_configuration(link, &link->conf);
553 if (fail_rc != 0) { 534 if (fail_rc != 0) {
554 dev_printk(KERN_INFO, &link->dev, 535 dev_printk(KERN_INFO, &link->dev,
555 "pcmcia_request_configuration failed 0x%x\n", 536 "pcmcia_enable_device failed 0x%x\n",
556 fail_rc); 537 fail_rc);
557 goto cs_release; 538 goto cs_release;
558 } 539 }
@@ -599,7 +580,6 @@ static int reader_probe(struct pcmcia_device *link)
599 link->priv = dev; 580 link->priv = dev;
600 dev->p_dev = link; 581 dev->p_dev = link;
601 582
602 link->conf.IntType = INT_MEMORY_AND_IO;
603 dev_table[i] = link; 583 dev_table[i] = link;
604 584
605 init_waitqueue_head(&dev->devq); 585 init_waitqueue_head(&dev->devq);
@@ -650,6 +630,7 @@ static const struct file_operations reader_fops = {
650 .open = cm4040_open, 630 .open = cm4040_open,
651 .release = cm4040_close, 631 .release = cm4040_close,
652 .poll = cm4040_poll, 632 .poll = cm4040_poll,
633 .llseek = no_llseek,
653}; 634};
654 635
655static struct pcmcia_device_id cm4040_ids[] = { 636static struct pcmcia_device_id cm4040_ids[] = {
@@ -662,9 +643,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4040_ids);
662 643
663static struct pcmcia_driver reader_driver = { 644static struct pcmcia_driver reader_driver = {
664 .owner = THIS_MODULE, 645 .owner = THIS_MODULE,
665 .drv = { 646 .name = "cm4040_cs",
666 .name = "cm4040_cs",
667 },
668 .probe = reader_probe, 647 .probe = reader_probe,
669 .remove = reader_detach, 648 .remove = reader_detach,
670 .id_table = cm4040_ids, 649 .id_table = cm4040_ids,
@@ -674,7 +653,6 @@ static int __init cm4040_init(void)
674{ 653{
675 int rc; 654 int rc;
676 655
677 printk(KERN_INFO "%s\n", version);
678 cmx_class = class_create(THIS_MODULE, "cardman_4040"); 656 cmx_class = class_create(THIS_MODULE, "cardman_4040");
679 if (IS_ERR(cmx_class)) 657 if (IS_ERR(cmx_class))
680 return PTR_ERR(cmx_class); 658 return PTR_ERR(cmx_class);
@@ -699,7 +677,6 @@ static int __init cm4040_init(void)
699 677
700static void __exit cm4040_exit(void) 678static void __exit cm4040_exit(void)
701{ 679{
702 printk(KERN_INFO MODULE_NAME ": unloading\n");
703 pcmcia_unregister_driver(&reader_driver); 680 pcmcia_unregister_driver(&reader_driver);
704 unregister_chrdev(major, DEVICE_NAME); 681 unregister_chrdev(major, DEVICE_NAME);
705 class_destroy(cmx_class); 682 class_destroy(cmx_class);
diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c
index 67bdb05798b1..94b8eb4d691d 100644
--- a/drivers/char/pcmcia/ipwireless/main.c
+++ b/drivers/char/pcmcia/ipwireless/main.c
@@ -32,7 +32,6 @@
32#include <pcmcia/device_id.h> 32#include <pcmcia/device_id.h>
33#include <pcmcia/ss.h> 33#include <pcmcia/ss.h>
34#include <pcmcia/ds.h> 34#include <pcmcia/ds.h>
35#include <pcmcia/cs.h>
36 35
37static struct pcmcia_device_id ipw_ids[] = { 36static struct pcmcia_device_id ipw_ids[] = {
38 PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100), 37 PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100),
@@ -76,23 +75,18 @@ static void signalled_reboot_callback(void *callback_data)
76 schedule_work(&ipw->work_reboot); 75 schedule_work(&ipw->work_reboot);
77} 76}
78 77
79static int ipwireless_probe(struct pcmcia_device *p_dev, 78static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data)
80 cistpl_cftable_entry_t *cfg,
81 cistpl_cftable_entry_t *dflt,
82 unsigned int vcc,
83 void *priv_data)
84{ 79{
85 struct ipw_dev *ipw = priv_data; 80 struct ipw_dev *ipw = priv_data;
86 struct resource *io_resource; 81 struct resource *io_resource;
87 int ret; 82 int ret;
88 83
84 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
89 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 85 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
90 p_dev->resource[0]->start = cfg->io.win[0].base;
91 p_dev->resource[0]->end = cfg->io.win[0].len;
92 86
93 /* 0x40 causes it to generate level mode interrupts. */ 87 /* 0x40 causes it to generate level mode interrupts. */
94 /* 0x04 enables IREQ pin. */ 88 /* 0x04 enables IREQ pin. */
95 p_dev->conf.ConfigIndex = cfg->index | 0x44; 89 p_dev->config_index |= 0x44;
96 p_dev->io_lines = 16; 90 p_dev->io_lines = 16;
97 ret = pcmcia_request_io(p_dev); 91 ret = pcmcia_request_io(p_dev);
98 if (ret) 92 if (ret)
@@ -102,65 +96,49 @@ static int ipwireless_probe(struct pcmcia_device *p_dev,
102 resource_size(p_dev->resource[0]), 96 resource_size(p_dev->resource[0]),
103 IPWIRELESS_PCCARD_NAME); 97 IPWIRELESS_PCCARD_NAME);
104 98
105 if (cfg->mem.nwin == 0) 99 p_dev->resource[2]->flags |=
106 return 0;
107
108 ipw->request_common_memory.Attributes =
109 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE; 100 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE;
110 ipw->request_common_memory.Base = cfg->mem.win[0].host_addr;
111 ipw->request_common_memory.Size = cfg->mem.win[0].len;
112 if (ipw->request_common_memory.Size < 0x1000)
113 ipw->request_common_memory.Size = 0x1000;
114 ipw->request_common_memory.AccessSpeed = 0;
115
116 ret = pcmcia_request_window(p_dev, &ipw->request_common_memory,
117 &ipw->handle_common_memory);
118 101
102 ret = pcmcia_request_window(p_dev, p_dev->resource[2], 0);
119 if (ret != 0) 103 if (ret != 0)
120 goto exit1; 104 goto exit1;
121 105
122 ret = pcmcia_map_mem_page(p_dev, ipw->handle_common_memory, 106 ret = pcmcia_map_mem_page(p_dev, p_dev->resource[2], p_dev->card_addr);
123 cfg->mem.win[0].card_addr);
124
125 if (ret != 0) 107 if (ret != 0)
126 goto exit2; 108 goto exit2;
127 109
128 ipw->is_v2_card = cfg->mem.win[0].len == 0x100; 110 ipw->is_v2_card = resource_size(p_dev->resource[2]) == 0x100;
129 111
130 ipw->common_memory = ioremap(ipw->request_common_memory.Base, 112 ipw->attr_memory = ioremap(p_dev->resource[2]->start,
131 ipw->request_common_memory.Size); 113 resource_size(p_dev->resource[2]));
132 request_mem_region(ipw->request_common_memory.Base, 114 request_mem_region(p_dev->resource[2]->start,
133 ipw->request_common_memory.Size, 115 resource_size(p_dev->resource[2]),
134 IPWIRELESS_PCCARD_NAME); 116 IPWIRELESS_PCCARD_NAME);
135 117
136 ipw->request_attr_memory.Attributes = 118 p_dev->resource[3]->flags |= WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM |
137 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM | WIN_ENABLE; 119 WIN_ENABLE;
138 ipw->request_attr_memory.Base = 0; 120 p_dev->resource[3]->end = 0; /* this used to be 0x1000 */
139 ipw->request_attr_memory.Size = 0; /* this used to be 0x1000 */ 121 ret = pcmcia_request_window(p_dev, p_dev->resource[3], 0);
140 ipw->request_attr_memory.AccessSpeed = 0;
141
142 ret = pcmcia_request_window(p_dev, &ipw->request_attr_memory,
143 &ipw->handle_attr_memory);
144
145 if (ret != 0) 122 if (ret != 0)
146 goto exit2; 123 goto exit2;
147 124
148 ret = pcmcia_map_mem_page(p_dev, ipw->handle_attr_memory, 0); 125 ret = pcmcia_map_mem_page(p_dev, p_dev->resource[3], 0);
149 if (ret != 0) 126 if (ret != 0)
150 goto exit3; 127 goto exit3;
151 128
152 ipw->attr_memory = ioremap(ipw->request_attr_memory.Base, 129 ipw->attr_memory = ioremap(p_dev->resource[3]->start,
153 ipw->request_attr_memory.Size); 130 resource_size(p_dev->resource[3]));
154 request_mem_region(ipw->request_attr_memory.Base, 131 request_mem_region(p_dev->resource[3]->start,
155 ipw->request_attr_memory.Size, IPWIRELESS_PCCARD_NAME); 132 resource_size(p_dev->resource[3]),
133 IPWIRELESS_PCCARD_NAME);
156 134
157 return 0; 135 return 0;
158 136
159exit3: 137exit3:
160exit2: 138exit2:
161 if (ipw->common_memory) { 139 if (ipw->common_memory) {
162 release_mem_region(ipw->request_common_memory.Base, 140 release_mem_region(p_dev->resource[2]->start,
163 ipw->request_common_memory.Size); 141 resource_size(p_dev->resource[2]));
164 iounmap(ipw->common_memory); 142 iounmap(ipw->common_memory);
165 } 143 }
166exit1: 144exit1:
@@ -175,14 +153,13 @@ static int config_ipwireless(struct ipw_dev *ipw)
175 int ret = 0; 153 int ret = 0;
176 154
177 ipw->is_v2_card = 0; 155 ipw->is_v2_card = 0;
156 link->config_flags |= CONF_AUTO_SET_IO | CONF_AUTO_SET_IOMEM |
157 CONF_ENABLE_IRQ;
178 158
179 ret = pcmcia_loop_config(link, ipwireless_probe, ipw); 159 ret = pcmcia_loop_config(link, ipwireless_probe, ipw);
180 if (ret != 0) 160 if (ret != 0)
181 return ret; 161 return ret;
182 162
183 link->conf.Attributes = CONF_ENABLE_IRQ;
184 link->conf.IntType = INT_MEMORY_AND_IO;
185
186 INIT_WORK(&ipw->work_reboot, signalled_reboot_work); 163 INIT_WORK(&ipw->work_reboot, signalled_reboot_work);
187 164
188 ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start, 165 ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start,
@@ -201,13 +178,9 @@ static int config_ipwireless(struct ipw_dev *ipw)
201 (unsigned int) link->irq); 178 (unsigned int) link->irq);
202 if (ipw->attr_memory && ipw->common_memory) 179 if (ipw->attr_memory && ipw->common_memory)
203 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 180 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
204 ": attr memory 0x%08lx-0x%08lx, common memory 0x%08lx-0x%08lx\n", 181 ": attr memory %pR, common memory %pR\n",
205 ipw->request_attr_memory.Base, 182 link->resource[3],
206 ipw->request_attr_memory.Base 183 link->resource[2]);
207 + ipw->request_attr_memory.Size - 1,
208 ipw->request_common_memory.Base,
209 ipw->request_common_memory.Base
210 + ipw->request_common_memory.Size - 1);
211 184
212 ipw->network = ipwireless_network_create(ipw->hardware); 185 ipw->network = ipwireless_network_create(ipw->hardware);
213 if (!ipw->network) 186 if (!ipw->network)
@@ -223,25 +196,23 @@ static int config_ipwireless(struct ipw_dev *ipw)
223 * Do the RequestConfiguration last, because it enables interrupts. 196 * Do the RequestConfiguration last, because it enables interrupts.
224 * Then we don't get any interrupts before we're ready for them. 197 * Then we don't get any interrupts before we're ready for them.
225 */ 198 */
226 ret = pcmcia_request_configuration(link, &link->conf); 199 ret = pcmcia_enable_device(link);
227
228 if (ret != 0) 200 if (ret != 0)
229 goto exit; 201 goto exit;
230 202
231 return 0; 203 return 0;
232 204
233exit: 205exit:
234 if (ipw->attr_memory) {
235 release_mem_region(ipw->request_attr_memory.Base,
236 ipw->request_attr_memory.Size);
237 iounmap(ipw->attr_memory);
238
239 }
240 if (ipw->common_memory) { 206 if (ipw->common_memory) {
241 release_mem_region(ipw->request_common_memory.Base, 207 release_mem_region(link->resource[2]->start,
242 ipw->request_common_memory.Size); 208 resource_size(link->resource[2]));
243 iounmap(ipw->common_memory); 209 iounmap(ipw->common_memory);
244 } 210 }
211 if (ipw->attr_memory) {
212 release_mem_region(link->resource[3]->start,
213 resource_size(link->resource[3]));
214 iounmap(ipw->attr_memory);
215 }
245 pcmcia_disable_device(link); 216 pcmcia_disable_device(link);
246 return -1; 217 return -1;
247} 218}
@@ -249,13 +220,13 @@ exit:
249static void release_ipwireless(struct ipw_dev *ipw) 220static void release_ipwireless(struct ipw_dev *ipw)
250{ 221{
251 if (ipw->common_memory) { 222 if (ipw->common_memory) {
252 release_mem_region(ipw->request_common_memory.Base, 223 release_mem_region(ipw->link->resource[2]->start,
253 ipw->request_common_memory.Size); 224 resource_size(ipw->link->resource[2]));
254 iounmap(ipw->common_memory); 225 iounmap(ipw->common_memory);
255 } 226 }
256 if (ipw->attr_memory) { 227 if (ipw->attr_memory) {
257 release_mem_region(ipw->request_attr_memory.Base, 228 release_mem_region(ipw->link->resource[3]->start,
258 ipw->request_attr_memory.Size); 229 resource_size(ipw->link->resource[3]));
259 iounmap(ipw->attr_memory); 230 iounmap(ipw->attr_memory);
260 } 231 }
261 pcmcia_disable_device(ipw->link); 232 pcmcia_disable_device(ipw->link);
@@ -324,7 +295,7 @@ static struct pcmcia_driver me = {
324 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
325 .probe = ipwireless_attach, 296 .probe = ipwireless_attach,
326 .remove = ipwireless_detach, 297 .remove = ipwireless_detach,
327 .drv = { .name = IPWIRELESS_PCCARD_NAME }, 298 .name = IPWIRELESS_PCCARD_NAME,
328 .id_table = ipw_ids 299 .id_table = ipw_ids
329}; 300};
330 301
@@ -336,9 +307,6 @@ static int __init init_ipwireless(void)
336{ 307{
337 int ret; 308 int ret;
338 309
339 printk(KERN_INFO IPWIRELESS_PCCARD_NAME " "
340 IPWIRELESS_PCMCIA_VERSION " by " IPWIRELESS_PCMCIA_AUTHOR "\n");
341
342 ret = ipwireless_tty_init(); 310 ret = ipwireless_tty_init();
343 if (ret != 0) 311 if (ret != 0)
344 return ret; 312 return ret;
@@ -355,9 +323,6 @@ static int __init init_ipwireless(void)
355 */ 323 */
356static void __exit exit_ipwireless(void) 324static void __exit exit_ipwireless(void)
357{ 325{
358 printk(KERN_INFO IPWIRELESS_PCCARD_NAME " "
359 IPWIRELESS_PCMCIA_VERSION " removed\n");
360
361 pcmcia_unregister_driver(&me); 326 pcmcia_unregister_driver(&me);
362 ipwireless_tty_release(); 327 ipwireless_tty_release();
363} 328}
diff --git a/drivers/char/pcmcia/ipwireless/main.h b/drivers/char/pcmcia/ipwireless/main.h
index c207be87b597..f2cbb116bccb 100644
--- a/drivers/char/pcmcia/ipwireless/main.h
+++ b/drivers/char/pcmcia/ipwireless/main.h
@@ -21,7 +21,6 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/types.h> 22#include <linux/types.h>
23 23
24#include <pcmcia/cs.h>
25#include <pcmcia/cistpl.h> 24#include <pcmcia/cistpl.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
27 26
@@ -45,13 +44,9 @@ struct ipw_dev {
45 struct pcmcia_device *link; 44 struct pcmcia_device *link;
46 int is_v2_card; 45 int is_v2_card;
47 46
48 window_handle_t handle_attr_memory;
49 void __iomem *attr_memory; 47 void __iomem *attr_memory;
50 win_req_t request_attr_memory;
51 48
52 window_handle_t handle_common_memory;
53 void __iomem *common_memory; 49 void __iomem *common_memory;
54 win_req_t request_common_memory;
55 50
56 /* Reference to attribute memory, containing CIS data */ 51 /* Reference to attribute memory, containing CIS data */
57 void *attribute_memory; 52 void *attribute_memory;
diff --git a/drivers/char/pcmcia/ipwireless/tty.h b/drivers/char/pcmcia/ipwireless/tty.h
index 3e163d4cab15..747b2d637860 100644
--- a/drivers/char/pcmcia/ipwireless/tty.h
+++ b/drivers/char/pcmcia/ipwireless/tty.h
@@ -21,7 +21,6 @@
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23 23
24#include <pcmcia/cs.h>
25#include <pcmcia/cistpl.h> 24#include <pcmcia/cistpl.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
27 26
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 9ecd6bef5d3b..be1810057607 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -70,7 +70,6 @@
70#include <linux/workqueue.h> 70#include <linux/workqueue.h>
71#include <linux/hdlc.h> 71#include <linux/hdlc.h>
72 72
73#include <pcmcia/cs.h>
74#include <pcmcia/cistpl.h> 73#include <pcmcia/cistpl.h>
75#include <pcmcia/cisreg.h> 74#include <pcmcia/cisreg.h>
76#include <pcmcia/ds.h> 75#include <pcmcia/ds.h>
@@ -550,9 +549,6 @@ static int mgslpc_probe(struct pcmcia_device *link)
550 549
551 /* Initialize the struct pcmcia_device structure */ 550 /* Initialize the struct pcmcia_device structure */
552 551
553 link->conf.Attributes = 0;
554 link->conf.IntType = INT_MEMORY_AND_IO;
555
556 ret = mgslpc_config(link); 552 ret = mgslpc_config(link);
557 if (ret) 553 if (ret)
558 return ret; 554 return ret;
@@ -565,20 +561,8 @@ static int mgslpc_probe(struct pcmcia_device *link)
565/* Card has been inserted. 561/* Card has been inserted.
566 */ 562 */
567 563
568static int mgslpc_ioprobe(struct pcmcia_device *p_dev, 564static int mgslpc_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
569 cistpl_cftable_entry_t *cfg,
570 cistpl_cftable_entry_t *dflt,
571 unsigned int vcc,
572 void *priv_data)
573{ 565{
574 if (!cfg->io.nwin)
575 return -ENODEV;
576
577 p_dev->resource[0]->start = cfg->io.win[0].base;
578 p_dev->resource[0]->end = cfg->io.win[0].len;
579 p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags);
580 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK;
581
582 return pcmcia_request_io(p_dev); 566 return pcmcia_request_io(p_dev);
583} 567}
584 568
@@ -590,32 +574,24 @@ static int mgslpc_config(struct pcmcia_device *link)
590 if (debug_level >= DEBUG_LEVEL_INFO) 574 if (debug_level >= DEBUG_LEVEL_INFO)
591 printk("mgslpc_config(0x%p)\n", link); 575 printk("mgslpc_config(0x%p)\n", link);
592 576
577 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
578
593 ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); 579 ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL);
594 if (ret != 0) 580 if (ret != 0)
595 goto failed; 581 goto failed;
596 582
597 link->conf.Attributes = CONF_ENABLE_IRQ; 583 link->config_index = 8;
598 link->conf.IntType = INT_MEMORY_AND_IO; 584 link->config_regs = PRESENT_OPTION;
599 link->conf.ConfigIndex = 8;
600 link->conf.Present = PRESENT_OPTION;
601 585
602 ret = pcmcia_request_irq(link, mgslpc_isr); 586 ret = pcmcia_request_irq(link, mgslpc_isr);
603 if (ret) 587 if (ret)
604 goto failed; 588 goto failed;
605 ret = pcmcia_request_configuration(link, &link->conf); 589 ret = pcmcia_enable_device(link);
606 if (ret) 590 if (ret)
607 goto failed; 591 goto failed;
608 592
609 info->io_base = link->resource[0]->start; 593 info->io_base = link->resource[0]->start;
610 info->irq_level = link->irq; 594 info->irq_level = link->irq;
611
612 dev_info(&link->dev, "index 0x%02x:",
613 link->conf.ConfigIndex);
614 if (link->conf.Attributes & CONF_ENABLE_IRQ)
615 printk(", irq %d", link->irq);
616 if (link->resource[0])
617 printk(", io %pR", link->resource[0]);
618 printk("\n");
619 return 0; 595 return 0;
620 596
621failed: 597failed:
@@ -2797,9 +2773,7 @@ MODULE_DEVICE_TABLE(pcmcia, mgslpc_ids);
2797 2773
2798static struct pcmcia_driver mgslpc_driver = { 2774static struct pcmcia_driver mgslpc_driver = {
2799 .owner = THIS_MODULE, 2775 .owner = THIS_MODULE,
2800 .drv = { 2776 .name = "synclink_cs",
2801 .name = "synclink_cs",
2802 },
2803 .probe = mgslpc_probe, 2777 .probe = mgslpc_probe,
2804 .remove = mgslpc_detach, 2778 .remove = mgslpc_detach,
2805 .id_table = mgslpc_ids, 2779 .id_table = mgslpc_ids,
@@ -2835,8 +2809,6 @@ static void synclink_cs_cleanup(void)
2835{ 2809{
2836 int rc; 2810 int rc;
2837 2811
2838 printk("Unloading %s: version %s\n", driver_name, driver_version);
2839
2840 while(mgslpc_device_list) 2812 while(mgslpc_device_list)
2841 mgslpc_remove_device(mgslpc_device_list); 2813 mgslpc_remove_device(mgslpc_device_list);
2842 2814
@@ -2859,8 +2831,6 @@ static int __init synclink_cs_init(void)
2859 BREAKPOINT(); 2831 BREAKPOINT();
2860 } 2832 }
2861 2833
2862 printk("%s %s\n", driver_name, driver_version);
2863
2864 if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) 2834 if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0)
2865 return rc; 2835 return rc;
2866 2836
@@ -4127,6 +4097,8 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4127 if (cmd != SIOCWANDEV) 4097 if (cmd != SIOCWANDEV)
4128 return hdlc_ioctl(dev, ifr, cmd); 4098 return hdlc_ioctl(dev, ifr, cmd);
4129 4099
4100 memset(&new_line, 0, size);
4101
4130 switch(ifr->ifr_settings.type) { 4102 switch(ifr->ifr_settings.type) {
4131 case IF_GET_IFACE: /* return current sync_serial_settings */ 4103 case IF_GET_IFACE: /* return current sync_serial_settings */
4132 4104
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 02abfddce45a..723152d978a9 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -67,7 +67,7 @@
67#include <linux/slab.h> 67#include <linux/slab.h>
68#include <linux/major.h> 68#include <linux/major.h>
69#include <linux/ppdev.h> 69#include <linux/ppdev.h>
70#include <linux/smp_lock.h> 70#include <linux/mutex.h>
71#include <linux/uaccess.h> 71#include <linux/uaccess.h>
72 72
73#define PP_VERSION "ppdev: user-space parallel port driver" 73#define PP_VERSION "ppdev: user-space parallel port driver"
@@ -97,6 +97,7 @@ struct pp_struct {
97/* ROUND_UP macro from fs/select.c */ 97/* ROUND_UP macro from fs/select.c */
98#define ROUND_UP(x,y) (((x)+(y)-1)/(y)) 98#define ROUND_UP(x,y) (((x)+(y)-1)/(y))
99 99
100static DEFINE_MUTEX(pp_do_mutex);
100static inline void pp_enable_irq (struct pp_struct *pp) 101static inline void pp_enable_irq (struct pp_struct *pp)
101{ 102{
102 struct parport *port = pp->pdev->port; 103 struct parport *port = pp->pdev->port;
@@ -630,9 +631,9 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
630static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 631static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
631{ 632{
632 long ret; 633 long ret;
633 lock_kernel(); 634 mutex_lock(&pp_do_mutex);
634 ret = pp_do_ioctl(file, cmd, arg); 635 ret = pp_do_ioctl(file, cmd, arg);
635 unlock_kernel(); 636 mutex_unlock(&pp_do_mutex);
636 return ret; 637 return ret;
637} 638}
638 639
@@ -641,7 +642,6 @@ static int pp_open (struct inode * inode, struct file * file)
641 unsigned int minor = iminor(inode); 642 unsigned int minor = iminor(inode);
642 struct pp_struct *pp; 643 struct pp_struct *pp;
643 644
644 cycle_kernel_lock();
645 if (minor >= PARPORT_MAX) 645 if (minor >= PARPORT_MAX)
646 return -ENXIO; 646 return -ENXIO;
647 647
diff --git a/drivers/char/random.c b/drivers/char/random.c
index caef35a46890..5a1aa64f4e76 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1165,6 +1165,7 @@ const struct file_operations random_fops = {
1165 .poll = random_poll, 1165 .poll = random_poll,
1166 .unlocked_ioctl = random_ioctl, 1166 .unlocked_ioctl = random_ioctl,
1167 .fasync = random_fasync, 1167 .fasync = random_fasync,
1168 .llseek = noop_llseek,
1168}; 1169};
1169 1170
1170const struct file_operations urandom_fops = { 1171const struct file_operations urandom_fops = {
@@ -1172,6 +1173,7 @@ const struct file_operations urandom_fops = {
1172 .write = random_write, 1173 .write = random_write,
1173 .unlocked_ioctl = random_ioctl, 1174 .unlocked_ioctl = random_ioctl,
1174 .fasync = random_fasync, 1175 .fasync = random_fasync,
1176 .llseek = noop_llseek,
1175}; 1177};
1176 1178
1177/*************************************************************** 1179/***************************************************************
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index b38942f6bf31..bfe25ea9766b 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,8 +19,8 @@
19#include <linux/cdev.h> 19#include <linux/cdev.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/smp_lock.h>
23#include <linux/gfp.h> 22#include <linux/gfp.h>
23#include <linux/compat.h>
24 24
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26 26
@@ -55,7 +55,6 @@ static int raw_open(struct inode *inode, struct file *filp)
55 return 0; 55 return 0;
56 } 56 }
57 57
58 lock_kernel();
59 mutex_lock(&raw_mutex); 58 mutex_lock(&raw_mutex);
60 59
61 /* 60 /*
@@ -82,7 +81,6 @@ static int raw_open(struct inode *inode, struct file *filp)
82 bdev->bd_inode->i_mapping; 81 bdev->bd_inode->i_mapping;
83 filp->private_data = bdev; 82 filp->private_data = bdev;
84 mutex_unlock(&raw_mutex); 83 mutex_unlock(&raw_mutex);
85 unlock_kernel();
86 return 0; 84 return 0;
87 85
88out2: 86out2:
@@ -91,7 +89,6 @@ out1:
91 blkdev_put(bdev, filp->f_mode); 89 blkdev_put(bdev, filp->f_mode);
92out: 90out:
93 mutex_unlock(&raw_mutex); 91 mutex_unlock(&raw_mutex);
94 unlock_kernel();
95 return err; 92 return err;
96} 93}
97 94
@@ -125,20 +122,84 @@ static long
125raw_ioctl(struct file *filp, unsigned int command, unsigned long arg) 122raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
126{ 123{
127 struct block_device *bdev = filp->private_data; 124 struct block_device *bdev = filp->private_data;
128 int ret; 125 return blkdev_ioctl(bdev, 0, command, arg);
126}
127
128static int bind_set(int number, u64 major, u64 minor)
129{
130 dev_t dev = MKDEV(major, minor);
131 struct raw_device_data *rawdev;
132 int err = 0;
129 133
130 lock_kernel(); 134 if (number <= 0 || number >= MAX_RAW_MINORS)
131 ret = blkdev_ioctl(bdev, 0, command, arg); 135 return -EINVAL;
132 unlock_kernel();
133 136
134 return ret; 137 if (MAJOR(dev) != major || MINOR(dev) != minor)
138 return -EINVAL;
139
140 rawdev = &raw_devices[number];
141
142 /*
143 * This is like making block devices, so demand the
144 * same capability
145 */
146 if (!capable(CAP_SYS_ADMIN))
147 return -EPERM;
148
149 /*
150 * For now, we don't need to check that the underlying
151 * block device is present or not: we can do that when
152 * the raw device is opened. Just check that the
153 * major/minor numbers make sense.
154 */
155
156 if (MAJOR(dev) == 0 && dev != 0)
157 return -EINVAL;
158
159 mutex_lock(&raw_mutex);
160 if (rawdev->inuse) {
161 mutex_unlock(&raw_mutex);
162 return -EBUSY;
163 }
164 if (rawdev->binding) {
165 bdput(rawdev->binding);
166 module_put(THIS_MODULE);
167 }
168 if (!dev) {
169 /* unbind */
170 rawdev->binding = NULL;
171 device_destroy(raw_class, MKDEV(RAW_MAJOR, number));
172 } else {
173 rawdev->binding = bdget(dev);
174 if (rawdev->binding == NULL) {
175 err = -ENOMEM;
176 } else {
177 dev_t raw = MKDEV(RAW_MAJOR, number);
178 __module_get(THIS_MODULE);
179 device_destroy(raw_class, raw);
180 device_create(raw_class, NULL, raw, NULL,
181 "raw%d", number);
182 }
183 }
184 mutex_unlock(&raw_mutex);
185 return err;
135} 186}
136 187
137static void bind_device(struct raw_config_request *rq) 188static int bind_get(int number, dev_t *dev)
138{ 189{
139 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 190 struct raw_device_data *rawdev;
140 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL, 191 struct block_device *bdev;
141 "raw%d", rq->raw_minor); 192
193 if (number <= 0 || number >= MAX_RAW_MINORS)
194 return -EINVAL;
195
196 rawdev = &raw_devices[number];
197
198 mutex_lock(&raw_mutex);
199 bdev = rawdev->binding;
200 *dev = bdev ? bdev->bd_dev : 0;
201 mutex_unlock(&raw_mutex);
202 return 0;
142} 203}
143 204
144/* 205/*
@@ -149,105 +210,78 @@ static long raw_ctl_ioctl(struct file *filp, unsigned int command,
149 unsigned long arg) 210 unsigned long arg)
150{ 211{
151 struct raw_config_request rq; 212 struct raw_config_request rq;
152 struct raw_device_data *rawdev; 213 dev_t dev;
153 int err = 0; 214 int err;
154 215
155 lock_kernel();
156 switch (command) { 216 switch (command) {
157 case RAW_SETBIND: 217 case RAW_SETBIND:
218 if (copy_from_user(&rq, (void __user *) arg, sizeof(rq)))
219 return -EFAULT;
220
221 return bind_set(rq.raw_minor, rq.block_major, rq.block_minor);
222
158 case RAW_GETBIND: 223 case RAW_GETBIND:
224 if (copy_from_user(&rq, (void __user *) arg, sizeof(rq)))
225 return -EFAULT;
159 226
160 /* First, find out which raw minor we want */ 227 err = bind_get(rq.raw_minor, &dev);
228 if (err)
229 return err;
161 230
162 if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) { 231 rq.block_major = MAJOR(dev);
163 err = -EFAULT; 232 rq.block_minor = MINOR(dev);
164 goto out;
165 }
166 233
167 if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) { 234 if (copy_to_user((void __user *)arg, &rq, sizeof(rq)))
168 err = -EINVAL; 235 return -EFAULT;
169 goto out; 236
170 } 237 return 0;
171 rawdev = &raw_devices[rq.raw_minor];
172
173 if (command == RAW_SETBIND) {
174 dev_t dev;
175
176 /*
177 * This is like making block devices, so demand the
178 * same capability
179 */
180 if (!capable(CAP_SYS_ADMIN)) {
181 err = -EPERM;
182 goto out;
183 }
184
185 /*
186 * For now, we don't need to check that the underlying
187 * block device is present or not: we can do that when
188 * the raw device is opened. Just check that the
189 * major/minor numbers make sense.
190 */
191
192 dev = MKDEV(rq.block_major, rq.block_minor);
193 if ((rq.block_major == 0 && rq.block_minor != 0) ||
194 MAJOR(dev) != rq.block_major ||
195 MINOR(dev) != rq.block_minor) {
196 err = -EINVAL;
197 goto out;
198 }
199
200 mutex_lock(&raw_mutex);
201 if (rawdev->inuse) {
202 mutex_unlock(&raw_mutex);
203 err = -EBUSY;
204 goto out;
205 }
206 if (rawdev->binding) {
207 bdput(rawdev->binding);
208 module_put(THIS_MODULE);
209 }
210 if (rq.block_major == 0 && rq.block_minor == 0) {
211 /* unbind */
212 rawdev->binding = NULL;
213 device_destroy(raw_class,
214 MKDEV(RAW_MAJOR, rq.raw_minor));
215 } else {
216 rawdev->binding = bdget(dev);
217 if (rawdev->binding == NULL)
218 err = -ENOMEM;
219 else {
220 __module_get(THIS_MODULE);
221 bind_device(&rq);
222 }
223 }
224 mutex_unlock(&raw_mutex);
225 } else {
226 struct block_device *bdev;
227
228 mutex_lock(&raw_mutex);
229 bdev = rawdev->binding;
230 if (bdev) {
231 rq.block_major = MAJOR(bdev->bd_dev);
232 rq.block_minor = MINOR(bdev->bd_dev);
233 } else {
234 rq.block_major = rq.block_minor = 0;
235 }
236 mutex_unlock(&raw_mutex);
237 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
238 err = -EFAULT;
239 goto out;
240 }
241 }
242 break;
243 default:
244 err = -EINVAL;
245 break;
246 } 238 }
247out: 239
248 unlock_kernel(); 240 return -EINVAL;
249 return err; 241}
242
243#ifdef CONFIG_COMPAT
244struct raw32_config_request {
245 compat_int_t raw_minor;
246 compat_u64 block_major;
247 compat_u64 block_minor;
248};
249
250static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd,
251 unsigned long arg)
252{
253 struct raw32_config_request __user *user_req = compat_ptr(arg);
254 struct raw32_config_request rq;
255 dev_t dev;
256 int err = 0;
257
258 switch (cmd) {
259 case RAW_SETBIND:
260 if (copy_from_user(&rq, user_req, sizeof(rq)))
261 return -EFAULT;
262
263 return bind_set(rq.raw_minor, rq.block_major, rq.block_minor);
264
265 case RAW_GETBIND:
266 if (copy_from_user(&rq, user_req, sizeof(rq)))
267 return -EFAULT;
268
269 err = bind_get(rq.raw_minor, &dev);
270 if (err)
271 return err;
272
273 rq.block_major = MAJOR(dev);
274 rq.block_minor = MINOR(dev);
275
276 if (copy_to_user(user_req, &rq, sizeof(rq)))
277 return -EFAULT;
278
279 return 0;
280 }
281
282 return -EINVAL;
250} 283}
284#endif
251 285
252static const struct file_operations raw_fops = { 286static const struct file_operations raw_fops = {
253 .read = do_sync_read, 287 .read = do_sync_read,
@@ -258,13 +292,18 @@ static const struct file_operations raw_fops = {
258 .open = raw_open, 292 .open = raw_open,
259 .release = raw_release, 293 .release = raw_release,
260 .unlocked_ioctl = raw_ioctl, 294 .unlocked_ioctl = raw_ioctl,
295 .llseek = default_llseek,
261 .owner = THIS_MODULE, 296 .owner = THIS_MODULE,
262}; 297};
263 298
264static const struct file_operations raw_ctl_fops = { 299static const struct file_operations raw_ctl_fops = {
265 .unlocked_ioctl = raw_ctl_ioctl, 300 .unlocked_ioctl = raw_ctl_ioctl,
301#ifdef CONFIG_COMPAT
302 .compat_ioctl = raw_ctl_compat_ioctl,
303#endif
266 .open = raw_open, 304 .open = raw_open,
267 .owner = THIS_MODULE, 305 .owner = THIS_MODULE,
306 .llseek = noop_llseek,
268}; 307};
269 308
270static struct cdev raw_cdev; 309static struct cdev raw_cdev;
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index d58c2eb07f07..5e33293d24e3 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -44,7 +44,7 @@
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/smp_lock.h> 47#include <linux/mutex.h>
48#include <linux/miscdevice.h> 48#include <linux/miscdevice.h>
49#include <linux/init.h> 49#include <linux/init.h>
50 50
@@ -122,6 +122,7 @@ more than 512 ports.... */
122 122
123 123
124/* These constants are derived from SCO Source */ 124/* These constants are derived from SCO Source */
125static DEFINE_MUTEX(rio_fw_mutex);
125static struct Conf 126static struct Conf
126 RIOConf = { 127 RIOConf = {
127 /* locator */ "RIO Config here", 128 /* locator */ "RIO Config here",
@@ -241,6 +242,7 @@ static struct real_driver rio_real_driver = {
241static const struct file_operations rio_fw_fops = { 242static const struct file_operations rio_fw_fops = {
242 .owner = THIS_MODULE, 243 .owner = THIS_MODULE,
243 .unlocked_ioctl = rio_fw_ioctl, 244 .unlocked_ioctl = rio_fw_ioctl,
245 .llseek = noop_llseek,
244}; 246};
245 247
246static struct miscdevice rio_fw_device = { 248static struct miscdevice rio_fw_device = {
@@ -566,9 +568,9 @@ static long rio_fw_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
566 func_enter(); 568 func_enter();
567 569
568 /* The "dev" argument isn't used. */ 570 /* The "dev" argument isn't used. */
569 lock_kernel(); 571 mutex_lock(&rio_fw_mutex);
570 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); 572 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN));
571 unlock_kernel(); 573 mutex_unlock(&rio_fw_mutex);
572 574
573 func_exit(); 575 func_exit();
574 return rc; 576 return rc;
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 99e5272e3c53..0bc135b9b16f 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -67,6 +67,7 @@ static const struct file_operations scx200_gpio_fileops = {
67 .read = nsc_gpio_read, 67 .read = nsc_gpio_read,
68 .open = scx200_gpio_open, 68 .open = scx200_gpio_open,
69 .release = scx200_gpio_release, 69 .release = scx200_gpio_release,
70 .llseek = no_llseek,
70}; 71};
71 72
72static struct cdev scx200_gpio_cdev; /* use 1 cdev for all pins */ 73static struct cdev scx200_gpio_cdev; /* use 1 cdev for all pins */
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 32b74de18f5f..5816b39ff5a9 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -21,7 +21,7 @@
21#include <linux/poll.h> 21#include <linux/poll.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/smp_lock.h> 24#include <linux/mutex.h>
25#include <asm/sn/io.h> 25#include <asm/sn/io.h>
26#include <asm/sn/sn_sal.h> 26#include <asm/sn/sn_sal.h>
27#include <asm/sn/module.h> 27#include <asm/sn/module.h>
@@ -34,6 +34,7 @@
34#define SCDRV_BUFSZ 2048 34#define SCDRV_BUFSZ 2048
35#define SCDRV_TIMEOUT 1000 35#define SCDRV_TIMEOUT 1000
36 36
37static DEFINE_MUTEX(scdrv_mutex);
37static irqreturn_t 38static irqreturn_t
38scdrv_interrupt(int irq, void *subch_data) 39scdrv_interrupt(int irq, void *subch_data)
39{ 40{
@@ -105,7 +106,7 @@ scdrv_open(struct inode *inode, struct file *file)
105 file->private_data = sd; 106 file->private_data = sd;
106 107
107 /* hook this subchannel up to the system controller interrupt */ 108 /* hook this subchannel up to the system controller interrupt */
108 lock_kernel(); 109 mutex_lock(&scdrv_mutex);
109 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, 110 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt,
110 IRQF_SHARED | IRQF_DISABLED, 111 IRQF_SHARED | IRQF_DISABLED,
111 SYSCTL_BASENAME, sd); 112 SYSCTL_BASENAME, sd);
@@ -113,10 +114,10 @@ scdrv_open(struct inode *inode, struct file *file)
113 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); 114 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch);
114 kfree(sd); 115 kfree(sd);
115 printk("%s: irq request failed (%d)\n", __func__, rv); 116 printk("%s: irq request failed (%d)\n", __func__, rv);
116 unlock_kernel(); 117 mutex_unlock(&scdrv_mutex);
117 return -EBUSY; 118 return -EBUSY;
118 } 119 }
119 unlock_kernel(); 120 mutex_unlock(&scdrv_mutex);
120 return 0; 121 return 0;
121} 122}
122 123
@@ -357,6 +358,7 @@ static const struct file_operations scdrv_fops = {
357 .poll = scdrv_poll, 358 .poll = scdrv_poll,
358 .open = scdrv_open, 359 .open = scdrv_open,
359 .release = scdrv_release, 360 .release = scdrv_release,
361 .llseek = noop_llseek,
360}; 362};
361 363
362static struct class *snsc_class; 364static struct class *snsc_class;
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index f2167f8e5aab..8ef16490810c 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -608,6 +608,7 @@ static unsigned int sc26198_baudtable[] = {
608static const struct file_operations stl_fsiomem = { 608static const struct file_operations stl_fsiomem = {
609 .owner = THIS_MODULE, 609 .owner = THIS_MODULE,
610 .unlocked_ioctl = stl_memioctl, 610 .unlocked_ioctl = stl_memioctl,
611 .llseek = noop_llseek,
611}; 612};
612 613
613static struct class *stallion_class; 614static struct class *stallion_class;
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 5b24db4ff7f1..e53f16865397 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -397,6 +397,7 @@ static struct real_driver sx_real_driver = {
397static const struct file_operations sx_fw_fops = { 397static const struct file_operations sx_fw_fops = {
398 .owner = THIS_MODULE, 398 .owner = THIS_MODULE,
399 .unlocked_ioctl = sx_fw_ioctl, 399 .unlocked_ioctl = sx_fw_ioctl,
400 .llseek = noop_llseek,
400}; 401};
401 402
402static struct miscdevice sx_fw_device = { 403static struct miscdevice sx_fw_device = {
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index ef31bb81e843..f3019f53e875 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -772,6 +772,7 @@ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
772 772
773static const struct file_operations proc_sysrq_trigger_operations = { 773static const struct file_operations proc_sysrq_trigger_operations = {
774 .write = write_sysrq_trigger, 774 .write = write_sysrq_trigger,
775 .llseek = noop_llseek,
775}; 776};
776 777
777static void sysrq_init_procfs(void) 778static void sysrq_init_procfs(void)
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index cad4eb65f13d..ad264185eb10 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -261,6 +261,7 @@ static const struct file_operations tb0219_fops = {
261 .write = tanbac_tb0219_write, 261 .write = tanbac_tb0219_write,
262 .open = tanbac_tb0219_open, 262 .open = tanbac_tb0219_open,
263 .release = tanbac_tb0219_release, 263 .release = tanbac_tb0219_release,
264 .llseek = no_llseek,
264}; 265};
265 266
266static void tb0219_restart(char *command) 267static void tb0219_restart(char *command)
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 80ea6bcfffdc..0c964cdcc223 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -37,7 +37,7 @@
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/smp_lock.h> 40#include <linux/mutex.h>
41#include <linux/timer.h> 41#include <linux/timer.h>
42#include <linux/sysfs.h> 42#include <linux/sysfs.h>
43#include <linux/device.h> 43#include <linux/device.h>
@@ -206,7 +206,7 @@ static int tlclk_open(struct inode *inode, struct file *filp)
206{ 206{
207 int result; 207 int result;
208 208
209 lock_kernel(); 209 mutex_lock(&tlclk_mutex);
210 if (test_and_set_bit(0, &useflags)) { 210 if (test_and_set_bit(0, &useflags)) {
211 result = -EBUSY; 211 result = -EBUSY;
212 /* this legacy device is always one per system and it doesn't 212 /* this legacy device is always one per system and it doesn't
@@ -229,7 +229,7 @@ static int tlclk_open(struct inode *inode, struct file *filp)
229 inb(TLCLK_REG6); /* Clear interrupt events */ 229 inb(TLCLK_REG6); /* Clear interrupt events */
230 230
231out: 231out:
232 unlock_kernel(); 232 mutex_unlock(&tlclk_mutex);
233 return result; 233 return result;
234} 234}
235 235
@@ -267,6 +267,7 @@ static const struct file_operations tlclk_fops = {
267 .read = tlclk_read, 267 .read = tlclk_read,
268 .open = tlclk_open, 268 .open = tlclk_open,
269 .release = tlclk_release, 269 .release = tlclk_release,
270 .llseek = noop_llseek,
270 271
271}; 272};
272 273
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index f8bc79f6de34..014c9d90d297 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -68,7 +68,7 @@
68#include <linux/stat.h> 68#include <linux/stat.h>
69#include <linux/proc_fs.h> 69#include <linux/proc_fs.h>
70#include <linux/seq_file.h> 70#include <linux/seq_file.h>
71#include <linux/smp_lock.h> 71#include <linux/mutex.h>
72#include <linux/toshiba.h> 72#include <linux/toshiba.h>
73 73
74#define TOSH_MINOR_DEV 181 74#define TOSH_MINOR_DEV 181
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Jonathan Buzzard <jonathan@buzzard.org.uk>");
78MODULE_DESCRIPTION("Toshiba laptop SMM driver"); 78MODULE_DESCRIPTION("Toshiba laptop SMM driver");
79MODULE_SUPPORTED_DEVICE("toshiba"); 79MODULE_SUPPORTED_DEVICE("toshiba");
80 80
81static DEFINE_MUTEX(tosh_mutex);
81static int tosh_fn; 82static int tosh_fn;
82module_param_named(fn, tosh_fn, int, 0); 83module_param_named(fn, tosh_fn, int, 0);
83MODULE_PARM_DESC(fn, "User specified Fn key detection port"); 84MODULE_PARM_DESC(fn, "User specified Fn key detection port");
@@ -95,6 +96,7 @@ static long tosh_ioctl(struct file *, unsigned int,
95static const struct file_operations tosh_fops = { 96static const struct file_operations tosh_fops = {
96 .owner = THIS_MODULE, 97 .owner = THIS_MODULE,
97 .unlocked_ioctl = tosh_ioctl, 98 .unlocked_ioctl = tosh_ioctl,
99 .llseek = noop_llseek,
98}; 100};
99 101
100static struct miscdevice tosh_device = { 102static struct miscdevice tosh_device = {
@@ -274,16 +276,16 @@ static long tosh_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
274 return -EINVAL; 276 return -EINVAL;
275 277
276 /* do we need to emulate the fan ? */ 278 /* do we need to emulate the fan ? */
277 lock_kernel(); 279 mutex_lock(&tosh_mutex);
278 if (tosh_fan==1) { 280 if (tosh_fan==1) {
279 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { 281 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) {
280 err = tosh_emulate_fan(&regs); 282 err = tosh_emulate_fan(&regs);
281 unlock_kernel(); 283 mutex_unlock(&tosh_mutex);
282 break; 284 break;
283 } 285 }
284 } 286 }
285 err = tosh_smm(&regs); 287 err = tosh_smm(&regs);
286 unlock_kernel(); 288 mutex_unlock(&tosh_mutex);
287 break; 289 break;
288 default: 290 default:
289 return -EINVAL; 291 return -EINVAL;
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 05ad4a17a28f..7c4133582dba 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -47,6 +47,16 @@ enum tpm_duration {
47#define TPM_MAX_PROTECTED_ORDINAL 12 47#define TPM_MAX_PROTECTED_ORDINAL 12
48#define TPM_PROTECTED_ORDINAL_MASK 0xFF 48#define TPM_PROTECTED_ORDINAL_MASK 0xFF
49 49
50/*
51 * Bug workaround - some TPM's don't flush the most
52 * recently changed pcr on suspend, so force the flush
53 * with an extend to the selected _unused_ non-volatile pcr.
54 */
55static int tpm_suspend_pcr;
56module_param_named(suspend_pcr, tpm_suspend_pcr, uint, 0644);
57MODULE_PARM_DESC(suspend_pcr,
58 "PCR to use for dummy writes to faciltate flush on suspend.");
59
50static LIST_HEAD(tpm_chip_list); 60static LIST_HEAD(tpm_chip_list);
51static DEFINE_SPINLOCK(driver_lock); 61static DEFINE_SPINLOCK(driver_lock);
52static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES); 62static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
@@ -1077,18 +1087,6 @@ static struct tpm_input_header savestate_header = {
1077 .ordinal = TPM_ORD_SAVESTATE 1087 .ordinal = TPM_ORD_SAVESTATE
1078}; 1088};
1079 1089
1080/* Bug workaround - some TPM's don't flush the most
1081 * recently changed pcr on suspend, so force the flush
1082 * with an extend to the selected _unused_ non-volatile pcr.
1083 */
1084static int tpm_suspend_pcr;
1085static int __init tpm_suspend_setup(char *str)
1086{
1087 get_option(&str, &tpm_suspend_pcr);
1088 return 1;
1089}
1090__setup("tpm_suspend_pcr=", tpm_suspend_setup);
1091
1092/* 1090/*
1093 * We are about to suspend. Save the TPM state 1091 * We are about to suspend. Save the TPM state
1094 * so that it can be restored. 1092 * so that it can be restored.
diff --git a/drivers/char/uv_mmtimer.c b/drivers/char/uv_mmtimer.c
index c7072ba14f48..493b47a0d511 100644
--- a/drivers/char/uv_mmtimer.c
+++ b/drivers/char/uv_mmtimer.c
@@ -52,6 +52,7 @@ static const struct file_operations uv_mmtimer_fops = {
52 .owner = THIS_MODULE, 52 .owner = THIS_MODULE,
53 .mmap = uv_mmtimer_mmap, 53 .mmap = uv_mmtimer_mmap,
54 .unlocked_ioctl = uv_mmtimer_ioctl, 54 .unlocked_ioctl = uv_mmtimer_ioctl,
55 .llseek = noop_llseek,
55}; 56};
56 57
57/** 58/**
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 42f7fa442ff8..ad6e64a2912d 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -46,7 +46,7 @@
46#include <linux/completion.h> 46#include <linux/completion.h>
47#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
48#include <linux/seq_file.h> 48#include <linux/seq_file.h>
49#include <linux/smp_lock.h> 49#include <linux/mutex.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51 51
52#include <asm/uaccess.h> 52#include <asm/uaccess.h>
@@ -64,6 +64,7 @@
64#define VIOTAPE_KERN_WARN KERN_WARNING "viotape: " 64#define VIOTAPE_KERN_WARN KERN_WARNING "viotape: "
65#define VIOTAPE_KERN_INFO KERN_INFO "viotape: " 65#define VIOTAPE_KERN_INFO KERN_INFO "viotape: "
66 66
67static DEFINE_MUTEX(proc_viotape_mutex);
67static int viotape_numdev; 68static int viotape_numdev;
68 69
69/* 70/*
@@ -684,9 +685,9 @@ static long viotap_unlocked_ioctl(struct file *file,
684{ 685{
685 long rc; 686 long rc;
686 687
687 lock_kernel(); 688 mutex_lock(&proc_viotape_mutex);
688 rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 689 rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
689 unlock_kernel(); 690 mutex_unlock(&proc_viotape_mutex);
690 return rc; 691 return rc;
691} 692}
692 693
@@ -700,7 +701,7 @@ static int viotap_open(struct inode *inode, struct file *file)
700 if (op == NULL) 701 if (op == NULL)
701 return -ENOMEM; 702 return -ENOMEM;
702 703
703 lock_kernel(); 704 mutex_lock(&proc_viotape_mutex);
704 get_dev_info(file->f_path.dentry->d_inode, &devi); 705 get_dev_info(file->f_path.dentry->d_inode, &devi);
705 706
706 /* Note: We currently only support one mode! */ 707 /* Note: We currently only support one mode! */
@@ -731,7 +732,7 @@ static int viotap_open(struct inode *inode, struct file *file)
731 732
732free_op: 733free_op:
733 free_op_struct(op); 734 free_op_struct(op);
734 unlock_kernel(); 735 mutex_unlock(&proc_viotape_mutex);
735 return ret; 736 return ret;
736} 737}
737 738
@@ -804,6 +805,7 @@ const struct file_operations viotap_fops = {
804 .unlocked_ioctl = viotap_unlocked_ioctl, 805 .unlocked_ioctl = viotap_unlocked_ioctl,
805 .open = viotap_open, 806 .open = viotap_open,
806 .release = viotap_release, 807 .release = viotap_release,
808 .llseek = noop_llseek,
807}; 809};
808 810
809/* Handle interrupt events for tape */ 811/* Handle interrupt events for tape */
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 0f69c5ec0ecd..6c1b676643a9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -48,6 +48,9 @@ struct ports_driver_data {
48 /* Used for exporting per-port information to debugfs */ 48 /* Used for exporting per-port information to debugfs */
49 struct dentry *debugfs_dir; 49 struct dentry *debugfs_dir;
50 50
51 /* List of all the devices we're handling */
52 struct list_head portdevs;
53
51 /* Number of devices this driver is handling */ 54 /* Number of devices this driver is handling */
52 unsigned int index; 55 unsigned int index;
53 56
@@ -108,6 +111,9 @@ struct port_buffer {
108 * ports for that device (vdev->priv). 111 * ports for that device (vdev->priv).
109 */ 112 */
110struct ports_device { 113struct ports_device {
114 /* Next portdev in the list, head is in the pdrvdata struct */
115 struct list_head list;
116
111 /* 117 /*
112 * Workqueue handlers where we process deferred work after 118 * Workqueue handlers where we process deferred work after
113 * notification 119 * notification
@@ -178,15 +184,21 @@ struct port {
178 struct console cons; 184 struct console cons;
179 185
180 /* Each port associates with a separate char device */ 186 /* Each port associates with a separate char device */
181 struct cdev cdev; 187 struct cdev *cdev;
182 struct device *dev; 188 struct device *dev;
183 189
190 /* Reference-counting to handle port hot-unplugs and file operations */
191 struct kref kref;
192
184 /* A waitqueue for poll() or blocking read operations */ 193 /* A waitqueue for poll() or blocking read operations */
185 wait_queue_head_t waitqueue; 194 wait_queue_head_t waitqueue;
186 195
187 /* The 'name' of the port that we expose via sysfs properties */ 196 /* The 'name' of the port that we expose via sysfs properties */
188 char *name; 197 char *name;
189 198
199 /* We can notify apps of host connect / disconnect events via SIGIO */
200 struct fasync_struct *async_queue;
201
190 /* The 'id' to identify the port with the Host */ 202 /* The 'id' to identify the port with the Host */
191 u32 id; 203 u32 id;
192 204
@@ -221,6 +233,41 @@ out:
221 return port; 233 return port;
222} 234}
223 235
236static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev,
237 dev_t dev)
238{
239 struct port *port;
240 unsigned long flags;
241
242 spin_lock_irqsave(&portdev->ports_lock, flags);
243 list_for_each_entry(port, &portdev->ports, list)
244 if (port->cdev->dev == dev)
245 goto out;
246 port = NULL;
247out:
248 spin_unlock_irqrestore(&portdev->ports_lock, flags);
249
250 return port;
251}
252
253static struct port *find_port_by_devt(dev_t dev)
254{
255 struct ports_device *portdev;
256 struct port *port;
257 unsigned long flags;
258
259 spin_lock_irqsave(&pdrvdata_lock, flags);
260 list_for_each_entry(portdev, &pdrvdata.portdevs, list) {
261 port = find_port_by_devt_in_portdev(portdev, dev);
262 if (port)
263 goto out;
264 }
265 port = NULL;
266out:
267 spin_unlock_irqrestore(&pdrvdata_lock, flags);
268 return port;
269}
270
224static struct port *find_port_by_id(struct ports_device *portdev, u32 id) 271static struct port *find_port_by_id(struct ports_device *portdev, u32 id)
225{ 272{
226 struct port *port; 273 struct port *port;
@@ -410,7 +457,10 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id,
410static ssize_t send_control_msg(struct port *port, unsigned int event, 457static ssize_t send_control_msg(struct port *port, unsigned int event,
411 unsigned int value) 458 unsigned int value)
412{ 459{
413 return __send_control_msg(port->portdev, port->id, event, value); 460 /* Did the port get unplugged before userspace closed it? */
461 if (port->portdev)
462 return __send_control_msg(port->portdev, port->id, event, value);
463 return 0;
414} 464}
415 465
416/* Callers must take the port->outvq_lock */ 466/* Callers must take the port->outvq_lock */
@@ -525,6 +575,10 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
525/* The condition that must be true for polling to end */ 575/* The condition that must be true for polling to end */
526static bool will_read_block(struct port *port) 576static bool will_read_block(struct port *port)
527{ 577{
578 if (!port->guest_connected) {
579 /* Port got hot-unplugged. Let's exit. */
580 return false;
581 }
528 return !port_has_data(port) && port->host_connected; 582 return !port_has_data(port) && port->host_connected;
529} 583}
530 584
@@ -575,6 +629,9 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
575 if (ret < 0) 629 if (ret < 0)
576 return ret; 630 return ret;
577 } 631 }
632 /* Port got hot-unplugged. */
633 if (!port->guest_connected)
634 return -ENODEV;
578 /* 635 /*
579 * We could've received a disconnection message while we were 636 * We could've received a disconnection message while we were
580 * waiting for more data. 637 * waiting for more data.
@@ -616,6 +673,9 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
616 if (ret < 0) 673 if (ret < 0)
617 return ret; 674 return ret;
618 } 675 }
676 /* Port got hot-unplugged. */
677 if (!port->guest_connected)
678 return -ENODEV;
619 679
620 count = min((size_t)(32 * 1024), count); 680 count = min((size_t)(32 * 1024), count);
621 681
@@ -656,6 +716,10 @@ static unsigned int port_fops_poll(struct file *filp, poll_table *wait)
656 port = filp->private_data; 716 port = filp->private_data;
657 poll_wait(filp, &port->waitqueue, wait); 717 poll_wait(filp, &port->waitqueue, wait);
658 718
719 if (!port->guest_connected) {
720 /* Port got unplugged */
721 return POLLHUP;
722 }
659 ret = 0; 723 ret = 0;
660 if (!will_read_block(port)) 724 if (!will_read_block(port))
661 ret |= POLLIN | POLLRDNORM; 725 ret |= POLLIN | POLLRDNORM;
@@ -667,6 +731,8 @@ static unsigned int port_fops_poll(struct file *filp, poll_table *wait)
667 return ret; 731 return ret;
668} 732}
669 733
734static void remove_port(struct kref *kref);
735
670static int port_fops_release(struct inode *inode, struct file *filp) 736static int port_fops_release(struct inode *inode, struct file *filp)
671{ 737{
672 struct port *port; 738 struct port *port;
@@ -687,6 +753,16 @@ static int port_fops_release(struct inode *inode, struct file *filp)
687 reclaim_consumed_buffers(port); 753 reclaim_consumed_buffers(port);
688 spin_unlock_irq(&port->outvq_lock); 754 spin_unlock_irq(&port->outvq_lock);
689 755
756 /*
757 * Locks aren't necessary here as a port can't be opened after
758 * unplug, and if a port isn't unplugged, a kref would already
759 * exist for the port. Plus, taking ports_lock here would
760 * create a dependency on other locks taken by functions
761 * inside remove_port if we're the last holder of the port,
762 * creating many problems.
763 */
764 kref_put(&port->kref, remove_port);
765
690 return 0; 766 return 0;
691} 767}
692 768
@@ -694,22 +770,31 @@ static int port_fops_open(struct inode *inode, struct file *filp)
694{ 770{
695 struct cdev *cdev = inode->i_cdev; 771 struct cdev *cdev = inode->i_cdev;
696 struct port *port; 772 struct port *port;
773 int ret;
697 774
698 port = container_of(cdev, struct port, cdev); 775 port = find_port_by_devt(cdev->dev);
699 filp->private_data = port; 776 filp->private_data = port;
700 777
778 /* Prevent against a port getting hot-unplugged at the same time */
779 spin_lock_irq(&port->portdev->ports_lock);
780 kref_get(&port->kref);
781 spin_unlock_irq(&port->portdev->ports_lock);
782
701 /* 783 /*
702 * Don't allow opening of console port devices -- that's done 784 * Don't allow opening of console port devices -- that's done
703 * via /dev/hvc 785 * via /dev/hvc
704 */ 786 */
705 if (is_console_port(port)) 787 if (is_console_port(port)) {
706 return -ENXIO; 788 ret = -ENXIO;
789 goto out;
790 }
707 791
708 /* Allow only one process to open a particular port at a time */ 792 /* Allow only one process to open a particular port at a time */
709 spin_lock_irq(&port->inbuf_lock); 793 spin_lock_irq(&port->inbuf_lock);
710 if (port->guest_connected) { 794 if (port->guest_connected) {
711 spin_unlock_irq(&port->inbuf_lock); 795 spin_unlock_irq(&port->inbuf_lock);
712 return -EMFILE; 796 ret = -EMFILE;
797 goto out;
713 } 798 }
714 799
715 port->guest_connected = true; 800 port->guest_connected = true;
@@ -724,10 +809,23 @@ static int port_fops_open(struct inode *inode, struct file *filp)
724 reclaim_consumed_buffers(port); 809 reclaim_consumed_buffers(port);
725 spin_unlock_irq(&port->outvq_lock); 810 spin_unlock_irq(&port->outvq_lock);
726 811
812 nonseekable_open(inode, filp);
813
727 /* Notify host of port being opened */ 814 /* Notify host of port being opened */
728 send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1); 815 send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);
729 816
730 return 0; 817 return 0;
818out:
819 kref_put(&port->kref, remove_port);
820 return ret;
821}
822
823static int port_fops_fasync(int fd, struct file *filp, int mode)
824{
825 struct port *port;
826
827 port = filp->private_data;
828 return fasync_helper(fd, filp, mode, &port->async_queue);
731} 829}
732 830
733/* 831/*
@@ -743,6 +841,8 @@ static const struct file_operations port_fops = {
743 .write = port_fops_write, 841 .write = port_fops_write,
744 .poll = port_fops_poll, 842 .poll = port_fops_poll,
745 .release = port_fops_release, 843 .release = port_fops_release,
844 .fasync = port_fops_fasync,
845 .llseek = no_llseek,
746}; 846};
747 847
748/* 848/*
@@ -1001,6 +1101,12 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
1001 return nr_added_bufs; 1101 return nr_added_bufs;
1002} 1102}
1003 1103
1104static void send_sigio_to_port(struct port *port)
1105{
1106 if (port->async_queue && port->guest_connected)
1107 kill_fasync(&port->async_queue, SIGIO, POLL_OUT);
1108}
1109
1004static int add_port(struct ports_device *portdev, u32 id) 1110static int add_port(struct ports_device *portdev, u32 id)
1005{ 1111{
1006 char debugfs_name[16]; 1112 char debugfs_name[16];
@@ -1015,6 +1121,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1015 err = -ENOMEM; 1121 err = -ENOMEM;
1016 goto fail; 1122 goto fail;
1017 } 1123 }
1124 kref_init(&port->kref);
1018 1125
1019 port->portdev = portdev; 1126 port->portdev = portdev;
1020 port->id = id; 1127 port->id = id;
@@ -1022,6 +1129,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1022 port->name = NULL; 1129 port->name = NULL;
1023 port->inbuf = NULL; 1130 port->inbuf = NULL;
1024 port->cons.hvc = NULL; 1131 port->cons.hvc = NULL;
1132 port->async_queue = NULL;
1025 1133
1026 port->cons.ws.ws_row = port->cons.ws.ws_col = 0; 1134 port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
1027 1135
@@ -1032,14 +1140,20 @@ static int add_port(struct ports_device *portdev, u32 id)
1032 port->in_vq = portdev->in_vqs[port->id]; 1140 port->in_vq = portdev->in_vqs[port->id];
1033 port->out_vq = portdev->out_vqs[port->id]; 1141 port->out_vq = portdev->out_vqs[port->id];
1034 1142
1035 cdev_init(&port->cdev, &port_fops); 1143 port->cdev = cdev_alloc();
1144 if (!port->cdev) {
1145 dev_err(&port->portdev->vdev->dev, "Error allocating cdev\n");
1146 err = -ENOMEM;
1147 goto free_port;
1148 }
1149 port->cdev->ops = &port_fops;
1036 1150
1037 devt = MKDEV(portdev->chr_major, id); 1151 devt = MKDEV(portdev->chr_major, id);
1038 err = cdev_add(&port->cdev, devt, 1); 1152 err = cdev_add(port->cdev, devt, 1);
1039 if (err < 0) { 1153 if (err < 0) {
1040 dev_err(&port->portdev->vdev->dev, 1154 dev_err(&port->portdev->vdev->dev,
1041 "Error %d adding cdev for port %u\n", err, id); 1155 "Error %d adding cdev for port %u\n", err, id);
1042 goto free_port; 1156 goto free_cdev;
1043 } 1157 }
1044 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, 1158 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,
1045 devt, port, "vport%up%u", 1159 devt, port, "vport%up%u",
@@ -1104,7 +1218,7 @@ free_inbufs:
1104free_device: 1218free_device:
1105 device_destroy(pdrvdata.class, port->dev->devt); 1219 device_destroy(pdrvdata.class, port->dev->devt);
1106free_cdev: 1220free_cdev:
1107 cdev_del(&port->cdev); 1221 cdev_del(port->cdev);
1108free_port: 1222free_port:
1109 kfree(port); 1223 kfree(port);
1110fail: 1224fail:
@@ -1113,21 +1227,45 @@ fail:
1113 return err; 1227 return err;
1114} 1228}
1115 1229
1116/* Remove all port-specific data. */ 1230/* No users remain, remove all port-specific data. */
1117static int remove_port(struct port *port) 1231static void remove_port(struct kref *kref)
1232{
1233 struct port *port;
1234
1235 port = container_of(kref, struct port, kref);
1236
1237 sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
1238 device_destroy(pdrvdata.class, port->dev->devt);
1239 cdev_del(port->cdev);
1240
1241 kfree(port->name);
1242
1243 debugfs_remove(port->debugfs_file);
1244
1245 kfree(port);
1246}
1247
1248/*
1249 * Port got unplugged. Remove port from portdev's list and drop the
1250 * kref reference. If no userspace has this port opened, it will
1251 * result in immediate removal the port.
1252 */
1253static void unplug_port(struct port *port)
1118{ 1254{
1119 struct port_buffer *buf; 1255 struct port_buffer *buf;
1120 1256
1257 spin_lock_irq(&port->portdev->ports_lock);
1258 list_del(&port->list);
1259 spin_unlock_irq(&port->portdev->ports_lock);
1260
1121 if (port->guest_connected) { 1261 if (port->guest_connected) {
1122 port->guest_connected = false; 1262 port->guest_connected = false;
1123 port->host_connected = false; 1263 port->host_connected = false;
1124 wake_up_interruptible(&port->waitqueue); 1264 wake_up_interruptible(&port->waitqueue);
1125 send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
1126 }
1127 1265
1128 spin_lock_irq(&port->portdev->ports_lock); 1266 /* Let the app know the port is going down. */
1129 list_del(&port->list); 1267 send_sigio_to_port(port);
1130 spin_unlock_irq(&port->portdev->ports_lock); 1268 }
1131 1269
1132 if (is_console_port(port)) { 1270 if (is_console_port(port)) {
1133 spin_lock_irq(&pdrvdata_lock); 1271 spin_lock_irq(&pdrvdata_lock);
@@ -1146,9 +1284,6 @@ static int remove_port(struct port *port)
1146 hvc_remove(port->cons.hvc); 1284 hvc_remove(port->cons.hvc);
1147#endif 1285#endif
1148 } 1286 }
1149 sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
1150 device_destroy(pdrvdata.class, port->dev->devt);
1151 cdev_del(&port->cdev);
1152 1287
1153 /* Remove unused data this port might have received. */ 1288 /* Remove unused data this port might have received. */
1154 discard_port_data(port); 1289 discard_port_data(port);
@@ -1159,12 +1294,19 @@ static int remove_port(struct port *port)
1159 while ((buf = virtqueue_detach_unused_buf(port->in_vq))) 1294 while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
1160 free_buf(buf); 1295 free_buf(buf);
1161 1296
1162 kfree(port->name); 1297 /*
1163 1298 * We should just assume the device itself has gone off --
1164 debugfs_remove(port->debugfs_file); 1299 * else a close on an open port later will try to send out a
1300 * control message.
1301 */
1302 port->portdev = NULL;
1165 1303
1166 kfree(port); 1304 /*
1167 return 0; 1305 * Locks around here are not necessary - a port can't be
1306 * opened after we removed the port struct from ports_list
1307 * above.
1308 */
1309 kref_put(&port->kref, remove_port);
1168} 1310}
1169 1311
1170/* Any private messages that the Host and Guest want to share */ 1312/* Any private messages that the Host and Guest want to share */
@@ -1203,7 +1345,7 @@ static void handle_control_message(struct ports_device *portdev,
1203 add_port(portdev, cpkt->id); 1345 add_port(portdev, cpkt->id);
1204 break; 1346 break;
1205 case VIRTIO_CONSOLE_PORT_REMOVE: 1347 case VIRTIO_CONSOLE_PORT_REMOVE:
1206 remove_port(port); 1348 unplug_port(port);
1207 break; 1349 break;
1208 case VIRTIO_CONSOLE_CONSOLE_PORT: 1350 case VIRTIO_CONSOLE_CONSOLE_PORT:
1209 if (!cpkt->value) 1351 if (!cpkt->value)
@@ -1245,6 +1387,12 @@ static void handle_control_message(struct ports_device *portdev,
1245 spin_lock_irq(&port->outvq_lock); 1387 spin_lock_irq(&port->outvq_lock);
1246 reclaim_consumed_buffers(port); 1388 reclaim_consumed_buffers(port);
1247 spin_unlock_irq(&port->outvq_lock); 1389 spin_unlock_irq(&port->outvq_lock);
1390
1391 /*
1392 * If the guest is connected, it'll be interested in
1393 * knowing the host connection state changed.
1394 */
1395 send_sigio_to_port(port);
1248 break; 1396 break;
1249 case VIRTIO_CONSOLE_PORT_NAME: 1397 case VIRTIO_CONSOLE_PORT_NAME:
1250 /* 1398 /*
@@ -1341,6 +1489,9 @@ static void in_intr(struct virtqueue *vq)
1341 1489
1342 wake_up_interruptible(&port->waitqueue); 1490 wake_up_interruptible(&port->waitqueue);
1343 1491
1492 /* Send a SIGIO indicating new data in case the process asked for it */
1493 send_sigio_to_port(port);
1494
1344 if (is_console_port(port) && hvc_poll(port->cons.hvc)) 1495 if (is_console_port(port) && hvc_poll(port->cons.hvc))
1345 hvc_kick(); 1496 hvc_kick();
1346} 1497}
@@ -1577,6 +1728,10 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1577 add_port(portdev, 0); 1728 add_port(portdev, 0);
1578 } 1729 }
1579 1730
1731 spin_lock_irq(&pdrvdata_lock);
1732 list_add_tail(&portdev->list, &pdrvdata.portdevs);
1733 spin_unlock_irq(&pdrvdata_lock);
1734
1580 __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, 1735 __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID,
1581 VIRTIO_CONSOLE_DEVICE_READY, 1); 1736 VIRTIO_CONSOLE_DEVICE_READY, 1);
1582 return 0; 1737 return 0;
@@ -1600,23 +1755,41 @@ static void virtcons_remove(struct virtio_device *vdev)
1600{ 1755{
1601 struct ports_device *portdev; 1756 struct ports_device *portdev;
1602 struct port *port, *port2; 1757 struct port *port, *port2;
1603 struct port_buffer *buf;
1604 unsigned int len;
1605 1758
1606 portdev = vdev->priv; 1759 portdev = vdev->priv;
1607 1760
1761 spin_lock_irq(&pdrvdata_lock);
1762 list_del(&portdev->list);
1763 spin_unlock_irq(&pdrvdata_lock);
1764
1765 /* Disable interrupts for vqs */
1766 vdev->config->reset(vdev);
1767 /* Finish up work that's lined up */
1608 cancel_work_sync(&portdev->control_work); 1768 cancel_work_sync(&portdev->control_work);
1609 1769
1610 list_for_each_entry_safe(port, port2, &portdev->ports, list) 1770 list_for_each_entry_safe(port, port2, &portdev->ports, list)
1611 remove_port(port); 1771 unplug_port(port);
1612 1772
1613 unregister_chrdev(portdev->chr_major, "virtio-portsdev"); 1773 unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1614 1774
1615 while ((buf = virtqueue_get_buf(portdev->c_ivq, &len))) 1775 /*
1616 free_buf(buf); 1776 * When yanking out a device, we immediately lose the
1777 * (device-side) queues. So there's no point in keeping the
1778 * guest side around till we drop our final reference. This
1779 * also means that any ports which are in an open state will
1780 * have to just stop using the port, as the vqs are going
1781 * away.
1782 */
1783 if (use_multiport(portdev)) {
1784 struct port_buffer *buf;
1785 unsigned int len;
1617 1786
1618 while ((buf = virtqueue_detach_unused_buf(portdev->c_ivq))) 1787 while ((buf = virtqueue_get_buf(portdev->c_ivq, &len)))
1619 free_buf(buf); 1788 free_buf(buf);
1789
1790 while ((buf = virtqueue_detach_unused_buf(portdev->c_ivq)))
1791 free_buf(buf);
1792 }
1620 1793
1621 vdev->config->del_vqs(vdev); 1794 vdev->config->del_vqs(vdev);
1622 kfree(portdev->in_vqs); 1795 kfree(portdev->in_vqs);
@@ -1663,6 +1836,7 @@ static int __init init(void)
1663 PTR_ERR(pdrvdata.debugfs_dir)); 1836 PTR_ERR(pdrvdata.debugfs_dir));
1664 } 1837 }
1665 INIT_LIST_HEAD(&pdrvdata.consoles); 1838 INIT_LIST_HEAD(&pdrvdata.consoles);
1839 INIT_LIST_HEAD(&pdrvdata.portdevs);
1666 1840
1667 return register_virtio_driver(&virtio_console); 1841 return register_virtio_driver(&virtio_console);
1668} 1842}
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index b663d573aad9..9f2272e6de1c 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -81,7 +81,6 @@
81#include <linux/poll.h> 81#include <linux/poll.h>
82#include <linux/proc_fs.h> 82#include <linux/proc_fs.h>
83#include <linux/mutex.h> 83#include <linux/mutex.h>
84#include <linux/smp_lock.h>
85#include <linux/sysctl.h> 84#include <linux/sysctl.h>
86#include <linux/fs.h> 85#include <linux/fs.h>
87#include <linux/cdev.h> 86#include <linux/cdev.h>
@@ -112,6 +111,7 @@
112#define HWICAP_DEVICES 1 111#define HWICAP_DEVICES 1
113 112
114/* An array, which is set to true when the device is registered. */ 113/* An array, which is set to true when the device is registered. */
114static DEFINE_MUTEX(hwicap_mutex);
115static bool probed_devices[HWICAP_DEVICES]; 115static bool probed_devices[HWICAP_DEVICES];
116static struct mutex icap_sem; 116static struct mutex icap_sem;
117 117
@@ -502,7 +502,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
502 struct hwicap_drvdata *drvdata; 502 struct hwicap_drvdata *drvdata;
503 int status; 503 int status;
504 504
505 lock_kernel(); 505 mutex_lock(&hwicap_mutex);
506 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 506 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
507 507
508 status = mutex_lock_interruptible(&drvdata->sem); 508 status = mutex_lock_interruptible(&drvdata->sem);
@@ -528,7 +528,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
528 error: 528 error:
529 mutex_unlock(&drvdata->sem); 529 mutex_unlock(&drvdata->sem);
530 out: 530 out:
531 unlock_kernel(); 531 mutex_unlock(&hwicap_mutex);
532 return status; 532 return status;
533} 533}
534 534
@@ -567,6 +567,7 @@ static const struct file_operations hwicap_fops = {
567 .read = hwicap_read, 567 .read = hwicap_read,
568 .open = hwicap_open, 568 .open = hwicap_open,
569 .release = hwicap_release, 569 .release = hwicap_release,
570 .llseek = noop_llseek,
570}; 571};
571 572
572static int __devinit hwicap_setup(struct device *dev, int id, 573static int __devinit hwicap_setup(struct device *dev, int id,