Re: [PATCH 4/6] firewire: OHCI-1394 lowlevel driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +/* ---------- pci subsystem interface ---------- */
> +
> +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;
> +	size_t size;
> +
> +	ohci = kzalloc(sizeof *ohci, GFP_KERNEL);
> +	if (ohci == NULL) {
> +		fw_error("Could not malloc fw_ohci data.\n");
> +		return -ENOMEM;
> +	}
> +
> +	fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev);
> +
> +	if (pci_enable_device(dev)) {
> +		fw_error("Failed to enable OHCI hardware.\n");
> +		return cleanup(ohci, CLEANUP_PUT_CARD, -ENODEV);

Please use normal goto unwinding so the driver follows the same model
as almost all other pci drivers and allows people to follow your driver
more easily.  Also it's not a alot of cleanup code, so removing this
might actually be a net decrease in lines of code.

> +	if (software_reset(ohci)) {

Please give all your function a nice prefix so that oops messages are
more readable.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux