X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fieee1394%2Fcsr.c;h=c90be4070e40c5097ad3920b1ed4161c1fd87f38;hb=2cca775baecbfede2fec20c99add709232311fe7;hp=149573db91c5a1dc35d727694de54263f0dc96f3;hpb=a98a5d04f400ad112e59cadd739dbabf89417e60;p=linux-2.6-omap-h63xx.git diff --git a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c index 149573db91c..c90be4070e4 100644 --- a/drivers/ieee1394/csr.c +++ b/drivers/ieee1394/csr.c @@ -17,11 +17,13 @@ * */ -#include +#include +#include #include #include #include #include +#include #include "csr1212.h" #include "ieee1394_types.h" @@ -131,8 +133,7 @@ static void host_reset(struct hpsb_host *host) host->csr.state &= ~0x100; } - host->csr.topology_map[1] = - cpu_to_be32(be32_to_cpu(host->csr.topology_map[1]) + 1); + be32_add_cpu(&host->csr.topology_map[1], 1); host->csr.topology_map[2] = cpu_to_be32(host->node_count << 16 | host->selfid_count); host->csr.topology_map[0] = @@ -140,8 +141,7 @@ static void host_reset(struct hpsb_host *host) | csr_crc16(host->csr.topology_map + 1, host->selfid_count + 2)); - host->csr.speed_map[1] = - cpu_to_be32(be32_to_cpu(host->csr.speed_map[1]) + 1); + be32_add_cpu(&host->csr.speed_map[1], 1); host->csr.speed_map[0] = cpu_to_be32(0x3f1 << 16 | csr_crc16(host->csr.speed_map+1, 0x3f1)); @@ -149,32 +149,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); }