[PATCH] irq-flags: drivers/char: Use the new IRQF_ constants
[linux-2.6-block.git] / drivers / char / ipmi / ipmi_si_intf.c
index a86c0f29953e7c1e2fa5921af10bb7ba88ebe062..f57eba0bf253553135c1cd62495664baa46d6dae 100644 (file)
@@ -38,7 +38,6 @@
  * and drives the real SMI state machine.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <asm/system.h>
 #include <linux/mutex.h>
 #include <linux/kthread.h>
 #include <asm/irq.h>
-#ifdef CONFIG_HIGH_RES_TIMERS
-#include <linux/hrtime.h>
-# if defined(schedule_next_int)
-/* Old high-res timer code, do translations. */
-#  define get_arch_cycles(a) quick_update_jiffies_sub(a)
-#  define arch_cycles_per_jiffy cycles_per_jiffies
-# endif
-static inline void add_usec_to_timer(struct timer_list *t, long v)
-{
-       t->arch_cycle_expires += nsec_to_arch_cycle(v * 1000);
-       while (t->arch_cycle_expires >= arch_cycles_per_jiffy)
-       {
-               t->expires++;
-               t->arch_cycle_expires -= arch_cycles_per_jiffy;
-       }
-}
-#endif
 #include <linux/interrupt.h>
 #include <linux/rcupdate.h>
 #include <linux/ipmi_smi.h>
@@ -243,8 +225,6 @@ static int register_xaction_notifier(struct notifier_block * nb)
        return atomic_notifier_chain_register(&xaction_notifier_list, nb);
 }
 
-static void si_restart_short_timer(struct smi_info *smi_info);
-
 static void deliver_recv_msg(struct smi_info *smi_info,
                             struct ipmi_smi_msg *msg)
 {
@@ -768,7 +748,6 @@ static void sender(void                *send_info,
            && (smi_info->curr_msg == NULL))
        {
                start_next_msg(smi_info);
-               si_restart_short_timer(smi_info);
        }
        spin_unlock_irqrestore(&(smi_info->si_lock), flags);
 }
@@ -809,7 +788,7 @@ static int ipmi_thread(void *data)
                        /* do nothing */
                }
                else if (smi_result == SI_SM_CALL_WITH_DELAY)
-                       udelay(1);
+                       schedule();
                else
                        schedule_timeout_interruptible(1);
        }
@@ -833,37 +812,6 @@ static void request_events(void *send_info)
 
 static int initialized = 0;
 
-/* Must be called with interrupts off and with the si_lock held. */
-static void si_restart_short_timer(struct smi_info *smi_info)
-{
-#if defined(CONFIG_HIGH_RES_TIMERS)
-       unsigned long flags;
-       unsigned long jiffies_now;
-       unsigned long seq;
-
-       if (del_timer(&(smi_info->si_timer))) {
-               /* If we don't delete the timer, then it will go off
-                  immediately, anyway.  So we only process if we
-                  actually delete the timer. */
-
-               do {
-                       seq = read_seqbegin_irqsave(&xtime_lock, flags);
-                       jiffies_now = jiffies;
-                       smi_info->si_timer.expires = jiffies_now;
-                       smi_info->si_timer.arch_cycle_expires
-                               = get_arch_cycles(jiffies_now);
-               } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
-
-               add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
-
-               add_timer(&(smi_info->si_timer));
-               spin_lock_irqsave(&smi_info->count_lock, flags);
-               smi_info->timeout_restarts++;
-               spin_unlock_irqrestore(&smi_info->count_lock, flags);
-       }
-#endif
-}
-
 static void smi_timeout(unsigned long data)
 {
        struct smi_info   *smi_info = (struct smi_info *) data;
@@ -904,31 +852,15 @@ static void smi_timeout(unsigned long data)
        /* If the state machine asks for a short delay, then shorten
            the timer timeout. */
        if (smi_result == SI_SM_CALL_WITH_DELAY) {
-#if defined(CONFIG_HIGH_RES_TIMERS)
-               unsigned long seq;
-#endif
                spin_lock_irqsave(&smi_info->count_lock, flags);
                smi_info->short_timeouts++;
                spin_unlock_irqrestore(&smi_info->count_lock, flags);
-#if defined(CONFIG_HIGH_RES_TIMERS)
-               do {
-                       seq = read_seqbegin_irqsave(&xtime_lock, flags);
-                       smi_info->si_timer.expires = jiffies;
-                       smi_info->si_timer.arch_cycle_expires
-                               = get_arch_cycles(smi_info->si_timer.expires);
-               } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
-               add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
-#else
                smi_info->si_timer.expires = jiffies + 1;
-#endif
        } else {
                spin_lock_irqsave(&smi_info->count_lock, flags);
                smi_info->long_timeouts++;
                spin_unlock_irqrestore(&smi_info->count_lock, flags);
                smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
-#if defined(CONFIG_HIGH_RES_TIMERS)
-               smi_info->si_timer.arch_cycle_expires = 0;
-#endif
        }
 
  do_add_timer:
@@ -1109,7 +1041,7 @@ static int std_irq_setup(struct smi_info *info)
        if (info->si_type == SI_BT) {
                rv = request_irq(info->irq,
                                 si_bt_irq_handler,
-                                SA_INTERRUPT,
+                                IRQF_DISABLED,
                                 DEVICE_NAME,
                                 info);
                if (!rv)
@@ -1119,7 +1051,7 @@ static int std_irq_setup(struct smi_info *info)
        } else
                rv = request_irq(info->irq,
                                 si_irq_handler,
-                                SA_INTERRUPT,
+                                IRQF_DISABLED,
                                 DEVICE_NAME,
                                 info);
        if (rv) {
@@ -1184,20 +1116,20 @@ static void port_outl(struct si_sm_io *io, unsigned int offset,
 static void port_cleanup(struct smi_info *info)
 {
        unsigned int addr = info->io.addr_data;
-       int          mapsize;
+       int          idx;
 
        if (addr) {
-               mapsize = ((info->io_size * info->io.regspacing)
-                          - (info->io.regspacing - info->io.regsize));
-
-               release_region (addr, mapsize);
+               for (idx = 0; idx < info->io_size; idx++) {
+                       release_region(addr + idx * info->io.regspacing,
+                                      info->io.regsize);
+               }
        }
 }
 
 static int port_setup(struct smi_info *info)
 {
        unsigned int addr = info->io.addr_data;
-       int          mapsize;
+       int          idx;
 
        if (!addr)
                return -ENODEV;
@@ -1225,16 +1157,22 @@ static int port_setup(struct smi_info *info)
                return -EINVAL;
        }
 
-       /* Calculate the total amount of memory to claim.  This is an
-        * unusual looking calculation, but it avoids claiming any
-        * more memory than it has to.  It will claim everything
-        * between the first address to the end of the last full
-        * register. */
-       mapsize = ((info->io_size * info->io.regspacing)
-                  - (info->io.regspacing - info->io.regsize));
-
-       if (request_region(addr, mapsize, DEVICE_NAME) == NULL)
-               return -EIO;
+       /* Some BIOSes reserve disjoint I/O regions in their ACPI
+        * tables.  This causes problems when trying to register the
+        * entire I/O region.  Therefore we must register each I/O
+        * port separately.
+        */
+       for (idx = 0; idx < info->io_size; idx++) {
+               if (request_region(addr + idx * info->io.regspacing,
+                                  info->io.regsize, DEVICE_NAME) == NULL) {
+                       /* Undo allocations */
+                       while (idx--) {
+                               release_region(addr + idx * info->io.regspacing,
+                                              info->io.regsize);
+                       }
+                       return -EIO;
+               }
+       }
        return 0;
 }
 
@@ -2198,11 +2136,11 @@ static inline void wait_for_timer_and_thread(struct smi_info *smi_info)
        }
 }
 
-static struct ipmi_default_vals
+static __devinitdata struct ipmi_default_vals
 {
        int type;
        int port;
-} __devinit ipmi_defaults[] =
+} ipmi_defaults[] =
 {
        { .type = SI_KCS, .port = 0xca2 },
        { .type = SI_SMIC, .port = 0xca9 },