USB: usbmon: fix bug in mon_buff_area_shrink
[safe/jmp/linux-2.6] / drivers / char / ds1620.c
index 953e670..61f0146 100644 (file)
@@ -3,15 +3,14 @@
  *   thermometer driver (as used in the Rebel.com NetWinder)
  */
 #include <linux/module.h>
-#include <linux/sched.h>
 #include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
 #include <linux/capability.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 
-#include <asm/hardware.h>
+#include <mach/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/uaccess.h>
 #include <asm/therm.h>
@@ -44,52 +43,51 @@ static const char *fan_state[] = { "off", "on", "on (hardwired)" };
  *  chance that the WaveArtist driver could touch these bits to
  *  enable or disable the speaker.
  */
-extern spinlock_t gpio_lock;
 extern unsigned int system_rev;
 
 static inline void netwinder_ds1620_set_clk(int clk)
 {
-       gpio_modify_op(GPIO_DSCLK, clk ? GPIO_DSCLK : 0);
+       nw_gpio_modify_op(GPIO_DSCLK, clk ? GPIO_DSCLK : 0);
 }
 
 static inline void netwinder_ds1620_set_data(int dat)
 {
-       gpio_modify_op(GPIO_DATA, dat ? GPIO_DATA : 0);
+       nw_gpio_modify_op(GPIO_DATA, dat ? GPIO_DATA : 0);
 }
 
 static inline int netwinder_ds1620_get_data(void)
 {
-       return gpio_read() & GPIO_DATA;
+       return nw_gpio_read() & GPIO_DATA;
 }
 
 static inline void netwinder_ds1620_set_data_dir(int dir)
 {
-       gpio_modify_io(GPIO_DATA, dir ? GPIO_DATA : 0);
+       nw_gpio_modify_io(GPIO_DATA, dir ? GPIO_DATA : 0);
 }
 
 static inline void netwinder_ds1620_reset(void)
 {
-       cpld_modify(CPLD_DS_ENABLE, 0);
-       cpld_modify(CPLD_DS_ENABLE, CPLD_DS_ENABLE);
+       nw_cpld_modify(CPLD_DS_ENABLE, 0);
+       nw_cpld_modify(CPLD_DS_ENABLE, CPLD_DS_ENABLE);
 }
 
 static inline void netwinder_lock(unsigned long *flags)
 {
-       spin_lock_irqsave(&gpio_lock, *flags);
+       spin_lock_irqsave(&nw_gpio_lock, *flags);
 }
 
 static inline void netwinder_unlock(unsigned long *flags)
 {
-       spin_unlock_irqrestore(&gpio_lock, *flags);
+       spin_unlock_irqrestore(&nw_gpio_lock, *flags);
 }
 
 static inline void netwinder_set_fan(int i)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&gpio_lock, flags);
-       gpio_modify_op(GPIO_FAN, i ? GPIO_FAN : 0);
-       spin_unlock_irqrestore(&gpio_lock, flags);
+       spin_lock_irqsave(&nw_gpio_lock, flags);
+       nw_gpio_modify_op(GPIO_FAN, i ? GPIO_FAN : 0);
+       spin_unlock_irqrestore(&nw_gpio_lock, flags);
 }
 
 static inline int netwinder_get_fan(void)
@@ -97,7 +95,7 @@ static inline int netwinder_get_fan(void)
        if ((system_rev & 0xf000) == 0x4000)
                return FAN_ALWAYS_ON;
 
-       return (gpio_read() & GPIO_FAN) ? FAN_ON : FAN_OFF;
+       return (nw_gpio_read() & GPIO_FAN) ? FAN_ON : FAN_OFF;
 }
 
 /*
@@ -210,6 +208,12 @@ static void ds1620_read_state(struct therm *therm)
        therm->hi = cvt_9_to_int(ds1620_in(THERM_READ_TH, 9));
 }
 
+static int ds1620_open(struct inode *inode, struct file *file)
+{
+       cycle_kernel_lock();
+       return nonseekable_open(inode, file);
+}
+
 static ssize_t
 ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
 {
@@ -336,9 +340,9 @@ proc_therm_ds1620_read(char *buf, char **start, off_t offset,
 static struct proc_dir_entry *proc_therm_ds1620;
 #endif
 
-static struct file_operations ds1620_fops = {
+static const struct file_operations ds1620_fops = {
        .owner          = THIS_MODULE,
-       .open           = nonseekable_open,
+       .open           = ds1620_open,
        .read           = ds1620_read,
        .ioctl          = ds1620_ioctl,
 };