fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / ieee1394 / csr.c
index 6bfc74d..52ac83e 100644 (file)
  *
  */
 
-#include <linux/string.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/param.h>
 #include <linux/spinlock.h>
+#include <linux/string.h>
 
 #include "csr1212.h"
 #include "ieee1394_types.h"
 #include "hosts.h"
 #include "ieee1394.h"
 #include "highlevel.h"
+#include "ieee1394_core.h"
 
 /* Module Parameters */
 /* this module parameter can be used to disable mapping of the FCP registers */
@@ -148,32 +151,17 @@ static void host_reset(struct hpsb_host *host)
 
 /*
  * HI == seconds (bits 0:2)
- * LO == fraction units of 1/8000 of a second, as per 1394 (bits 19:31)
- *
- * Convert to units and then to HZ, for comparison to jiffies.
- *
- * By default this will end up being 800 units, or 100ms (125usec per
- * unit).
+ * LO == fractions of a second in units of 125usec (bits 19:31)
  *
- * NOTE: The spec says 1/8000, but also says we can compute based on 1/8192
- * like CSR specifies. Should make our math less complex.
+ * Convert SPLIT_TIMEOUT to jiffies.
+ * The default and minimum as per 1394a-2000 clause 8.3.2.2.6 is 100ms.
  */
 static inline void calculate_expire(struct csr_control *csr)
 {
-       unsigned long units;
-
-       /* Take the seconds, and convert to units */
-       units = (unsigned long)(csr->split_timeout_hi & 0x07) << 13;
-
-       /* Add in the fractional units */
-       units += (unsigned long)(csr->split_timeout_lo >> 19);
-
-       /* Convert to jiffies */
-       csr->expire = (unsigned long)(units * HZ) >> 13UL;
-
-       /* Just to keep from rounding low */
-       csr->expire++;
+       unsigned int usecs = (csr->split_timeout_hi & 7) * 1000000 +
+                            (csr->split_timeout_lo >> 19) * 125;
 
+       csr->expire = usecs_to_jiffies(usecs > 100000 ? usecs : 100000);
        HPSB_VERBOSE("CSR: setting expire to %lu, HZ=%u", csr->expire, HZ);
 }
 
@@ -201,7 +189,7 @@ static void add_host(struct hpsb_host *host)
                                CSR_REGISTER_BASE + CSR_SPEED_MAP,
                                CSR_REGISTER_BASE + CSR_SPEED_MAP_END);
 
-        host->csr.lock = SPIN_LOCK_UNLOCKED;
+        spin_lock_init(&host->csr.lock);
 
         host->csr.state                 = 0;
         host->csr.node_ids              = 0;
@@ -232,7 +220,7 @@ static void add_host(struct hpsb_host *host)
        host->csr.generation = 2;
 
        bus_info[1] = __constant_cpu_to_be32(0x31333934);
-       bus_info[2] = cpu_to_be32((1 << CSR_IRMC_SHIFT) |
+       bus_info[2] = cpu_to_be32((hpsb_disable_irm ? 0 : 1 << CSR_IRMC_SHIFT) |
                                  (1 << CSR_CMC_SHIFT) |
                                  (1 << CSR_ISC_SHIFT) |
                                  (0 << CSR_BMC_SHIFT) |