Merge commit 'v2.6.26' into bkl-removal
authorJonathan Corbet <corbet@lwn.net>
Mon, 14 Jul 2008 21:29:34 +0000 (15:29 -0600)
committerJonathan Corbet <corbet@lwn.net>
Mon, 14 Jul 2008 21:29:34 +0000 (15:29 -0600)
30 files changed:
1  2 
block/bsg.c
drivers/char/agp/frontend.c
drivers/char/drm/drm_fops.c
drivers/char/ip2/ip2main.c
drivers/char/ipmi/ipmi_watchdog.c
drivers/char/rtc.c
drivers/char/tty_io.c
drivers/char/viotape.c
drivers/infiniband/core/user_mad.c
drivers/infiniband/core/uverbs_main.c
drivers/isdn/hardware/eicon/divasmain.c
drivers/isdn/i4l/isdn_common.c
drivers/macintosh/smu.c
drivers/media/video/videodev.c
drivers/net/tun.c
drivers/s390/char/vmlogrdr.c
drivers/sbus/char/bpp.c
drivers/scsi/3w-9xxx.c
drivers/scsi/ch.c
drivers/scsi/osst.c
drivers/scsi/sg.c
drivers/scsi/st.c
drivers/spi/spidev.c
drivers/uio/uio.c
fs/cifs/cifsfs.c
fs/fat/file.c
fs/nfs/file.c
fs/ocfs2/stack_user.c
include/linux/fs.h
sound/core/sound.c

diff --combined block/bsg.c
@@@ -19,7 -19,6 +19,7 @@@
  #include <linux/uio.h>
  #include <linux/idr.h>
  #include <linux/bsg.h>
 +#include <linux/smp_lock.h>
  
  #include <scsi/scsi.h>
  #include <scsi/scsi_ioctl.h>
