Re: [PATCH] 2.5.5-pre1 IDE cleanup 9

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Fri Feb 22 2002 - 18:59:41 EST


Andre Hedrick wrote:
> The problem is how do you deal with multiple HOSTs given there drivers are
> not (have not checked lately) capable of discrete HOST addition and
> removal.
>
> SCSI/ATA share the same problem IIRC, the host/chipset drivers load all
> the device hosts who match that driver code.
>
> What am I missing?

Nothing, I think --

The PCI API is just a different way of doing the same thing: discrete
HOST addition and removal. That is --exactly-- what the PCI API is.

Let me give an example of a very simple PCI API IDE driver:
(WARNING WARNING, no error checking!)

struct pci_driver jgarzik_ide_driver = {
        probe: jg_host_add,
        remove: jg_host_remove,
};

static int __devinit jg_host_add(struct pci_dev *host_pci, ...)
{
        ide_hwif_t *host_ata = kmalloc(sizeof(*host_ata), GFP_KERNEL);
        pci_set_drvdata(host_pci, host_ata);
        ide_setup_ports(&host_ata->hw, ...);
        return ide_register_hw(&host_ata->hw, &host_ata);
}

static void __devexit jg_host_remove(struct pci_dev *host_pci)
{
        ide_hwif_t *host_ata = pci_get_drvdata(host_pci);
        ide_unregister_hw(&host_ata->hw, &host_ata);
        kfree(host_ata);
        pci_set_drvdata(host_pci, NULL);
}

static int __init jg_driver_init(void)
{
        return pci_module_init(&jgarzik_ide_driver);
}

static void __exit jg_driver_exit(void)
{
        pci_unregister_driver(&jgarzik_ide_driver);
}
module_init(jg_driver_init);
module_exit(jg_driver_exit);

-- 
Jeff Garzik      | "UNIX enhancements aren't."
Building 1024    |           -- says /usr/games/fortune
MandrakeSoft     |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Feb 23 2002 - 21:00:47 EST