From e1d8e05d15b1dc01bb9c461c4fa5e935852a49d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 5 Nov 2010 18:13:50 +0000 Subject: [PATCH] * some style cleanup * don't try to non configured memory map IO space * use a kernel thread when irq number is zero or 0xff Should help with #4491 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39310 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/audio/ac97/auich/auich.c | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c b/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c index 8754faf431..02e18cb845 100644 --- a/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c +++ b/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c @@ -637,17 +637,30 @@ auich_setup(auich_dev * card) if (card->info.device_id == SIS_SI7012_AC97_DEVICE_ID) card->config.type |= TYPE_SIS7012; - PRINT(("%s deviceid = %#04x chiprev = %x model = %x enhanced at %lx\n", card->name, card->info.device_id, - card->info.revision, card->info.u.h0.subsystem_id, card->config.nabmbar)); + PRINT(("%s deviceid = %#04x chiprev = %x model = %x enhanced at %lx\n", + card->name, card->info.device_id, card->info.revision, + card->info.u.h0.subsystem_id, card->config.nabmbar)); if (IS_ICH4(&card->config)) { // memory mapped access - card->config.mmbar = 0xfffffffe & (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, 0x18, 4); - card->config.mbbar = 0xfffffffe & (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, 0x1C, 4); + card->config.mmbar = 0xfffffffe & (*pci->read_pci_config) + (card->info.bus, card->info.device, card->info.function, 0x18, 4); + card->config.mbbar = 0xfffffffe & (*pci->read_pci_config) + (card->info.bus, card->info.device, card->info.function, 0x1C, 4); + if (card->config.mmbar == 0 || card->config.mbbar == 0) { + PRINT(("memory mapped IO not configured\n")); + return B_ERROR; + } } else { // pio access - card->config.nambar = 0xfffffffe & (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, 0x10, 4); - card->config.nabmbar = 0xfffffffe & (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, 0x14, 4); + card->config.nambar = 0xfffffffe & (*pci->read_pci_config) + (card->info.bus, card->info.device, card->info.function, 0x10, 4); + card->config.nabmbar = 0xfffffffe & (*pci->read_pci_config) + (card->info.bus, card->info.device, card->info.function, 0x14, 4); + if (card->config.nambar == 0 || card->config.nabmbar == 0) { + PRINT(("IO space not configured\n")); + return B_ERROR; + } } /* before doing anything else, map the IO memory */ @@ -657,14 +670,18 @@ auich_setup(auich_dev * card) return B_ERROR; } - cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2); + cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, + card->info.function, PCI_command, 2); PRINT(("PCI command before: %x\n", cmd)); if (IS_ICH4(&card->config)) { - (*pci->write_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2, cmd | PCI_command_memory); + (*pci->write_pci_config)(card->info.bus, card->info.device, + card->info.function, PCI_command, 2, cmd | PCI_command_memory); } else { - (*pci->write_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2, cmd | PCI_command_io); + (*pci->write_pci_config)(card->info.bus, card->info.device, + card->info.function, PCI_command, 2, cmd | PCI_command_io); } - cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2); + cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, + card->info.function, PCI_command, 2); PRINT(("PCI command after: %x\n", cmd)); /* do a cold reset */ @@ -707,7 +724,8 @@ auich_setup(auich_dev * card) LOG(("6ch PCM output support\n")); } - if (current_settings.use_thread) { + if (current_settings.use_thread || card->config.irq == 0 + || card->config.irq == 0xff) { int_thread_id = spawn_kernel_thread(auich_int_thread, "auich interrupt poller", B_REAL_TIME_PRIORITY, card); resume_thread(int_thread_id);