2 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 * @ret rc Return status code
41 static int undipci_probe ( struct pci_device *pci,
42 const struct pci_device_id *id __unused ) {
43 struct undi_device *undi;
44 struct undi_rom *undirom;
45 unsigned long rombase;
48 /* Ignore non-network devices */
49 if ( PCI_BASE_CLASS ( pci->class ) != PCI_BASE_CLASS_NETWORK )
52 /* Try to find a driver for this device. Try an exact match
53 * on the ROM address first, then fall back to a vendor/device
56 rombase = pci_bar_start ( pci, PCI_ROM_ADDRESS );
57 undirom = undirom_find_pci ( pci->vendor, pci->device, rombase );
59 undirom = undirom_find_pci ( pci->vendor, pci->device, 0 );
63 /* Allocate UNDI device structure */
64 undi = malloc ( sizeof ( *undi ) );
67 memset ( undi, 0, sizeof ( *undi ) );
68 pci_set_drvdata ( pci, undi );
70 /* Add to device hierarchy */
71 undi->dev.parent = &pci->dev;
72 INIT_LIST_HEAD ( &undi->dev.children );
73 list_add ( &undi->dev.siblings, &pci->dev.children );
75 /* Call UNDI ROM loader to create pixie */
76 DBGC ( undi, "UNDI %p using UNDI ROM %p\n", undi, undirom );
77 if ( ( rc = undi_load_pci ( undi, undirom, pci->bus,
81 /* Create network device */
82 if ( ( rc = undinet_probe ( undi ) ) != 0 )
83 goto err_undinet_probe;
90 list_del ( &undi->dev.siblings );
92 pci_set_drvdata ( pci, NULL );
101 static void undipci_remove ( struct pci_device *pci ) {
102 struct undi_device *undi = pci_get_drvdata ( pci );
104 undi_unload ( undi );
105 list_del ( &undi->dev.siblings );
107 pci_set_drvdata ( pci, NULL );
110 static struct pci_device_id undipci_nics[] = {
111 PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)" ),
114 struct pci_driver undipci_driver __pci_driver = {
116 .id_count = ( sizeof ( undipci_nics ) / sizeof ( undipci_nics[0] ) ),
117 .probe = undipci_probe,
118 .remove = undipci_remove,