| 951 | | u_int32_t __ahdecl |
|---|
| 952 | | ath_hal_getuptime(struct ath_hal *ah) |
|---|
| 953 | | { |
|---|
| 954 | | /* NB: Original uptime logic was totally wrong for Linux. |
|---|
| 955 | | * |
|---|
| 956 | | * Linux systems use unsigned long and special detection of rollover |
|---|
| 957 | | * using macros like time_before, time_after, ... |
|---|
| 958 | | * |
|---|
| 959 | | * Linux initializes jiffies to cause rollover 5m after boot (to detect |
|---|
| 960 | | * bugs earlier). |
|---|
| 961 | | * |
|---|
| 962 | | */ |
|---|
| 963 | | static unsigned long last_uptime_seconds = 0; |
|---|
| 964 | | unsigned long uptime_jiffies = (jiffies - INITIAL_JIFFIES); |
|---|
| 965 | | unsigned long uptime_seconds = ((uptime_jiffies / HZ) * 1000) + |
|---|
| 966 | | (uptime_jiffies % HZ) * (1000 / HZ); |
|---|
| 967 | | |
|---|
| 968 | | #define TEST_ROLLOVER_THEORY |
|---|
| 969 | | #ifdef TEST_ROLLOVER_THEORY |
|---|
| 970 | | static unsigned long last_old_uptime_seconds = 0; |
|---|
| 971 | | unsigned long old_uptime_jiffies = jiffies; |
|---|
| 972 | | unsigned long old_uptime_seconds = ((old_uptime_jiffies / HZ) * 1000) + |
|---|
| 973 | | (old_uptime_jiffies % HZ) * (1000 / HZ); |
|---|
| 974 | | |
|---|
| 975 | | if (old_uptime_seconds < last_old_uptime_seconds) { |
|---|
| 976 | | printk("ROLLOVER ROLLOVER ROLLOVER\n"); |
|---|
| 977 | | printk("ROLLOVER ROLLOVER ROLLOVER\n"); |
|---|
| 978 | | printk("ROLLOVER ROLLOVER ROLLOVER\n"); |
|---|
| 979 | | printk("Expect bugs to follow...\n"); |
|---|
| 980 | | } |
|---|
| 981 | | last_old_uptime_seconds = old_uptime_seconds; |
|---|
| 982 | | #endif |
|---|
| 983 | | if (uptime_seconds < last_uptime_seconds) { |
|---|
| 984 | | printk("ROLLOVER ROLLOVER ROLLOVER\n"); |
|---|
| 985 | | printk("ROLLOVER ROLLOVER ROLLOVER\n"); |
|---|
| 986 | | printk("ROLLOVER ROLLOVER ROLLOVER\n"); |
|---|
| 987 | | printk("Expect bugs to follow...\n"); |
|---|
| 988 | | // XXX: Replace stupid message with a HAL reset?? |
|---|
| 989 | | } |
|---|
| 990 | | last_uptime_seconds = uptime_seconds; |
|---|
| 991 | | return uptime_seconds; |
|---|
| 992 | | } |
|---|
| 993 | | EXPORT_SYMBOL(ath_hal_getuptime); |
|---|
| 994 | | |
|---|