Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 55811
b: refs/heads/master
c: d79406d
h: refs/heads/master
i:
  55809: 9e9e241
  55807: d3f5cf8
v: v3
  • Loading branch information
Kristian Høgsberg authored and Stefan Richter committed May 10, 2007
1 parent 08e3d81 commit 3df10f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2d826cc5c791bdc5f5651324c485746be9492be0
refs/heads/master: d79406dd140a3e6eed6f26b17f0c6620fe30b50c
86 changes: 42 additions & 44 deletions trunk/drivers/firewire/fw-ohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,44 +1715,13 @@ static int software_reset(struct fw_ohci *ohci)
return -EBUSY;
}

enum {
CLEANUP_SELF_ID,
CLEANUP_REGISTERS,
CLEANUP_IOMEM,
CLEANUP_DISABLE,
CLEANUP_PUT_CARD,
};

static int cleanup(struct fw_ohci *ohci, int stage, int code)
{
struct pci_dev *dev = to_pci_dev(ohci->card.device);

switch (stage) {
case CLEANUP_SELF_ID:
dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE,
ohci->self_id_cpu, ohci->self_id_bus);
case CLEANUP_REGISTERS:
kfree(ohci->it_context_list);
kfree(ohci->ir_context_list);
pci_iounmap(dev, ohci->registers);
case CLEANUP_IOMEM:
pci_release_region(dev, 0);
case CLEANUP_DISABLE:
pci_disable_device(dev);
case CLEANUP_PUT_CARD:
fw_card_put(&ohci->card);
}

return code;
}

static int __devinit
pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
{
struct fw_ohci *ohci;
u32 bus_options, max_receive, link_speed;
u64 guid;
int error_code;
int err;
size_t size;

ohci = kzalloc(sizeof(*ohci), GFP_KERNEL);
Expand All @@ -1763,9 +1732,10 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)

fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev);

if (pci_enable_device(dev)) {
err = pci_enable_device(dev);
if (err) {
fw_error("Failed to enable OHCI hardware.\n");
return cleanup(ohci, CLEANUP_PUT_CARD, -ENODEV);
goto fail_put_card;
}

pci_set_master(dev);
Expand All @@ -1777,20 +1747,23 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
tasklet_init(&ohci->bus_reset_tasklet,
bus_reset_tasklet, (unsigned long)ohci);

if (pci_request_region(dev, 0, ohci_driver_name)) {
err = pci_request_region(dev, 0, ohci_driver_name);
if (err) {
fw_error("MMIO resource unavailable\n");
return cleanup(ohci, CLEANUP_DISABLE, -EBUSY);
goto fail_disable;
}

ohci->registers = pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE);
if (ohci->registers == NULL) {
fw_error("Failed to remap registers\n");
return cleanup(ohci, CLEANUP_IOMEM, -ENXIO);
err = -ENXIO;
goto fail_iomem;
}

if (software_reset(ohci)) {
fw_error("Failed to reset ohci card.\n");
return cleanup(ohci, CLEANUP_REGISTERS, -EBUSY);
err = -EBUSY;
goto fail_registers;
}

/*
Expand Down Expand Up @@ -1845,7 +1818,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)

if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) {
fw_error("Out of memory for it/ir contexts.\n");
return cleanup(ohci, CLEANUP_REGISTERS, -ENOMEM);
err = -ENOMEM;
goto fail_registers;
}

/* self-id dma buffer allocation */
Expand All @@ -1855,7 +1829,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
GFP_KERNEL);
if (ohci->self_id_cpu == NULL) {
fw_error("Out of memory for self ID buffer.\n");
return cleanup(ohci, CLEANUP_REGISTERS, -ENOMEM);
err = -ENOMEM;
goto fail_registers;
}

reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->self_id_bus);
Expand All @@ -1876,15 +1851,31 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
guid = ((u64) reg_read(ohci, OHCI1394_GUIDHi) << 32) |
reg_read(ohci, OHCI1394_GUIDLo);

error_code = fw_card_add(&ohci->card, max_receive, link_speed, guid);
if (error_code < 0)
return cleanup(ohci, CLEANUP_SELF_ID, error_code);
err = fw_card_add(&ohci->card, max_receive, link_speed, guid);
if (err < 0)
goto fail_self_id;

ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n",
dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff);

return 0;

fail_self_id:
dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE,
ohci->self_id_cpu, ohci->self_id_bus);
fail_registers:
kfree(ohci->it_context_list);
kfree(ohci->ir_context_list);
pci_iounmap(dev, ohci->registers);
fail_iomem:
pci_release_region(dev, 0);
fail_disable:
pci_disable_device(dev);
fail_put_card:
fw_card_put(&ohci->card);

return err;
}

static void pci_remove(struct pci_dev *dev)
Expand All @@ -1903,7 +1894,14 @@ static void pci_remove(struct pci_dev *dev)

software_reset(ohci);
free_irq(dev->irq, ohci);
cleanup(ohci, CLEANUP_SELF_ID, 0);
dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE,
ohci->self_id_cpu, ohci->self_id_bus);
kfree(ohci->it_context_list);
kfree(ohci->ir_context_list);
pci_iounmap(dev, ohci->registers);
pci_release_region(dev, 0);
pci_disable_device(dev);
fw_card_put(&ohci->card);

fw_notify("Removed fw-ohci device.\n");
}
Expand Down

0 comments on commit 3df10f4

Please sign in to comment.