aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/hpet.c
diff options
context:
space:
mode:
authorJan Beulich <JBeulich@novell.com>2009-08-19 03:44:24 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-21 15:55:25 -0400
commit5946fa3d5cdeb846a647a1900026af9f8b08c8b5 (patch)
treea77b8061bc2b191eb78cc663ce74aa11b8661cc8 /arch/x86/kernel/hpet.c
parent39fe05e58c5e448601ce46e6b03900d5bf31c4b0 (diff)
x86, hpet: Simplify the HPET code
On 64-bits, using unsigned long when unsigned int suffices needlessly creates larger code (due to the need for REX prefixes), and most of the logic in hpet.c really doesn't need 64-bit operations. At once this avoids the need for a couple of type casts. Signed-off-by: Jan Beulich <jbeulich@novell.com> Cc: Shaohua Li <shaohua.li@intel.com> Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> LKML-Reference: <4A8BC9780200007800010832@vpn.id2.novell.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/hpet.c')
-rw-r--r--arch/x86/kernel/hpet.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 5969e1078fc2..ba575f0f2e34 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -47,12 +47,12 @@ struct hpet_dev {
47 char name[10]; 47 char name[10];
48}; 48};
49 49
50unsigned long hpet_readl(unsigned long a) 50inline unsigned int hpet_readl(unsigned int a)
51{ 51{
52 return readl(hpet_virt_address + a); 52 return readl(hpet_virt_address + a);
53} 53}
54 54
55static inline void hpet_writel(unsigned long d, unsigned long a) 55static inline void hpet_writel(unsigned int d, unsigned int a)
56{ 56{
57 writel(d, hpet_virt_address + a); 57 writel(d, hpet_virt_address + a);
58} 58}
@@ -167,7 +167,7 @@ do { \
167 167
168static void hpet_reserve_msi_timers(struct hpet_data *hd); 168static void hpet_reserve_msi_timers(struct hpet_data *hd);
169 169
170static void hpet_reserve_platform_timers(unsigned long id) 170static void hpet_reserve_platform_timers(unsigned int id)
171{ 171{
172 struct hpet __iomem *hpet = hpet_virt_address; 172 struct hpet __iomem *hpet = hpet_virt_address;
173 struct hpet_timer __iomem *timer = &hpet->hpet_timers[2]; 173 struct hpet_timer __iomem *timer = &hpet->hpet_timers[2];
@@ -205,7 +205,7 @@ static void hpet_reserve_platform_timers(unsigned long id)
205 205
206} 206}
207#else 207#else
208static void hpet_reserve_platform_timers(unsigned long id) { } 208static void hpet_reserve_platform_timers(unsigned int id) { }
209#endif 209#endif
210 210
211/* 211/*
@@ -246,7 +246,7 @@ static void hpet_reset_counter(void)
246 246
247static void hpet_start_counter(void) 247static void hpet_start_counter(void)
248{ 248{
249 unsigned long cfg = hpet_readl(HPET_CFG); 249 unsigned int cfg = hpet_readl(HPET_CFG);
250 cfg |= HPET_CFG_ENABLE; 250 cfg |= HPET_CFG_ENABLE;
251 hpet_writel(cfg, HPET_CFG); 251 hpet_writel(cfg, HPET_CFG);
252} 252}
@@ -271,7 +271,7 @@ static void hpet_resume_counter(void)
271 271
272static void hpet_enable_legacy_int(void) 272static void hpet_enable_legacy_int(void)
273{ 273{
274 unsigned long cfg = hpet_readl(HPET_CFG); 274 unsigned int cfg = hpet_readl(HPET_CFG);
275 275
276 cfg |= HPET_CFG_LEGACY; 276 cfg |= HPET_CFG_LEGACY;
277 hpet_writel(cfg, HPET_CFG); 277 hpet_writel(cfg, HPET_CFG);
@@ -314,7 +314,7 @@ static int hpet_setup_msi_irq(unsigned int irq);
314static void hpet_set_mode(enum clock_event_mode mode, 314static void hpet_set_mode(enum clock_event_mode mode,
315 struct clock_event_device *evt, int timer) 315 struct clock_event_device *evt, int timer)
316{ 316{
317 unsigned long cfg, cmp, now; 317 unsigned int cfg, cmp, now;
318 uint64_t delta; 318 uint64_t delta;
319 319
320 switch (mode) { 320 switch (mode) {
@@ -323,7 +323,7 @@ static void hpet_set_mode(enum clock_event_mode mode,
323 delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult; 323 delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult;
324 delta >>= evt->shift; 324 delta >>= evt->shift;
325 now = hpet_readl(HPET_COUNTER); 325 now = hpet_readl(HPET_COUNTER);
326 cmp = now + (unsigned long) delta; 326 cmp = now + (unsigned int) delta;
327 cfg = hpet_readl(HPET_Tn_CFG(timer)); 327 cfg = hpet_readl(HPET_Tn_CFG(timer));
328 /* Make sure we use edge triggered interrupts */ 328 /* Make sure we use edge triggered interrupts */
329 cfg &= ~HPET_TN_LEVEL; 329 cfg &= ~HPET_TN_LEVEL;
@@ -339,7 +339,7 @@ static void hpet_set_mode(enum clock_event_mode mode,
339 * (See AMD-8111 HyperTransport I/O Hub Data Sheet, 339 * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
340 * Publication # 24674) 340 * Publication # 24674)
341 */ 341 */
342 hpet_writel((unsigned long) delta, HPET_Tn_CMP(timer)); 342 hpet_writel((unsigned int) delta, HPET_Tn_CMP(timer));
343 hpet_start_counter(); 343 hpet_start_counter();
344 hpet_print_config(); 344 hpet_print_config();
345 break; 345 break;
@@ -387,9 +387,9 @@ static int hpet_next_event(unsigned long delta,
387 * what we wrote hit the chip before we compare it to the 387 * what we wrote hit the chip before we compare it to the
388 * counter. 388 * counter.
389 */ 389 */
390 WARN_ON_ONCE((u32)hpet_readl(HPET_Tn_CMP(timer)) != cnt); 390 WARN_ON_ONCE(hpet_readl(HPET_Tn_CMP(timer)) != cnt);
391 391
392 return (s32)((u32)hpet_readl(HPET_COUNTER) - cnt) >= 0 ? -ETIME : 0; 392 return (s32)(hpet_readl(HPET_COUNTER) - cnt) >= 0 ? -ETIME : 0;
393} 393}
394 394
395static void hpet_legacy_set_mode(enum clock_event_mode mode, 395static void hpet_legacy_set_mode(enum clock_event_mode mode,
@@ -415,7 +415,7 @@ static struct hpet_dev *hpet_devs;
415void hpet_msi_unmask(unsigned int irq) 415void hpet_msi_unmask(unsigned int irq)
416{ 416{
417 struct hpet_dev *hdev = get_irq_data(irq); 417 struct hpet_dev *hdev = get_irq_data(irq);
418 unsigned long cfg; 418 unsigned int cfg;
419 419
420 /* unmask it */ 420 /* unmask it */
421 cfg = hpet_readl(HPET_Tn_CFG(hdev->num)); 421 cfg = hpet_readl(HPET_Tn_CFG(hdev->num));
@@ -425,7 +425,7 @@ void hpet_msi_unmask(unsigned int irq)
425 425
426void hpet_msi_mask(unsigned int irq) 426void hpet_msi_mask(unsigned int irq)
427{ 427{
428 unsigned long cfg; 428 unsigned int cfg;
429 struct hpet_dev *hdev = get_irq_data(irq); 429 struct hpet_dev *hdev = get_irq_data(irq);
430 430
431 /* mask it */ 431 /* mask it */
@@ -600,7 +600,7 @@ static void hpet_msi_capability_lookup(unsigned int start_timer)
600 600
601 for (i = start_timer; i < num_timers - RESERVE_TIMERS; i++) { 601 for (i = start_timer; i < num_timers - RESERVE_TIMERS; i++) {
602 struct hpet_dev *hdev = &hpet_devs[num_timers_used]; 602 struct hpet_dev *hdev = &hpet_devs[num_timers_used];
603 unsigned long cfg = hpet_readl(HPET_Tn_CFG(i)); 603 unsigned int cfg = hpet_readl(HPET_Tn_CFG(i));
604 604
605 /* Only consider HPET timer with MSI support */ 605 /* Only consider HPET timer with MSI support */
606 if (!(cfg & HPET_TN_FSB_CAP)) 606 if (!(cfg & HPET_TN_FSB_CAP))
@@ -815,7 +815,7 @@ static int hpet_clocksource_register(void)
815 */ 815 */
816int __init hpet_enable(void) 816int __init hpet_enable(void)
817{ 817{
818 unsigned long id; 818 unsigned int id;
819 int i; 819 int i;
820 820
821 if (!is_hpet_capable()) 821 if (!is_hpet_capable())
@@ -933,7 +933,7 @@ fs_initcall(hpet_late_init);
933void hpet_disable(void) 933void hpet_disable(void)
934{ 934{
935 if (is_hpet_capable()) { 935 if (is_hpet_capable()) {
936 unsigned long cfg = hpet_readl(HPET_CFG); 936 unsigned int cfg = hpet_readl(HPET_CFG);
937 937
938 if (hpet_legacy_int_enabled) { 938 if (hpet_legacy_int_enabled) {
939 cfg &= ~HPET_CFG_LEGACY; 939 cfg &= ~HPET_CFG_LEGACY;
@@ -973,8 +973,8 @@ static int hpet_prev_update_sec;
973static struct rtc_time hpet_alarm_time; 973static struct rtc_time hpet_alarm_time;
974static unsigned long hpet_pie_count; 974static unsigned long hpet_pie_count;
975static u32 hpet_t1_cmp; 975static u32 hpet_t1_cmp;
976static unsigned long hpet_default_delta; 976static u32 hpet_default_delta;
977static unsigned long hpet_pie_delta; 977static u32 hpet_pie_delta;
978static unsigned long hpet_pie_limit; 978static unsigned long hpet_pie_limit;
979 979
980static rtc_irq_handler irq_handler; 980static rtc_irq_handler irq_handler;
@@ -1025,7 +1025,8 @@ EXPORT_SYMBOL_GPL(hpet_unregister_irq_handler);
1025 */ 1025 */
1026int hpet_rtc_timer_init(void) 1026int hpet_rtc_timer_init(void)
1027{ 1027{
1028 unsigned long cfg, cnt, delta, flags; 1028 unsigned int cfg, cnt, delta;
1029 unsigned long flags;
1029 1030
1030 if (!is_hpet_enabled()) 1031 if (!is_hpet_enabled())
1031 return 0; 1032 return 0;
@@ -1035,7 +1036,7 @@ int hpet_rtc_timer_init(void)
1035 1036
1036 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC; 1037 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC;
1037 clc >>= hpet_clockevent.shift + DEFAULT_RTC_SHIFT; 1038 clc >>= hpet_clockevent.shift + DEFAULT_RTC_SHIFT;
1038 hpet_default_delta = (unsigned long) clc; 1039 hpet_default_delta = clc;
1039 } 1040 }
1040 1041
1041 if (!(hpet_rtc_flags & RTC_PIE) || hpet_pie_limit) 1042 if (!(hpet_rtc_flags & RTC_PIE) || hpet_pie_limit)
@@ -1121,7 +1122,7 @@ int hpet_set_periodic_freq(unsigned long freq)
1121 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC; 1122 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC;
1122 do_div(clc, freq); 1123 do_div(clc, freq);
1123 clc >>= hpet_clockevent.shift; 1124 clc >>= hpet_clockevent.shift;
1124 hpet_pie_delta = (unsigned long) clc; 1125 hpet_pie_delta = clc;
1125 } 1126 }
1126 return 1; 1127 return 1;
1127} 1128}
@@ -1135,7 +1136,7 @@ EXPORT_SYMBOL_GPL(hpet_rtc_dropped_irq);
1135 1136
1136static void hpet_rtc_timer_reinit(void) 1137static void hpet_rtc_timer_reinit(void)
1137{ 1138{
1138 unsigned long cfg, delta; 1139 unsigned int cfg, delta;
1139 int lost_ints = -1; 1140 int lost_ints = -1;
1140 1141
1141 if (unlikely(!hpet_rtc_flags)) { 1142 if (unlikely(!hpet_rtc_flags)) {