aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hpet.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2011-03-17 13:32:41 +0000
committerJan Beulich <jbeulich@novell.com>2011-03-17 13:32:41 +0000
commitf9c1de946c4e283777fc7115f266ea668baa7438 (patch)
tree68cbe6da311f984d9ef22e030bbb08947683f434 /xen/arch/x86/hpet.c
parenta5e1b534ac6fe2372205b63583e8d0c074d3467e (diff)
downloadxen-f9c1de946c4e283777fc7115f266ea668baa7438.tar.gz
xen-f9c1de946c4e283777fc7115f266ea668baa7438.tar.bz2
xen-f9c1de946c4e283777fc7115f266ea668baa7438.zip
x86/HPET: fix oversight in 23033:84bacd800bf8 (2nd try)
Clearly for the adjusted BUG_ON()s to not yield false positives num_hpets_used (rather than num_chs_used, as done mistakenly in 23042:599ceb5b0a9b) must be incremented before setting up an IRQ (and decremented back when the setup failed). To avoid further confusion, just eliminate the local variable altogether. Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen/arch/x86/hpet.c')
-rw-r--r--xen/arch/x86/hpet.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index 987a9ff8ce..a884718af6 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -392,17 +392,17 @@ static int __init hpet_assign_irq(unsigned int idx)
return irq;
}
-static unsigned int __init hpet_fsb_cap_lookup(void)
+static void __init hpet_fsb_cap_lookup(void)
{
u32 id;
- unsigned int i, num_chs, num_chs_used;
+ unsigned int i, num_chs;
/* TODO. */
if ( iommu_intremap )
{
printk(XENLOG_INFO "HPET's MSI mode hasn't been supported when "
"Interrupt Remapping is enabled.\n");
- return 0;
+ return;
}
id = hpet_read32(HPET_ID);
@@ -412,13 +412,12 @@ static unsigned int __init hpet_fsb_cap_lookup(void)
hpet_events = xmalloc_array(struct hpet_event_channel, num_chs);
if ( !hpet_events )
- return 0;
+ return;
memset(hpet_events, 0, num_chs * sizeof(*hpet_events));
- num_chs_used = 0;
for ( i = 0; i < num_chs; i++ )
{
- struct hpet_event_channel *ch = &hpet_events[num_chs_used];
+ struct hpet_event_channel *ch = &hpet_events[num_hpets_used];
u32 cfg = hpet_read32(HPET_Tn_CFG(i));
/* Only consider HPET timer with MSI support */
@@ -428,14 +427,12 @@ static unsigned int __init hpet_fsb_cap_lookup(void)
ch->flags = 0;
ch->idx = i;
- if ( (ch->irq = hpet_assign_irq(num_chs_used++)) < 0 )
- num_chs_used--;
+ if ( (ch->irq = hpet_assign_irq(num_hpets_used++)) < 0 )
+ num_hpets_used--;
}
printk(XENLOG_INFO "HPET: %u timers (%u will be used for broadcast)\n",
- num_chs, num_chs_used);
-
- return num_chs_used;
+ num_chs, num_hpets_used);
}
static struct hpet_event_channel *hpet_get_channel(unsigned int cpu)
@@ -555,7 +552,7 @@ void __init hpet_broadcast_init(void)
cfg = hpet_read32(HPET_CFG);
- num_hpets_used = hpet_fsb_cap_lookup();
+ hpet_fsb_cap_lookup();
if ( num_hpets_used > 0 )
{
/* Stop HPET legacy interrupts */