| 
				
			 | 
			
			
				
				@@ -228,75 +228,72 @@ static void pci_remove ( struct pci_device *pci ) { 
			 | 
		
		
	
		
			
			| 
				228
			 | 
			
				228
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				229
			 | 
			
				229
			 | 
			
			
				
				 static int pcibus_probe ( struct root_device *rootdev ) { 
			 | 
		
		
	
		
			
			| 
				230
			 | 
			
				230
			 | 
			
			
				
				 	struct pci_device *pci = NULL; 
			 | 
		
		
	
		
			
			| 
				231
			 | 
			
				
			 | 
			
			
				
				-	unsigned int max_bus; 
			 | 
		
		
	
		
			
			| 
				232
			 | 
			
				
			 | 
			
			
				
				-	unsigned int bus; 
			 | 
		
		
	
		
			
			| 
				233
			 | 
			
				
			 | 
			
			
				
				-	unsigned int devfn; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				231
			 | 
			
			
				
				+	unsigned int num_bus; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				232
			 | 
			
			
				
				+	unsigned int busdevfn; 
			 | 
		
		
	
		
			
			| 
				234
			 | 
			
				233
			 | 
			
			
				
				 	uint8_t hdrtype = 0; 
			 | 
		
		
	
		
			
			| 
				235
			 | 
			
				234
			 | 
			
			
				
				 	uint32_t tmp; 
			 | 
		
		
	
		
			
			| 
				236
			 | 
			
				235
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
		
			
			| 
				237
			 | 
			
				236
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				238
			 | 
			
				
			 | 
			
			
				
				-	max_bus = pci_max_bus(); 
			 | 
		
		
	
		
			
			| 
				239
			 | 
			
				
			 | 
			
			
				
				-	for ( bus = 0 ; bus <= max_bus ; bus++ ) { 
			 | 
		
		
	
		
			
			| 
				240
			 | 
			
				
			 | 
			
			
				
				-		for ( devfn = 0 ; devfn <= 0xff ; devfn++ ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				237
			 | 
			
			
				
				+	num_bus = ( pci_max_bus() + 1 ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				238
			 | 
			
			
				
				+	for ( busdevfn = 0 ; busdevfn < PCI_BUSDEVFN ( num_bus, 0, 0 ) ; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				239
			 | 
			
			
				
				+	      busdevfn++ ) { 
			 | 
		
		
	
		
			
			| 
				241
			 | 
			
				240
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				242
			 | 
			
				
			 | 
			
			
				
				-			/* Allocate struct pci_device */ 
			 | 
		
		
	
		
			
			| 
				243
			 | 
			
				
			 | 
			
			
				
				-			if ( ! pci ) 
			 | 
		
		
	
		
			
			| 
				244
			 | 
			
				
			 | 
			
			
				
				-				pci = malloc ( sizeof ( *pci ) ); 
			 | 
		
		
	
		
			
			| 
				245
			 | 
			
				
			 | 
			
			
				
				-			if ( ! pci ) { 
			 | 
		
		
	
		
			
			| 
				246
			 | 
			
				
			 | 
			
			
				
				-				rc = -ENOMEM; 
			 | 
		
		
	
		
			
			| 
				247
			 | 
			
				
			 | 
			
			
				
				-				goto err; 
			 | 
		
		
	
		
			
			| 
				248
			 | 
			
				
			 | 
			
			
				
				-			} 
			 | 
		
		
	
		
			
			| 
				249
			 | 
			
				
			 | 
			
			
				
				-			memset ( pci, 0, sizeof ( *pci ) ); 
			 | 
		
		
	
		
			
			| 
				250
			 | 
			
				
			 | 
			
			
				
				-			pci->bus = bus; 
			 | 
		
		
	
		
			
			| 
				251
			 | 
			
				
			 | 
			
			
				
				-			pci->devfn = devfn; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				241
			 | 
			
			
				
				+		/* Allocate struct pci_device */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				242
			 | 
			
			
				
				+		if ( ! pci ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				243
			 | 
			
			
				
				+			pci = malloc ( sizeof ( *pci ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				244
			 | 
			
			
				
				+		if ( ! pci ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				245
			 | 
			
			
				
				+			rc = -ENOMEM; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				246
			 | 
			
			
				
				+			goto err; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				247
			 | 
			
			
				
				+		} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				248
			 | 
			
			
				
				+		memset ( pci, 0, sizeof ( *pci ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				249
			 | 
			
			
				
				+		pci->busdevfn = busdevfn; 
			 | 
		
		
	
		
			
			| 
				252
			 | 
			
				250
			 | 
			
			
				
				 			 
			 | 
		
		
	
		
			
			| 
				253
			 | 
			
				
			 | 
			
			
				
				-			/* Skip all but the first function on 
			 | 
		
		
	
		
			
			| 
				254
			 | 
			
				
			 | 
			
			
				
				-			 * non-multifunction cards 
			 | 
		
		
	
		
			
			| 
				255
			 | 
			
				
			 | 
			
			
				
				-			 */ 
			 | 
		
		
	
		
			
			| 
				256
			 | 
			
				
			 | 
			
			
				
				-			if ( PCI_FUNC ( devfn ) == 0 ) { 
			 | 
		
		
	
		
			
			| 
				257
			 | 
			
				
			 | 
			
			
				
				-				pci_read_config_byte ( pci, PCI_HEADER_TYPE, 
			 | 
		
		
	
		
			
			| 
				258
			 | 
			
				
			 | 
			
			
				
				-						       &hdrtype ); 
			 | 
		
		
	
		
			
			| 
				259
			 | 
			
				
			 | 
			
			
				
				-			} else if ( ! ( hdrtype & 0x80 ) ) { 
			 | 
		
		
	
		
			
			| 
				260
			 | 
			
				
			 | 
			
			
				
				-					continue; 
			 | 
		
		
	
		
			
			| 
				261
			 | 
			
				
			 | 
			
			
				
				-			} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				251
			 | 
			
			
				
				+		/* Skip all but the first function on 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				252
			 | 
			
			
				
				+		 * non-multifunction cards 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				253
			 | 
			
			
				
				+		 */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				254
			 | 
			
			
				
				+		if ( PCI_FUNC ( busdevfn ) == 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				255
			 | 
			
			
				
				+			pci_read_config_byte ( pci, PCI_HEADER_TYPE, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				256
			 | 
			
			
				
				+					       &hdrtype ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				257
			 | 
			
			
				
				+		} else if ( ! ( hdrtype & 0x80 ) ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				258
			 | 
			
			
				
				+			continue; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				259
			 | 
			
			
				
				+		} 
			 | 
		
		
	
		
			
			| 
				262
			 | 
			
				260
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				263
			 | 
			
				
			 | 
			
			
				
				-			/* Check for physical device presence */ 
			 | 
		
		
	
		
			
			| 
				264
			 | 
			
				
			 | 
			
			
				
				-			pci_read_config_dword ( pci, PCI_VENDOR_ID, &tmp ); 
			 | 
		
		
	
		
			
			| 
				265
			 | 
			
				
			 | 
			
			
				
				-			if ( ( tmp == 0xffffffff ) || ( tmp == 0 ) ) 
			 | 
		
		
	
		
			
			| 
				266
			 | 
			
				
			 | 
			
			
				
				-				continue; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				261
			 | 
			
			
				
				+		/* Check for physical device presence */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				262
			 | 
			
			
				
				+		pci_read_config_dword ( pci, PCI_VENDOR_ID, &tmp ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				263
			 | 
			
			
				
				+		if ( ( tmp == 0xffffffff ) || ( tmp == 0 ) ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				264
			 | 
			
			
				
				+			continue; 
			 | 
		
		
	
		
			
			| 
				267
			 | 
			
				265
			 | 
			
			
				
				 			 
			 | 
		
		
	
		
			
			| 
				268
			 | 
			
				
			 | 
			
			
				
				-			/* Populate struct pci_device */ 
			 | 
		
		
	
		
			
			| 
				269
			 | 
			
				
			 | 
			
			
				
				-			pci->vendor = ( tmp & 0xffff ); 
			 | 
		
		
	
		
			
			| 
				270
			 | 
			
				
			 | 
			
			
				
				-			pci->device = ( tmp >> 16 ); 
			 | 
		
		
	
		
			
			| 
				271
			 | 
			
				
			 | 
			
			
				
				-			pci_read_config_dword ( pci, PCI_REVISION, &tmp ); 
			 | 
		
		
	
		
			
			| 
				272
			 | 
			
				
			 | 
			
			
				
				-			pci->class = ( tmp >> 8 ); 
			 | 
		
		
	
		
			
			| 
				273
			 | 
			
				
			 | 
			
			
				
				-			pci_read_config_byte ( pci, PCI_INTERRUPT_LINE, 
			 | 
		
		
	
		
			
			| 
				274
			 | 
			
				
			 | 
			
			
				
				-					       &pci->irq ); 
			 | 
		
		
	
		
			
			| 
				275
			 | 
			
				
			 | 
			
			
				
				-			pci_read_bases ( pci ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				266
			 | 
			
			
				
				+		/* Populate struct pci_device */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				267
			 | 
			
			
				
				+		pci->vendor = ( tmp & 0xffff ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				268
			 | 
			
			
				
				+		pci->device = ( tmp >> 16 ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				269
			 | 
			
			
				
				+		pci_read_config_dword ( pci, PCI_REVISION, &tmp ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				270
			 | 
			
			
				
				+		pci->class = ( tmp >> 8 ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				271
			 | 
			
			
				
				+		pci_read_config_byte ( pci, PCI_INTERRUPT_LINE, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				272
			 | 
			
			
				
				+				       &pci->irq ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				273
			 | 
			
			
				
				+		pci_read_bases ( pci ); 
			 | 
		
		
	
		
			
			| 
				276
			 | 
			
				274
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				277
			 | 
			
				
			 | 
			
			
				
				-			/* Add to device hierarchy */ 
			 | 
		
		
	
		
			
			| 
				278
			 | 
			
				
			 | 
			
			
				
				-			snprintf ( pci->dev.name, sizeof ( pci->dev.name ), 
			 | 
		
		
	
		
			
			| 
				279
			 | 
			
				
			 | 
			
			
				
				-				   "PCI%02x:%02x.%x", bus, 
			 | 
		
		
	
		
			
			| 
				280
			 | 
			
				
			 | 
			
			
				
				-				   PCI_SLOT ( devfn ), PCI_FUNC ( devfn ) ); 
			 | 
		
		
	
		
			
			| 
				281
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.bus_type = BUS_TYPE_PCI; 
			 | 
		
		
	
		
			
			| 
				282
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.location = PCI_BUSDEVFN (bus, devfn); 
			 | 
		
		
	
		
			
			| 
				283
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.vendor = pci->vendor; 
			 | 
		
		
	
		
			
			| 
				284
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.device = pci->device; 
			 | 
		
		
	
		
			
			| 
				285
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.class = pci->class; 
			 | 
		
		
	
		
			
			| 
				286
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.ioaddr = pci->ioaddr; 
			 | 
		
		
	
		
			
			| 
				287
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.desc.irq = pci->irq; 
			 | 
		
		
	
		
			
			| 
				288
			 | 
			
				
			 | 
			
			
				
				-			pci->dev.parent = &rootdev->dev; 
			 | 
		
		
	
		
			
			| 
				289
			 | 
			
				
			 | 
			
			
				
				-			list_add ( &pci->dev.siblings, &rootdev->dev.children); 
			 | 
		
		
	
		
			
			| 
				290
			 | 
			
				
			 | 
			
			
				
				-			INIT_LIST_HEAD ( &pci->dev.children ); 
			 | 
		
		
	
		
			
			| 
				291
			 | 
			
				
			 | 
			
			
				
				-			 
			 | 
		
		
	
		
			
			| 
				292
			 | 
			
				
			 | 
			
			
				
				-			/* Look for a driver */ 
			 | 
		
		
	
		
			
			| 
				293
			 | 
			
				
			 | 
			
			
				
				-			if ( pci_probe ( pci ) == 0 ) { 
			 | 
		
		
	
		
			
			| 
				294
			 | 
			
				
			 | 
			
			
				
				-				/* pcidev registered, we can drop our ref */ 
			 | 
		
		
	
		
			
			| 
				295
			 | 
			
				
			 | 
			
			
				
				-				pci = NULL; 
			 | 
		
		
	
		
			
			| 
				296
			 | 
			
				
			 | 
			
			
				
				-			} else { 
			 | 
		
		
	
		
			
			| 
				297
			 | 
			
				
			 | 
			
			
				
				-				/* Not registered; re-use struct pci_device */ 
			 | 
		
		
	
		
			
			| 
				298
			 | 
			
				
			 | 
			
			
				
				-				list_del ( &pci->dev.siblings ); 
			 | 
		
		
	
		
			
			| 
				299
			 | 
			
				
			 | 
			
			
				
				-			} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				275
			 | 
			
			
				
				+		/* Add to device hierarchy */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				276
			 | 
			
			
				
				+		snprintf ( pci->dev.name, sizeof ( pci->dev.name ), 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				277
			 | 
			
			
				
				+			   "PCI%02x:%02x.%x", PCI_BUS ( busdevfn ), 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				278
			 | 
			
			
				
				+			   PCI_SLOT ( busdevfn ), PCI_FUNC ( busdevfn ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				279
			 | 
			
			
				
				+		pci->dev.desc.bus_type = BUS_TYPE_PCI; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				280
			 | 
			
			
				
				+		pci->dev.desc.location = pci->busdevfn; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				281
			 | 
			
			
				
				+		pci->dev.desc.vendor = pci->vendor; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				282
			 | 
			
			
				
				+		pci->dev.desc.device = pci->device; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				283
			 | 
			
			
				
				+		pci->dev.desc.class = pci->class; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				284
			 | 
			
			
				
				+		pci->dev.desc.ioaddr = pci->ioaddr; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				285
			 | 
			
			
				
				+		pci->dev.desc.irq = pci->irq; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				286
			 | 
			
			
				
				+		pci->dev.parent = &rootdev->dev; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				287
			 | 
			
			
				
				+		list_add ( &pci->dev.siblings, &rootdev->dev.children); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				288
			 | 
			
			
				
				+		INIT_LIST_HEAD ( &pci->dev.children ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				289
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				290
			 | 
			
			
				
				+		/* Look for a driver */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				291
			 | 
			
			
				
				+		if ( pci_probe ( pci ) == 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				292
			 | 
			
			
				
				+			/* pcidev registered, we can drop our ref */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				293
			 | 
			
			
				
				+			pci = NULL; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				294
			 | 
			
			
				
				+		} else { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				
				+			/* Not registered; re-use struct pci_device */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				296
			 | 
			
			
				
				+			list_del ( &pci->dev.siblings ); 
			 | 
		
		
	
		
			
			| 
				300
			 | 
			
				297
			 | 
			
			
				
				 		} 
			 | 
		
		
	
		
			
			| 
				301
			 | 
			
				298
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				302
			 | 
			
				299
			 | 
			
			
				
				  
			 |