revalidate: no (see below)
Additionally, ->rmdir() has i_zombie on victim and so does ->rename()
in case when target exists and is a directory.
+ ->rename() on directories has (per-superblock) ->s_vfs_rename_sem.
->revalidate(), it may be called both with and without the i_sem
on dentry->d_inode. VFS never calls it with i_zombie on dentry->d_inode,
but watch for other methods directly calling this one...
mmap: no
open: maybe (see below)
flush: yes
-release: yes
+release: no
fsync: yes (see below)
fasync: yes (see below)
lock: yes
end up in ->i_fop/->proc_fops, i.e. ones that belong to character devices
(chrdev_open() takes lock before replacing ->f_op and calling the secondary
method. As soon as we fix the handling of module reference counters all
-instances of ->open() will be called without the BKL. At the same point
-->release() will lose BKL. Currently ext2_release() is *the* source of
-contention on fs-intensive loads and dropping BKL on ->release() will get
-rid of that (we will still need some locking for cases when we close a file
-that had been opened r/w, but that can be done using the internal locking with
-smaller critical areas). sock_close() is also going to win from that change.
+instances of ->open() will be called without the BKL.
+
+Note: ext2_release() was *the* source of contention on fs-intensive
+loads and dropping BKL on ->release() helps to get rid of that (we still
+grab BKL for cases when we close a file that had been opened r/w, but that
+can and should be done using the internal locking with smaller critical areas).
+Current worst offender is ext2_get_block()...
->fasync() is a mess. This area needs a big cleanup and that will probably
affect locking.
usb-help.txt
-2000-March-24
+2000-July-12
For USB help other than the readme files that are located in
linux/Documentation/usb/*, see the following:
Linux-USB project: http://www.linux-usb.org
mirrors at http://www.suse.cz/development/linux-usb/
and http://usb.in.tum.de/linux-usb/
-Linux USB Guide: http://linuxusbguide.sourceforge.net
+Linux USB Guide: http://linux-usb.sourceforge.net
Linux-USB device overview (working devices and drivers):
http://www.qbik.ch/usb/devices/
-The Linux-USB mailing list is linux-usb@suse.com .
+The Linux-USB mailing lists are:
+ linux-usb-users@lists.sourceforge.net for general user help
+ linux-usb-devel@lists.sourceforge.net for developer discussions
###
USB ACM DRIVER
P: Vojtech Pavlik
M: vojtech@suse.cz
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Supported
USB BLUETOOTH DRIVER
P: Greg Kroah-Hartman
M: greg@kroah.com
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Maintained
W: http://www.kroah.com/linux-usb/
USB HID/HIDBP/INPUT DRIVERS
P: Vojtech Pavlik
M: vojtech@suse.cz
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
W: http://www.suse.cz/development/input/
S: Supported
USB HUB
P: Johannes Erdfelt
M: jerdfelt@sventech.com
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Maintained
USB OHCI DRIVER
P: Roman Weissgaerber
M: weissg@vienna.at
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Maintained
USB OV511 DRIVER
P: Mark McClelland
M: mmcclelland@delphi.com
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
W: http://alpha.dyndns.org/ov511/
S: Maintained
USB PEGASUS DRIVER
P: Petko Manolov
M: petkan@spct.net
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Maintained
USB PRINTER DRIVER
P: Vojtech Pavlik
M: vojtech@suse.cz
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Supported
USB SERIAL DIGI ACCELEPORT DRIVER
P: Peter Berger and Al Borchers
M: pberger@brimson.com
M: alborchers@steinerpoint.com
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Supported
USB SERIAL DRIVER
P: Greg Kroah-Hartman
M: greg@kroah.com
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Maintained
W: http://www.kroah.com/linux-usb/
USB MASS STORAGE DRIVER
P: Matthew Dharm
M: mdharm-usb@one-eyed-alien.net
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
S: Maintained
W: http://www.one-eyed-alien.net/~mdharm/linux-usb/
USB UHCI DRIVER
P: Georg Acher
M: usb@in.tum.de
-L: linux-usb@suse.com
+L: linux-usb-users@lists.sourceforge.net
+L: linux-usb-devel@lists.sourceforge.net
W: http://usb.in.tum.de
S: Maintained
#include <linux/sched.h>
#include <linux/pm.h>
#include <linux/kernel.h>
+#include <linux/smp_lock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
if (check_apm_user(as, "release"))
return 0;
filp->private_data = NULL;
+ lock_kernel();
if (as->standbys_pending > 0) {
standbys_pending -= as->standbys_pending;
if (standbys_pending <= 0)
else
as1->next = as->next;
}
+ unlock_kernel();
kfree_s(as, sizeof(*as));
return 0;
}
static int microcode_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
clear_bit(MICROCODE_IS_OPEN, µcode_status);
+ unlock_kernel();
return 0;
}
#include <asm/mtrr.h>
#include <linux/init.h>
#include <linux/smp.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
unsigned int *fcount = file->private_data;
if (fcount == NULL) return 0;
+ lock_kernel();
max = get_num_var_ranges ();
for (i = 0; i < max; ++i)
{
--fcount[i];
}
}
+ unlock_kernel();
kfree (fcount);
file->private_data = NULL;
return 0;
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#include <asm/atarikb.h>
#include <asm/atari_joystick.h>
{
int minor = DEVICE_NR(inode->i_rdev);
+ lock_kernel();
joystick[minor].active = 0;
joystick[minor].ready = 0;
if ((joystick[0].active == 0) && (joystick[1].active == 0))
ikbd_joystick_disable();
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
+#include <linux/smp_lock.h>
#include <asm/bvme6000hw.h>
#include <asm/io.h>
static int rtc_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
rtc_status = 0;
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
+#include <linux/smp_lock.h>
#include <asm/mvme16xhw.h>
#include <asm/io.h>
static int rtc_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
rtc_status = 0;
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
+#include <linux/smp_lock.h>
#include <asm/m48t35.h>
#include <asm/ioc3.h>
* in use, and clear the data.
*/
+ lock_kernel();
rtc_status &= ~RTC_IS_OPEN;
+ unlock_kernel();
return 0;
}
#include <linux/malloc.h>
#include <linux/in.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/termios.h>
struct T_primsg *it;
/* XXX: check this */
+ lock_kernel();
sock = (struct sol_socket_struct *)filp->private_data;
SOLDD(("sock release %016lx(%016lx)\n", sock, filp));
it = sock->pfirst;
filp->private_data = NULL;
SOLDD(("socksys_release %016lx\n", sock));
mykfree((char*)sock);
+ unlock_kernel();
return 0;
}
#include <linux/mm.h>
#include <linux/malloc.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#include <asm/pgtable.h>
#include <asm/system.h>
device = MINOR(inode->i_rdev);
sip = &slm_info[device];
+ lock_kernel();
if (file->f_mode & 2)
sip->wbusy = 0;
if (file->f_mode & 1)
sip->rbusy = 0;
+ unlock_kernel();
return( 0 );
}
static inline void __make_request(request_queue_t * q, int rw,
struct buffer_head * bh)
{
- int major = MAJOR(bh->b_rdev);
unsigned int sector, count;
int max_segments = MAX_SEGMENTS;
struct request * req = NULL;
count = bh->b_size >> 9;
sector = bh->b_rsector;
- if (blk_size[major]) {
- unsigned long maxsector = (blk_size[major][MINOR(bh->b_rdev)] << 1) + 1;
-
- if (maxsector < count || maxsector - count < sector) {
- bh->b_state &= (1 << BH_Lock) | (1 << BH_Mapped);
- if (!blk_size[major][MINOR(bh->b_rdev)])
- goto end_io;
- /* This may well happen - the kernel calls bread()
- without checking the size of the device, e.g.,
- when mounting a device. */
- printk(KERN_INFO
- "attempt to access beyond end of device\n");
- printk(KERN_INFO "%s: rw=%d, want=%d, limit=%d\n",
- kdevname(bh->b_rdev), rw,
- (sector + count)>>1,
- blk_size[major][MINOR(bh->b_rdev)]);
- goto end_io;
- }
- }
-
rw_ahead = 0; /* normal case; gets changed below for READA */
switch (rw) {
case READA:
bh->b_end_io(bh, test_bit(BH_Uptodate, &bh->b_state));
}
-int generic_make_request (request_queue_t *q, int rw, struct buffer_head * bh)
+void generic_make_request (request_queue_t *q, int rw, struct buffer_head * bh)
{
- int ret;
+ int major = MAJOR(bh->b_rdev);
+
+ if (blk_size[major]) {
+ unsigned long maxsector = (blk_size[major][MINOR(bh->b_rdev)] << 1) + 1;
+ unsigned int sector, count;
+
+ count = bh->b_size >> 9;
+ sector = bh->b_rsector;
+
+ if (maxsector < count || maxsector - count < sector) {
+ bh->b_state &= (1 << BH_Lock) | (1 << BH_Mapped);
+ if (blk_size[major][MINOR(bh->b_rdev)]) {
+
+ /* This may well happen - the kernel calls bread()
+ without checking the size of the device, e.g.,
+ when mounting a device. */
+ printk(KERN_INFO
+ "attempt to access beyond end of device\n");
+ printk(KERN_INFO "%s: rw=%d, want=%d, limit=%d\n",
+ kdevname(bh->b_rdev), rw,
+ (sector + count)>>1,
+ blk_size[major][MINOR(bh->b_rdev)]);
+ }
+ bh->b_end_io(bh, 0);
+ return;
+ }
+ }
/*
* Resolve the mapping until finished. (drivers are
* by explicitly returning 0)
*/
while (q->make_request_fn) {
- ret = q->make_request_fn(q, rw, bh);
- if (ret > 0) {
- q = blk_get_queue(bh->b_rdev);
- continue;
- }
- return ret;
+ if (q->make_request_fn(q, rw, bh) == 0)
+ return;
+ q = blk_get_queue(bh->b_rdev);
}
/*
* Does the block device want us to queue
if (q && !q->plugged)
(q->request_fn)(q);
spin_unlock_irq(&io_request_lock);
-
- return 0;
}
/* This function can be used to request a number of buffers from a block
static struct file_operations lvm_chr_fops =
{
+ owner: THIS_MODULE,
open: lvm_chr_open,
release: lvm_chr_close,
ioctl: lvm_chr_ioctl,
/* Group special file open */
if (VG_CHR(minor) > MAX_VG) return -ENXIO;
- MOD_INC_USE_COUNT;
-
lvm_chr_open_count++;
return 0;
} /* lvm_chr_open() */
"%s -- lvm_chr_close VG#: %d\n", lvm_name, VG_CHR(minor));
#endif
+ lock_kernel();
#ifdef LVM_TOTAL_RESET
if (lvm_reset_spindown > 0) {
lvm_reset_spindown = 0;
lock = 0; /* release lock */
wake_up_interruptible(&lvm_wait);
}
-
-#ifdef MODULE
- if (GET_USE_COUNT(&__this_module) > 0) MOD_DEC_USE_COUNT;
-#endif
+ unlock_kernel();
return 0;
} /* lvm_chr_close() */
#include <linux/mtio.h>
#include <linux/pg.h>
#include <linux/wait.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
if ((unit >= PG_UNITS) || (PG.access <= 0))
return -EINVAL;
+ lock_kernel();
PG.access--;
kfree(PG.bufptr);
PG.bufptr = NULL;
+ unlock_kernel();
return 0;
#include <linux/malloc.h>
#include <linux/mtio.h>
#include <linux/wait.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
if ((unit >= PT_UNITS) || (PT.access <= 0))
return -EINVAL;
+ lock_kernel();
if (PT.flags & PT_WRITING) pt_write_fm(unit);
if (PT.flags & PT_REWIND) pt_rewind(unit);
kfree(PT.bufptr);
PT.bufptr = NULL;
+ unlock_kernel();
return 0;
#include <linux/module.h>
#include <linux/init.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
{
extern void free_initrd_mem(unsigned long, unsigned long);
- if (--initrd_users) return 0;
- blkdev_put(inode->i_bdev, BDEV_FILE);
- iput(inode);
- free_initrd_mem(initrd_start, initrd_end);
- initrd_start = 0;
+ lock_kernel();
+ if (!--initrd_users) {
+ blkdev_put(inode->i_bdev, BDEV_FILE);
+ iput(inode);
+ free_initrd_mem(initrd_start, initrd_end);
+ initrd_start = 0;
+ }
+ unlock_kernel();
return 0;
}
#include <linux/reboot.h>
#include <linux/init.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
static int acq_is_open=0;
static spinlock_t acq_lock;
static int acq_close(struct inode *inode, struct file *file)
{
+ lock_kernel();
if(MINOR(inode->i_rdev)==WATCHDOG_MINOR)
{
spin_lock(&acq_lock);
acq_is_open=0;
spin_unlock(&acq_lock);
}
+ unlock_kernel();
return 0;
}
#include <linux/miscdevice.h>
#include <linux/agp_backend.h>
#include <linux/agpgart.h>
+#include <linux/smp_lock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/io.h>
agp_file_private *priv = (agp_file_private *) file->private_data;
agp_kern_info kerninfo;
+ lock_kernel();
AGP_LOCK();
if (agp_fe.backend_acquired != TRUE) {
AGP_UNLOCK();
+ unlock_kernel();
return -EPERM;
}
if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags))) {
AGP_UNLOCK();
+ unlock_kernel();
return -EPERM;
}
agp_copy_info(&kerninfo);
if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) {
if ((size + offset) > current_size) {
AGP_UNLOCK();
+ unlock_kernel();
return -EINVAL;
}
client = agp_find_client_by_pid(current->pid);
if (client == NULL) {
AGP_UNLOCK();
+ unlock_kernel();
return -EPERM;
}
if (!agp_find_seg_in_client(client, offset,
size, vma->vm_page_prot)) {
AGP_UNLOCK();
+ unlock_kernel();
return -EINVAL;
}
if (remap_page_range(vma->vm_start,
(kerninfo.aper_base + offset),
size, vma->vm_page_prot)) {
AGP_UNLOCK();
+ unlock_kernel();
return -EAGAIN;
}
AGP_UNLOCK();
+ unlock_kernel();
return 0;
}
if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
if (size != current_size) {
AGP_UNLOCK();
+ unlock_kernel();
return -EINVAL;
}
if (remap_page_range(vma->vm_start, kerninfo.aper_base,
size, vma->vm_page_prot)) {
AGP_UNLOCK();
+ unlock_kernel();
return -EAGAIN;
}
AGP_UNLOCK();
+ unlock_kernel();
return 0;
}
AGP_UNLOCK();
+ unlock_kernel();
return -EPERM;
}
{
agp_file_private *priv = (agp_file_private *) file->private_data;
+ lock_kernel();
AGP_LOCK();
if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
agp_remove_file_private(priv);
kfree(priv);
AGP_UNLOCK();
+ unlock_kernel();
return 0;
}
static unsigned int DeviceErrorCount; /* number of device error */
static loff_t ac_llseek(struct file *, loff_t, int);
-static int ac_open(struct inode *, struct file *);
static ssize_t ac_read (struct file *, char *, size_t, loff_t *);
static ssize_t ac_write (struct file *, const char *, size_t, loff_t *);
static int ac_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
-static int ac_release(struct inode *, struct file *);
static void ac_interrupt(int, void *, struct pt_regs *);
struct file_operations ac_fops = {
+ owner:THIS_MODULE,
llseek:ac_llseek,
read:ac_read,
write:ac_write,
ioctl:ac_ioctl,
- open:ac_open,
- release:ac_release,
};
struct miscdevice ac_miscdev = {
&ac_fops
};
+static int dummy; /* dev_id for request_irq() */
+
int ac_register_board(unsigned long physloc, unsigned long loc,
unsigned char boardno)
{
iounmap((void *) apbs[i].RamIO);
if (apbs[i].irq)
- free_irq(apbs[i].irq, &ac_open);
+ free_irq(apbs[i].irq, &dummy);
}
}
continue;
}
- if (request_irq(dev->irq, &ac_interrupt, SA_SHIRQ, "Applicom PCI", &ac_open)) {
+ if (request_irq(dev->irq, &ac_interrupt, SA_SHIRQ, "Applicom PCI", &dummy)) {
printk(KERN_INFO "Could not allocate IRQ %d for PCI Applicom device.\n", dev->irq);
iounmap(RamIO);
apbs[boardno - 1].RamIO = 0;
printk(KERN_NOTICE "Applicom ISA card found at mem 0x%lx, irq %d\n", mem + (LEN_RAM_IO*i), irq);
if (!numisa) {
- if (request_irq(irq, &ac_interrupt, SA_SHIRQ, "Applicom ISA", &ac_open)) {
+ if (request_irq(irq, &ac_interrupt, SA_SHIRQ, "Applicom ISA", &dummy)) {
printk(KERN_WARNING "Could not allocate IRQ %d for ISA Applicom device.\n", irq);
iounmap((void *) RamIO);
apbs[boardno - 1].RamIO = 0;
return -ESPIPE;
}
-static int ac_open(struct inode *inode, struct file *filp)
-{
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static int ac_release(struct inode *inode, struct file *file)
-{
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-
static ssize_t ac_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
{
unsigned int NumCard; /* Board number 1 -> 8 */
#include <linux/miscdevice.h>
#include <linux/random.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/system.h>
struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
int ret = 0;
+ lock_kernel();
busmouse_fasync(-1, file, 0);
if (--mse->active == 0) {
}
mse->ready = 0;
}
+ unlock_kernel();
return ret;
}
#include "drmP.h"
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <asm/oplib.h>
#include <asm/upa.h>
extern int ffb_context_switch(drm_device_t *, int, int);
static struct file_operations ffb_fops = {
+ owner: THIS_MODULE,
open: ffb_open,
flush: drm_flush,
release: ffb_release,
DRM_DEBUG("open_count = %d\n", dev->open_count);
ret = drm_open_helper(inode, filp, dev);
if (!ret) {
- MOD_INC_USE_COUNT;
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
static int ffb_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int ret = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (dev->lock.hw_lock != NULL
&& _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
ret = drm_release(inode, filp);
if (!ret) {
- MOD_DEC_USE_COUNT;
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
- return ffb_takedown(dev);
+ ret = ffb_takedown(dev);
+ unlock_kernel();
+ return ret;
}
spin_unlock(&dev->count_lock);
}
+ unlock_kernel();
return ret;
}
DRM_DEBUG("start = 0x%lx, end = 0x%lx, offset = 0x%lx\n",
vma->vm_start, vma->vm_end, VM_OFFSET(vma));
+ lock_kernel();
minor = MINOR(filp->f_dentry->d_inode->i_rdev);
ffb_priv = NULL;
for (i = 0; i < ffb_dev_table_size; i++) {
if (ffb_priv->miscdev.minor == minor)
break;
}
- if (i >= ffb_dev_table_size)
+ if (i >= ffb_dev_table_size) {
+ unlock_kernel();
return -EINVAL;
-
+ }
/* We don't support/need dma mappings, so... */
- if (!VM_OFFSET(vma))
+ if (!VM_OFFSET(vma)) {
+ unlock_kernel();
return -EINVAL;
-
+ }
for (i = 0; i < dev->map_count; i++) {
unsigned long off;
break;
}
- if (i >= dev->map_count)
+ if (i >= dev->map_count) {
+ unlock_kernel();
return -EINVAL;
-
+ }
if (!map ||
- ((map->flags & _DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN)))
+ ((map->flags & _DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN))) {
+ unlock_kernel();
return -EPERM;
-
- if (map->size != (vma->vm_end - vma->vm_start))
+ }
+ if (map->size != (vma->vm_end - vma->vm_start)) {
+ unlock_kernel();
return -EINVAL;
-
+ }
/* Set read-only attribute before mappings are created
* so it works for fb/reg maps too.
*/
if (io_remap_page_range(vma->vm_start,
ffb_priv->card_phys_base + VM_OFFSET(vma),
vma->vm_end - vma->vm_start,
- vma->vm_page_prot, 0))
+ vma->vm_page_prot, 0)) {
+ unlock_kernel();
return -EAGAIN;
-
+ }
vma->vm_ops = &drm_vm_ops;
break;
case _DRM_SHM:
vma->vm_flags |= VM_LOCKED;
break;
default:
+ unlock_kernel();
return -EINVAL; /* This should never happen. */
};
+ unlock_kernel();
vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */
*/
#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include "drmP.h"
#include "gamma_drv.h"
EXPORT_SYMBOL(gamma_init);
static drm_device_t gamma_device;
static struct file_operations gamma_fops = {
- open: gamma_open,
- flush: drm_flush,
- release: gamma_release,
- ioctl: gamma_ioctl,
- mmap: drm_mmap,
- read: drm_read,
- fasync: drm_fasync,
- poll: drm_poll,
+ owner: THIS_MODULE,
+ open: gamma_open,
+ flush: drm_flush,
+ release: gamma_release,
+ ioctl: gamma_ioctl,
+ mmap: drm_mmap,
+ read: drm_read,
+ fasync: drm_fasync,
+ poll: drm_poll,
};
static struct miscdevice gamma_misc = {
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int gamma_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
- return gamma_takedown(dev);
+ retcode = gamma_takedown(dev);
+ unlock_kernel();
+ return retcode;
}
spin_unlock(&dev->count_lock);
}
+ unlock_kernel();
return retcode;
}
*/
#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include "drmP.h"
#include "tdfx_drv.h"
drm_ctx_t tdfx_res_ctx;
static struct file_operations tdfx_fops = {
+ owner: THIS_MODULE,
open: tdfx_open,
flush: drm_flush,
release: tdfx_release,
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int tdfx_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
- return tdfx_takedown(dev);
+ retcode = tdfx_takedown(dev);
+ unlock_kernel();
+ return retcode;
}
spin_unlock(&dev->count_lock);
}
+ unlock_kernel();
return retcode;
}
DRM_DEBUG("0x%08lx,0x%08lx\n",
vma->vm_start, vma->vm_end - vma->vm_start);
atomic_inc(&dev->vma_count);
- MOD_INC_USE_COUNT;
#if DRM_DEBUG_CODE
vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
DRM_DEBUG("0x%08lx,0x%08lx\n",
vma->vm_start, vma->vm_end - vma->vm_start);
- MOD_DEC_USE_COUNT;
atomic_dec(&dev->vma_count);
#if DRM_DEBUG_CODE
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#include <asm/segment.h>
#include <asm/atarihw.h>
{
case DSP56K_DEV_56001:
+ lock_kernel();
dsp56k.in_use = 0;
+ unlock_kernel();
break;
default:
#include <linux/poll.h> /* for POLLIN, etc. */
#include <linux/dtlk.h> /* local header file for DoubleTalk values */
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#ifdef TRACING
#define TRACE_TEXT(str) printk(str);
}
TRACE_RET;
+ lock_kernel();
del_timer(&dtlk_timer);
+ unlock_kernel();
return 0;
}
#endif
#include <linux/fcntl.h>
#include <linux/wrapper.h>
+#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/zftape.h>
-#if LINUX_VERSION_CODE >=KERNEL_VER(2,1,16)
#include <linux/init.h>
-#else
-#define __initdata
-#define __initfunc(__arg) __arg
-#endif
#include "../zftape/zftape-init.h"
#include "../zftape/zftape-read.h"
char zft_rev[] __initdata = "$Revision: 1.8 $";
char zft_dat[] __initdata = "$Date: 1997/11/06 00:48:56 $";
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18)
MODULE_AUTHOR("(c) 1996, 1997 Claus-Justus Heine "
"(claus@momo.math.rwth-aachen.de)");
MODULE_DESCRIPTION(ZFTAPE_VERSION " - "
"Support for QIC-113 compatible volume table "
"and builtin compression (lzrw3 algorithm)");
MODULE_SUPPORTED_DEVICE("char-major-27");
-#endif
/* Global vars.
*/
*/
static int zft_open (struct inode *ino, struct file *filep);
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,31)
static int zft_close(struct inode *ino, struct file *filep);
-#else
-static void zft_close(struct inode *ino, struct file *filep);
-#endif
static int zft_ioctl(struct inode *ino, struct file *filep,
unsigned int command, unsigned long arg);
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,56)
static int zft_mmap(struct file *filep, struct vm_area_struct *vma);
-#else
-static int zft_mmap(struct inode *ino, struct file *filep,
- struct vm_area_struct *vma);
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60)
static ssize_t zft_read (struct file *fp, char *buff,
size_t req_len, loff_t *ppos);
static ssize_t zft_write(struct file *fp, const char *buff,
size_t req_len, loff_t *ppos);
-#elif LINUX_VERSION_CODE >= KERNEL_VER(2,1,0)
-static long zft_read (struct inode *ino, struct file *fp, char *buff,
- unsigned long req_len);
-static long zft_write(struct inode *ino, struct file *fp, const char *buff,
- unsigned long req_len);
-#else
-static int zft_read (struct inode *ino, struct file *fp, char *buff,
- int req_len);
-static int zft_write(struct inode *ino, struct file *fp, const char *buff,
- int req_len);
-#endif
static struct file_operations zft_cdev =
{
+ owner: THIS_MODULE,
read: zft_read,
write: zft_write,
ioctl: zft_ioctl,
int result;
TRACE_FUN(ft_t_flow);
-#if LINUX_VERSION_CODE < KERNEL_VER(2,1,18)
- if (!MOD_IN_USE) {
- MOD_INC_USE_COUNT; /* lock module in memory */
- }
-#else
- MOD_INC_USE_COUNT; /* sets MOD_VISITED and MOD_USED_ONCE,
- * locking is done with can_unload()
- */
-#endif
TRACE(ft_t_flow, "called for minor %d", MINOR(ino->i_rdev));
if (busy_flag) {
TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
>
FTAPE_SEL_D) {
busy_flag = 0;
-#if defined(MODULE) && LINUX_VERSION_CODE < KERNEL_VER(2,1,18)
- if (!zft_dirty()) {
- MOD_DEC_USE_COUNT; /* unlock module in memory */
- }
-#endif
TRACE_ABORT(-ENXIO, ft_t_err, "failed: illegal unit nr");
}
orig_sigmask = current->blocked;
if (result < 0) {
current->blocked = orig_sigmask; /* restore mask */
busy_flag = 0;
-#if defined(MODULE) && LINUX_VERSION_CODE < KERNEL_VER(2,1,18)
- if (!zft_dirty()) {
- MOD_DEC_USE_COUNT; /* unlock module in memory */
- }
-#endif
TRACE_ABORT(result, ft_t_err, "_ftape_open failed");
} else {
/* Mask signals that will disturb proper operation of the
int result;
TRACE_FUN(ft_t_flow);
+ lock_kernel();
if (!busy_flag || MINOR(ino->i_rdev) != zft_unit) {
TRACE(ft_t_err, "failed: not busy or wrong unit");
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,31)
+ unlock_kernel();
TRACE_EXIT 0;
-#else
- TRACE_EXIT; /* keep busy_flag !(?) */
-#endif
}
sigfillset(¤t->blocked);
result = _zft_close();
}
current->blocked = orig_sigmask; /* restore before open state */
busy_flag = 0;
-#if defined(MODULE) && LINUX_VERSION_CODE < KERNEL_VER(2,1,18)
- if (!zft_dirty()) {
- MOD_DEC_USE_COUNT; /* unlock module in memory */
- }
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,31)
+ unlock_kernel();
TRACE_EXIT 0;
-#else
- TRACE_EXIT;
-#endif
}
/* Ioctl for floppy tape device
/* Ioctl for floppy tape device
*/
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,56)
static int zft_mmap(struct file *filep, struct vm_area_struct *vma)
-#else
-static int zft_mmap(struct inode *ino,
- struct file *filep,
- struct vm_area_struct *vma)
-#endif
{
int result = -EIO;
sigset_t old_sigmask;
TRACE_FUN(ft_t_flow);
if (!busy_flag ||
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,56)
MINOR(filep->f_dentry->d_inode->i_rdev) != zft_unit ||
-#else
- MINOR(ino->i_rdev) != zft_unit ||
-#endif
ft_failure)
{
TRACE_ABORT(-EIO, ft_t_err,
}
old_sigmask = current->blocked; /* save mask */
sigfillset(¤t->blocked);
+ lock_kernel();
if ((result = ftape_mmap(vma)) >= 0) {
#ifndef MSYNC_BUG_WAS_FIXED
static struct vm_operations_struct dummy = { NULL, };
vma->vm_ops = &dummy;
#endif
}
+ unlock_kernel();
current->blocked = old_sigmask; /* restore mask */
TRACE_EXIT result;
}
/* Read from floppy tape device
*/
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60)
static ssize_t zft_read(struct file *fp, char *buff,
size_t req_len, loff_t *ppos)
-#elif LINUX_VERSION_CODE >= KERNEL_VER(2,1,0)
-static long zft_read(struct inode *ino, struct file *fp, char *buff,
- unsigned long req_len)
-#else
-static int zft_read(struct inode *ino, struct file *fp, char *buff,
- int req_len)
-#endif
{
int result = -EIO;
sigset_t old_sigmask;
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60)
struct inode *ino = fp->f_dentry->d_inode;
-#endif
TRACE_FUN(ft_t_flow);
TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len);
/* Write to tape device
*/
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60)
static ssize_t zft_write(struct file *fp, const char *buff,
size_t req_len, loff_t *ppos)
-#elif LINUX_VERSION_CODE >= KERNEL_VER(2,1,0)
-static long zft_write(struct inode *ino, struct file *fp, const char *buff,
- unsigned long req_len)
-#else
-static int zft_write(struct inode *ino, struct file *fp, const char *buff,
- int req_len)
-#endif
{
int result = -EIO;
sigset_t old_sigmask;
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60)
struct inode *ino = fp->f_dentry->d_inode;
-#endif
TRACE_FUN(ft_t_flow);
TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len);
&zft_cdev, NULL);
}
-#if LINUX_VERSION_CODE < KERNEL_VER(2,1,18)
- register_symtab(&zft_symbol_table); /* add global zftape symbols */
-#endif
#ifdef CONFIG_ZFT_COMPRESSOR
(void)zft_compressor_init();
#endif
#ifdef MODULE
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18)
/* Called by modules package before trying to unload the module
*/
static int can_unload(void)
{
- return (zft_dirty() || busy_flag) ? -EBUSY : 0;
+ return (GET_USE_COUNT(THIS_MODULE)||zft_dirty()||busy_flag)?-EBUSY:0;
}
-#endif
/* Called by modules package when installing the driver
*/
int init_module(void)
{
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18)
if (!mod_member_present(&__this_module, can_unload)) {
return -EBUSY;
}
__this_module.can_unload = can_unload;
-#endif
return zft_init();
}
static char driver_version[] = "X0.0";/* no spaces */
-static struct file_operations h8_fops = {
- /* twelve lines of crap^WNULLs were here */
-};
-
-static struct miscdevice h8_device = {
- H8_MINOR_DEV,
- "h8",
- &h8_fops
-};
-
union intr_buf intrbuf;
int intr_buf_ptr;
union intr_buf xx;
static void __exit h8_cleanup (void)
{
remove_proc_entry("driver/h8", NULL);
- misc_deregister(&h8_device);
release_region(h8_base, 8);
free_irq(h8_irq, NULL);
}
create_proc_info_entry("driver/h8", 0, NULL, h8_get_info);
- misc_register(&h8_device);
request_region(h8_base, 8, "h8");
h8_alloc_queues();
#include <linux/random.h>
#include <linux/sysctl.h>
#include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/uaccess.h>
static int rng_dev_release (struct inode *inode, struct file *filp)
{
- if (rng_enable(0) != 0)
+ lock_kernel();
+ if (rng_enable(0) != 0) {
+ unlock_kernel();
return -EIO;
+ }
spin_lock_bh (&rng_lock);
rng_open = 0;
spin_unlock_bh (&rng_lock);
+ unlock_kernel();
return 0;
}
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/malloc.h>
#include <linux/fcntl.h>
{
unsigned int minor = MINOR(inode->i_rdev);
+ lock_kernel();
kfree_s(lp_table[minor].lp_buffer, LP_BUFFER_SIZE);
lp_table[minor].lp_buffer = NULL;
LP_F(minor) &= ~LP_BUSY;
+ unlock_kernel();
return 0;
}
#include <linux/watchdog.h>
#include <linux/reboot.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
static int mixcomwd_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
#ifndef CONFIG_WATCHDOG_NOWAYOUT
if(mixcomwd_timer_alive) {
printk(KERN_ERR "mixcomwd: release called while internal timer alive");
+ unlock_kernel();
return -EBUSY;
}
init_timer(&mixcomwd_timer);
#endif
clear_bit(0,&mixcomwd_opened);
+ unlock_kernel();
return 0;
}
{
struct i2c_client *client = file->private_data;
+ lock_kernel();
if (client->adapter->dec_use)
client->adapter->dec_use(client->adapter);
+ unlock_kernel();
return 0;
}
#include <linux/module.h>
#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
#define PC 1
#define ATARI 2
static int nvram_release( struct inode *inode, struct file *file )
{
+ lock_kernel();
nvram_open_cnt--;
if (file->f_flags & O_EXCL)
nvram_open_mode &= ~NVRAM_EXCL;
if (file->f_mode & 2)
nvram_open_mode &= ~NVRAM_WRITE;
+ unlock_kernel();
return( 0 );
}
#include <linux/poll.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
+#include <linux/smp_lock.h>
#include <asm/signal.h>
#include <asm/io.h>
static int close_pad(struct inode * inode, struct file * file)
{
+ lock_kernel();
fasync_pad(-1, file, 0);
- if (--active)
- return 0;
- outb(0x30, current_params.io+2); /* switch off digitiser */
+ if (!--active)
+ outb(0x30, current_params.io+2); /* switch off digitiser */
+ unlock_kernel();
return 0;
}
#include <linux/miscdevice.h>
#include <linux/malloc.h>
#include <linux/kbd_kern.h>
+#include <linux/smp_lock.h>
#include <asm/keyboard.h>
#include <asm/bitops.h>
static int release_aux(struct inode * inode, struct file * file)
{
+ lock_kernel();
fasync_aux(-1, file, 0);
- if (--aux_count)
+ if (--aux_count) {
+ unlock_kernel();
return 0;
+ }
kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */
kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE);
aux_free_irq(AUX_DEV);
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
{
if (MINOR(ino->i_rdev)==WATCHDOG_MINOR)
{
+ lock_kernel();
is_open = 0;
#ifndef CONFIG_WATCHDOG_NOWAYOUT
/* Disable the board */
outb_p(0xA5, current_readport + 3);
spin_unlock(&io_lock);
}
+ unlock_kernel();
#endif
}
return 0;
#include <linux/poll.h>
#include <asm/uaccess.h>
#include <linux/ppdev.h>
+#include <linux/smp_lock.h>
#define PP_VERSION "ppdev: user-space parallel port driver"
#define CHRDEV "ppdev"
unsigned int minor = MINOR (inode->i_rdev);
struct pp_struct *pp = file->private_data;
+ lock_kernel();
if (pp->pdev && pp->pdev->port->ieee1284.mode != IEEE1284_MODE_COMPAT) {
if (!(pp->flags & PP_CLAIMED)) {
parport_claim_or_block (pp->pdev);
printk (KERN_DEBUG CHRDEV "%x: unregistered pardevice\n",
minor);
}
+ unlock_kernel();
kfree (pp);
#include <linux/random.h>
#include <linux/poll.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/uaccess.h>
{
unsigned char status;
+ lock_kernel();
fasync_qp(-1, file, 0);
if (!--qp_count) {
if (!poll_qp_status())
printk("Warning: Mouse device busy in release_qp()\n");
free_irq(QP_IRQ, NULL);
}
+ unlock_kernel();
return 0;
}
#include <linux/blkdev.h>
#include <linux/raw.h>
#include <linux/capability.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#define dprintk(x...)
struct block_device *bdev;
minor = MINOR(inode->i_rdev);
+ lock_kernel();
bdev = raw_device_bindings[minor];
blkdev_put(bdev, BDEV_RAW);
raw_device_inuse[minor]--;
+ unlock_kernel();
return 0;
}
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/uaccess.h>
unsigned char tmp;
+ lock_kernel();
spin_lock_irq(&rtc_lock);
tmp = CMOS_READ(RTC_CONTROL);
tmp &= ~RTC_PIE;
rtc_fasync (-1, file, 0);
}
+#else
+ lock_kernel();
#endif
spin_lock_irq (&rtc_lock);
rtc_irq_data = 0;
spin_unlock_irq (&rtc_lock);
rtc_status = rtc_status & ~RTC_IS_OPEN;
+ unlock_kernel();
return 0;
}
#include <linux/malloc.h>
#include <linux/ioport.h>
#include <linux/fcntl.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/system.h>
static int fop_close(struct inode * inode, struct file * file)
{
+ lock_kernel();
if(MINOR(inode->i_rdev) == WATCHDOG_MINOR)
{
if(wdt_expect_close)
}
}
wdt_is_open = 0;
+ unlock_kernel();
return 0;
}
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/reboot.h>
+#include <linux/smp_lock.h>
#include <linux/init.h>
#include <asm/uaccess.h>
{
if(timer_alive)
return -EBUSY;
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
MOD_INC_USE_COUNT;
+#endif
/*
* Activate timer
*/
* Shut off the timer.
* Lock it in if it's a module and we defined ...NOWAYOUT
*/
+ lock_kernel();
#ifndef CONFIG_WATCHDOG_NOWAYOUT
del_timer(&watchdog_ticktock);
- MOD_DEC_USE_COUNT;
#endif
timer_alive=0;
+ unlock_kernel();
return 0;
}
static struct file_operations softdog_fops=
{
+ owner: THIS_MODULE,
write: softdog_write,
ioctl: softdog_ioctl,
open: softdog_open,
#include <linux/mm.h>
#include <linux/malloc.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/dma.h>
{
kdev_t dev = inode->i_rdev;
+ lock_kernel();
if (TP_DIAGS(dev))
{
printk("qic02_tape_release: dev=%s\n", kdevname(dev));
(void) do_qic_cmd(QCMD_REWIND, TIM_R);
}
}
+ unlock_kernel();
return 0;
} /* qic02_tape_release */
static int tty_release(struct inode * inode, struct file * filp)
{
+ lock_kernel();
release_dev(filp);
+ unlock_kernel();
return 0;
}
#include <linux/errno.h>
#include <linux/malloc.h>
#include <linux/i2c.h>
+#include <linux/smp_lock.h>
#include <linux/videodev.h>
#include <asm/semaphore.h>
#include <linux/init.h>
static int tvmixer_release(struct inode *inode, struct file *file)
{
struct TVMIXER *mix = file->private_data;
- struct i2c_client *client = mix->dev;
+ struct i2c_client *client;
- if (NULL == client)
+ lock_kernel();
+ client = mix->dev;
+ if (NULL == client) {
+ unlock_kernel();
return -ENODEV;
+ }
if (client->adapter->dec_use)
client->adapter->dec_use(client->adapter);
+ unlock_kernel();
return 0;
}
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
if(vfl==NULL) {
char modname[20];
- MOD_INC_USE_COUNT;
sprintf (modname, "char-major-%d-%d", VIDEO_MAJOR, minor);
request_module(modname);
vfl=video_device[minor];
- MOD_DEC_USE_COUNT;
if (vfl==NULL)
return -ENODEV;
}
static int video_release(struct inode *inode, struct file *file)
{
- struct video_device *vfl=video_device[MINOR(inode->i_rdev)];
+ struct video_device *vfl;
+ lock_kernel();
+ vfl=video_device[MINOR(inode->i_rdev)];
if(vfl->close)
vfl->close(vfl);
vfl->busy=0;
+ unlock_kernel();
return 0;
}
int video_mmap(struct file *file, struct vm_area_struct *vma)
{
+ int ret = -EINVAL;
struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
- if(vfl->mmap)
- return vfl->mmap(vfl, (char *)vma->vm_start,
+ if(vfl->mmap) {
+ lock_kernel();
+ ret = vfl->mmap(vfl, (char *)vma->vm_start,
(unsigned long)(vma->vm_end-vma->vm_start));
- return -EINVAL;
+ unlock_kernel();
+ }
+ return ret;
}
/*
static struct file_operations video_fops=
{
+ owner: THIS_MODULE,
llseek: video_lseek,
read: video_read,
write: video_write,
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include "wd501p.h"
static int wdt_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
if(MINOR(inode->i_rdev)==WATCHDOG_MINOR)
{
#ifndef CONFIG_WATCHDOG_NOWAYOUT
#endif
wdt_is_open=0;
}
+ unlock_kernel();
return 0;
}
#include <linux/reboot.h>
#include <linux/init.h>
#include <linux/interrupt.h>
+#include <linux/smp_lock.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
{
if(timer_alive)
return -EBUSY;
- MOD_INC_USE_COUNT;
/*
* Ahead watchdog factor ten, Mr Sulu
*/
request_irq(IRQ_TIMER4, watchdog_fire, 0, "watchdog", NULL);
#else
*CSR_SA110_CNTL |= 1 << 13;
+ MOD_INC_USE_COUNT;
#endif
timer_alive = 1;
return 0;
static int watchdog_release(struct inode *inode, struct file *file)
{
#ifdef ONLY_TESTING
+ lock_kernel();
free_irq(IRQ_TIMER4, NULL);
timer_alive = 0;
- MOD_DEC_USE_COUNT;
+ unlock_kernel();
#else
/*
* It's irreversible!
static struct file_operations watchdog_fops=
{
+ owner: THIS_MODULE,
write: watchdog_write,
ioctl: watchdog_ioctl,
open: watchdog_open,
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/system.h>
{
if(timer_alive)
return -EBUSY;
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
MOD_INC_USE_COUNT;
+#endif
timer_alive++;
//max timeout value = 255 minutes (0xFF). Write 0 to disable WatchDog.
* Lock it in if it's a module and we defined ...NOWAYOUT
*/
#ifndef CONFIG_WATCHDOG_NOWAYOUT
+ lock_kernel();
// unlock the SuperIO chip
outb(0x87,0x370);
// lock the SuperIO chip
outb(0xAA,0x370);
- MOD_DEC_USE_COUNT;
timer_alive=0;
+ unlock_kernel();
printk(KERN_INFO "Watchdog: shutdown.\n");
#endif
static struct file_operations wdt977_fops=
{
+ owner: THIS_MODULE,
write: wdt977_write,
open: wdt977_open,
release: wdt977_release,
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <linux/pci.h>
case WATCHDOG_MINOR:
if(wdt_is_open)
return -EBUSY;
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
MOD_INC_USE_COUNT;
+#endif
/*
* Activate
*/
outb_p(0, WDT_DC); /* Enable */
return 0;
case TEMP_MINOR:
- MOD_INC_USE_COUNT;
return 0;
default:
return -ENODEV;
{
if(MINOR(inode->i_rdev)==WATCHDOG_MINOR)
{
+ lock_kernel();
#ifndef CONFIG_WATCHDOG_NOWAYOUT
inb_p(WDT_DC); /* Disable counters */
wdtpci_ctr_load(2,0); /* 0 length reset pulses now */
#endif
wdt_is_open=0;
+ unlock_kernel();
}
- MOD_DEC_USE_COUNT;
return 0;
}
static struct file_operations wdtpci_fops = {
+ owner: THIS_MODULE,
llseek: wdtpci_llseek,
read: wdtpci_read,
write: wdtpci_write,
#include <linux/fs.h>
#include <linux/malloc.h>
#include <linux/version.h>
+#include <linux/smp_lock.h>
/* If you want debugging uncomment: */
/* #define DEBUG */
static int i2cdev_cleanup(void);
static struct file_operations i2cdev_fops = {
+ owner: THIS_MODULE,
llseek: i2cdev_lseek,
read: i2cdev_read,
write: i2cdev_write,
if (i2cdev_adaps[minor]->inc_use)
i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]);
- MOD_INC_USE_COUNT;
#ifdef DEBUG
printk("i2c-dev.o: opened i2c-%d\n",minor);
#ifdef DEBUG
printk("i2c-dev.o: Closed: i2c-%d\n", minor);
#endif
- MOD_DEC_USE_COUNT;
+ lock_kernel();
if (i2cdev_adaps[minor]->dec_use)
i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]);
+ unlock_kernel();
return 0;
}
#include <linux/miscdevice.h>
#include <linux/mm.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
struct i2o_cfg_info *p1, *p2;
unsigned int flags;
+ lock_kernel();
p1 = p2 = NULL;
spin_lock_irqsave(&i2o_config_lock, flags);
p1 = p1->next;
}
spin_unlock_irqrestore(&i2o_config_lock, flags);
+ unlock_kernel();
return 0;
}
#include <linux/malloc.h>
#include <linux/pci.h>
#include <linux/ide.h>
+#include <linux/smp_lock.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
if (test_and_set_bit (IDETAPE_BUSY, &tape->flags))
return -EBUSY;
- MOD_INC_USE_COUNT;
-#if ONSTREAM_DEBUG
- if (tape->debug_level >= 6)
- printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_chrdev_open-1\n");
-#endif
if (!tape->onstream) {
idetape_read_position(drive);
if (!test_bit (IDETAPE_ADDRESS_VALID, &tape->flags))
}
if (idetape_wait_ready(drive, 60 * HZ)) {
clear_bit(IDETAPE_BUSY, &tape->flags);
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- if (tape->debug_level >= 6)
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_chrdev_open-1\n");
-#endif
printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name);
return -EBUSY;
}
idetape_read_position(drive);
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- if (tape->debug_level >= 6)
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_chrdev_open-2\n");
-#endif
clear_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
if (tape->chrdev_direction == idetape_direction_none) {
- MOD_INC_USE_COUNT;
-#if ONSTREAM_DEBUG
- if (tape->debug_level >= 6)
- printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_chrdev_open-2\n");
-#endif
idetape_create_prevent_cmd(drive, &pc, 1);
if (!idetape_queue_pc_tail (drive,&pc)) {
if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
static int idetape_chrdev_release (struct inode *inode, struct file *filp)
{
ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
- idetape_tape_t *tape = drive->driver_data;
+ idetape_tape_t *tape;
idetape_pc_t pc;
unsigned int minor=MINOR (inode->i_rdev);
-
+
+ lock_kernel();
+ tape = drive->driver_data;
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 3)
printk (KERN_INFO "ide-tape: Reached idetape_chrdev_release\n");
if (!idetape_queue_pc_tail (drive,&pc))
tape->door_locked = DOOR_UNLOCKED;
}
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- if (tape->debug_level >= 6)
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_chrdev_release\n");
-#endif
}
clear_bit (IDETAPE_BUSY, &tape->flags);
+ unlock_kernel();
return 0;
}
* Our character device supporting functions, passed to register_chrdev.
*/
static struct file_operations idetape_fops = {
+ owner: THIS_MODULE,
read: idetape_chrdev_read,
write: idetape_chrdev_write,
ioctl: idetape_chrdev_ioctl,
#include <linux/poll.h>
#include <linux/module.h>
#include <linux/version.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
struct pending_request *req;
int done = 0, i;
+ lock_kernel();
for (i = 0; i < 64; i++) {
if (fi->listen_channels & (1ULL << i)) {
hpsb_unlisten_channel(hl_handle, fi->host, i);
kfree(fi);
V22_COMPAT_MOD_DEC_USE_COUNT;
+ unlock_kernel();
return 0;
}
#include <linux/pci.h>
#include <linux/fs.h>
#include <linux/poll.h>
+#include <linux/smp_lock.h>
#include <asm/byteorder.h>
#include <asm/atomic.h>
#include <asm/io.h>
{
struct video_card *video =
&video_cards[MINOR(file->f_dentry->d_inode->i_rdev)];
- struct ti_ohci *ohci= video->ohci;
+ struct ti_ohci *ohci;
+ int res = -EINVAL;
+ lock_kernel();
+ ohci = video->ohci;
PRINT(KERN_INFO, ohci->id, "mmap");
if (video->current_ctx == NULL) {
PRINT(KERN_ERR, ohci->id, "current iso context not set");
- return -EINVAL;
- }
-
- return do_iso_mmap(ohci, video->current_ctx,
+ } else
+ res = do_iso_mmap(ohci, video->current_ctx,
(char *)vma->vm_start,
(unsigned long)(vma->vm_end-vma->vm_start));
- return 0;
+ unlock_kernel();
+ return res;
}
static int video1394_open(struct inode *inode, struct file *file)
struct ti_ohci *ohci= video->ohci;
int i;
+ lock_kernel();
for (i=0;i<ohci->nb_iso_rcv_ctx-1;i++)
if (video->ir_context[i]) {
if (!test_and_clear_bit(
V22_COMPAT_MOD_DEC_USE_COUNT;
PRINT(KERN_INFO, ohci->id, "release");
+ unlock_kernel();
return 0;
}
#include <linux/fs.h>
#include <linux/signal.h>
#include <linux/mm.h>
+#include <linux/smp_lock.h>
#include <linux/timer.h>
#include <linux/wait.h>
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
struct capiminor *mp, **pp;
unsigned int minor = 0;
- MOD_INC_USE_COUNT;
mp = (struct capiminor *)kmem_cache_alloc(capiminor_cachep, GFP_ATOMIC);
if (!mp) {
- MOD_DEC_USE_COUNT;
printk(KERN_ERR "capi: can't alloc capiminor\n");
return 0;
}
kfree_skb(skb);
capiminor_del_all_ack(mp);
kmem_cache_free(capiminor_cachep, mp);
- MOD_DEC_USE_COUNT;
#ifdef _DEBUG_REFCOUNT
printk(KERN_DEBUG "capiminor_free %d\n", GET_USE_COUNT(THIS_MODULE));
#endif
if ((file->private_data = capidev_alloc(file)) == 0)
return -ENOMEM;
- MOD_INC_USE_COUNT;
#ifdef _DEBUG_REFCOUNT
printk(KERN_DEBUG "capi_open %d\n", GET_USE_COUNT(THIS_MODULE));
#endif
{
struct capidev *cdev = (struct capidev *)file->private_data;
+ lock_kernel();
capincci_free(cdev, 0xffffffff);
capidev_free(cdev);
file->private_data = NULL;
- MOD_DEC_USE_COUNT;
#ifdef _DEBUG_REFCOUNT
printk(KERN_DEBUG "capi_release %d\n", GET_USE_COUNT(THIS_MODULE));
#endif
+ unlock_kernel();
return 0;
}
struct capiminor *mp = (struct capiminor *)file->private_data;
if (mp) {
+ lock_kernel();
mp->file = 0;
if (mp->nccip == 0) {
capiminor_free(mp);
file->private_data = NULL;
}
+ unlock_kernel();
}
#ifdef _DEBUG_REFCOUNT
{
char *p;
- MOD_INC_USE_COUNT;
-
if ((p = strchr(revision, ':'))) {
strcpy(rev, p + 2);
p = strchr(rev, '$');
if (devfs_register_chrdev(capi_major, "capi20", &capi_fops)) {
printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
- MOD_DEC_USE_COUNT;
return -EIO;
}
if (devfs_register_chrdev(capi_rawmajor, "capi/r%d", &capinc_raw_fops)) {
devfs_unregister_chrdev(capi_major, "capi20");
printk(KERN_ERR "capi20: unable to get major %d\n", capi_rawmajor);
- MOD_DEC_USE_COUNT;
return -EIO;
}
devfs_register_series (NULL, "capi/r%u", CAPINC_NR_PORTS,
if ((capifuncs = attach_capi_interface(&cuser)) == 0) {
- MOD_DEC_USE_COUNT;
devfs_unregister_chrdev(capi_major, "capi20");
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
devfs_unregister_chrdev(capi_rawmajor, "capi/r%d");
(void) detach_capi_interface(&cuser);
devfs_unregister_chrdev(capi_major, "capi20");
devfs_unregister_chrdev(capi_rawmajor, "capi/r%d");
- MOD_DEC_USE_COUNT;
return -ENOMEM;
}
#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
devfs_unregister(devfs_find_handle(NULL, "capi20",
capi_major, 0,
DEVFS_SPECIAL_CHR, 0));
- MOD_DEC_USE_COUNT;
return -ENOMEM;
}
printk(KERN_NOTICE "capi20: Rev%s: started up with major %d\n",
rev, capi_major);
- MOD_DEC_USE_COUNT;
return 0;
}
struct divert_info *inf;
int flags;
+ lock_kernel();
save_flags(flags);
cli();
if_used--;
divert_info_head = divert_info_head->next;
kfree(inf);
}
+ unlock_kernel();
return (0);
} /* isdn_divert_close */
int retval = 0;
struct proc_dir_entry *pd;
+ lock_kernel();
/* search the addressed card */
card = card_root;
while (card) {
card = card->next; /* search next entry */
}
if (!card) {
+ unlock_kernel();
return (-ENODEV); /* device is unknown/invalid */
}
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
if (filep->private_data)
kfree(filep->private_data); /* release memory */
}
+ unlock_kernel();
return (retval);
} /* hysdn_conf_close */
hysdn_card *card;
int flags, retval = 0;
-
+ lock_kernel();
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
/* write only access -> write debug completely written */
retval = 0; /* success */
}
} /* read access */
+ unlock_kernel();
return (retval);
} /* hysdn_log_close */
int flags, retval = 0;
+ lock_kernel();
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
/* write only access -> write debug level written */
retval = 0; /* success */
kfree(inf);
}
} /* read access */
+ unlock_kernel();
return (retval);
} /* hysdn_log_close */
#include <linux/poll.h>
#include <linux/vmalloc.h>
#include <linux/isdn.h>
+#include <linux/smp_lock.h>
#include "isdn_common.h"
#include "isdn_tty.h"
#include "isdn_net.h"
static void isdn_unregister_devfs(int);
void
-isdn_MOD_INC_USE_COUNT(void)
+isdn_lock_drivers(void)
{
int i;
- MOD_INC_USE_COUNT;
for (i = 0; i < dev->drivers; i++) {
isdn_ctrl cmd;
}
void
-isdn_MOD_DEC_USE_COUNT(void)
+isdn_MOD_INC_USE_COUNT(void)
+{
+ MOD_INC_USE_COUNT;
+ isdn_lock_drivers();
+}
+
+void
+isdn_unlock_drivers(void)
{
int i;
- MOD_DEC_USE_COUNT;
for (i = 0; i < dev->drivers; i++)
if (dev->drv[i]->locks > 0) {
isdn_ctrl cmd;
}
}
+void
+isdn_MOD_DEC_USE_COUNT(void)
+{
+ MOD_DEC_USE_COUNT;
+ isdn_unlock_drivers();
+}
+
#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP)
void
isdn_dumppkt(char *s, u_char * p, int len, int dumplen)
/*
* Open the device code.
- * MOD_INC_USE_COUNT make sure that the driver memory is not freed
- * while the device is in use.
*/
static int
isdn_open(struct inode *ino, struct file *filep)
infostruct *p;
if ((p = (infostruct *) kmalloc(sizeof(infostruct), GFP_KERNEL))) {
- MOD_INC_USE_COUNT;
p->next = (char *) dev->infochain;
p->private = (char *) &(filep->private_data);
dev->infochain = p;
return -ENODEV;
if (!(dev->drv[drvidx]->online & (1 << chidx)))
return -ENODEV;
- isdn_MOD_INC_USE_COUNT();
+ isdn_lock_drivers();
return 0;
}
if (minor <= ISDN_MINOR_CTRLMAX) {
drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL);
if (drvidx < 0)
return -ENODEV;
- isdn_MOD_INC_USE_COUNT();
+ isdn_lock_drivers();
return 0;
}
#ifdef CONFIG_ISDN_PPP
if (minor <= ISDN_MINOR_PPPMAX) {
int ret;
if (!(ret = isdn_ppp_open(minor - ISDN_MINOR_PPP, filep)))
- isdn_MOD_INC_USE_COUNT();
+ isdn_lock_drivers();
return ret;
}
#endif
{
uint minor = MINOR(ino->i_rdev);
+ lock_kernel();
if (minor == ISDN_MINOR_STATUS) {
infostruct *p = dev->infochain;
infostruct *q = NULL;
- MOD_DEC_USE_COUNT;
while (p) {
if (p->private == (char *) &(filep->private_data)) {
if (q)
else
dev->infochain = (infostruct *) (p->next);
kfree(p);
+ unlock_kernel();
return 0;
}
q = p;
p = (infostruct *) (p->next);
}
printk(KERN_WARNING "isdn: No private data while closing isdnctrl\n");
+ unlock_kernel();
return 0;
}
- isdn_MOD_DEC_USE_COUNT();
- if (minor < ISDN_MINOR_CTRL)
+ isdn_unlock_drivers();
+ if (minor < ISDN_MINOR_CTRL) {
+ unlock_kernel();
return 0;
+ }
if (minor <= ISDN_MINOR_CTRLMAX) {
if (dev->profd == current)
dev->profd = NULL;
+ unlock_kernel();
return 0;
}
#ifdef CONFIG_ISDN_PPP
if (minor <= ISDN_MINOR_PPPMAX)
isdn_ppp_release(minor - ISDN_MINOR_PPP, filep);
#endif
+ unlock_kernel();
return 0;
}
static struct file_operations isdn_fops =
{
+ owner: THIS_MODULE,
llseek: isdn_lseek,
read: isdn_read,
write: isdn_write,
#include <linux/devfs_fs_kernel.h>
#include <linux/mm.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/adb.h>
#include <linux/cuda.h>
#include <linux/pmu.h>
struct adbdev_state *state = file->private_data;
unsigned long flags;
+ lock_kernel();
if (state) {
file->private_data = NULL;
spin_lock_irqsave(&state->lock, flags);
spin_unlock_irqrestore(&state->lock, flags);
}
}
+ unlock_kernel();
return 0;
}
#include <linux/adb.h>
#include <linux/pmu.h>
#include <linux/cuda.h>
+#include <linux/smp_lock.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/io.h>
struct pmu_private *pp = file->private_data;
unsigned long flags;
+ lock_kernel();
if (pp != 0) {
file->private_data = 0;
spin_lock_irqsave(&all_pvt_lock, flags);
spin_unlock_irqrestore(&all_pvt_lock, flags);
kfree(pp);
}
+ unlock_kernel();
return 0;
}
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/malloc.h>
+#include <linux/smp_lock.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
if ((file->f_mode & 2) && (minor & 1))
return -EACCES;
- MOD_INC_USE_COUNT;
-
mtd = get_mtd_device(NULL, devnum);
- if (!mtd) {
- MOD_DEC_USE_COUNT;
+ if (!mtd)
return -ENODEV;
- }
file->private_data = mtd;
/* You can't open it RW if it's not a writeable device */
if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
put_mtd_device(mtd);
- MOD_DEC_USE_COUNT;
return -EACCES;
}
mtd = (struct mtd_info *)file->private_data;
+ lock_kernel();
if (mtd->sync)
mtd->sync(mtd);
put_mtd_device(mtd);
+ unlock_kernel();
- MOD_DEC_USE_COUNT;
release_return(0);
} /* mtd_close */
} /* memory_ioctl */
static struct file_operations mtd_fops = {
-
+ owner: THIS_MODULE,
llseek: mtd_lseek, /* lseek */
read: mtd_read, /* read */
write: mtd_write, /* write */
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <net/slhc_vj.h>
#include <asm/atomic.h>
{
struct ppp_file *pf = (struct ppp_file *) file->private_data;
+ lock_kernel();
if (pf != 0) {
file->private_data = 0;
if (atomic_dec_and_test(&pf->refcnt)) {
}
}
}
+ unlock_kernel();
return 0;
}
#include <linux/ioport.h>
#include <linux/netdevice.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#undef COSA_SLOW_IO /* for testing purposes only */
#undef REALLY_SLOW_IO
static int cosa_release(struct inode *inode, struct file *file)
{
struct channel_data *channel = (struct channel_data *)file->private_data;
- struct cosa_data *cosa = channel->cosa;
+ struct cosa_data *cosa;
unsigned long flags;
+ lock_kernel();
+ cosa = channel->cosa;
spin_lock_irqsave(&cosa->lock, flags);
cosa->usage--;
channel->usage--;
spin_unlock_irqrestore(&cosa->lock, flags);
+ unlock_kernel();
return 0;
}
#include <linux/mm.h>
#include <linux/fcntl.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/timer.h>
#include <linux/ioctl.h>
#include <linux/proc_fs.h>
user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
if (!user) return -ENOMEM;
- MOD_INC_USE_COUNT;
user->event_tail = user->event_head = 0;
user->next = s->user;
user->user_magic = USER_MAGIC;
DEBUG(0, "ds_release(socket %d)\n", i);
if ((i >= sockets) || (sockets == 0))
return 0;
+ lock_kernel();
s = &socket_table[i];
user = file->private_data;
if (CHECK_USER(user))
- return 0;
+ goto out;
/* Unlink user data structure */
if ((file->f_flags & O_ACCMODE) != O_RDONLY)
for (link = &s->user; *link; link = &(*link)->next)
if (*link == user) break;
if (link == NULL)
- return 0;
+ goto out;
*link = user->next;
user->user_magic = 0;
kfree(user);
-
- MOD_DEC_USE_COUNT;
+out:
+ unlock_kernel();
return 0;
} /* ds_release */
/*====================================================================*/
static struct file_operations ds_fops = {
- open: ds_open,
- release: ds_release,
- ioctl: ds_ioctl,
- read: ds_read,
- write: ds_write,
- poll: ds_poll,
+ owner: THIS_MODULE,
+ open: ds_open,
+ release: ds_release,
+ ioctl: ds_ioctl,
+ read: ds_read,
+ write: ds_write,
+ poll: ds_poll,
};
EXPORT_SYMBOL(register_pccard_driver);
if ((buffer = (isapnp_info_buffer_t *) file->private_data) == NULL)
return -EINVAL;
mode = file->f_flags & O_ACCMODE;
+ lock_kernel();
if (mode == O_WRONLY)
isapnp_info_write(buffer);
vfree(buffer->buffer);
kfree(buffer);
+ unlock_kernel();
return 0;
}
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/mm.h>
#include <linux/tqueue.h>
#include <linux/major.h>
struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
SPARCAUDIO_DEVICE_SHIFT)];
+ lock_kernel();
if (file->f_mode & FMODE_READ) {
/* Stop input */
drv->ops->stop_input(drv);
kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
wake_up_interruptible(&drv->open_wait);
+ unlock_kernel();
return 0;
}
static struct file_operations sparcaudio_fops = {
+ owner: THIS_MODULE,
llseek: sparcaudio_lseek,
read: sparcaudio_read,
write: sparcaudio_write,
#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/timer.h>
#include <linux/ioport.h>
#include <linux/major.h>
static int bpp_release(struct inode *inode, struct file *f)
{
unsigned minor = MINOR(inode->i_rdev);
+
+ lock_kernel();
instances[minor].opened = 0;
if (instances[minor].mode != COMPATIBILITY)
terminate(minor);
+ unlock_kernel();
return 0;
}
#include <linux/fcntl.h>
#include <linux/poll.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
unsigned long addr;
unsigned long size;
+ lock_kernel();
if (flash.read_base == flash.write_base) {
addr = flash.read_base;
size = flash.read_size;
} else {
if ((vma->vm_flags & VM_READ) &&
- (vma->vm_flags & VM_WRITE))
+ (vma->vm_flags & VM_WRITE)) {
+ unlock_kernel();
return -EINVAL;
-
+ }
if (vma->vm_flags & VM_READ) {
addr = flash.read_base;
size = flash.read_size;
} else if (vma->vm_flags & VM_WRITE) {
addr = flash.write_base;
size = flash.write_size;
- } else
+ } else {
+ unlock_kernel();
return -ENXIO;
+ }
}
+ unlock_kernel();
if ((vma->vm_pgoff << PAGE_SHIFT) > size)
return -ENXIO;
static int
flash_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
flash.busy = 0;
+ unlock_kernel();
return 0;
}
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/string.h>
+#include <linux/smp_lock.h>
/*
* <linux/blk.h> is controlled from the outside with these definitions.
static int jsf_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
jsf0.busy = 0;
+ unlock_kernel();
return 0;
}
#include <linux/kbd_kern.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/init.h>
#include <asm/ebus.h>
{
unsigned long flags;
+ lock_kernel();
aux_fasync(-1, file, 0);
if (--aux_count)
- return 0;
+ goto out;
spin_lock_irqsave(&pcikbd_lock, flags);
poll_aux_status();
spin_unlock_irqrestore(&pcikbd_lock, flags);
+out:
+ unlock_kernel();
return 0;
}
#include <linux/fcntl.h>
#include <linux/poll.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/mostek.h>
#include <asm/system.h>
#include <asm/uaccess.h>
static int rtc_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
rtc_busy = 0;
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/sysrq.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/kbio.h>
static int
kbd_close (struct inode *i, struct file *f)
{
- if (--kbd_active)
- return 0;
-
- if (kbd_redirected)
- kbd_table [kbd_redirected-1].kbdmode = VC_XLATE;
-
- kbd_redirected = 0;
- kbd_opened = 0;
-
- kbd_fasync (-1, f, 0);
+ lock_kernel();
+ if (!--kbd_active) {
+ if (kbd_redirected)
+ kbd_table [kbd_redirected-1].kbdmode = VC_XLATE;
+ kbd_redirected = 0;
+ kbd_opened = 0;
+ kbd_fasync (-1, f, 0);
+ }
+ unlock_kernel();
return 0;
}
#include <linux/mm.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/system.h>
static int
sun_mouse_close(struct inode *inode, struct file *file)
{
+ lock_kernel();
sun_mouse_fasync (-1, file, 0);
sunmouse.active--;
+ unlock_kernel();
return 0;
}
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/fs.h>
+#include <linux/smp_lock.h>
#include <asm/openprom.h>
#include <asm/oplib.h>
return 0;
}
-static void vfc_release(struct inode *inode,struct file *file)
+static int vfc_release(struct inode *inode,struct file *file)
{
struct vfc_dev *dev;
+ lock_kernel();
dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
- if (dev == NULL)
- return;
- if (!dev->busy)
- return;
+ if (!dev || !dev->busy) {
+ unlock_kernel();
+ return -EINVAL;
+ }
dev->busy = 0;
+ unlock_kernel();
+ return 0;
}
static int vfc_debug(struct vfc_dev *dev, int cmd, unsigned long arg)
unsigned int map_size, ret, map_offset;
struct vfc_dev *dev;
+ lock_kernel();
dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
- if(dev == NULL)
+ if(dev == NULL) {
+ unlock_kernel();
return -ENODEV;
-
+ }
map_size = vma->vm_end - vma->vm_start;
if(map_size > sizeof(struct vfc_regs))
map_size = sizeof(struct vfc_regs);
map_offset = (unsigned int) (long)dev->phys_regs;
ret = io_remap_page_range(vma->vm_start, map_offset, map_size,
vma->vm_page_prot, dev->which_io);
+ unlock_kernel();
if(ret)
return -EAGAIN;
#include <linux/fcntl.h>
#include <linux/init.h>
#include <linux/poll.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/uaccess.h>
if (sdp->device->host->hostt->module)
__MOD_INC_USE_COUNT(sdp->device->host->hostt->module);
- if (sg_template.module)
- __MOD_INC_USE_COUNT(sg_template.module);
return 0;
}
Sg_device * sdp;
Sg_fd * sfp;
- if ((! (sfp = (Sg_fd *)filp->private_data)) || (! (sdp = sfp->parentdp)))
+ lock_kernel();
+ if ((! (sfp = (Sg_fd *)filp->private_data)) || (! (sdp = sfp->parentdp))) {
+ unlock_kernel();
return -ENXIO;
+ }
SCSI_LOG_TIMEOUT(3, printk("sg_release: dev=%d\n", MINOR(sdp->i_rdev)));
sg_fasync(-1, filp, 0); /* remove filp from async notification list */
sg_remove_sfp(sdp, sfp);
if (sdp->device->host->hostt->module)
__MOD_DEC_USE_COUNT(sdp->device->host->hostt->module);
- if(sg_template.module)
- __MOD_DEC_USE_COUNT(sg_template.module);
sdp->exclude = 0;
wake_up_interruptible(&sdp->o_excl_wait);
+ unlock_kernel();
return 0;
}
}
static struct file_operations sg_fops = {
- read: sg_read,
- write: sg_write,
- poll: sg_poll,
- ioctl: sg_ioctl,
- open: sg_open,
- release: sg_release,
- fasync: sg_fasync,
+ owner: THIS_MODULE,
+ read: sg_read,
+ write: sg_write,
+ poll: sg_poll,
+ ioctl: sg_ioctl,
+ open: sg_open,
+ release: sg_release,
+ fasync: sg_fasync,
};
#include <linux/ioctl.h>
#include <linux/fcntl.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/dma.h>
#include <asm/system.h>
if (STp->device->host->hostt->module)
__MOD_INC_USE_COUNT(STp->device->host->hostt->module);
- if (st_template.module)
- __MOD_INC_USE_COUNT(st_template.module);
if (mode != STp->current_mode) {
DEBC(printk(ST_DEB_MSG "st%d: Mode change from %d to %d.\n",
STp->in_use = 0;
if (STp->device->host->hostt->module)
__MOD_DEC_USE_COUNT(STp->device->host->hostt->module);
- if (st_template.module)
- __MOD_DEC_USE_COUNT(st_template.module);
return retval;
}
int dev;
dev = TAPE_NR(devt);
+ lock_kernel();
read_lock(&st_dev_arr_lock);
STp = scsi_tapes[dev];
read_unlock(&st_dev_arr_lock);
STp->in_use = 0;
if (STp->device->host->hostt->module)
__MOD_DEC_USE_COUNT(STp->device->host->hostt->module);
- if (st_template.module)
- __MOD_DEC_USE_COUNT(st_template.module);
+ unlock_kernel();
return result;
}
static struct file_operations st_fops =
{
+ owner: THIS_MODULE,
read: st_read,
write: st_write,
ioctl: st_ioctl,
#include <linux/poll.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/ds1286.h>
#include <asm/io.h>
static int ds1286_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
ds1286_status &= ~RTC_IS_OPEN;
+ unlock_kernel();
return 0;
}
#include <linux/mman.h>
#include <linux/malloc.h>
#include <linux/module.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include "gconsole.h"
#include "graphics.h"
int board = GRAPHICS_CARD (inode->i_rdev);
/* Tell the rendering manager that one client is going away */
+ lock_kernel();
rrm_close (inode, file);
/* Was this file handle from the board owner?, clear it */
(*cards [board].g_reset_console)();
enable_gconsole ();
}
+ unlock_kernel();
return 0;
}
size = vma->vm_end - vma->vm_start;
start = vma->vm_start;
+ lock_kernel();
mem = (unsigned long) shmiqs [minor].shmiq_vaddr = vmalloc_uncached (size);
- if (!mem)
+ if (!mem) {
+ unlock_kernel();
return -EINVAL;
+ }
/* Prevent the swapper from considering these pages for swap and touching them */
vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO);
shmiqs [minor].tail = 0;
/* Init the shared memory input queue */
memset (shmiqs [minor].shmiq_vaddr, 0, size);
+ unlock_kernel();
return error;
}
#include <linux/sched.h>
#include <linux/kbd_kern.h>
#include <linux/vt_kern.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/shmiq.h>
#include <asm/keyboard.h>
}
/* /dev/gfx device */
-static int
-sgi_gfx_open (struct inode *inode, struct file *file)
-{
- printk ("GFX: Opened by %d\n", current->pid);
- return 0;
-}
-
-static int
-sgi_gfx_close (struct inode *inode, struct file *file)
-{
- printk ("GFX: Closed by %d\n", current->pid);
- return 0;
-}
-
static int
sgi_gfx_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
struct file_operations sgi_gfx_fops = {
ioctl: sgi_gfx_ioctl,
- open: sgi_gfx_open,
- release: sgi_gfx_close,
};
static struct miscdevice dev_gfx = {
static int
sgi_mouse_close (struct inode *inode, struct file *filp)
{
+ lock_kernel();
mouse_opened = 0;
+ unlock_kernel();
return 0;
}
return 0;
}
-static int
-sgi_usemaclone_release(struct inode *inode, struct file *filp)
-{
- return 0;
-}
-
struct file_operations sgi_usemaclone_fops = {
poll: sgi_usemaclone_poll,
ioctl: sgi_usemaclone_ioctl,
open: sgi_usemaclone_open,
- release: sgi_usemaclone_release,
};
static struct miscdevice dev_usemaclone = {
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
{
struct cm_state *s = (struct cm_state *)file->private_data;
struct dmabuf *db;
- int ret;
+ int ret = -EINVAL;
unsigned long size;
VALIDATE_STATE(s);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf(s, 1)) != 0)
- return ret;
+ goto out;
db = &s->dma_dac;
} else if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf(s, 0)) != 0)
- return ret;
+ goto out;
db = &s->dma_adc;
} else
- return -EINVAL;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << db->buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
db->mapped = 1;
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int cm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct cm_state *s = (struct cm_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE) {
__set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&s->midi.owait, &wait);
spin_unlock_irqrestore(&s->lock, flags);
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
unsigned int regb;
VALIDATE_STATE(s);
+ lock_kernel();
down(&s->open_sem);
s->open_mode &= ~FMODE_DMFM;
for (regb = 0xb0; regb < 0xb9; regb++) {
}
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
#include <linux/sound.h>
#include <linux/init.h>
#include <linux/soundcard.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
static int mixer_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
mixer.busy = 0;
dmasound.mach.release();
+ unlock_kernel();
return 0;
}
static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd,
{
int rc = 0;
+ lock_kernel();
if (write_sq.busy)
rc = sq_fsync(file, file->f_dentry);
dmasound.soft = dmasound.dsp;
/* Wake up a process waiting for the queue being released.
* Note: There may be several processes waiting for a call
* to open() returning. */
+ unlock_kernel();
return rc;
}
static int state_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
state.busy = 0;
dmasound.mach.release();
+ unlock_kernel();
return 0;
}
#include "cardwi.h"
#include "recmgr.h"
#include "audio.h"
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
static void calculate_ofrag(struct woinst *);
static void calculate_ifrag(struct wiinst *);
if (vma_get_pgoff(vma) != 0)
return -ENXIO;
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
struct woinst *woinst = wave_dev->woinst;
struct wave_out *wave_out;
if (emu10k1_waveout_open(wave_dev) != CTSTATUS_SUCCESS) {
spin_unlock_irqrestore(&woinst->lock, flags);
ERROR();
+ unlock_kernel();
return -EINVAL;
}
if (size > (PAGE_SIZE * wave_out->wavexferbuf->numpages)) {
spin_unlock_irqrestore(&woinst->lock, flags);
+ unlock_kernel();
return -EINVAL;
}
for (i = 0; i < wave_out->wavexferbuf->numpages; i++) {
if (remap_page_range(vma->vm_start + (i * PAGE_SIZE), virt_to_phys(wave_out->pagetable[i]), PAGE_SIZE, vma->vm_page_prot)) {
spin_unlock_irqrestore(&woinst->lock, flags);
+ unlock_kernel();
return -EAGAIN;
}
}
wiinst->mapped = 1;
spin_unlock_irqrestore(&wiinst->lock, flags);
}
+ unlock_kernel();
return 0;
}
static int emu10k1_audio_release(struct inode *inode, struct file *file)
{
struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
- struct emu10k1_card *card = wave_dev->card;
+ struct emu10k1_card *card;
unsigned long flags;
+ lock_kernel();
+ card = wave_dev->card;
DPF(2, "emu10k1_audio_release()\n");
if (file->f_mode & FMODE_WRITE) {
kfree(wave_dev);
wake_up_interruptible(&card->open_wait);
+ unlock_kernel();
return 0;
}
#define __NO_VERSION__
#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include "hwaccess.h"
static int emu10k1_midi_release(struct inode *inode, struct file *file)
{
struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) file->private_data;
- struct emu10k1_card *card = midi_dev->card;
+ struct emu10k1_card *card;
+ lock_kernel();
+ card = midi_dev->card;
DPF(2, "emu10k1_midi_release()\n");
if (file->f_mode & FMODE_WRITE) {
card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE));
up(&card->open_sem);
wake_up_interruptible(&card->open_wait);
+ unlock_kernel();
return 0;
}
#include <linux/malloc.h>
#include <linux/soundcard.h>
#include <linux/pci.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/dma.h>
#include <linux/init.h>
unsigned long size;
VALIDATE_STATE(s);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
- if ((ret = prog_dmabuf_dac2(s)) != 0)
+ if ((ret = prog_dmabuf_dac2(s)) != 0) {
+ unlock_kernel();
return ret;
+ }
db = &s->dma_dac2;
} else if (vma->vm_flags & VM_READ) {
- if ((ret = prog_dmabuf_adc(s)) != 0)
+ if ((ret = prog_dmabuf_adc(s)) != 0) {
+ unlock_kernel();
return ret;
+ }
db = &s->dma_adc;
- } else
+ } else {
+ unlock_kernel();
return -EINVAL;
- if (vma->vm_pgoff != 0)
+ }
+ if (vma->vm_pgoff != 0) {
+ unlock_kernel();
return -EINVAL;
+ }
size = vma->vm_end - vma->vm_start;
- if (size > (PAGE_SIZE << db->buforder))
+ if (size > (PAGE_SIZE << db->buforder)) {
+ unlock_kernel();
return -EINVAL;
- if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+ }
+ if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+ unlock_kernel();
return -EAGAIN;
+ }
db->mapped = 1;
+ unlock_kernel();
return 0;
}
struct es1370_state *s = (struct es1370_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac2(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
wake_up(&s->open_wait);
up(&s->open_sem);
return 0;
+ unlock_kernel();
}
static /*const*/ struct file_operations es1370_audio_fops = {
VALIDATE_STATE(s);
if (!(vma->vm_flags & VM_WRITE))
return -EINVAL;
+ lock_kernel();
if ((ret = prog_dmabuf_dac1(s)) != 0)
- return ret;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << s->dma_dac1.buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
s->dma_dac1.mapped = 1;
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int es1370_ioctl_dac(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct es1370_state *s = (struct es1370_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
drain_dac1(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
stop_dac1(s);
s->open_mode &= ~FMODE_DAC;
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE) {
add_wait_queue(&s->midi.owait, &wait);
for (;;) {
spin_unlock_irqrestore(&s->lock, flags);
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
#include <linux/bitops.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <asm/io.h>
#include <asm/dma.h>
unsigned long size;
VALIDATE_STATE(s);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
- if ((ret = prog_dmabuf_dac2(s)) != 0)
+ if ((ret = prog_dmabuf_dac2(s)) != 0) {
+ unlock_kernel();
return ret;
+ }
db = &s->dma_dac2;
} else if (vma->vm_flags & VM_READ) {
- if ((ret = prog_dmabuf_adc(s)) != 0)
+ if ((ret = prog_dmabuf_adc(s)) != 0) {
+ unlock_kernel();
return ret;
+ }
db = &s->dma_adc;
- } else
+ } else {
+ unlock_kernel();
return -EINVAL;
- if (vma->vm_pgoff != 0)
+ }
+ if (vma->vm_pgoff != 0) {
+ unlock_kernel();
return -EINVAL;
+ }
size = vma->vm_end - vma->vm_start;
- if (size > (PAGE_SIZE << db->buforder))
+ if (size > (PAGE_SIZE << db->buforder)) {
+ unlock_kernel();
return -EINVAL;
- if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+ }
+ if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+ unlock_kernel();
return -EAGAIN;
+ }
db->mapped = 1;
+ unlock_kernel();
return 0;
}
struct es1371_state *s = (struct es1371_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac2(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
VALIDATE_STATE(s);
if (!(vma->vm_flags & VM_WRITE))
return -EINVAL;
+ lock_kernel();
if ((ret = prog_dmabuf_dac1(s)) != 0)
- return ret;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << s->dma_dac1.buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
s->dma_dac1.mapped = 1;
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int es1371_ioctl_dac(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct es1371_state *s = (struct es1371_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
drain_dac1(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
stop_dac1(s);
s->open_mode &= ~FMODE_DAC;
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
unsigned count, tmo;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE) {
add_wait_queue(&s->midi.owait, &wait);
for (;;) {
spin_unlock_irqrestore(&s->lock, flags);
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
{
struct solo1_state *s = (struct solo1_state *)file->private_data;
struct dmabuf *db;
- int ret;
+ int ret = -EINVAL;
unsigned long size;
VALIDATE_STATE(s);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf_dac(s)) != 0)
- return ret;
+ goto out;
db = &s->dma_dac;
} else if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf_adc(s)) != 0)
- return ret;
+ goto out;
db = &s->dma_adc;
} else
- return -EINVAL;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << db->buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
db->mapped = 1;
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int solo1_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct solo1_state *s = (struct solo1_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
s->open_mode &= ~(FMODE_READ | FMODE_WRITE);
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE) {
add_wait_queue(&s->midi.owait, &wait);
for (;;) {
spin_unlock_irqrestore(&s->lock, flags);
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
unsigned int regb;
VALIDATE_STATE(s);
+ lock_kernel();
down(&s->open_sem);
s->open_mode &= ~FMODE_DMFM;
for (regb = 0xb0; regb < 0xb9; regb++) {
release_region(s->sbbase, FMSYNTH_EXTENT);
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
{
struct i810_state *state = (struct i810_state *)file->private_data;
struct dmabuf *dmabuf = &state->dmabuf;
- int ret;
+ int ret = -EINVAL;
unsigned long size;
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf(state, 0)) != 0)
- return ret;
+ goto out;
} else if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf(state, 1)) != 0)
- return ret;
+ goto out;
} else
- return -EINVAL;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << dmabuf->buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(dmabuf->rawbuf),
size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
dmabuf->mapped = 1;
-
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int i810_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct i810_state *state = (struct i810_state *)file->private_data;
struct dmabuf *dmabuf = &state->dmabuf;
+ lock_kernel();
if (file->f_mode & FMODE_WRITE) {
i810_clear_tail(state);
drain_dac(state, file->f_flags & O_NONBLOCK);
kfree(state->card->states[state->virt]);
state->card->states[state->virt] = NULL;
+ unlock_kernel();
return 0;
}
#include <linux/version.h>
#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
{
struct ess_state *s = (struct ess_state *)file->private_data;
struct dmabuf *db;
- int ret;
+ int ret = -EINVAL;
unsigned long size;
VALIDATE_STATE(s);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf(s, 1)) != 0)
- return ret;
+ goto out;
db = &s->dma_dac;
} else
#if 0
we can turn this back on. */
if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf(s, 0)) != 0)
- return ret;
+ goto out;
db = &s->dma_adc;
} else
#endif
- return -EINVAL;
+ goto out;
+ ret = -EINVAL;
if (SILLY_OFFSET(vma) != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << db->buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
db->mapped = 1;
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct ess_state *s = (struct ess_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
}
up(&s->open_sem);
wake_up(&s->open_wait);
+ unlock_kernel();
return 0;
}
# define inb inb_p
#endif
-#ifdef LINUX20
-# define __initfunc(f) f
-# define __initdata /* nothing */
-# define spin_lock_irqsave(junk,flags) do { save_flags(flags); cli(); } while (0)
-# define spin_unlock_irqrestore(junk,flags) do { restore_flags(flags); } while (0)
-#endif
-
/* JobQueueStruct */
#define JQS_wStart 0x00
#define JQS_wSize 0x02
wait_queue_head_t writeblock;
wait_queue_head_t readblock;
wait_queue_head_t writeflush;
-#ifndef LINUX20
spinlock_t lock;
-#endif
int nresets;
unsigned long recsrc;
int left_levels[16];
int rec_sample_size, rec_sample_rate, rec_channels;
int rec_ndelay;
BYTE bCurrentMidiPatch;
- void (*inc_ref)(void);
- void (*dec_ref)(void);
/* Digital audio FIFOs */
msnd_fifo DAPF, DARF;
#include <linux/config.h>
#include <linux/version.h>
-#if LINUX_VERSION_CODE < 0x020101
-# define LINUX20
-#endif
#include <linux/module.h>
#include <linux/malloc.h>
#include <linux/types.h>
#include <linux/delay.h>
-#ifndef LINUX20
-# include <linux/init.h>
-#endif
+#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/irq.h>
#include <asm/io.h>
#include "sound_config.h"
set_default_rec_audio_parameters();
}
-static void mod_inc_ref(void)
-{
- MOD_INC_USE_COUNT;
-}
-
-static void mod_dec_ref(void)
-{
- MOD_DEC_USE_COUNT;
-}
-
static int dev_open(struct inode *inode, struct file *file)
{
int minor = MINOR(inode->i_rdev);
} else
err = -EINVAL;
- if (err >= 0)
- mod_inc_ref();
-
return err;
}
-#ifdef LINUX20
-static void dev_release(struct inode *inode, struct file *file)
-#else
static int dev_release(struct inode *inode, struct file *file)
-#endif
{
int minor = MINOR(inode->i_rdev);
-#ifndef LINUX20
int err = 0;
-#endif
- if (minor == dev.dsp_minor) {
-#ifndef LINUX20
- err =
-#endif
- dsp_release(file);
- }
+ lock_kernel();
+ if (minor == dev.dsp_minor)
+ err = dsp_release(file);
else if (minor == dev.mixer_minor) {
/* nothing */
- }
-#ifndef LINUX20
- else
+ } else
err = -EINVAL;
-
- if (err >= 0)
-#endif
- mod_dec_ref();
-
-#ifndef LINUX20
+ unlock_kernel();
return err;
-#endif
}
static __inline__ int pack_DARQ_to_DARF(register int bank)
return len - count;
}
-#ifdef LINUX20
-static int dev_read(struct inode *inode, struct file *file, char *buf, int count)
-{
- int minor = MINOR(inode->i_rdev);
-#else
static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *off)
{
int minor = MINOR(file->f_dentry->d_inode->i_rdev);
-#endif
if (minor == dev.dsp_minor)
return dsp_read(buf, count);
else
return -EINVAL;
}
-#ifdef LINUX20
-static int dev_write(struct inode *inode, struct file *file, const char *buf, int count)
-{
- int minor = MINOR(inode->i_rdev);
-#else
static ssize_t dev_write(struct file *file, const char *buf, size_t count, loff_t *off)
{
int minor = MINOR(file->f_dentry->d_inode->i_rdev);
-#endif
if (minor == dev.dsp_minor)
return dsp_write(buf, count);
else
if (pack_DAPF_to_DAPQ(0) <= 0) {
if (!test_bit(F_WRITEBLOCK, &dev.flags)) {
-#ifdef LINUX20
- if (test_bit(F_WRITEFLUSH, &dev.flags)) {
- clear_bit(F_WRITEFLUSH, &dev.flags);
- wake_up_interruptible(&dev.writeflush);
- }
-#else
if (test_and_clear_bit(F_WRITEFLUSH, &dev.flags))
wake_up_interruptible(&dev.writeflush);
-#endif
}
clear_bit(F_WRITING, &dev.flags);
}
}
static struct file_operations dev_fileops = {
+ owner: THIS_MODULE,
read: dev_read,
write: dev_write,
ioctl: dev_ioctl,
dev.recsrc = 0;
dev.dspq_data_buff = DSPQ_DATA_BUFF;
dev.dspq_buff_size = DSPQ_BUFF_SIZE;
- dev.inc_ref = mod_inc_ref;
- dev.dec_ref = mod_dec_ref;
if (write_ndelay == -1)
write_ndelay = CONFIG_MSND_WRITE_NDELAY;
if (write_ndelay)
init_waitqueue_head(&dev.writeflush);
msnd_fifo_init(&dev.DAPF);
msnd_fifo_init(&dev.DARF);
-#ifndef LINUX20
spin_lock_init(&dev.lock);
-#endif
printk(KERN_INFO LOGNAME ": %u byte audio FIFOs (x2)\n", dev.fifosize);
if ((err = msnd_fifo_alloc(&dev.DAPF, dev.fifosize)) < 0) {
printk(KERN_ERR LOGNAME ": Couldn't allocate write FIFO\n");
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
{
struct sv_state *s = (struct sv_state *)file->private_data;
struct dmabuf *db;
- int ret;
+ int ret = -EINVAL;
unsigned long size;
VALIDATE_STATE(s);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf(s, 1)) != 0)
- return ret;
+ goto out;
db = &s->dma_dac;
} else if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf(s, 0)) != 0)
- return ret;
+ goto out;
db = &s->dma_adc;
} else
- return -EINVAL;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << db->buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
db->mapped = 1;
- return 0;
+ ret = 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
struct sv_state *s = (struct sv_state *)file->private_data;
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem);
s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
VALIDATE_STATE(s);
+ lock_kernel();
if (file->f_mode & FMODE_WRITE) {
add_wait_queue(&s->midi.owait, &wait);
for (;;) {
spin_unlock_irqrestore(&s->lock, flags);
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
unsigned int regb;
VALIDATE_STATE(s);
+ lock_kernel();
down(&s->open_sem);
s->open_mode &= ~FMODE_DMFM;
for (regb = 0xb0; regb < 0xb9; regb++) {
}
wake_up(&s->open_wait);
up(&s->open_sem);
+ unlock_kernel();
return 0;
}
{
int dev = MINOR(inode->i_rdev);
+ lock_kernel();
DEB(printk("sound_release(dev=%d)\n", dev));
switch (dev & 0x0f) {
case SND_DEV_CTL:
notifier_call_chain(&sound_locker, 0, 0);
lock_depth--;
+ unlock_kernel();
return 0;
}
printk(KERN_ERR "Sound: mmap() not supported for other than audio devices\n");
return -EINVAL;
}
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) /* Map write and read/write to the output buf */
dmap = audio_devs[dev]->dmap_out;
else if (vma->vm_flags & VM_READ)
dmap = audio_devs[dev]->dmap_in;
else {
printk(KERN_ERR "Sound: Undefined mmap() access\n");
+ unlock_kernel();
return -EINVAL;
}
if (dmap == NULL) {
printk(KERN_ERR "Sound: mmap() error. dmap == NULL\n");
+ unlock_kernel();
return -EIO;
}
if (dmap->raw_buf == NULL) {
printk(KERN_ERR "Sound: mmap() called when raw_buf == NULL\n");
+ unlock_kernel();
return -EIO;
}
if (dmap->mapping_flags) {
printk(KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n");
+ unlock_kernel();
return -EIO;
}
if (vma->vm_pgoff != 0) {
printk(KERN_ERR "Sound: mmap() offset must be 0.\n");
+ unlock_kernel();
return -EINVAL;
}
size = vma->vm_end - vma->vm_start;
}
if (remap_page_range(vma->vm_start, virt_to_phys(dmap->raw_buf),
vma->vm_end - vma->vm_start,
- vma->vm_page_prot))
+ vma->vm_page_prot)) {
+ unlock_kernel();
return -EAGAIN;
+ }
dmap->mapping_flags |= DMA_MAP_MAPPED;
memset(dmap->raw_buf,
dmap->neutral_byte,
dmap->bytes_in_use);
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
{
struct trident_state *state = (struct trident_state *)file->private_data;
struct dmabuf *dmabuf = &state->dmabuf;
- int ret;
+ int ret = -EINVAL;
unsigned long size;
VALIDATE_STATE(state);
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf(state, 0)) != 0)
- return ret;
+ goto out;
} else if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf(state, 1)) != 0)
- return ret;
- } else
- return -EINVAL;
+ goto out;
+ } else
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << dmabuf->buforder))
- return -EINVAL;
+ goto out;
+ ret = -EAGAIN;
if (remap_page_range(vma->vm_start, virt_to_phys(dmabuf->rawbuf),
size, vma->vm_page_prot))
- return -EAGAIN;
+ goto out;
dmabuf->mapped = 1;
-
- return 0;
+ ret = 0;
+out;
+ unlock_kernel();
+ return ret;
}
static int trident_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static int trident_release(struct inode *inode, struct file *file)
{
struct trident_state *state = (struct trident_state *)file->private_data;
- struct trident_card *card = state->card;
- struct dmabuf *dmabuf = &state->dmabuf;
+ struct trident_card *card;
+ struct dmabuf *dmabuf;
+ lock_kernel();
+ card = state->card;
+ dmabuf = &state->dmabuf;
VALIDATE_STATE(state);
if (file->f_mode & FMODE_WRITE) {
/* we're covered by the open_sem */
up(&card->open_sem);
+ unlock_kernel();
return 0;
}
#include <linux/poll.h>
#include <linux/soundcard.h>
#include <linux/ac97_codec.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
card = file->private_data;
assert (card != NULL);
+ lock_kernel();
if (file->f_mode & FMODE_READ)
via_chan_free (card, &card->ch_in);
spin_unlock_irqrestore (&card->lock, flags);
wake_up (&card->open_wait);
+ unlock_kernel();
DPRINTK("EXIT, returning 0\n");
return 0;
* Locking Notes
*
* INC_USE_COUNT and DEC_USE_COUNT keep track of the number of
- * open descriptors to this driver. When the driver is compiled
- * as a module, they call MOD_{INC,DEC}_USE_COUNT; otherwise they
- * bump vwsnd_use_count. The global device list, vwsnd_dev_list,
- * is immutable when the IN_USE is true.
+ * open descriptors to this driver. They store it in vwsnd_use_count.
+ * The global device list, vwsnd_dev_list, is immutable when the IN_USE
+ * is true.
*
* devc->open_lock is a semaphore that is used to enforce the
* single reader/single writer rule for /dev/audio. The rule is
#include <linux/module.h>
#include <linux/stddef.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <asm/fixmap.h>
#include <asm/cobalt.h>
#include <asm/semaphore.h>
static vwsnd_dev_t *vwsnd_dev_list; /* linked list of all devices */
-#ifdef MODULE
-
-# define INC_USE_COUNT MOD_INC_USE_COUNT
-# define DEC_USE_COUNT MOD_DEC_USE_COUNT
-# define IN_USE MOD_IN_USE
-
-#else
-
static atomic_t vwsnd_use_count = ATOMIC_INIT(0);
# define INC_USE_COUNT (atomic_inc(&vwsnd_use_count))
# define DEC_USE_COUNT (atomic_dec(&vwsnd_use_count))
# define IN_USE (atomic_read(&vwsnd_use_count) != 0)
-#endif
-
/*
* Lithium can only DMA multiples of 32 bytes. Its DMA buffer may
* be up to 8 Kb. This driver always uses 8 Kb.
vwsnd_port_t *wport = NULL, *rport = NULL;
int err = 0;
+ lock_kernel();
down(&devc->io_sema);
{
DBGEV("(inode=0x%p, file=0x%p)\n", inode, file);
}
up(&devc->open_sema);
wake_up(&devc->open_wait);
- DBGDO(if (IN_USE)) /* see hack in vwsnd_mixer_release() */
- DEC_USE_COUNT;
+ DEC_USE_COUNT;
DBGR();
+ unlock_kernel();
return err;
}
static struct file_operations vwsnd_audio_fops = {
+ owner: THIS_MODULE,
llseek: vwsnd_audio_llseek,
read: vwsnd_audio_read,
write: vwsnd_audio_write,
static int vwsnd_mixer_release(struct inode *inode, struct file *file)
{
DBGEV("(inode=0x%p, file=0x%p)\n", inode, file);
-
- /*
- * hack -- opening/closing the mixer device zeroes use count
- * so driver can be unloaded.
- * Use only while debugging module, and then use it carefully.
- */
-
- DBGDO(while (IN_USE))
- DEC_USE_COUNT;
+ DEC_USE_COUNT;
return 0;
}
}
static struct file_operations vwsnd_mixer_fops = {
+ owner: THIS_MODULE,
llseek: vwsnd_mixer_llseek,
ioctl: vwsnd_mixer_ioctl,
open: vwsnd_mixer_open,
DBGE("()\n");
- if (IN_USE)
- return -EBUSY;
devcp = &vwsnd_dev_list;
while ((devc = *devcp)) {
if (devc->audio_minor == hw_config->slots[0]) {
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/ptrace.h>
#include <linux/fcntl.h>
#include <linux/ioport.h>
static int
wavefront_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
dev.opened = 0;
dev.debug = 0;
+ unlock_kernel();
return 0;
}
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/pci.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/segment.h>
if (ixjdebug > 0)
printk(KERN_INFO "Closing board %d\n", NUM(inode->i_rdev));
+ lock_kernel();
daa_set_mode(board, SOP_PU_SLEEP);
ixj_set_port(board, PORT_POTS);
aec_stop(board);
j->rec_frame_size = j->play_frame_size = 0;
ixj_fasync(-1, file_p, 0); // remove from list of async notification
+ unlock_kernel();
return 0;
}
comment 'USB Devices'
dep_tristate ' USB Printer support' CONFIG_USB_PRINTER $CONFIG_USB
dep_tristate ' USB Scanner support' CONFIG_USB_SCANNER $CONFIG_USB
+ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+ dep_tristate ' Microtek X6USB scanner support (EXPERIMENTAL)' CONFIG_USB_MICROTEK $CONFIG_USB $CONFIG_SCSI
+ fi
dep_tristate ' USB Audio support' CONFIG_USB_AUDIO $CONFIG_USB $CONFIG_SOUND
dep_tristate ' USB Modem (CDC ACM) support' CONFIG_USB_ACM $CONFIG_USB
dep_tristate ' USB Serial Converter support' CONFIG_USB_SERIAL $CONFIG_USB
dep_tristate ' USB ADMtek Pegasus-based device support (EXPERIMENTAL)' CONFIG_USB_PEGASUS $CONFIG_USB $CONFIG_NET
dep_tristate ' USB Diamond Rio500 support (EXPERIMENTAL)' CONFIG_USB_RIO500 $CONFIG_USB
dep_tristate ' D-Link USB FM radio support (EXPERIMENTAL)' CONFIG_USB_DSBR $CONFIG_USB $CONFIG_VIDEO_DEV
- dep_tristate ' Microtek X6USB scanner support (EXPERIMENTAL)' CONFIG_USB_MICROTEK $CONFIG_USB $CONFIG_SCSI
dep_tristate ' USB Bluetooth support (EXPERIMENTAL)' CONFIG_USB_BLUETOOTH $CONFIG_USB
fi
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/module.h>
#include <linux/sound.h>
#include <linux/soundcard.h>
static int usb_audio_release_mixdev(struct inode *inode, struct file *file)
{
struct usb_mixerdev *ms = (struct usb_mixerdev *)file->private_data;
- struct usb_audio_state *s = ms->state;
+ struct usb_audio_state *s;
+ lock_kernel();
+ s = ms->state;
down(&open_sem);
release(s);
+ unlock_kernel();
return 0;
}
{
struct usb_audiodev *as = (struct usb_audiodev *)file->private_data;
struct dmabuf *db;
- int ret;
+ int ret = -EINVAL;
+ lock_kernel();
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf_out(as)) != 0)
- return ret;
+ goto out;
db = &as->usbout.dma;
} else if (vma->vm_flags & VM_READ) {
if ((ret = prog_dmabuf_in(as)) != 0)
- return ret;
+ goto out;
db = &as->usbin.dma;
} else
- return -EINVAL;
+ goto out;
+ ret = -EINVAL;
if (vma->vm_pgoff != 0)
- return -EINVAL;
+ goto out;
- return dmabuf_mmap(db, vma->vm_start, vma->vm_end - vma->vm_start, vma->vm_page_prot);
+ ret = dmabuf_mmap(db, vma->vm_start, vma->vm_end - vma->vm_start, vma->vm_page_prot);
+out:
+ unlock_kernel();
+ return ret;
}
static int usb_audio_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static int usb_audio_release(struct inode *inode, struct file *file)
{
struct usb_audiodev *as = (struct usb_audiodev *)file->private_data;
- struct usb_audio_state *s = as->state;
- struct usb_device *dev = s->usbdev;
+ struct usb_audio_state *s;
+ struct usb_device *dev;
struct usb_interface *iface;
+ lock_kernel();
+ s = as->state;
+ dev = s->usbdev;
if (file->f_mode & FMODE_WRITE)
drain_out(as, file->f_flags & O_NONBLOCK);
down(&open_sem);
as->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
release(s);
wake_up(&open_wait);
+ unlock_kernel();
return 0;
}
#include <asm/atomic.h>
#include <linux/delay.h>
#include <linux/usb.h>
+#include <linux/smp_lock.h>
#include "dabusb.h"
#include "dabfirmware.h"
dbg("dabusb_release");
+ lock_kernel();
down (&s->mutex);
dabusb_stop (s);
dabusb_free_buffers (s);
wake_up (&s->remove_ok);
s->opened = 0;
+ unlock_kernel();
return 0;
}
#include <linux/module.h>
#undef DEBUG
#include <linux/usb.h>
+#include <linux/smp_lock.h>
kfree (camera->buf);
/* If camera was unplugged with open file ... */
+ lock_kernel();
if (!camera->dev) {
minor_data [camera->subminor] = NULL;
kfree (camera);
}
+ unlock_kernel();
dbg ("close");
#include <linux/module.h>
#include <linux/init.h>
#include <linux/input.h>
+#include <linux/smp_lock.h>
struct evdev {
int exist;
static int evdev_release(struct inode * inode, struct file * file)
{
struct evdev_list *list = file->private_data;
- struct evdev_list **listptr = &list->evdev->list;
+ struct evdev_list **listptr;
+ lock_kernel();
+ listptr = &list->evdev->list;
evdev_fasync(-1, file, 0);
while (*listptr && (*listptr != list))
}
kfree(list);
+ unlock_kernel();
return 0;
}
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#define JOYDEV_MINOR_BASE 0
#define JOYDEV_MINORS 32
static int joydev_release(struct inode * inode, struct file * file)
{
struct joydev_list *list = file->private_data;
- struct joydev_list **listptr = &list->joydev->list;
+ struct joydev_list **listptr;
+ lock_kernel();
+ listptr = &list->joydev->list;
joydev_fasync(-1, file, 0);
while (*listptr && (*listptr != list))
}
kfree(list);
+ unlock_kernel();
return 0;
}
#include <linux/init.h>
#include <linux/malloc.h>
#include <linux/module.h>
+#include <linux/smp_lock.h>
#include <linux/usb.h>
int retval=0;
dbg ("Mustek MDC800 device closed.");
+ lock_kernel();
if (mdc800->open && (mdc800->state != NOT_CONNECTED))
{
mdc800->open=0;
{
retval=-EIO;
}
+ unlock_kernel();
return retval;
}
#include <linux/init.h>
#include <linux/input.h>
#include <linux/config.h>
+#include <linux/smp_lock.h>
#ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_X
#define CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024
static int mousedev_release(struct inode * inode, struct file * file)
{
struct mousedev_list *list = file->private_data;
- struct mousedev_list **listptr = &list->mousedev->list;
+ struct mousedev_list **listptr;
+ lock_kernel();
+ listptr = &list->mousedev->list;
mousedev_fasync(-1, file, 0);
while (*listptr && (*listptr != list))
}
kfree(list);
+ unlock_kernel();
return 0;
}
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/signal.h>
#include <linux/poll.h>
#include <linux/init.h>
if (minor < 0 || minor >= USBLP_MINORS)
return -ENODEV;
+ lock_kernel();
usblp = usblp_table[minor];
+ retval = -ENODEV;
if (!usblp || !usblp->dev)
- return -ENODEV;
+ goto out;
+ retval = -EBUSY;
if (usblp->used)
- return -EBUSY;
+ goto out;
- if ((retval = usblp_check_status(usblp))) {
- return retval;
- }
+ if ((retval = usblp_check_status(usblp)))
+ goto out;
usblp->used = 1;
file->private_data = usblp;
usblp->readcount = 0;
usb_submit_urb(&usblp->readurb);
}
-
- return 0;
+out:
+ unlock_kernel();
+ return retval;
}
static int usblp_release(struct inode *inode, struct file *file)
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/malloc.h>
off = vma->vm_pgoff << PAGE_SHIFT;
if (!fb)
return -ENODEV;
- if (fb->fb_mmap)
- return fb->fb_mmap(info, file, vma);
+ if (fb->fb_mmap) {
+ int res;
+ lock_kernel();
+ res = fb->fb_mmap(info, file, vma);
+ unlock_kernel();
+ return res;
+ }
#if defined(__sparc__) && !defined(__sparc_v9__)
/* Should never get here, all fb drivers should have their own
#else
/* !sparc32... */
+ lock_kernel();
fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
/* frame buffer memory */
start = fix.mmio_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len);
}
+ unlock_kernel();
start &= PAGE_MASK;
if ((vma->vm_end - vma->vm_start + off) > len)
return -EINVAL;
fb_release(struct inode *inode, struct file *file)
{
int fbidx = GET_FB_IDX(inode->i_rdev);
- struct fb_info *info = registered_fb[fbidx];
+ struct fb_info *info;
+ lock_kernel();
+ info = registered_fb[fbidx];
if (info->fbops->fb_release)
info->fbops->fb_release(info,1);
if (info->fbops->owner)
__MOD_DEC_USE_COUNT(info->fbops->owner);
+ unlock_kernel();
return 0;
}
kdev_t rdev = to_kdev_t(bdev->bd_dev); /* this should become bdev */
down(&bdev->bd_sem);
/* syncing will go here */
+ lock_kernel();
if (kind == BDEV_FILE || kind == BDEV_FS)
fsync_dev(rdev);
if (atomic_dec_and_test(&bdev->bd_openers)) {
if (!atomic_read(&bdev->bd_openers))
bdev->bd_op = NULL; /* we can't rely on driver being */
/* kind to stay around. */
+ unlock_kernel();
up(&bdev->bd_sem);
return ret;
}
unsigned short cflags = coda_flags_to_cflags(flags);
struct coda_cred *cred;
+ lock_kernel();
ENTRY;
coda_vfs_stat.release++;
CODA_FREE(cred, sizeof(*cred));
CDEBUG(D_FILE, "coda_release: result: %d\n", error);
+ unlock_kernel();
return error;
}
#include <linux/locks.h>
#include <asm/segment.h>
#include <linux/string.h>
+#define __NO_VERSION__
+#include <linux/module.h>
#include <asm/uaccess.h>
#include <linux/coda.h>
/* pioctl ops */
static int coda_ioctl_permission(struct inode *inode, int mask);
-static int coda_ioctl_open(struct inode *i, struct file *f);
-static int coda_ioctl_release(struct inode *i, struct file *f);
static int coda_pioctl(struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg);
};
struct file_operations coda_ioctl_operations = {
+ owner: THIS_MODULE,
ioctl: coda_pioctl,
- open: coda_ioctl_open,
- release: coda_ioctl_release,
};
/* the coda pioctl inode ops */
return 0;
}
-/* The pioctl file ops*/
-int coda_ioctl_open(struct inode *i, struct file *f)
-{
- ENTRY;
-
- CDEBUG(D_PIOCTL, "File inode number: %ld\n",
- f->f_dentry->d_inode->i_ino);
-
- EXIT;
- return 0;
-}
-
-int coda_ioctl_release(struct inode *i, struct file *f)
-{
- return 0;
-}
-
-
static int coda_pioctl(struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long user_data)
{
ENTRY;
/* first opener, initialize */
+ lock_kernel();
if (!vcp->vc_inuse++) {
INIT_LIST_HEAD(&vcp->vc_pending);
INIT_LIST_HEAD(&vcp->vc_processing);
CDEBUG(D_PSDEV, "inuse: %d\n", vcp->vc_inuse);
EXIT;
+ unlock_kernel();
return 0;
}
struct list_head *lh, *next;
ENTRY;
+ lock_kernel();
if ( !vcp->vc_inuse ) {
+ unlock_kernel();
printk("psdev_release: Not open.\n");
return -1;
}
CDEBUG(D_PSDEV, "psdev_release: inuse %d\n", vcp->vc_inuse);
- if (--vcp->vc_inuse) return 0;
+ if (--vcp->vc_inuse) {
+ unlock_kernel();
+ return 0;
+ }
/* Wakeup clients so they can return. */
CDEBUG(D_PSDEV, "wake up pending clients\n");
CDEBUG(D_PSDEV, "Done.\n");
EXIT;
+ unlock_kernel();
return 0;
}
{
struct fs_info *fs_info = inode->i_sb->u.generic_sbp;
- if (fs_info->devfsd_file != file) return 0;
+ lock_kernel();
+ if (fs_info->devfsd_file != file)
+ {
+ unlock_kernel();
+ return 0;
+ }
fs_info->devfsd_event_mask = 0;
fs_info->devfsd_file = NULL;
if (fs_info->devfsd_buffer)
fs_info->devfsd_buffer = NULL;
fs_info->devfsd_task = NULL;
wake_up (&fs_info->revalidate_wait_queue);
+ unlock_kernel();
return 0;
} /* End Function devfsd_close */
#include <linux/fs.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
static loff_t ext2_file_lseek(struct file *, loff_t, int);
static int ext2_open_file (struct inode *, struct file *);
*/
static int ext2_release_file (struct inode * inode, struct file * filp)
{
- if (filp->f_mode & FMODE_WRITE)
+ if (filp->f_mode & FMODE_WRITE) {
+ lock_kernel();
ext2_discard_prealloc (inode);
+ unlock_kernel();
+ }
return 0;
}
struct vfsmount * mnt = filp->f_vfsmnt;
struct inode * inode = dentry->d_inode;
- if (filp->f_op && filp->f_op->release) {
- lock_kernel();
+ if (filp->f_op && filp->f_op->release)
filp->f_op->release(inode, filp);
- unlock_kernel();
- }
fops_put(filp->f_op);
filp->f_dentry = NULL;
filp->f_vfsmnt = NULL;
*/
#include "hpfs_fn.h"
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
int hpfs_dir_release(struct inode *inode, struct file *filp)
{
+ lock_kernel();
hpfs_del_pos(inode, &filp->f_pos);
/*hpfs_write_if_changed(inode);*/
+ unlock_kernel();
return 0;
}
int hpfs_file_release(struct inode *inode, struct file *file)
{
+ lock_kernel();
hpfs_write_if_changed(inode);
+ unlock_kernel();
return 0;
}
int nfs_release(struct inode *inode, struct file *filp)
{
- struct rpc_auth *auth = NFS_CLIENT(inode)->cl_auth;
- struct rpc_cred *cred = nfs_file_cred(filp);
+ struct rpc_auth *auth;
+ struct rpc_cred *cred;
+ lock_kernel();
+ auth = NFS_CLIENT(inode)->cl_auth;
+ cred = nfs_file_cred(filp);
if (cred)
rpcauth_releasecred(auth, cred);
+ unlock_kernel();
return 0;
}
if (err)
goto out_nfserr;
if (EX_ISSYNC(fhp->fh_export))
- write_inode_now(inode, 0);
+ write_inode_now(inode, 1);
err = 0;
out:
return err;
if (EX_ISSYNC(fhp->fh_export)) {
nfsd_sync_dir(dentry);
- write_inode_now(dchild->d_inode, 0);
+ write_inode_now(dchild->d_inode, 1);
}
| S_IFLNK;
err = notify_change(dnew, iap);
if (!err && EX_ISSYNC(fhp->fh_export))
- write_inode_now(dentry->d_inode, 0);
+ write_inode_now(dentry->d_inode, 1);
}
}
} else
if (!err) {
if (EX_ISSYNC(ffhp->fh_export)) {
nfsd_sync_dir(ddir);
- write_inode_now(dest, 0);
+ write_inode_now(dest, 1);
}
} else {
if (err == -EXDEV && rqstp->rq_vers == 2)
#include <linux/locks.h>
#include <linux/init.h>
#include <linux/malloc.h>
+#include <linux/smp_lock.h>
#include <asm/openprom.h>
#include <asm/oplib.h>
if (!op)
return 0;
+ lock_kernel();
node = nodes[(u16)((long)inode->u.generic_ip)].node;
if ((u16)((long)inode->u.generic_ip) == aliases) {
if ((op->flag & OPP_DIRTY) && (op->flag & OPP_STRING)) {
op->name);
}
}
+ unlock_kernel();
kfree (filp->private_data);
return 0;
}
pipe_release(struct inode *inode, int decr, int decw)
{
down(PIPE_SEM(*inode));
+ lock_kernel();
PIPE_READERS(*inode) -= decr;
PIPE_WRITERS(*inode) -= decw;
if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
} else {
wake_up_interruptible(PIPE_WAIT(*inode));
}
+ unlock_kernel();
up(PIPE_SEM(*inode));
return 0;
static int
smb_file_release(struct inode *inode, struct file * file)
{
+ lock_kernel();
if (!--inode->u.smbfs_i.openers)
smb_close(inode);
+ unlock_kernel();
return 0;
}
#include <linux/string.h> /* memset */
#include <linux/errno.h>
#include <linux/locks.h>
+#include <linux/smp_lock.h>
#include "udf_i.h"
#include "udf_sb.h"
*/
static int udf_release_file(struct inode * inode, struct file * filp)
{
- if (filp->f_mode & FMODE_WRITE)
+ if (filp->f_mode & FMODE_WRITE) {
+ lock_kernel();
udf_discard_prealloc(inode);
+ unlock_kernel();
+ }
return 0;
}
extern void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size);
extern void register_disk(struct gendisk *dev, kdev_t first, unsigned minors, struct block_device_operations *ops, long size);
extern void generic_unplug_device(void *data);
-extern int generic_make_request(request_queue_t *q, int rw,
+extern void generic_make_request(request_queue_t *q, int rw,
struct buffer_head * bh);
extern request_queue_t *blk_get_queue(kdev_t dev);
extern void blkdev_release_request(struct request *);
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
+#include <linux/smp_lock.h>
#include <asm/segment.h>
{
IRDA_DEBUG( 4, __FUNCTION__ "()\n");
+ lock_kernel();
if (irda.in_use) {
+ unlock_kernel();
IRDA_DEBUG(0, __FUNCTION__
"(), irmanager is already running!\n");
return -1;
}
irda.in_use = TRUE;
+ unlock_kernel();
return 0;
}
{
IRDA_DEBUG(4, __FUNCTION__ "()\n");
+ lock_kernel();
irda.in_use = FALSE;
+ unlock_kernel();
return 0;
}
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
static int netlink_release(struct inode * inode, struct file * file)
{
unsigned int minor = MINOR(inode->i_rdev);
- struct socket *sock = netlink_user[minor];
+ struct socket *sock;
+ lock_kernel();
+ sock = netlink_user[minor];
netlink_user[minor] = NULL;
open_map &= ~(1<<minor);
+ unlock_kernel();
sock_release(sock);
return 0;
}
printk(KERN_DEBUG "sock_close: NULL inode\n");
return 0;
}
- unlock_kernel();
sock_fasync(-1, filp, 0);
sock_release(socki_lookup(inode));
- lock_kernel();
return 0;
}