Merge branch 'bkl-drivers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 9 Dec 2009 16:07:38 +0000 (08:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 9 Dec 2009 16:07:38 +0000 (08:07 -0800)
* 'bkl-drivers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  agp: Remove the BKL from agp_open
  inifiband: Remove BKL from ipath_open()
  mips: Remove BKL from tb0219
  drivers: Remove BKL from scx200_gpio
  drivers: Remove BKL from pc8736x_gpio
  parisc: Remove BKL from eisa_eeprom
  rtc: Remove BKL from efirtc
  input: Remove BKL from hp_sdc_rtc
  hw_random: Remove BKL from core
  macintosh: Remove BKL from ans-lcd
  nvram: Drop the bkl from non-generic nvram_llseek()
  nvram: Drop the bkl from nvram_llseek()
  mem_class: Drop the bkl from memory_open()
  spi: Remove BKL from spidev_open
  drivers: Remove BKL from cs5535_gpio
  drivers: Remove BKL from misc_open

1  2 
drivers/char/hw_random/core.c
drivers/input/misc/hp_sdc_rtc.c

index 8b7d56a0fe3a50f3620709a8b0c14ec703409305,75fb859a50be4740012b9e5afb94a9f446876475..e989f67bb61f14b84fd66f90f1a87008ff9117dc
@@@ -52,9 -52,7 +52,9 @@@
  static struct hwrng *current_rng;
  static LIST_HEAD(rng_list);
  static DEFINE_MUTEX(rng_mutex);
 -
 +static int data_avail;
 +static u8 rng_buffer[SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES]
 +      __cacheline_aligned;
  
  static inline int hwrng_init(struct hwrng *rng)
  {
@@@ -69,6 -67,19 +69,6 @@@ static inline void hwrng_cleanup(struc
                rng->cleanup(rng);
  }
  
 -static inline int hwrng_data_present(struct hwrng *rng, int wait)
 -{
 -      if (!rng->data_present)
 -              return 1;
 -      return rng->data_present(rng, wait);
 -}
 -
 -static inline int hwrng_data_read(struct hwrng *rng, u32 *data)
 -{
 -      return rng->data_read(rng, data);
 -}
 -
 -
  static int rng_dev_open(struct inode *inode, struct file *filp)
  {
        /* enforce read-only access to this chrdev */
                return -EINVAL;
        if (filp->f_mode & FMODE_WRITE)
                return -EINVAL;
-       cycle_kernel_lock();
        return 0;
  }
  
 +static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
 +                      int wait) {
 +      int present;
 +
 +      if (rng->read)
 +              return rng->read(rng, (void *)buffer, size, wait);
 +
 +      if (rng->data_present)
 +              present = rng->data_present(rng, wait);
 +      else
 +              present = 1;
 +
 +      if (present)
 +              return rng->data_read(rng, (u32 *)buffer);
 +
 +      return 0;
 +}
 +
  static ssize_t rng_dev_read(struct file *filp, char __user *buf,
                            size_t size, loff_t *offp)
  {
 -      u32 data;
        ssize_t ret = 0;
        int err = 0;
 -      int bytes_read;
 +      int bytes_read, len;
  
        while (size) {
 -              err = -ERESTARTSYS;
 -              if (mutex_lock_interruptible(&rng_mutex))
 +              if (mutex_lock_interruptible(&rng_mutex)) {
 +                      err = -ERESTARTSYS;
                        goto out;
 +              }
 +
                if (!current_rng) {
 -                      mutex_unlock(&rng_mutex);
                        err = -ENODEV;
 -                      goto out;
 +                      goto out_unlock;
                }
  
 -              bytes_read = 0;
 -              if (hwrng_data_present(current_rng,
 -                                     !(filp->f_flags & O_NONBLOCK)))
 -                      bytes_read = hwrng_data_read(current_rng, &data);
 -              mutex_unlock(&rng_mutex);
 -
 -              err = -EAGAIN;
 -              if (!bytes_read && (filp->f_flags & O_NONBLOCK))
 -                      goto out;
 -              if (bytes_read < 0) {
 -                      err = bytes_read;
 -                      goto out;
 +              if (!data_avail) {
 +                      bytes_read = rng_get_data(current_rng, rng_buffer,
 +                              sizeof(rng_buffer),
 +                              !(filp->f_flags & O_NONBLOCK));
 +                      if (bytes_read < 0) {
 +                              err = bytes_read;
 +                              goto out_unlock;
 +                      }
 +                      data_avail = bytes_read;
                }
  
 -              err = -EFAULT;
 -              while (bytes_read && size) {
 -                      if (put_user((u8)data, buf++))
 -                              goto out;
 -                      size--;
 -                      ret++;
 -                      bytes_read--;
 -                      data >>= 8;
 +              if (!data_avail) {
 +                      if (filp->f_flags & O_NONBLOCK) {
 +                              err = -EAGAIN;
 +                              goto out_unlock;
 +                      }
 +              } else {
 +                      len = data_avail;
 +                      if (len > size)
 +                              len = size;
 +
 +                      data_avail -= len;
 +
 +                      if (copy_to_user(buf + ret, rng_buffer + data_avail,
 +                                                              len)) {
 +                              err = -EFAULT;
 +                              goto out_unlock;
 +                      }
 +
 +                      size -= len;
 +                      ret += len;
                }
  
 +              mutex_unlock(&rng_mutex);
 +
                if (need_resched())
                        schedule_timeout_interruptible(1);
 -              err = -ERESTARTSYS;
 -              if (signal_pending(current))
 +
 +              if (signal_pending(current)) {
 +                      err = -ERESTARTSYS;
                        goto out;
 +              }
        }
 +out_unlock:
 +      mutex_unlock(&rng_mutex);
  out:
        return ret ? : err;
  }
@@@ -302,7 -279,7 +301,7 @@@ int hwrng_register(struct hwrng *rng
        struct hwrng *old_rng, *tmp;
  
        if (rng->name == NULL ||
 -          rng->data_read == NULL)
 +          (rng->data_read == NULL && rng->read == NULL))
                goto out;
  
        mutex_lock(&rng_mutex);
index ea821b54696991929e835ec1e308d7ba2f987fcf,4d1aa9a2c336db9794df26f5f01d7ef2ddcf9ddd..ad730e15afc0c7ce8f2cb30b13f12e2cc34aec3a
@@@ -35,7 -35,6 +35,6 @@@
  
  #include <linux/hp_sdc.h>
  #include <linux/errno.h>
- #include <linux/smp_lock.h>
  #include <linux/types.h>
  #include <linux/init.h>
  #include <linux/module.h>
@@@ -209,7 -208,7 +208,7 @@@ static inline int hp_sdc_rtc_read_rt(st
  
  /* Read the i8042 fast handshake timer */
  static inline int hp_sdc_rtc_read_fhs(struct timeval *res) {
 -      uint64_t raw;
 +      int64_t raw;
        unsigned int tenms;
  
        raw = hp_sdc_rtc_read_i8042timer(HP_SDC_CMD_LOAD_FHS, 2);
@@@ -409,7 -408,6 +408,6 @@@ static unsigned int hp_sdc_rtc_poll(str
  
  static int hp_sdc_rtc_open(struct inode *inode, struct file *file)
  {
-       cycle_kernel_lock();
          return 0;
  }