data->dev = pci_find_slot(data->id.bus, PCI_DEVFN(data->id.device, data->id.function)); 
bus = pci_find_bus(data->id.segment, data->id.bus); if (bus) { list_for_each_entry(dev, &bus->devices, bus_list) { if (dev->devfn == PCI_DEVFN(data->id.device, data->id.function)) { data->dev = dev; break; } } } 
acpi_pci_bind (	struct acpi_device	*device){	int			result = 0;	acpi_status		status = AE_OK;	struct acpi_pci_data	*data = NULL;	struct acpi_pci_data	*pdata = NULL;	char			*pathname = NULL;	struct acpi_buffer	buffer = {0, NULL};	acpi_handle		handle = NULL;	ACPI_FUNCTION_TRACE("acpi_pci_bind");	if (!device || !device->parent)		return_VALUE(-EINVAL);	pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);	if(!pathname)		return_VALUE(-ENOMEM);	memset(pathname, 0, ACPI_PATHNAME_MAX);	buffer.length = ACPI_PATHNAME_MAX;	buffer.pointer = pathname;	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);	if (!data){		kfree (pathname);		return_VALUE(-ENOMEM);	}	memset(data, 0, sizeof(struct acpi_pci_data));	acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 		pathname));	/* 	 * Segment & Bus	 * -------------	 * These are obtained via the parent device's ACPI-PCI context.	 */	status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 		(void**) &pdata);	if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 			"Invalid ACPI-PCI context for parent device %s\n",			acpi_device_bid(device->parent)));		result = -ENODEV;		goto end;	}	data->id.segment = pdata->id.segment;	data->id.bus = pdata->bus->number;	/*	 * Device & Function	 * -----------------	 * These are simply obtained from the device's _ADR method.  Note	 * that a value of zero is valid.	 */	data->id.device = device->pnp.bus_address >> 16;	data->id.function = device->pnp.bus_address & 0xFFFF;	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n",		data->id.segment, data->id.bus, data->id.device, 		data->id.function));	/*	 * TBD: Support slot devices (e.g. function=0xFFFF).	 */	/* 	 * Locate PCI Device	 * -----------------	 * Locate matching device in PCI namespace.  If it doesn't exist	 * this typically means that the device isn't currently inserted	 * (e.g. docking station, port replicator, etc.).	 */	data->dev = pci_find_slot(data->id.bus, PCI_DEVFN(data->id.device, data->id.function));	if (!data->dev) {		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 			"Device %02x:%02x:%02x.%02x not present in PCI namespace\n",			data->id.segment, data->id.bus, 			data->id.device, data->id.function));		result = -ENODEV;		goto end;	}	if (!data->dev->bus) {		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 			"Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",			data->id.segment, data->id.bus, 			data->id.device, data->id.function));		result = -ENODEV;		goto end;	}	/*	 * PCI Bridge?	 * -----------	 * If so, set the 'bus' field and install the 'bind' function to 	 * facilitate callbacks for all of its children.	 */	if (data->dev->subordinate) {		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 			"Device %02x:%02x:%02x.%02x is a PCI bridge\n",			data->id.segment, data->id.bus, 			data->id.device, data->id.function));		data->bus = data->dev->subordinate;		device->ops.bind = acpi_pci_bind;		device->ops.unbind = acpi_pci_unbind;	}	/*	 * Attach ACPI-PCI Context	 * -----------------------	 * Thus binding the ACPI and PCI devices.	 */	status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);	if (ACPI_FAILURE(status)) {		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,			"Unable to attach ACPI-PCI context to device %s\n",			acpi_device_bid(device)));		result = -ENODEV;		goto end;	}	/*	 * PCI Routing Table	 * -----------------	 * Evaluate and parse _PRT, if exists.  This code is independent of 	 * PCI bridges (above) to allow parsing of _PRT objects within the	 * scope of non-bridge devices.  Note that _PRTs within the scope of	 * a PCI bridge assume the bridge's subordinate bus number.	 *	 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?	 */	status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);	if (ACPI_SUCCESS(status)) {		if (data->bus)				    /* PCI-PCI bridge */			acpi_pci_irq_add_prt(device->handle, data->id.segment, 				data->bus->number);		else				     /* non-bridge PCI device */			acpi_pci_irq_add_prt(device->handle, data->id.segment,				data->id.bus);	}end:	kfree(pathname);	if (result)		kfree(data);	return_VALUE(result);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/c431ada45d65b305a6aab4557067e564b23ce5a5/pci_bind.c/clean/drivers/acpi/pci_bind.c