@@@ -710,11 -709,12 +710,12 @@@ static void bsg_kref_release_function(s
  {
        struct bsg_class_device *bcd =
                container_of(kref, struct bsg_class_device, ref);
+       struct device *parent = bcd->parent;
  
        if (bcd->release)
                bcd->release(bcd->parent);
  
-       put_device(bcd->parent);
+       put_device(parent);
  }
  
  static int bsg_put_device(struct bsg_device *bd)
@@@ -835,11 -835,7 +836,11 @@@ static struct bsg_device *bsg_get_devic
  
  static int bsg_open(struct inode *inode, struct file *file)
  {
 -      struct bsg_device *bd = bsg_get_device(inode, file);
 +      struct bsg_device *bd;
 +
 +      lock_kernel();
 +      bd = bsg_get_device(inode, file);
 +      unlock_kernel();
  
        if (IS_ERR(bd))
                return PTR_ERR(bd);
@@@ -39,7 -39,6 +39,7 @@@
  #include <linux/mm.h>
  #include <linux/fs.h>
  #include <linux/sched.h>
 +#include <linux/smp_lock.h>
  #include <asm/uaccess.h>
  #include <asm/pgtable.h>
  #include "agp.h"
@@@ -396,7 -395,7 +396,7 @@@ static int agp_remove_controller(struc
  
        if (agp_fe.current_controller == controller) {
                agp_fe.current_controller = NULL;
-               agp_fe.backend_acquired = FALSE;
+               agp_fe.backend_acquired = false;
                agp_backend_release(agp_bridge);
        }
        kfree(controller);
@@@ -444,7 -443,7 +444,7 @@@ static void agp_controller_release_curr
        }
  
        agp_fe.current_controller = NULL;
-       agp_fe.used_by_controller = FALSE;
+       agp_fe.used_by_controller = false;
        agp_backend_release(agp_bridge);
  }
  
@@@ -574,7 -573,7 +574,7 @@@ static int agp_mmap(struct file *file, 
  
        mutex_lock(&(agp_fe.agp_mutex));
  
-       if (agp_fe.backend_acquired != TRUE)
+       if (agp_fe.backend_acquired != true)
                goto out_eperm;
  
        if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
@@@ -678,7 -677,6 +678,7 @@@ static int agp_open(struct inode *inode
        struct agp_client *client;
        int rc = -ENXIO;
  
 +      lock_kernel();
        mutex_lock(&(agp_fe.agp_mutex));
  
        if (minor != AGPGART_MINOR)
        agp_insert_file_private(priv);
        DBG("private=%p, client=%p", priv, client);
        mutex_unlock(&(agp_fe.agp_mutex));
 +      unlock_kernel();
        return 0;
  
  err_out_nomem:
        rc = -ENOMEM;
  err_out:
        mutex_unlock(&(agp_fe.agp_mutex));
 +      unlock_kernel();
        return rc;
  }
  
@@@ -772,7 -768,7 +772,7 @@@ int agpioc_acquire_wrap(struct agp_file
  
        atomic_inc(&agp_bridge->agp_in_use);
  
-       agp_fe.backend_acquired = TRUE;
+       agp_fe.backend_acquired = true;
  
        controller = agp_find_controller_by_pid(priv->my_pid);
  
                controller = agp_create_controller(priv->my_pid);
  
                if (controller == NULL) {
-                       agp_fe.backend_acquired = FALSE;
+                       agp_fe.backend_acquired = false;
                        agp_backend_release(agp_bridge);
                        return -ENOMEM;
                }
@@@ -985,7 -981,7 +985,7 @@@ static long agp_ioctl(struct file *file
                ret_val = -EINVAL;
                goto ioctl_out;
        }
-       if ((agp_fe.backend_acquired != TRUE) &&
+       if ((agp_fe.backend_acquired != true) &&
            (cmd != AGPIOC_ACQUIRE)) {
                ret_val = -EBUSY;
                goto ioctl_out;
@@@ -37,7 -37,6 +37,7 @@@
  #include "drmP.h"
  #include "drm_sarea.h"
  #include <linux/poll.h>
 +#include <linux/smp_lock.h>
  
  static int drm_open_helper(struct inode *inode, struct file *filp,
                           struct drm_device * dev);
@@@ -175,14 -174,12 +175,14 @@@ int drm_stub_open(struct inode *inode, 
  
        DRM_DEBUG("\n");
  
 +      /* BKL pushdown: note that nothing else serializes idr_find() */
 +      lock_kernel();
        minor = idr_find(&drm_minors_idr, minor_id);
        if (!minor)
 -              return -ENODEV;
 +              goto out;
  
        if (!(dev = minor->dev))
 -              return -ENODEV;
 +              goto out;
  
        old_fops = filp->f_op;
        filp->f_op = fops_get(&dev->driver->fops);
        }
        fops_put(old_fops);
  
 +out:
 +      unlock_kernel();
        return err;
  }
  
@@@ -328,7 -323,6 +328,6 @@@ int drm_release(struct inode *inode, st
        struct drm_file *file_priv = filp->private_data;
        struct drm_device *dev = file_priv->minor->dev;
        int retcode = 0;
-       unsigned long irqflags;
  
        lock_kernel();
  
                         */
  
                        do{
-                               spin_lock_irqsave(&dev->lock.spinlock,
-                                                 irqflags);
+                               spin_lock_bh(&dev->lock.spinlock);
                                locked = dev->lock.idle_has_lock;
-                               spin_unlock_irqrestore(&dev->lock.spinlock,
-                                                      irqflags);
+                               spin_unlock_bh(&dev->lock.spinlock);
                                if (locked)
                                        break;
                                schedule();
@@@ -98,7 -98,6 +98,7 @@@
  #include <linux/major.h>
  #include <linux/wait.h>
  #include <linux/device.h>
 +#include <linux/smp_lock.h>
  
  #include <linux/tty.h>
  #include <linux/tty_flip.h>
@@@ -346,27 -345,6 +346,6 @@@ have_requested_irq( char irq 
        return 0;
  }
  
- /******************************************************************************/
- /* Function:   init_module()                                                  */
- /* Parameters: None                                                           */
- /* Returns:    Success (0)                                                    */
- /*                                                                            */
- /* Description:                                                               */
- /* This is a required entry point for an installable module. It simply calls  */
- /* the driver initialisation function and returns what it returns.            */
- /******************************************************************************/
- #ifdef MODULE
- static int __init
- ip2_init_module(void)
- {
- #ifdef IP2DEBUG_INIT
-       printk (KERN_DEBUG "Loading module ...\n" );
- #endif
-     return 0;
- }
- module_init(ip2_init_module);
- #endif /* MODULE */
  /******************************************************************************/
  /* Function:   cleanup_module()                                               */
  /* Parameters: None                                                           */
@@@ -780,8 -758,6 +759,6 @@@ out
        return err;
  }
  
- EXPORT_SYMBOL(ip2_loadmain);
  /******************************************************************************/
  /* Function:   ip2_init_board()                                               */
  /* Parameters: Index of board in configuration structure                      */
@@@ -2932,11 -2908,42 +2909,11 @@@ ip2_ipl_ioctl ( struct inode *pInode, s
  static int
  ip2_ipl_open( struct inode *pInode, struct file *pFile )
  {
 -      unsigned int iplminor = iminor(pInode);
 -      i2eBordStrPtr pB;
 -      i2ChanStrPtr  pCh;
  
  #ifdef IP2DEBUG_IPL
        printk (KERN_DEBUG "IP2IPL: open\n" );
  #endif
 -
 -      switch(iplminor) {
 -      // These are the IPL devices
 -      case 0:
 -      case 4:
 -      case 8:
 -      case 12:
 -              break;
 -
 -      // These are the status devices
 -      case 1:
 -      case 5:
 -      case 9:
 -      case 13:
 -              break;
 -
 -      // These are the debug devices
 -      case 2:
 -      case 6:
 -      case 10:
 -      case 14:
 -              pB = i2BoardPtrTable[iplminor / 4];
 -              pCh = (i2ChanStrPtr) pB->i2eChannelPtr;
 -              break;
 -
 -      // This is the trace device
 -      case 3:
 -              break;
 -      }
 +      cycle_kernel_lock();
        return 0;
  }
  
@@@ -35,7 -35,6 +35,7 @@@
  #include <linux/moduleparam.h>
  #include <linux/ipmi.h>
  #include <linux/ipmi_smi.h>
 +#include <linux/smp_lock.h>
  #include <linux/watchdog.h>
  #include <linux/miscdevice.h>
  #include <linux/init.h>
@@@ -756,9 -755,8 +756,8 @@@ static ssize_t ipmi_write(struct file *
                rv = ipmi_heartbeat();
                if (rv)
                        return rv;
-               return 1;
        }
-       return 0;
+       return len;
  }
  
  static ssize_t ipmi_read(struct file *file,
@@@ -820,8 -818,6 +819,8 @@@ static int ipmi_open(struct inode *ino
                if (test_and_set_bit(0, &ipmi_wdog_open))
                        return -EBUSY;
  
 +              cycle_kernel_lock();
 +
                /*
                 * Don't start the timer now, let it start on the
                 * first heartbeat.
diff --combined drivers/char/rtc.c
@@@ -73,7 -73,6 +73,7 @@@
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include <linux/spinlock.h>
 +#include <linux/smp_lock.h>
  #include <linux/sysctl.h>
  #include <linux/wait.h>
  #include <linux/bcd.h>
@@@ -679,12 -678,13 +679,13 @@@ static int rtc_do_ioctl(unsigned int cm
                if (arg != (1<<tmp))
                        return -EINVAL;
  
+               rtc_freq = arg;
                spin_lock_irqsave(&rtc_lock, flags);
                if (hpet_set_periodic_freq(arg)) {
                        spin_unlock_irqrestore(&rtc_lock, flags);
                        return 0;
                }
-               rtc_freq = arg;
  
                val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
                val |= (16 - tmp);
@@@ -734,7 -734,6 +735,7 @@@ static int rtc_ioctl(struct inode *inod
   * needed here. Or anywhere else in this driver. */
  static int rtc_open(struct inode *inode, struct file *file)
  {
 +      lock_kernel();
        spin_lock_irq(&rtc_lock);
  
        if (rtc_status & RTC_IS_OPEN)
  
        rtc_irq_data = 0;
        spin_unlock_irq(&rtc_lock);
 +      unlock_kernel();
        return 0;
  
  out_busy:
        spin_unlock_irq(&rtc_lock);
 +      unlock_kernel();
        return -EBUSY;
  }
  
diff --combined drivers/char/tty_io.c
@@@ -2665,7 -2665,7 +2665,7 @@@ static void release_dev(struct file *fi
   *             ->siglock protects ->signal/->sighand
   */
  
 -static int tty_open(struct inode *inode, struct file *filp)
 +static int __tty_open(struct inode *inode, struct file *filp)
  {
        struct tty_struct *tty;
        int noctty, retval;
@@@ -2779,19 -2779,6 +2779,19 @@@ got_driver
        return 0;
  }
  
 +/* BKL pushdown: scary code avoidance wrapper */
 +static int tty_open(struct inode *inode, struct file *filp)
 +{
 +      int ret;
 +
 +      lock_kernel();
 +      ret = __tty_open(inode, filp);
 +      unlock_kernel();
 +      return ret;
 +}
 +
 +
 +
  #ifdef CONFIG_UNIX98_PTYS
  /**
   *    ptmx_open               -       open a unix 98 pty master
   *            allocated_ptys_lock handles the list of free pty numbers
   */
  
 -static int ptmx_open(struct inode *inode, struct file *filp)
 +static int __ptmx_open(struct inode *inode, struct file *filp)
  {
        struct tty_struct *tty;
        int retval;
        devpts_kill_index(index);
        return retval;
  }
 +
 +static int ptmx_open(struct inode *inode, struct file *filp)
 +{
 +      int ret;
 +
 +      lock_kernel();
 +      ret = __ptmx_open(inode, filp);
 +      unlock_kernel();
 +      return ret;
 +}
  #endif
  
  /**
@@@ -2909,16 -2886,15 +2909,16 @@@ static int tty_fasync(int fd, struct fi
  {
        struct tty_struct *tty;
        unsigned long flags;
 -      int retval;
 +      int retval = 0;
  
 +      lock_kernel();
        tty = (struct tty_struct *)filp->private_data;
        if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync"))
 -              return 0;
 +              goto out;
  
        retval = fasync_helper(fd, filp, on, &tty->fasync);
        if (retval <= 0)
 -              return retval;
 +              goto out;
  
        if (on) {
                enum pid_type type;
                spin_unlock_irqrestore(&tty->ctrl_lock, flags);
                retval = __f_setown(filp, pid, type, 0);
                if (retval)
 -                      return retval;
 +                      goto out;
        } else {
                if (!tty->fasync && !waitqueue_active(&tty->read_wait))
                        tty->minimum_to_wake = N_TTY_BUF_SIZE;
        }
 -      return 0;
 +      retval = 0;
 +out:
 +      unlock_kernel();
 +      return retval;
  }
  
  /**
@@@ -3349,7 -3322,7 +3349,7 @@@ static int send_break(struct tty_struc
                msleep_interruptible(duration);
        tty->ops->break_ctl(tty, 0);
        tty_write_unlock(tty);
-       if (!signal_pending(current))
+       if (signal_pending(current))
                return -EINTR;
        return 0;
  }
diff --combined drivers/char/viotape.c
@@@ -6,7 -6,7 +6,7 @@@
   *  Authors: Dave Boutcher <boutcher@us.ibm.com>
   *           Ryan Arnold <ryanarn@us.ibm.com>
   *           Colin Devilbiss <devilbis@us.ibm.com>
-  *           Stephen Rothwell <sfr@au1.ibm.com>
+  *           Stephen Rothwell
   *
   * (C) Copyright 2000-2004 IBM Corporation
   *
@@@ -46,7 -46,6 +46,7 @@@
  #include <linux/completion.h>
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
 +#include <linux/smp_lock.h>
  
  #include <asm/uaccess.h>
  #include <asm/ioctls.h>
@@@ -688,7 -687,6 +688,7 @@@ static int viotap_open(struct inode *in
        if (op == NULL)
                return -ENOMEM;
  
 +      lock_kernel();
        get_dev_info(file->f_path.dentry->d_inode, &devi);
  
        /* Note: We currently only support one mode! */
  
  free_op:
        free_op_struct(op);
 +      unlock_kernel();
        return ret;
  }
  
@@@ -777,19 -777,6 +777,19 @@@ static long ib_umad_compat_ioctl(struc
  }
  #endif
  
 +/*
 + * ib_umad_open() does not need the BKL:
 + *
 + *  - umad_port[] accesses are protected by port_lock, the
 + *    ib_umad_port structures are properly reference counted, and
 + *    everything else is purely local to the file being created, so
 + *    races against other open calls are not a problem;
 + *  - the ioctl method does not affect any global state outside of the
 + *    file structure being operated on;
 + *  - the port is added to umad_port[] as the last part of module
 + *    initialization so the open method will either immediately run
 + *    -ENXIO, or all required initialization will be done.
 + */
  static int ib_umad_open(struct inode *inode, struct file *filp)
  {
        struct ib_umad_port *port;
@@@ -1018,8 -1005,9 +1018,9 @@@ static int ib_umad_init_port(struct ib_
        if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
                goto err_cdev;
  
-       port->dev = device_create(umad_class, device->dma_device,
-                                 port->cdev->dev, "umad%d", port->dev_num);
+       port->dev = device_create_drvdata(umad_class, device->dma_device,
+                                         port->cdev->dev, port,
+                                         "umad%d", port->dev_num);
        if (IS_ERR(port->dev))
                goto err_cdev;
  
        if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
                goto err_sm_cdev;
  
-       port->sm_dev = device_create(umad_class, device->dma_device,
-                                    port->sm_cdev->dev,
-                                    "issm%d", port->dev_num);
+       port->sm_dev = device_create_drvdata(umad_class, device->dma_device,
+                                            port->sm_cdev->dev, port,
+                                            "issm%d", port->dev_num);
        if (IS_ERR(port->sm_dev))
                goto err_sm_cdev;
  
-       dev_set_drvdata(port->dev,    port);
-       dev_set_drvdata(port->sm_dev, port);
        if (device_create_file(port->sm_dev, &dev_attr_ibdev))
                goto err_sm_dev;
        if (device_create_file(port->sm_dev, &dev_attr_port))
@@@ -423,7 -423,7 +423,7 @@@ static void ib_uverbs_async_handler(str
        unsigned long flags;
  
        spin_lock_irqsave(&file->async_file->lock, flags);
-       if (!file->async_file->is_closed) {
+       if (file->async_file->is_closed) {
                spin_unlock_irqrestore(&file->async_file->lock, flags);
                return;
        }
@@@ -610,18 -610,6 +610,18 @@@ static int ib_uverbs_mmap(struct file *
                return file->device->ib_dev->mmap(file->ucontext, vma);
  }
  
 +/*
 + * ib_uverbs_open() does not need the BKL:
 + *
 + *  - dev_table[] accesses are protected by map_lock, the
 + *    ib_uverbs_device structures are properly reference counted, and
 + *    everything else is purely local to the file being created, so
 + *    races against other open calls are not a problem;
 + *  - there is no ioctl method to race against;
 + *  - the device is added to dev_table[] as the last part of module
 + *    initialization, the open method will either immediately run
 + *    -ENXIO, or all required initialization will be done.
 + */
  static int ib_uverbs_open(struct inode *inode, struct file *filp)
  {
        struct ib_uverbs_device *dev;
@@@ -663,6 -651,7 +663,6 @@@ err_module
  
  err:
        kref_put(&dev->ref, ib_uverbs_release_dev);
 -
        return ret;
  }
  
@@@ -766,14 -755,15 +766,15 @@@ static void ib_uverbs_add_one(struct ib
        if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
                goto err_cdev;
  
-       uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
-                                       uverbs_dev->cdev->dev,
-                                       "uverbs%d", uverbs_dev->devnum);
+       uverbs_dev->dev = device_create_drvdata(uverbs_class,
+                                               device->dma_device,
+                                               uverbs_dev->cdev->dev,
+                                               uverbs_dev,
+                                               "uverbs%d",
+                                               uverbs_dev->devnum);
        if (IS_ERR(uverbs_dev->dev))
                goto err_cdev;
  
-       dev_set_drvdata(uverbs_dev->dev, uverbs_dev);
        if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev))
                goto err_class;
        if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
@@@ -21,7 -21,6 +21,7 @@@
  #include <linux/list.h>
  #include <linux/poll.h>
  #include <linux/kmod.h>
 +#include <linux/smp_lock.h>
  
  #include "platform.h"
  #undef ID_MASK
@@@ -581,7 -580,6 +581,7 @@@ xdi_copy_from_user(void *os_handle, voi
   */
  static int divas_open(struct inode *inode, struct file *file)
  {
 +      cycle_kernel_lock();
        return (0);
  }
  
@@@ -808,7 -806,6 +808,6 @@@ static int DIVA_INIT_FUNCTION divas_ini
  
        if (!create_divas_proc()) {
  #ifdef MODULE
-               remove_divas_proc();
                divas_unregister_chrdev();
                divasfunc_exit();
  #endif
@@@ -1732,7 -1732,7 +1732,7 @@@ isdn_open(struct inode *ino, struct fil
        int chidx;
        int retval = -ENODEV;
  
 -
 +      lock_kernel();
        if (minor == ISDN_MINOR_STATUS) {
                infostruct *p;
  
  #endif
   out:
        nonseekable_open(ino, filep);
 +      unlock_kernel();
        return retval;
  }
  
@@@ -1978,8 -1977,10 +1978,10 @@@ isdn_writebuf_stub(int drvidx, int chan
        if (!skb)
                return -ENOMEM;
        skb_reserve(skb, hl);
-       if (copy_from_user(skb_put(skb, len), buf, len))
+       if (copy_from_user(skb_put(skb, len), buf, len)) {
+               dev_kfree_skb(skb);
                return -EFAULT;
+       }
        ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, 1, skb);
        if (ret <= 0)
                dev_kfree_skb(skb);
diff --combined drivers/macintosh/smu.c
@@@ -19,7 -19,6 +19,7 @@@
   *    the userland interface
   */
  
 +#include <linux/smp_lock.h>
  #include <linux/types.h>
  #include <linux/kernel.h>
  #include <linux/device.h>
@@@ -484,12 -483,15 +484,15 @@@ int __init smu_init (void
  
        if (smu_cmdbuf_abs == 0) {
                printk(KERN_ERR "SMU: Command buffer not allocated !\n");
+               of_node_put(np);
                return -EINVAL;
        }
  
        smu = alloc_bootmem(sizeof(struct smu_device));
-       if (smu == NULL)
+       if (smu == NULL) {
+               of_node_put(np);
                return -ENOMEM;
+       }
        memset(smu, 0, sizeof(*smu));
  
        spin_lock_init(&smu->lock);
@@@ -1084,12 -1086,10 +1087,12 @@@ static int smu_open(struct inode *inode
        pp->mode = smu_file_commands;
        init_waitqueue_head(&pp->wait);
  
 +      lock_kernel();
        spin_lock_irqsave(&smu_clist_lock, flags);
        list_add(&pp->list, &smu_clist);
        spin_unlock_irqrestore(&smu_clist_lock, flags);
        file->private_data = pp;
 +      unlock_kernel();
  
        return 0;
  }
@@@ -36,7 -36,6 +36,7 @@@
  #include <linux/init.h>
  #include <linux/kmod.h>
  #include <linux/slab.h>
 +#include <linux/smp_lock.h>
  #include <asm/uaccess.h>
  #include <asm/system.h>
  
  #define VIDEO_NUM_DEVICES     256
  #define VIDEO_NAME              "video4linux"
  
+ struct std_descr {
+       v4l2_std_id std;
+       const char *descr;
+ };
+ static const struct std_descr standards[] = {
+       { V4L2_STD_NTSC,        "NTSC"      },
+       { V4L2_STD_NTSC_M,      "NTSC-M"    },
+       { V4L2_STD_NTSC_M_JP,   "NTSC-M-JP" },
+       { V4L2_STD_NTSC_M_KR,   "NTSC-M-KR" },
+       { V4L2_STD_NTSC_443,    "NTSC-443"  },
+       { V4L2_STD_PAL,         "PAL"       },
+       { V4L2_STD_PAL_BG,      "PAL-BG"    },
+       { V4L2_STD_PAL_B,       "PAL-B"     },
+       { V4L2_STD_PAL_B1,      "PAL-B1"    },
+       { V4L2_STD_PAL_G,       "PAL-G"     },
+       { V4L2_STD_PAL_H,       "PAL-H"     },
+       { V4L2_STD_PAL_I,       "PAL-I"     },
+       { V4L2_STD_PAL_DK,      "PAL-DK"    },
+       { V4L2_STD_PAL_D,       "PAL-D"     },
+       { V4L2_STD_PAL_D1,      "PAL-D1"    },
+       { V4L2_STD_PAL_K,       "PAL-K"     },
+       { V4L2_STD_PAL_M,       "PAL-M"     },
+       { V4L2_STD_PAL_N,       "PAL-N"     },
+       { V4L2_STD_PAL_Nc,      "PAL-Nc"    },
+       { V4L2_STD_PAL_60,      "PAL-60"    },
+       { V4L2_STD_SECAM,       "SECAM"     },
+       { V4L2_STD_SECAM_B,     "SECAM-B"   },
+       { V4L2_STD_SECAM_G,     "SECAM-G"   },
+       { V4L2_STD_SECAM_H,     "SECAM-H"   },
+       { V4L2_STD_SECAM_DK,    "SECAM-DK"  },
+       { V4L2_STD_SECAM_D,     "SECAM-D"   },
+       { V4L2_STD_SECAM_K,     "SECAM-K"   },
+       { V4L2_STD_SECAM_K1,    "SECAM-K1"  },
+       { V4L2_STD_SECAM_L,     "SECAM-L"   },
+       { V4L2_STD_SECAM_LC,    "SECAM-Lc"  },
+       { 0,                    "Unknown"   }
+ };
  /* video4linux standard ID conversion to standard name
   */
- char *v4l2_norm_to_name(v4l2_std_id id)
+ const char *v4l2_norm_to_name(v4l2_std_id id)
  {
-       char *name;
        u32 myid = id;
+       int i;
  
        /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
           64 bit comparations. So, on that architecture, with some gcc
         */
        BUG_ON(myid != id);
  
-       switch (myid) {
-       case V4L2_STD_PAL:
-               name = "PAL";
-               break;
-       case V4L2_STD_PAL_BG:
-               name = "PAL-BG";
-               break;
-       case V4L2_STD_PAL_DK:
-               name = "PAL-DK";
-               break;
-       case V4L2_STD_PAL_B:
-               name = "PAL-B";
-               break;
-       case V4L2_STD_PAL_B1:
-               name = "PAL-B1";
-               break;
-       case V4L2_STD_PAL_G:
-               name = "PAL-G";
-               break;
-       case V4L2_STD_PAL_H:
-               name = "PAL-H";
-               break;
-       case V4L2_STD_PAL_I:
-               name = "PAL-I";
-               break;
-       case V4L2_STD_PAL_D:
-               name = "PAL-D";
-               break;
-       case V4L2_STD_PAL_D1:
-               name = "PAL-D1";
-               break;
-       case V4L2_STD_PAL_K:
-               name = "PAL-K";
-               break;
-       case V4L2_STD_PAL_M:
-               name = "PAL-M";
-               break;
-       case V4L2_STD_PAL_N:
-               name = "PAL-N";
-               break;
-       case V4L2_STD_PAL_Nc:
-               name = "PAL-Nc";
-               break;
-       case V4L2_STD_PAL_60:
-               name = "PAL-60";
-               break;
-       case V4L2_STD_NTSC:
-               name = "NTSC";
-               break;
-       case V4L2_STD_NTSC_M:
-               name = "NTSC-M";
-               break;
-       case V4L2_STD_NTSC_M_JP:
-               name = "NTSC-M-JP";
-               break;
-       case V4L2_STD_NTSC_443:
-               name = "NTSC-443";
-               break;
-       case V4L2_STD_NTSC_M_KR:
-               name = "NTSC-M-KR";
-               break;
-       case V4L2_STD_SECAM:
-               name = "SECAM";
-               break;
-       case V4L2_STD_SECAM_DK:
-               name = "SECAM-DK";
-               break;
-       case V4L2_STD_SECAM_B:
-               name = "SECAM-B";
-               break;
-       case V4L2_STD_SECAM_D:
-               name = "SECAM-D";
-               break;
-       case V4L2_STD_SECAM_G:
-               name = "SECAM-G";
-               break;
-       case V4L2_STD_SECAM_H:
-               name = "SECAM-H";
-               break;
-       case V4L2_STD_SECAM_K:
-               name = "SECAM-K";
-               break;
-       case V4L2_STD_SECAM_K1:
-               name = "SECAM-K1";
-               break;
-       case V4L2_STD_SECAM_L:
-               name = "SECAM-L";
-               break;
-       case V4L2_STD_SECAM_LC:
-               name = "SECAM-LC";
-               break;
-       default:
-               name = "Unknown";
-               break;
-       }
-       return name;
+       for (i = 0; standards[i].std; i++)
+               if (myid == standards[i].std)
+                       break;
+       return standards[i].descr;
  }
  EXPORT_SYMBOL(v4l2_norm_to_name);
  
  /* Fill in the fields of a v4l2_standard structure according to the
     'id' and 'transmission' parameters.  Returns negative on error.  */
  int v4l2_video_std_construct(struct v4l2_standard *vs,
-                            int id, char *name)
+                            int id, const char *name)
  {
        u32 index = vs->index;
  
@@@ -497,7 -442,6 +443,7 @@@ static int video_open(struct inode *ino
  
        if(minor>=VIDEO_NUM_DEVICES)
                return -ENODEV;
 +      lock_kernel();
        mutex_lock(&videodev_lock);
        vfl=video_device[minor];
        if(vfl==NULL) {
                vfl=video_device[minor];
                if (vfl==NULL) {
                        mutex_unlock(&videodev_lock);
 +                      unlock_kernel();
                        return -ENODEV;
                }
        }
        }
        fops_put(old_fops);
        mutex_unlock(&videodev_lock);
 +      unlock_kernel();
        return err;
  }
  
@@@ -1222,95 -1164,40 +1168,40 @@@ static int __video_do_ioctl(struct inod
        case VIDIOC_ENUMSTD:
        {
                struct v4l2_standard *p = arg;
-               v4l2_std_id id = vfd->tvnorms,curr_id=0;
-               unsigned int index = p->index,i;
-               if (index<0) {
-                       ret=-EINVAL;
-                       break;
-               }
-               /* Return norm array on a canonical way */
-               for (i=0;i<= index && id; i++) {
-                       if ( (id & V4L2_STD_PAL) == V4L2_STD_PAL) {
-                               curr_id = V4L2_STD_PAL;
-                       } else if ( (id & V4L2_STD_PAL_BG) == V4L2_STD_PAL_BG) {
-                               curr_id = V4L2_STD_PAL_BG;
-                       } else if ( (id & V4L2_STD_PAL_DK) == V4L2_STD_PAL_DK) {
-                               curr_id = V4L2_STD_PAL_DK;
-                       } else if ( (id & V4L2_STD_PAL_B) == V4L2_STD_PAL_B) {
-                               curr_id = V4L2_STD_PAL_B;
-                       } else if ( (id & V4L2_STD_PAL_B1) == V4L2_STD_PAL_B1) {
-                               curr_id = V4L2_STD_PAL_B1;
-                       } else if ( (id & V4L2_STD_PAL_G) == V4L2_STD_PAL_G) {
-                               curr_id = V4L2_STD_PAL_G;
-                       } else if ( (id & V4L2_STD_PAL_H) == V4L2_STD_PAL_H) {
-                               curr_id = V4L2_STD_PAL_H;
-                       } else if ( (id & V4L2_STD_PAL_I) == V4L2_STD_PAL_I) {
-                               curr_id = V4L2_STD_PAL_I;
-                       } else if ( (id & V4L2_STD_PAL_D) == V4L2_STD_PAL_D) {
-                               curr_id = V4L2_STD_PAL_D;
-                       } else if ( (id & V4L2_STD_PAL_D1) == V4L2_STD_PAL_D1) {
-                               curr_id = V4L2_STD_PAL_D1;
-                       } else if ( (id & V4L2_STD_PAL_K) == V4L2_STD_PAL_K) {
-                               curr_id = V4L2_STD_PAL_K;
-                       } else if ( (id & V4L2_STD_PAL_M) == V4L2_STD_PAL_M) {
-                               curr_id = V4L2_STD_PAL_M;
-                       } else if ( (id & V4L2_STD_PAL_N) == V4L2_STD_PAL_N) {
-                               curr_id = V4L2_STD_PAL_N;
-                       } else if ( (id & V4L2_STD_PAL_Nc) == V4L2_STD_PAL_Nc) {
-                               curr_id = V4L2_STD_PAL_Nc;
-                       } else if ( (id & V4L2_STD_PAL_60) == V4L2_STD_PAL_60) {
-                               curr_id = V4L2_STD_PAL_60;
-                       } else if ( (id & V4L2_STD_NTSC) == V4L2_STD_NTSC) {
-                               curr_id = V4L2_STD_NTSC;
-                       } else if ( (id & V4L2_STD_NTSC_M) == V4L2_STD_NTSC_M) {
-                               curr_id = V4L2_STD_NTSC_M;
-                       } else if ( (id & V4L2_STD_NTSC_M_JP) == V4L2_STD_NTSC_M_JP) {
-                               curr_id = V4L2_STD_NTSC_M_JP;
-                       } else if ( (id & V4L2_STD_NTSC_443) == V4L2_STD_NTSC_443) {
-                               curr_id = V4L2_STD_NTSC_443;
-                       } else if ( (id & V4L2_STD_NTSC_M_KR) == V4L2_STD_NTSC_M_KR) {
-                               curr_id = V4L2_STD_NTSC_M_KR;
-                       } else if ( (id & V4L2_STD_SECAM) == V4L2_STD_SECAM) {
-                               curr_id = V4L2_STD_SECAM;
-                       } else if ( (id & V4L2_STD_SECAM_DK) == V4L2_STD_SECAM_DK) {
-                               curr_id = V4L2_STD_SECAM_DK;
-                       } else if ( (id & V4L2_STD_SECAM_B) == V4L2_STD_SECAM_B) {
-                               curr_id = V4L2_STD_SECAM_B;
-                       } else if ( (id & V4L2_STD_SECAM_D) == V4L2_STD_SECAM_D) {
-                               curr_id = V4L2_STD_SECAM_D;
-                       } else if ( (id & V4L2_STD_SECAM_G) == V4L2_STD_SECAM_G) {
-                               curr_id = V4L2_STD_SECAM_G;
-                       } else if ( (id & V4L2_STD_SECAM_H) == V4L2_STD_SECAM_H) {
-                               curr_id = V4L2_STD_SECAM_H;
-                       } else if ( (id & V4L2_STD_SECAM_K) == V4L2_STD_SECAM_K) {
-                               curr_id = V4L2_STD_SECAM_K;
-                       } else if ( (id & V4L2_STD_SECAM_K1) == V4L2_STD_SECAM_K1) {
-                               curr_id = V4L2_STD_SECAM_K1;
-                       } else if ( (id & V4L2_STD_SECAM_L) == V4L2_STD_SECAM_L) {
-                               curr_id = V4L2_STD_SECAM_L;
-                       } else if ( (id & V4L2_STD_SECAM_LC) == V4L2_STD_SECAM_LC) {
-                               curr_id = V4L2_STD_SECAM_LC;
-                       } else {
+               v4l2_std_id id = vfd->tvnorms, curr_id = 0;
+               unsigned int index = p->index, i, j = 0;
+               const char *descr = "";
+               /* Return norm array in a canonical way */
+               for (i = 0; i <= index && id; i++) {
+                       /* last std value in the standards array is 0, so this
+                          while always ends there since (id & 0) == 0. */
+                       while ((id & standards[j].std) != standards[j].std)
+                               j++;
+                       curr_id = standards[j].std;
+                       descr = standards[j].descr;
+                       j++;
+                       if (curr_id == 0)
                                break;
-                       }
-                       id &= ~curr_id;
+                       if (curr_id != V4L2_STD_PAL &&
+                           curr_id != V4L2_STD_SECAM &&
+                           curr_id != V4L2_STD_NTSC)
+                               id &= ~curr_id;
                }
-               if (i<=index)
+               if (i <= index)
                        return -EINVAL;
  
-               v4l2_video_std_construct(p, curr_id,v4l2_norm_to_name(curr_id));
+               v4l2_video_std_construct(p, curr_id, descr);
                p->index = index;
  
-               dbgarg (cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, "
+               dbgarg(cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, "
                                "framelines=%d\n", p->index,
                                (unsigned long long)p->id, p->name,
                                p->frameperiod.numerator,
                                p->frameperiod.denominator,
                                p->framelines);
  
-               ret=0;
+               ret = 0;
                break;
        }
        case VIDIOC_G_STD:
diff --combined drivers/net/tun.c
@@@ -48,7 -48,6 +48,7 @@@
  #include <linux/kernel.h>
  #include <linux/major.h>
  #include <linux/slab.h>
 +#include <linux/smp_lock.h>
  #include <linux/poll.h>
  #include <linux/fcntl.h>
  #include <linux/init.h>
@@@ -314,6 -313,21 +314,21 @@@ static __inline__ ssize_t tun_get_user(
  
        switch (tun->flags & TUN_TYPE_MASK) {
        case TUN_TUN_DEV:
+               if (tun->flags & TUN_NO_PI) {
+                       switch (skb->data[0] & 0xf0) {
+                       case 0x40:
+                               pi.proto = htons(ETH_P_IP);
+                               break;
+                       case 0x60:
+                               pi.proto = htons(ETH_P_IPV6);
+                               break;
+                       default:
+                               tun->dev->stats.rx_dropped++;
+                               kfree_skb(skb);
+                               return -EINVAL;
+                       }
+               }
                skb_reset_mac_header(skb);
                skb->protocol = pi.proto;
                skb->dev = tun->dev;
@@@ -588,6 -602,12 +603,12 @@@ static int tun_set_iff(struct net *net
        tun->attached = 1;
        get_net(dev_net(tun->dev));
  
+       /* Make sure persistent devices do not get stuck in
+        * xoff state.
+        */
+       if (netif_running(tun->dev))
+               netif_wake_queue(tun->dev);
        strcpy(ifr->ifr_name, tun->dev->name);
        return 0;
  
@@@ -782,26 -802,22 +803,26 @@@ static int tun_chr_fasync(int fd, struc
  
        DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on);
  
 +      lock_kernel();
        if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0)
 -              return ret;
 +              goto out;
  
        if (on) {
                ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0);
                if (ret)
 -                      return ret;
 +                      goto out;
                tun->flags |= TUN_FASYNC;
        } else
                tun->flags &= ~TUN_FASYNC;
 -
 -      return 0;
 +      ret = 0;
 +out:
 +      unlock_kernel();
 +      return ret;
  }
  
  static int tun_chr_open(struct inode *inode, struct file * file)
  {
 +      cycle_kernel_lock();
        DBG1(KERN_INFO "tunX: tun_chr_open\n");
        file->private_data = NULL;
        return 0;
@@@ -25,7 -25,6 +25,7 @@@
  #include <linux/kmod.h>
  #include <linux/cdev.h>
  #include <linux/device.h>
 +#include <linux/smp_lock.h>
  #include <linux/string.h>
  
  
@@@ -320,11 -319,9 +320,11 @@@ static int vmlogrdr_open (struct inode 
                return -ENOSYS;
  
        /* Besure this device hasn't already been opened */
 +      lock_kernel();
        spin_lock_bh(&logptr->priv_lock);
        if (logptr->dev_in_use) {
                spin_unlock_bh(&logptr->priv_lock);
 +              unlock_kernel();
                return -EBUSY;
        }
        logptr->dev_in_use = 1;
                   || (logptr->iucv_path_severed));
        if (logptr->iucv_path_severed)
                goto out_record;
 -      return nonseekable_open(inode, filp);
 +      ret = nonseekable_open(inode, filp);
 +      unlock_kernel();
 +      return ret;
  
  out_record:
        if (logptr->autorecording)
@@@ -380,7 -375,6 +380,7 @@@ out_path
        logptr->path = NULL;
  out_dev:
        logptr->dev_in_use = 0;
 +      unlock_kernel();
        return -EIO;
  }
  
@@@ -768,10 -762,10 +768,10 @@@ static int vmlogrdr_register_device(str
                device_unregister(dev);
                return ret;
        }
-       priv->class_device = device_create(vmlogrdr_class, dev,
-                                          MKDEV(vmlogrdr_major,
-                                                priv->minor_num),
-                                          "%s", dev->bus_id);
+       priv->class_device = device_create_drvdata(vmlogrdr_class, dev,
+                                                  MKDEV(vmlogrdr_major,
+                                                        priv->minor_num),
+                                                  priv, "%s", dev->bus_id);
        if (IS_ERR(priv->class_device)) {
                ret = PTR_ERR(priv->class_device);
                priv->class_device=NULL;
                device_unregister(dev);
                return ret;
        }
-       dev->driver_data = priv;
        priv->device = dev;
        return 0;
  }
diff --combined drivers/sbus/char/bpp.c
@@@ -19,7 -19,6 +19,7 @@@
  #include <linux/timer.h>
  #include <linux/ioport.h>
  #include <linux/major.h>
 +#include <linux/smp_lock.h>
  
  #include <asm/uaccess.h>
  #include <asm/io.h>
@@@ -430,7 -429,6 +430,7 @@@ static int bpp_open(struct inode *inode
        unsigned minor = iminor(inode);
        int ret;
  
 +      lock_kernel();
        spin_lock(&bpp_open_lock);
        ret = 0;
        if (minor >= BPP_NO) {
              }
        }
        spin_unlock(&bpp_open_lock);
 +      unlock_kernel();
  
        return ret;
  }
@@@ -872,7 -869,7 +872,7 @@@ static void probeLptPort(unsigned idx
        instances[idx].mode = COMPATIBILITY;
        instances[idx].run_length = 0;
        instances[idx].run_flag = 0;
-       if (!request_region(lpAddr,3, dev_name)) return;
+       if (!request_region(lpAddr,3, bpp_dev_name)) return;
  
        /*
         * First, make sure the instance exists. Do this by writing to
@@@ -1024,7 -1021,7 +1024,7 @@@ static int __init bpp_init(void
        if (rc == 0)
                return -ENODEV;
  
-       rc = register_chrdev(BPP_MAJOR, dev_name, &bpp_fops);
+       rc = register_chrdev(BPP_MAJOR, bpp_dev_name, &bpp_fops);
        if (rc < 0)
                return rc;
  
@@@ -1040,7 -1037,7 +1040,7 @@@ static void __exit bpp_cleanup(void
  {
        unsigned idx;
  
-       unregister_chrdev(BPP_MAJOR, dev_name);
+       unregister_chrdev(BPP_MAJOR, bpp_dev_name);
  
        for (idx = 0;  idx < BPP_NO; idx++) {
                if (instances[idx].present)
diff --combined drivers/scsi/3w-9xxx.c
@@@ -84,7 -84,6 +84,7 @@@
  #include <linux/pci.h>
  #include <linux/time.h>
  #include <linux/mutex.h>
 +#include <linux/smp_lock.h>
  #include <asm/io.h>
  #include <asm/irq.h>
  #include <asm/uaccess.h>
@@@ -863,13 -862,11 +863,13 @@@ out
  } /* End twa_chrdev_ioctl() */
  
  /* This function handles open for the character device */
 +/* NOTE that this function will race with remove. */
  static int twa_chrdev_open(struct inode *inode, struct file *file)
  {
        unsigned int minor_number;
        int retval = TW_IOCTL_ERROR_OS_ENODEV;
  
 +      cycle_kernel_lock();
        minor_number = iminor(inode);
        if (minor_number >= twa_device_extension_count)
                goto out;
@@@ -1281,7 -1278,7 +1281,7 @@@ static irqreturn_t twa_interrupt(int ir
                        error = 0;
                        /* Check for command packet errors */
                        if (full_command_packet->command.newcommand.status != 0) {
-                               if (tw_dev->srb[request_id] != 0) {
+                               if (tw_dev->srb[request_id] != NULL) {
                                        error = twa_fill_sense(tw_dev, request_id, 1, 1);
                                } else {
                                        /* Skip ioctl error prints */
  
                        /* Check for correct state */
                        if (tw_dev->state[request_id] != TW_S_POSTED) {
-                               if (tw_dev->srb[request_id] != 0) {
+                               if (tw_dev->srb[request_id] != NULL) {
                                        TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted");
                                        TW_CLEAR_ALL_INTERRUPTS(tw_dev);
                                        goto twa_interrupt_bail;
                        }
  
                        /* Check for internal command completion */
-                       if (tw_dev->srb[request_id] == 0) {
+                       if (tw_dev->srb[request_id] == NULL) {
                                if (request_id != tw_dev->chrdev_request_id) {
                                        if (twa_aen_complete(tw_dev, request_id))
                                                TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt");
diff --combined drivers/scsi/ch.c
@@@ -22,7 -22,6 +22,7 @@@
  #include <linux/chio.h>                       /* here are all the ioctls */
  #include <linux/mutex.h>
  #include <linux/idr.h>
 +#include <linux/smp_lock.h>
  
  #include <scsi/scsi.h>
  #include <scsi/scsi_cmnd.h>
@@@ -572,19 -571,16 +572,19 @@@ ch_open(struct inode *inode, struct fil
        scsi_changer *ch;
        int minor = iminor(inode);
  
 +      lock_kernel();
        spin_lock(&ch_index_lock);
        ch = idr_find(&ch_index_idr, minor);
  
        if (NULL == ch || scsi_device_get(ch->device)) {
                spin_unlock(&ch_index_lock);
 +              unlock_kernel();
                return -ENXIO;
        }
        spin_unlock(&ch_index_lock);
  
        file->private_data = ch;
 +      unlock_kernel();
        return 0;
  }
  
@@@ -914,9 -910,9 +914,9 @@@ static int ch_probe(struct device *dev
        ch->minor = minor;
        sprintf(ch->name,"ch%d",ch->minor);
  
-       class_dev = device_create(ch_sysfs_class, dev,
-                                 MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
-                                 "s%s", ch->name);
+       class_dev = device_create_drvdata(ch_sysfs_class, dev,
+                                         MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
+                                         ch, "s%s", ch->name);
        if (IS_ERR(class_dev)) {
                printk(KERN_WARNING "ch%d: device_create failed\n",
                       ch->minor);
        if (init)
                ch_init_elem(ch);
  
-       dev_set_drvdata(dev, ch);
        sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
  
        return 0;
diff --combined drivers/scsi/osst.c
@@@ -50,7 -50,6 +50,7 @@@ static const char * osst_version = "0.9
  #include <linux/moduleparam.h>
  #include <linux/delay.h>
  #include <linux/jiffies.h>
 +#include <linux/smp_lock.h>
  #include <asm/uaccess.h>
  #include <asm/dma.h>
  #include <asm/system.h>
@@@ -4360,7 -4359,7 +4360,7 @@@ os_bypass
  
  
  /* Open the device */
 -static int os_scsi_tape_open(struct inode * inode, struct file * filp)
 +static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
  {
        unsigned short        flags;
        int                   i, b_size, new_session = 0, retval = 0;
@@@ -4726,18 -4725,6 +4726,18 @@@ err_out
        return retval;
  }
  
 +/* BKL pushdown: spaghetti avoidance wrapper */
 +static int os_scsi_tape_open(struct inode * inode, struct file * filp)
 +{
 +      int ret;
 +
 +      lock_kernel();
 +      ret = __os_scsi_tape_open(inode, filp);
 +      unlock_kernel();
 +      return ret;
 +}
 +
 +
  
  /* Flush the tape buffer before close */
  static int os_scsi_tape_flush(struct file * filp, fl_owner_t id)
@@@ -5708,13 -5695,12 +5708,12 @@@ static int osst_sysfs_add(dev_t dev, st
        struct device *osst_member;
        int err;
  
-       osst_member = device_create(osst_sysfs_class, device, dev, "%s", name);
+       osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name);
        if (IS_ERR(osst_member)) {
                printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
                return PTR_ERR(osst_member);
        }
  
-       dev_set_drvdata(osst_member, STp);
        err = device_create_file(osst_member, &dev_attr_ADR_rev);
        if (err)
                goto err_out;
diff --combined drivers/scsi/sg.c
@@@ -49,7 -49,6 +49,7 @@@ static int sg_version_num = 30534;    /* 
  #include <linux/delay.h>
  #include <linux/scatterlist.h>
  #include <linux/blktrace_api.h>
 +#include <linux/smp_lock.h>
  
  #include "scsi.h"
  #include <scsi/scsi_dbg.h>
@@@ -228,26 -227,19 +228,26 @@@ sg_open(struct inode *inode, struct fil
        int res;
        int retval;
  
 +      lock_kernel();
        nonseekable_open(inode, filp);
        SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags));
        sdp = sg_get_dev(dev);
 -      if ((!sdp) || (!sdp->device))
 +      if ((!sdp) || (!sdp->device)) {
 +              unlock_kernel();
                return -ENXIO;
 -      if (sdp->detached)
 +      }
 +      if (sdp->detached) {
 +              unlock_kernel();
                return -ENODEV;
 +      }
  
        /* This driver's module count bumped by fops_get in <linux/fs.h> */
        /* Prevent the device driver from vanishing while we sleep */
        retval = scsi_device_get(sdp->device);
 -      if (retval)
 +      if (retval) {
 +              unlock_kernel();
                return retval;
 +      }
  
        if (!((flags & O_NONBLOCK) ||
              scsi_block_when_processing_errors(sdp->device))) {
                retval = -ENOMEM;
                goto error_out;
        }
 +      unlock_kernel();
        return 0;
  
        error_out:
        scsi_device_put(sdp->device);
 +      unlock_kernel();
        return retval;
  }
  
@@@ -1451,17 -1441,18 +1451,18 @@@ sg_add(struct device *cl_dev, struct cl
        if (sg_sysfs_valid) {
                struct device *sg_class_member;
  
-               sg_class_member = device_create(sg_sysfs_class, cl_dev->parent,
-                                               MKDEV(SCSI_GENERIC_MAJOR,
-                                                     sdp->index),
-                                               "%s", disk->disk_name);
+               sg_class_member = device_create_drvdata(sg_sysfs_class,
+                                                       cl_dev->parent,
+                                                       MKDEV(SCSI_GENERIC_MAJOR,
+                                                             sdp->index),
+                                                       sdp,
+                                                       "%s", disk->disk_name);
                if (IS_ERR(sg_class_member)) {
                        printk(KERN_ERR "sg_add: "
                               "device_create failed\n");
                        error = PTR_ERR(sg_class_member);
                        goto cdev_add_err;
                }
-               dev_set_drvdata(sg_class_member, sdp);
                error = sysfs_create_link(&scsidp->sdev_gendev.kobj,
                                          &sg_class_member->kobj, "generic");
                if (error)
diff --combined drivers/scsi/st.c
@@@ -38,7 -38,6 +38,7 @@@ static const char *verstr = "20080224"
  #include <linux/cdev.h>
  #include <linux/delay.h>
  #include <linux/mutex.h>
 +#include <linux/smp_lock.h>
  
  #include <asm/uaccess.h>
  #include <asm/dma.h>
@@@ -1114,7 -1113,7 +1114,7 @@@ static int check_tape(struct scsi_tape 
  }
  
  
 -\f/* Open the device. Needs to be called with BKL only because of incrementing the SCSI host
 +\f/* Open the device. Needs to take the BKL only because of incrementing the SCSI host
     module count. */
  static int st_open(struct inode *inode, struct file *filp)
  {
        int dev = TAPE_NR(inode);
        char *name;
  
 +      lock_kernel();
        /*
         * We really want to do nonseekable_open(inode, filp); here, but some
         * versions of tar incorrectly call lseek on tapes and bail out if that
         */
        filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
  
 -      if (!(STp = scsi_tape_get(dev)))
 +      if (!(STp = scsi_tape_get(dev))) {
 +              unlock_kernel();
                return -ENXIO;
 +      }
  
        write_lock(&st_dev_arr_lock);
        filp->private_data = STp;
        if (STp->in_use) {
                write_unlock(&st_dev_arr_lock);
                scsi_tape_put(STp);
 +              unlock_kernel();
                DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )
                return (-EBUSY);
        }
                        retval = (-EIO);
                goto err_out;
        }
 +      unlock_kernel();
        return 0;
  
   err_out:
        normalize_buffer(STp->buffer);
        STp->in_use = 0;
        scsi_tape_put(STp);
 +      unlock_kernel();
        return retval;
  
  }
@@@ -4431,17 -4424,19 +4431,19 @@@ static int do_create_class_files(struc
                snprintf(name, 10, "%s%s%s", rew ? "n" : "",
                         STp->disk->disk_name, st_formats[i]);
                st_class_member =
-                       device_create(st_sysfs_class, &STp->device->sdev_gendev,
-                                     MKDEV(SCSI_TAPE_MAJOR,
-                                               TAPE_MINOR(dev_num, mode, rew)),
-                                     "%s", name);
+                       device_create_drvdata(st_sysfs_class,
+                                             &STp->device->sdev_gendev,
+                                             MKDEV(SCSI_TAPE_MAJOR,
+                                                   TAPE_MINOR(dev_num,
+                                                             mode, rew)),
+                                             &STp->modes[mode],
+                                             "%s", name);
                if (IS_ERR(st_class_member)) {
                        printk(KERN_WARNING "st%d: device_create failed\n",
                               dev_num);
                        error = PTR_ERR(st_class_member);
                        goto out;
                }
-               dev_set_drvdata(st_class_member, &STp->modes[mode]);
  
                error = device_create_file(st_class_member,
                                           &dev_attr_defined);
diff --combined drivers/spi/spidev.c
  #include <linux/ioctl.h>
  #include <linux/fs.h>
  #include <linux/device.h>
+ #include <linux/err.h>
  #include <linux/list.h>
  #include <linux/errno.h>
  #include <linux/mutex.h>
  #include <linux/slab.h>
 +#include <linux/smp_lock.h>
  
  #include <linux/spi/spi.h>
  #include <linux/spi/spidev.h>
@@@ -68,10 -68,12 +69,12 @@@ static unsigned long       minors[N_SPI_MINOR
                                | SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP)
  
  struct spidev_data {
-       struct device           dev;
+       dev_t                   devt;
+       spinlock_t              spi_lock;
        struct spi_device       *spi;
        struct list_head        device_entry;
  
+       /* buffer is NULL unless this device is open (users > 0) */
        struct mutex            buf_lock;
        unsigned                users;
        u8                      *buffer;
@@@ -86,12 -88,75 +89,75 @@@ MODULE_PARM_DESC(bufsiz, "data bytes i
  
  /*-------------------------------------------------------------------------*/
  
+ /*
+  * We can't use the standard synchronous wrappers for file I/O; we
+  * need to protect against async removal of the underlying spi_device.
+  */
+ static void spidev_complete(void *arg)
+ {
+       complete(arg);
+ }
+ static ssize_t
+ spidev_sync(struct spidev_data *spidev, struct spi_message *message)
+ {
+       DECLARE_COMPLETION_ONSTACK(done);
+       int status;
+       message->complete = spidev_complete;
+       message->context = &done;
+       spin_lock_irq(&spidev->spi_lock);
+       if (spidev->spi == NULL)
+               status = -ESHUTDOWN;
+       else
+               status = spi_async(spidev->spi, message);
+       spin_unlock_irq(&spidev->spi_lock);
+       if (status == 0) {
+               wait_for_completion(&done);
+               status = message->status;
+               if (status == 0)
+                       status = message->actual_length;
+       }
+       return status;
+ }
+ static inline ssize_t
+ spidev_sync_write(struct spidev_data *spidev, size_t len)
+ {
+       struct spi_transfer     t = {
+                       .tx_buf         = spidev->buffer,
+                       .len            = len,
+               };
+       struct spi_message      m;
+       spi_message_init(&m);
+       spi_message_add_tail(&t, &m);
+       return spidev_sync(spidev, &m);
+ }
+ static inline ssize_t
+ spidev_sync_read(struct spidev_data *spidev, size_t len)
+ {
+       struct spi_transfer     t = {
+                       .rx_buf         = spidev->buffer,
+                       .len            = len,
+               };
+       struct spi_message      m;
+       spi_message_init(&m);
+       spi_message_add_tail(&t, &m);
+       return spidev_sync(spidev, &m);
+ }
+ /*-------------------------------------------------------------------------*/
  /* Read-only message with current device setup */
  static ssize_t
  spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
  {
        struct spidev_data      *spidev;
-       struct spi_device       *spi;
        ssize_t                 status = 0;
  
        /* chipselect only toggles at start or end of operation */
                return -EMSGSIZE;
  
        spidev = filp->private_data;
-       spi = spidev->spi;
  
        mutex_lock(&spidev->buf_lock);
-       status = spi_read(spi, spidev->buffer, count);
-       if (status == 0) {
+       status = spidev_sync_read(spidev, count);
+       if (status > 0) {
                unsigned long   missing;
  
-               missing = copy_to_user(buf, spidev->buffer, count);
-               if (count && missing == count)
+               missing = copy_to_user(buf, spidev->buffer, status);
+               if (missing == status)
                        status = -EFAULT;
                else
-                       status = count - missing;
+                       status = status - missing;
        }
        mutex_unlock(&spidev->buf_lock);
  
@@@ -123,7 -187,6 +188,6 @@@ spidev_write(struct file *filp, const c
                size_t count, loff_t *f_pos)
  {
        struct spidev_data      *spidev;
-       struct spi_device       *spi;
        ssize_t                 status = 0;
        unsigned long           missing;
  
                return -EMSGSIZE;
  
        spidev = filp->private_data;
-       spi = spidev->spi;
  
        mutex_lock(&spidev->buf_lock);
        missing = copy_from_user(spidev->buffer, buf, count);
        if (missing == 0) {
-               status = spi_write(spi, spidev->buffer, count);
-               if (status == 0)
-                       status = count;
+               status = spidev_sync_write(spidev, count);
        } else
                status = -EFAULT;
        mutex_unlock(&spidev->buf_lock);
@@@ -154,7 -214,6 +215,6 @@@ static int spidev_message(struct spidev
        struct spi_transfer     *k_xfers;
        struct spi_transfer     *k_tmp;
        struct spi_ioc_transfer *u_tmp;
-       struct spi_device       *spi = spidev->spi;
        unsigned                n, total;
        u8                      *buf;
        int                     status = -EFAULT;
                spi_message_add_tail(k_tmp, &msg);
        }
  
-       status = spi_sync(spi, &msg);
+       status = spidev_sync(spidev, &msg);
        if (status < 0)
                goto done;
  
@@@ -270,8 -329,16 +330,16 @@@ spidev_ioctl(struct inode *inode, struc
        if (err)
                return -EFAULT;
  
+       /* guard against device removal before, or while,
+        * we issue this ioctl.
+        */
        spidev = filp->private_data;
-       spi = spidev->spi;
+       spin_lock_irq(&spidev->spi_lock);
+       spi = spi_dev_get(spidev->spi);
+       spin_unlock_irq(&spidev->spi_lock);
+       if (spi == NULL)
+               return -ESHUTDOWN;
  
        switch (cmd) {
        /* read requests */
        default:
                /* segmented and/or full-duplex I/O request */
                if (_IOC_NR(cmd) != _IOC_NR(SPI_IOC_MESSAGE(0))
-                               || _IOC_DIR(cmd) != _IOC_WRITE)
-                       return -ENOTTY;
+                               || _IOC_DIR(cmd) != _IOC_WRITE) {
+                       retval = -ENOTTY;
+                       break;
+               }
  
                tmp = _IOC_SIZE(cmd);
                if ((tmp % sizeof(struct spi_ioc_transfer)) != 0) {
                kfree(ioc);
                break;
        }
+       spi_dev_put(spi);
        return retval;
  }
  
@@@ -394,11 -464,10 +465,11 @@@ static int spidev_open(struct inode *in
        struct spidev_data      *spidev;
        int                     status = -ENXIO;
  
 +      lock_kernel();
        mutex_lock(&device_list_lock);
  
        list_for_each_entry(spidev, &device_list, device_entry) {
-               if (spidev->dev.devt == inode->i_rdev) {
+               if (spidev->devt == inode->i_rdev) {
                        status = 0;
                        break;
                }
                pr_debug("spidev: nothing for minor %d\n", iminor(inode));
  
        mutex_unlock(&device_list_lock);
 +      unlock_kernel();
        return status;
  }
  
@@@ -432,10 -500,22 +503,22 @@@ static int spidev_release(struct inode 
        mutex_lock(&device_list_lock);
        spidev = filp->private_data;
        filp->private_data = NULL;
+       /* last close? */
        spidev->users--;
        if (!spidev->users) {
+               int             dofree;
                kfree(spidev->buffer);
                spidev->buffer = NULL;
+               /* ... after we unbound from the underlying device? */
+               spin_lock_irq(&spidev->spi_lock);
+               dofree = (spidev->spi == NULL);
+               spin_unlock_irq(&spidev->spi_lock);
+               if (dofree)
+                       kfree(spidev);
        }
        mutex_unlock(&device_list_lock);
  
@@@ -462,19 -542,7 +545,7 @@@ static struct file_operations spidev_fo
   * It also simplifies memory management.
   */
  
- static void spidev_classdev_release(struct device *dev)
- {
-       struct spidev_data      *spidev;
-       spidev = container_of(dev, struct spidev_data, dev);
-       kfree(spidev);
- }
- static struct class spidev_class = {
-       .name           = "spidev",
-       .owner          = THIS_MODULE,
-       .dev_release    = spidev_classdev_release,
- };
+ static struct class *spidev_class;
  
  /*-------------------------------------------------------------------------*/
  
@@@ -491,6 -559,7 +562,7 @@@ static int spidev_probe(struct spi_devi
  
        /* Initialize the driver data */
        spidev->spi = spi;
+       spin_lock_init(&spidev->spi_lock);
        mutex_init(&spidev->buf_lock);
  
        INIT_LIST_HEAD(&spidev->device_entry);
        mutex_lock(&device_list_lock);
        minor = find_first_zero_bit(minors, N_SPI_MINORS);
        if (minor < N_SPI_MINORS) {
-               spidev->dev.parent = &spi->dev;
-               spidev->dev.class = &spidev_class;
-               spidev->dev.devt = MKDEV(SPIDEV_MAJOR, minor);
-               snprintf(spidev->dev.bus_id, sizeof spidev->dev.bus_id,
+               struct device *dev;
+               spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
+               dev = device_create(spidev_class, &spi->dev, spidev->devt,
                                "spidev%d.%d",
                                spi->master->bus_num, spi->chip_select);
-               status = device_register(&spidev->dev);
+               status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
        } else {
                dev_dbg(&spi->dev, "no minor number available!\n");
                status = -ENODEV;
        }
        if (status == 0) {
                set_bit(minor, minors);
-               dev_set_drvdata(&spi->dev, spidev);
+               spi_set_drvdata(spi, spidev);
                list_add(&spidev->device_entry, &device_list);
        }
        mutex_unlock(&device_list_lock);
  
  static int spidev_remove(struct spi_device *spi)
  {
-       struct spidev_data      *spidev = dev_get_drvdata(&spi->dev);
+       struct spidev_data      *spidev = spi_get_drvdata(spi);
  
-       mutex_lock(&device_list_lock);
+       /* make sure ops on existing fds can abort cleanly */
+       spin_lock_irq(&spidev->spi_lock);
+       spidev->spi = NULL;
+       spi_set_drvdata(spi, NULL);
+       spin_unlock_irq(&spidev->spi_lock);
  
+       /* prevent new opens */
+       mutex_lock(&device_list_lock);
        list_del(&spidev->device_entry);
-       dev_set_drvdata(&spi->dev, NULL);
-       clear_bit(MINOR(spidev->dev.devt), minors);
-       device_unregister(&spidev->dev);
+       device_destroy(spidev_class, spidev->devt);
+       clear_bit(MINOR(spidev->devt), minors);
+       if (spidev->users == 0)
+               kfree(spidev);
        mutex_unlock(&device_list_lock);
  
        return 0;
@@@ -571,15 -646,15 +649,15 @@@ static int __init spidev_init(void
        if (status < 0)
                return status;
  
-       status = class_register(&spidev_class);
-       if (status < 0) {
+       spidev_class = class_create(THIS_MODULE, "spidev");
+       if (IS_ERR(spidev_class)) {
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
-               return status;
+               return PTR_ERR(spidev_class);
        }
  
        status = spi_register_driver(&spidev_spi);
        if (status < 0) {
-               class_unregister(&spidev_class);
+               class_destroy(spidev_class);
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
        }
        return status;
@@@ -589,7 -664,7 +667,7 @@@ module_init(spidev_init)
  static void __exit spidev_exit(void)
  {
        spi_unregister_driver(&spidev_spi);
-       class_unregister(&spidev_class);
+       class_destroy(spidev_class);
        unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
  }
  module_exit(spidev_exit);
diff --combined drivers/uio/uio.c
@@@ -297,17 -297,12 +297,17 @@@ static int uio_open(struct inode *inode
        struct uio_listener *listener;
        int ret = 0;
  
 +      lock_kernel();
        idev = idr_find(&uio_idr, iminor(inode));
 -      if (!idev)
 -              return -ENODEV;
 +      if (!idev) {
 +              ret = -ENODEV;
 +              goto out;
 +      }
  
 -      if (!try_module_get(idev->owner))
 -              return -ENODEV;
 +      if (!try_module_get(idev->owner)) {
 +              ret = -ENODEV;
 +              goto out;
 +      }
  
        listener = kmalloc(sizeof(*listener), GFP_KERNEL);
        if (!listener) {
                if (ret)
                        goto err_infoopen;
        }
 -
 +      unlock_kernel();
        return 0;
  
  err_infoopen:
@@@ -334,8 -329,6 +334,8 @@@ err_alloc_listener
  
        module_put(idev->owner);
  
 +out:
 +      unlock_kernel();
        return ret;
  }
  
@@@ -656,15 -649,14 +656,14 @@@ int __uio_register_device(struct modul
        if (ret)
                goto err_get_minor;
  
-       idev->dev = device_create(uio_class->class, parent,
-                                 MKDEV(uio_major, idev->minor),
-                                 "uio%d", idev->minor);
+       idev->dev = device_create_drvdata(uio_class->class, parent,
+                                         MKDEV(uio_major, idev->minor), idev,
+                                         "uio%d", idev->minor);
        if (IS_ERR(idev->dev)) {
                printk(KERN_ERR "UIO: device register failed\n");
                ret = PTR_ERR(idev->dev);
                goto err_device_create;
        }
-       dev_set_drvdata(idev->dev, idev);
  
        ret = uio_dev_add_attributes(idev);
        if (ret)
diff --combined fs/cifs/cifsfs.c
@@@ -1,7 -1,7 +1,7 @@@
  /*
   *   fs/cifs/cifsfs.c
   *
-  *   Copyright (C) International Business Machines  Corp., 2002,2007
+  *   Copyright (C) International Business Machines  Corp., 2002,2008
   *   Author(s): Steve French (sfrench@us.ibm.com)
   *
   *   Common Internet FileSystem (CIFS) client
@@@ -97,9 -97,6 +97,6 @@@ cifs_read_super(struct super_block *sb
  {
        struct inode *inode;
        struct cifs_sb_info *cifs_sb;
- #ifdef CONFIG_CIFS_DFS_UPCALL
-       int len;
- #endif
        int rc = 0;
  
        /* BB should we make this contingent on mount parm? */
         * complex operation (mount), and in case of fail
         * just exit instead of doing mount and attempting
         * undo it if this copy fails?*/
-       len = strlen(data);
-       cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
-       if (cifs_sb->mountdata == NULL) {
-               kfree(sb->s_fs_info);
-               sb->s_fs_info = NULL;
-               return -ENOMEM;
+       if (data) {
+               int len = strlen(data);
+               cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
+               if (cifs_sb->mountdata == NULL) {
+                       kfree(sb->s_fs_info);
+                       sb->s_fs_info = NULL;
+                       return -ENOMEM;
+               }
+               strncpy(cifs_sb->mountdata, data, len + 1);
+               cifs_sb->mountdata[len] = '\0';
        }
-       strncpy(cifs_sb->mountdata, data, len + 1);
-       cifs_sb->mountdata[len] = '\0';
  #endif
  
        rc = cifs_mount(sb, cifs_sb, data, devname);
@@@ -353,9 -352,41 +352,41 @@@ cifs_show_options(struct seq_file *s, s
                        if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
                           !(cifs_sb->tcon->unix_ext))
                                seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
+                       if (!cifs_sb->tcon->unix_ext) {
+                               seq_printf(s, ",file_mode=0%o,dir_mode=0%o",
+                                          cifs_sb->mnt_file_mode,
+                                          cifs_sb->mnt_dir_mode);
+                       }
+                       if (cifs_sb->tcon->seal)
+                               seq_printf(s, ",seal");
+                       if (cifs_sb->tcon->nocase)
+                               seq_printf(s, ",nocase");
+                       if (cifs_sb->tcon->retry)
+                               seq_printf(s, ",hard");
                }
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
                        seq_printf(s, ",posixpaths");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
+                       seq_printf(s, ",setuids");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
+                       seq_printf(s, ",serverino");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
+                       seq_printf(s, ",directio");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
+                       seq_printf(s, ",nouser_xattr");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
+                       seq_printf(s, ",mapchars");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
+                       seq_printf(s, ",sfu");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
+                       seq_printf(s, ",nobrl");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
+                       seq_printf(s, ",cifsacl");
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
+                       seq_printf(s, ",dynperm");
+               if (m->mnt_sb->s_flags & MS_POSIXACL)
+                       seq_printf(s, ",acl");
                seq_printf(s, ",rsize=%d", cifs_sb->rsize);
                seq_printf(s, ",wsize=%d", cifs_sb->wsize);
        }
@@@ -581,7 -612,7 +612,7 @@@ static loff_t cifs_llseek(struct file *
                if (retval < 0)
                        return (loff_t)retval;
        }
 -      return remote_llseek(file, offset, origin);
 +      return generic_file_llseek_unlocked(file, offset, origin);
  }
  
  struct file_system_type cifs_fs_type = {
@@@ -657,7 -688,7 +688,7 @@@ const struct file_operations cifs_file_
        .splice_read = generic_file_splice_read,
        .llseek = cifs_llseek,
  #ifdef CONFIG_CIFS_POSIX
-       .ioctl  = cifs_ioctl,
+       .unlocked_ioctl = cifs_ioctl,
  #endif /* CONFIG_CIFS_POSIX */
  
  #ifdef CONFIG_CIFS_EXPERIMENTAL
@@@ -677,7 -708,7 +708,7 @@@ const struct file_operations cifs_file_
        .flush = cifs_flush,
        .splice_read = generic_file_splice_read,
  #ifdef CONFIG_CIFS_POSIX
-       .ioctl  = cifs_ioctl,
+       .unlocked_ioctl  = cifs_ioctl,
  #endif /* CONFIG_CIFS_POSIX */
        .llseek = cifs_llseek,
  #ifdef CONFIG_CIFS_EXPERIMENTAL
@@@ -697,7 -728,7 +728,7 @@@ const struct file_operations cifs_file_
        .splice_read = generic_file_splice_read,
        .llseek = cifs_llseek,
  #ifdef CONFIG_CIFS_POSIX
-       .ioctl  = cifs_ioctl,
+       .unlocked_ioctl = cifs_ioctl,
  #endif /* CONFIG_CIFS_POSIX */
  
  #ifdef CONFIG_CIFS_EXPERIMENTAL
@@@ -716,7 -747,7 +747,7 @@@ const struct file_operations cifs_file_
        .flush = cifs_flush,
        .splice_read = generic_file_splice_read,
  #ifdef CONFIG_CIFS_POSIX
-       .ioctl  = cifs_ioctl,
+       .unlocked_ioctl  = cifs_ioctl,
  #endif /* CONFIG_CIFS_POSIX */
        .llseek = cifs_llseek,
  #ifdef CONFIG_CIFS_EXPERIMENTAL
@@@ -731,7 -762,7 +762,7 @@@ const struct file_operations cifs_dir_o
  #ifdef CONFIG_CIFS_EXPERIMENTAL
        .dir_notify = cifs_dir_notify,
  #endif /* CONFIG_CIFS_EXPERIMENTAL */
-       .ioctl  = cifs_ioctl,
+       .unlocked_ioctl  = cifs_ioctl,
  };
  
  static void
diff --combined fs/fat/file.c
@@@ -11,6 -11,7 +11,6 @@@
  #include <linux/mount.h>
  #include <linux/time.h>
  #include <linux/msdos_fs.h>
 -#include <linux/smp_lock.h>
  #include <linux/buffer_head.h>
  #include <linux/writeback.h>
  #include <linux/backing-dev.h>
@@@ -241,7 -242,9 +241,7 @@@ void fat_truncate(struct inode *inode
  
        nr_clusters = (inode->i_size + (cluster_size - 1)) >> sbi->cluster_bits;
  
 -      lock_kernel();
        fat_free(inode, nr_clusters);
 -      unlock_kernel();
        fat_flush_inodes(inode->i_sb, inode, NULL);
  }
  
@@@ -254,26 -257,34 +254,34 @@@ int fat_getattr(struct vfsmount *mnt, s
  }
  EXPORT_SYMBOL_GPL(fat_getattr);
  
- static int fat_check_mode(const struct msdos_sb_info *sbi, struct inode *inode,
-                         mode_t mode)
+ static int fat_sanitize_mode(const struct msdos_sb_info *sbi,
+                            struct inode *inode, umode_t *mode_ptr)
  {
-       mode_t mask, req = mode & ~S_IFMT;
+       mode_t mask, perm;
  
-       if (S_ISREG(mode))
+       /*
+        * Note, the basic check is already done by a caller of
+        * (attr->ia_mode & ~MSDOS_VALID_MODE)
+        */
+       if (S_ISREG(inode->i_mode))
                mask = sbi->options.fs_fmask;
        else
                mask = sbi->options.fs_dmask;
  
+       perm = *mode_ptr & ~(S_IFMT | mask);
        /*
         * Of the r and x bits, all (subject to umask) must be present. Of the
         * w bits, either all (subject to umask) or none must be present.
         */
-       req &= ~mask;
-       if ((req & (S_IRUGO | S_IXUGO)) != (inode->i_mode & (S_IRUGO|S_IXUGO)))
+       if ((perm & (S_IRUGO | S_IXUGO)) != (inode->i_mode & (S_IRUGO|S_IXUGO)))
                return -EPERM;
-       if ((req & S_IWUGO) && ((req & S_IWUGO) != (S_IWUGO & ~mask)))
+       if ((perm & S_IWUGO) && ((perm & S_IWUGO) != (S_IWUGO & ~mask)))
                return -EPERM;
  
+       *mode_ptr &= S_IFMT | perm;
        return 0;
  }
  
@@@ -296,9 -307,11 +304,9 @@@ int fat_setattr(struct dentry *dentry, 
  {
        struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
        struct inode *inode = dentry->d_inode;
-       int mask, error = 0;
+       int error = 0;
        unsigned int ia_valid;
  
 -      lock_kernel();
 -
        /*
         * Expand the file. Since inode_setattr() updates ->i_size
         * before calling the ->truncate(), but FAT needs to fill the
                        error = 0;
                goto out;
        }
        if (((attr->ia_valid & ATTR_UID) &&
             (attr->ia_uid != sbi->options.fs_uid)) ||
            ((attr->ia_valid & ATTR_GID) &&
             (attr->ia_gid != sbi->options.fs_gid)) ||
            ((attr->ia_valid & ATTR_MODE) &&
-            fat_check_mode(sbi, inode, attr->ia_mode) < 0))
+            (attr->ia_mode & ~MSDOS_VALID_MODE)))
                error = -EPERM;
  
        if (error) {
                goto out;
        }
  
-       error = inode_setattr(inode, attr);
-       if (error)
-               goto out;
+       /*
+        * We don't return -EPERM here. Yes, strange, but this is too
+        * old behavior.
+        */
+       if (attr->ia_valid & ATTR_MODE) {
+               if (fat_sanitize_mode(sbi, inode, &attr->ia_mode) < 0)
+                       attr->ia_valid &= ~ATTR_MODE;
+       }
  
-       if (S_ISDIR(inode->i_mode))
-               mask = sbi->options.fs_dmask;
-       else
-               mask = sbi->options.fs_fmask;
-       inode->i_mode &= S_IFMT | (S_IRWXUGO & ~mask);
+       error = inode_setattr(inode, attr);
  out:
 -      unlock_kernel();
        return error;
  }
  EXPORT_SYMBOL_GPL(fat_setattr);
diff --combined fs/nfs/file.c
@@@ -170,7 -170,6 +170,7 @@@ force_reval
  
  static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
  {
 +      loff_t loff;
        /* origin == SEEK_END => we must revalidate the cached file length */
        if (origin == SEEK_END) {
                struct inode *inode = filp->f_mapping->host;
                if (retval < 0)
                        return (loff_t)retval;
        }
 -      return remote_llseek(filp, offset, origin);
 +      lock_kernel();  /* BKL needed? */
 +      loff = generic_file_llseek_unlocked(filp, offset, origin);
 +      unlock_kernel();
 +      return loff;
  }
  
  /*
@@@ -530,7 -526,7 +530,7 @@@ static int do_vfs_lock(struct file *fil
        if (res < 0)
                dprintk(KERN_WARNING "%s: VFS is out of sync with lock manager"
                        " - error %d!\n",
-                               __FUNCTION__, res);
+                               __func__, res);
        return res;
  }
  
diff --combined fs/ocfs2/stack_user.c
@@@ -21,7 -21,6 +21,7 @@@
  #include <linux/fs.h>
  #include <linux/miscdevice.h>
  #include <linux/mutex.h>
 +#include <linux/smp_lock.h>
  #include <linux/reboot.h>
  #include <asm/uaccess.h>
  
@@@ -62,7 -61,7 +62,7 @@@
   * negotiated by the client.  The client negotiates based on the maximum
   * version advertised in /sys/fs/ocfs2/max_locking_protocol.  The major
   * number from the "SETV" message must match
-  * user_stack.sp_proto->lp_max_version.pv_major, and the minor number
+  * ocfs2_user_plugin.sp_proto->lp_max_version.pv_major, and the minor number
   * must be less than or equal to ...->lp_max_version.pv_minor.
   *
   * Once this information has been set, mounts will be allowed.  From this
@@@ -154,7 -153,7 +154,7 @@@ union ocfs2_control_message 
        struct ocfs2_control_message_down       u_down;
  };
  
- static struct ocfs2_stack_plugin user_stack;
+ static struct ocfs2_stack_plugin ocfs2_user_plugin;
  
  static atomic_t ocfs2_control_opened;
  static int ocfs2_control_this_node = -1;
@@@ -400,7 -399,7 +400,7 @@@ static int ocfs2_control_do_setversion_
        char *ptr = NULL;
        struct ocfs2_control_private *p = file->private_data;
        struct ocfs2_protocol_version *max =
-               &user_stack.sp_proto->lp_max_version;
+               &ocfs2_user_plugin.sp_proto->lp_max_version;
  
        if (ocfs2_control_get_handshake_state(file) !=
            OCFS2_CONTROL_HANDSHAKE_PROTOCOL)
@@@ -620,12 -619,10 +620,12 @@@ static int ocfs2_control_open(struct in
                return -ENOMEM;
        p->op_this_node = -1;
  
 +      lock_kernel();
        mutex_lock(&ocfs2_control_lock);
        file->private_data = p;
        list_add(&p->op_list, &ocfs2_control_private_list);
        mutex_unlock(&ocfs2_control_lock);
 +      unlock_kernel();
  
        return 0;
  }
@@@ -683,7 -680,7 +683,7 @@@ static void fsdlm_lock_ast_wrapper(voi
        struct dlm_lksb *lksb = fsdlm_astarg_to_lksb(astarg);
        int status = lksb->sb_status;
  
-       BUG_ON(user_stack.sp_proto == NULL);
+       BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
  
        /*
         * For now we're punting on the issue of other non-standard errors
         */
  
        if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL)
-               user_stack.sp_proto->lp_unlock_ast(astarg, 0);
+               ocfs2_user_plugin.sp_proto->lp_unlock_ast(astarg, 0);
        else
-               user_stack.sp_proto->lp_lock_ast(astarg);
+               ocfs2_user_plugin.sp_proto->lp_lock_ast(astarg);
  }
  
  static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
  {
-       BUG_ON(user_stack.sp_proto == NULL);
+       BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
  
-       user_stack.sp_proto->lp_blocking_ast(astarg, level);
+       ocfs2_user_plugin.sp_proto->lp_blocking_ast(astarg, level);
  }
  
  static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
@@@ -819,8 -816,7 +819,7 @@@ out
        return rc;
  }
  
- static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn,
-                                  int hangup_pending)
+ static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
  {
        dlm_release_lockspace(conn->cc_lockspace, 2);
        conn->cc_lockspace = NULL;
@@@ -841,7 -837,7 +840,7 @@@ static int user_cluster_this_node(unsig
        return 0;
  }
  
- static struct ocfs2_stack_operations user_stack_ops = {
+ static struct ocfs2_stack_operations ocfs2_user_plugin_ops = {
        .connect        = user_cluster_connect,
        .disconnect     = user_cluster_disconnect,
        .this_node      = user_cluster_this_node,
        .dump_lksb      = user_dlm_dump_lksb,
  };
  
- static struct ocfs2_stack_plugin user_stack = {
+ static struct ocfs2_stack_plugin ocfs2_user_plugin = {
        .sp_name        = "user",
-       .sp_ops         = &user_stack_ops,
+       .sp_ops         = &ocfs2_user_plugin_ops,
        .sp_owner       = THIS_MODULE,
  };
  
  
- static int __init user_stack_init(void)
+ static int __init ocfs2_user_plugin_init(void)
  {
        int rc;
  
        rc = ocfs2_control_init();
        if (!rc) {
-               rc = ocfs2_stack_glue_register(&user_stack);
+               rc = ocfs2_stack_glue_register(&ocfs2_user_plugin);
                if (rc)
                        ocfs2_control_exit();
        }
        return rc;
  }
  
- static void __exit user_stack_exit(void)
+ static void __exit ocfs2_user_plugin_exit(void)
  {
-       ocfs2_stack_glue_unregister(&user_stack);
+       ocfs2_stack_glue_unregister(&ocfs2_user_plugin);
        ocfs2_control_exit();
  }
  
  MODULE_AUTHOR("Oracle");
  MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks");
  MODULE_LICENSE("GPL");
- module_init(user_stack_init);
- module_exit(user_stack_exit);
+ module_init(ocfs2_user_plugin_init);
+ module_exit(ocfs2_user_plugin_exit);
diff --combined include/linux/fs.h
@@@ -83,6 -83,7 +83,7 @@@ extern int dir_notify_enable
  #define READ_SYNC     (READ | (1 << BIO_RW_SYNC))
  #define READ_META     (READ | (1 << BIO_RW_META))
  #define WRITE_SYNC    (WRITE | (1 << BIO_RW_SYNC))
+ #define SWRITE_SYNC   (SWRITE | (1 << BIO_RW_SYNC))
  #define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER))
  
  #define SEL_IN                1
@@@ -894,8 -895,6 +895,6 @@@ static inline int file_check_writeable(
  typedef struct files_struct *fl_owner_t;
  
  struct file_lock_operations {
-       void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
-       void (*fl_remove)(struct file_lock *);  /* lock removal callback */
        void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
        void (*fl_release_private)(struct file_lock *);
  };
@@@ -1871,8 -1870,7 +1870,8 @@@ extern voi
  file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
  extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
  extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
 -extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
 +extern loff_t generic_file_llseek_unlocked(struct file *file, loff_t offset,
 +                      int origin);
  extern int generic_file_open(struct inode * inode, struct file * filp);
  extern int nonseekable_open(struct inode * inode, struct file * filp);
  
@@@ -2001,7 -1999,10 +2000,10 @@@ extern int simple_fill_super(struct sup
  extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
  extern void simple_release_fs(struct vfsmount **mount, int *count);
  
- extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
+ extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
+                       loff_t *ppos, const void *from, size_t available);
+ extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
+                       const void *from, size_t available);
  
  #ifdef CONFIG_MIGRATION
  extern int buffer_migrate_page(struct address_space *,
diff --combined sound/core/sound.c
@@@ -21,7 -21,6 +21,7 @@@
  
  #include <linux/init.h>
  #include <linux/slab.h>
 +#include <linux/smp_lock.h>
  #include <linux/time.h>
  #include <linux/device.h>
  #include <linux/moduleparam.h>
@@@ -122,7 -121,7 +122,7 @@@ void *snd_lookup_minor_data(unsigned in
  
  EXPORT_SYMBOL(snd_lookup_minor_data);
  
 -static int snd_open(struct inode *inode, struct file *file)
 +static int __snd_open(struct inode *inode, struct file *file)
  {
        unsigned int minor = iminor(inode);
        struct snd_minor *mptr = NULL;
        return err;
  }
  
 +
 +/* BKL pushdown: nasty #ifdef avoidance wrapper */
 +static int snd_open(struct inode *inode, struct file *file)
 +{
 +      int ret;
 +
 +      lock_kernel();
 +      ret = __snd_open(inode, file);
 +      unlock_kernel();
 +      return ret;
 +}
 +
  static const struct file_operations snd_fops =
  {
        .owner =        THIS_MODULE,
@@@ -272,8 -259,9 +272,9 @@@ int snd_register_device_for_dev(int typ
                return minor;
        }
        snd_minors[minor] = preg;
-       preg->dev = device_create(sound_class, device, MKDEV(major, minor),
-                                 "%s", name);
+       preg->dev = device_create_drvdata(sound_class, device,
+                                         MKDEV(major, minor),
+                                         private_data, "%s", name);
        if (IS_ERR(preg->dev)) {
                snd_minors[minor] = NULL;
                mutex_unlock(&sound_mutex);
                return minor;
        }
  
-       if (preg->dev)
-               dev_set_drvdata(preg->dev, private_data);
        mutex_unlock(&sound_mutex);
        return 0;
  }