* handles correctly failures during setup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33275 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -703,25 +703,32 @@ cardbus_device_removed(void *cookie)
|
|||||||
static status_t
|
static status_t
|
||||||
echo_setup(echo_dev * card)
|
echo_setup(echo_dev * card)
|
||||||
{
|
{
|
||||||
status_t err = B_OK;
|
|
||||||
unsigned char cmd;
|
unsigned char cmd;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
PRINT(("echo_setup(%p)\n", card));
|
PRINT(("echo_setup(%p)\n", card));
|
||||||
|
|
||||||
#ifndef CARDBUS
|
#ifndef CARDBUS
|
||||||
(*pci->write_pci_config)(card->info.bus, card->info.device, card->info.function,
|
(*pci->write_pci_config)(card->info.bus, card->info.device,
|
||||||
PCI_latency, 1, 0xc0 );
|
card->info.function, PCI_latency, 1, 0xc0 );
|
||||||
|
|
||||||
make_device_names(card);
|
make_device_names(card);
|
||||||
#endif
|
#endif
|
||||||
card->bmbar = card->info.u.h0.base_registers[0];
|
card->bmbar = card->info.u.h0.base_registers[0];
|
||||||
card->irq = card->info.u.h0.interrupt_line;
|
card->irq = card->info.u.h0.interrupt_line;
|
||||||
|
|
||||||
|
card->area_bmbar = map_mem(&card->log_bmbar, (void *)card->bmbar,
|
||||||
|
card->info.u.h0.base_register_sizes[0], DRIVER_NAME" bmbar io");
|
||||||
|
if (card->area_bmbar <= B_OK) {
|
||||||
|
LOG(("mapping of bmbar io failed, error = %#x\n",card->area_bmbar));
|
||||||
|
goto err5;
|
||||||
|
}
|
||||||
|
LOG(("mapping of bmbar: area %#x, phys %#x, log %#x\n", card->area_bmbar,
|
||||||
|
card->bmbar, card->log_bmbar));
|
||||||
|
|
||||||
card->pOSS = new COsSupport(card->info.device_id, card->info.revision);
|
card->pOSS = new COsSupport(card->info.device_id, card->info.revision);
|
||||||
if (card->pOSS == NULL)
|
if (card->pOSS == NULL)
|
||||||
return B_ERROR;
|
goto err4;
|
||||||
|
|
||||||
switch (card->type) {
|
switch (card->type) {
|
||||||
#ifdef ECHOGALS_FAMILY
|
#ifdef ECHOGALS_FAMILY
|
||||||
@@ -781,27 +788,21 @@ echo_setup(echo_dev * card)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
PRINT(("card type 0x%x not supported by "DRIVER_NAME"\n", card->type));
|
PRINT(("card type 0x%x not supported by "DRIVER_NAME"\n",
|
||||||
delete card->pOSS;
|
card->type));
|
||||||
return B_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card->pEG == NULL)
|
if (card->pEG == NULL)
|
||||||
return B_ERROR;
|
goto err2;
|
||||||
|
|
||||||
card->area_bmbar = map_mem(&card->log_bmbar, (void *)card->bmbar,
|
|
||||||
card->info.u.h0.base_register_sizes[0], DRIVER_NAME" bmbar io");
|
|
||||||
if (card->area_bmbar <= B_OK) {
|
|
||||||
LOG(("mapping of bmbar io failed, error = %#x\n",card->area_bmbar));
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
LOG(("mapping of bmbar: area %#x, phys %#x, log %#x\n", card->area_bmbar, card->bmbar, card->log_bmbar));
|
|
||||||
|
|
||||||
#ifndef CARDBUS
|
#ifndef CARDBUS
|
||||||
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));
|
PRINT(("PCI command before: %x\n", cmd));
|
||||||
(*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,
|
||||||
cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2);
|
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);
|
||||||
PRINT(("PCI command after: %x\n", cmd));
|
PRINT(("PCI command after: %x\n", cmd));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -810,7 +811,7 @@ echo_setup(echo_dev * card)
|
|||||||
ECHOSTATUS status;
|
ECHOSTATUS status;
|
||||||
status = card->pEG->InitHw();
|
status = card->pEG->InitHw();
|
||||||
if (status != ECHOSTATUS_OK)
|
if (status != ECHOSTATUS_OK)
|
||||||
return B_ERROR;
|
goto err3;
|
||||||
|
|
||||||
card->pEG->GetCapabilities(&card->caps);
|
card->pEG->GetCapabilities(&card->caps);
|
||||||
|
|
||||||
@@ -825,7 +826,11 @@ echo_setup(echo_dev * card)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRINT(("installing interrupt : %x\n", card->irq));
|
PRINT(("installing interrupt : %x\n", card->irq));
|
||||||
install_io_interrupt_handler(card->irq, echo_int, card, 0);
|
status = install_io_interrupt_handler(card->irq, echo_int, card, 0);
|
||||||
|
if (status != B_OK) {
|
||||||
|
PRINT(("failed to install interrupt\n"));
|
||||||
|
goto err2;
|
||||||
|
}
|
||||||
|
|
||||||
PRINT(("echo_setup done\n"));
|
PRINT(("echo_setup done\n"));
|
||||||
|
|
||||||
@@ -833,15 +838,32 @@ echo_setup(echo_dev * card)
|
|||||||
|
|
||||||
#ifdef ECHO3G_FAMILY
|
#ifdef ECHO3G_FAMILY
|
||||||
if (card->type == ECHO3G) {
|
if (card->type == ECHO3G) {
|
||||||
strncpy(card->caps.szName, ((C3g*)card->pEG)->Get3gBoxName(), ECHO_MAXNAMELEN);
|
strncpy(card->caps.szName, ((C3g*)card->pEG)->Get3gBoxName(),
|
||||||
|
ECHO_MAXNAMELEN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = card->pEG->OpenMixer(card->mixer);
|
status = card->pEG->OpenMixer(card->mixer);
|
||||||
if (status != ECHOSTATUS_OK)
|
if (status != ECHOSTATUS_OK) {
|
||||||
return B_ERROR;
|
PRINT(("failed to open mixer\n"));
|
||||||
|
goto err1;
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return B_OK;
|
||||||
|
|
||||||
|
err1:
|
||||||
|
remove_io_interrupt_handler(card->irq, echo_int, card);
|
||||||
|
err2:
|
||||||
|
#ifdef MIDI_SUPPORT
|
||||||
|
delete_sem(card->midi.midi_ready_sem);
|
||||||
|
#endif
|
||||||
|
err3:
|
||||||
|
delete card->pEG;
|
||||||
|
err4:
|
||||||
|
delete card->pOSS;
|
||||||
|
err5:
|
||||||
|
delete_area(card->area_bmbar);
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user