memset(device, 0, sizeof(struct acpi_device));  device->handle = handle; device->parent = parent;  acpi_device_get_busid(device,handle,type);  /* * Flags * ----- * Get prior to calling acpi_bus_get_status() so we know whether * or not _STA is present.  Note that we only look for object * handles -- cannot evaluate objects until we know the device is * present and properly initialized. */ result = acpi_bus_get_flags(device); if (result) goto end;  /* * Status * ------ * See if the device is present.  We always assume that non-Device() * objects (e.g. thermal zones, power resources, processors, etc.) are * present, functioning, etc. (at least when parent object is present). * Note that _STA has a different meaning for some objects (e.g. * power resources) so we need to be careful how we use it. */ switch (type) { case ACPI_BUS_TYPE_DEVICE: result = acpi_bus_get_status(device); if (ACPI_FAILURE(result) || !device->status.present) { result = -ENOENT; goto end; } break; default: STRUCT_TO_INT(device->status) = 0x0F; break; }  /* * Initialize Device * ----------------- * TBD: Synch with Core's enumeration/initialization process. */  /* * Hardware ID, Unique ID, & Bus Address * ------------------------------------- */ acpi_device_set_id(device,parent,handle,type);  /* * Power Management * ---------------- */ if (device->flags.power_manageable) { result = acpi_bus_get_power_flags(device); if (result) goto end; }  /* * Wakeup device management *----------------------- */ if (device->flags.wake_capable) { result = acpi_bus_get_wakeup_device_flags(device); if (result) goto end; }  /* * Performance Management * ---------------------- */ if (device->flags.performance_manageable) { result = acpi_bus_get_perf_flags(device); if (result) goto end; }  if ((result = acpi_device_set_context(device,type))) goto end;  acpi_device_get_debug_info(device,handle,type);  acpi_device_register(device,parent);  /* * Bind _ADR-Based Devices * ----------------------- * If there's a a bus address (_ADR) then we utilize the parent's * 'bind' function (if exists) to bind the ACPI- and natively- * enumerated device representations. */ if (device->flags.bus_address) { if (device->parent && device->parent->ops.bind) device->parent->ops.bind(device); }  /* * Locate & Attach Driver * ---------------------- * If there's a hardware id (_HID) or compatible ids (_CID) we check * to see if there's a driver installed for this kind of device.  Note * that drivers can install before or after a device is enumerated. * * TBD: Assumes LDM provides driver hot-plug capability. */ acpi_bus_find_driver(device);  end: if (!result) *child = device; else { if (device->pnp.cid_list) kfree(device->pnp.cid_list); kfree(device); }  
acpi_bus_add (	struct acpi_device	**child,	struct acpi_device	*parent,	acpi_handle		handle,	int			type){	int			result = 0;	struct acpi_device	*device = NULL;	ACPI_FUNCTION_TRACE("acpi_bus_add");	if (!child)		return_VALUE(-EINVAL);	device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);	if (!device) {		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));		return_VALUE(-ENOMEM);	}	memset(device, 0, sizeof(struct acpi_device));	device->handle = handle;	device->parent = parent;	acpi_device_get_busid(device,handle,type);	/*	 * Flags	 * -----	 * Get prior to calling acpi_bus_get_status() so we know whether	 * or not _STA is present.  Note that we only look for object	 * handles -- cannot evaluate objects until we know the device is	 * present and properly initialized.	 */	result = acpi_bus_get_flags(device);	if (result)		goto end;	/*	 * Status	 * ------	 * See if the device is present.  We always assume that non-Device()	 * objects (e.g. thermal zones, power resources, processors, etc.) are	 * present, functioning, etc. (at least when parent object is present).	 * Note that _STA has a different meaning for some objects (e.g.	 * power resources) so we need to be careful how we use it.	 */	switch (type) {	case ACPI_BUS_TYPE_DEVICE:		result = acpi_bus_get_status(device);		if (ACPI_FAILURE(result) || !device->status.present) {			result = -ENOENT;			goto end;		}		break;	default:		STRUCT_TO_INT(device->status) = 0x0F;		break;	}	/*	 * Initialize Device	 * -----------------	 * TBD: Synch with Core's enumeration/initialization process.	 */	/*	 * Hardware ID, Unique ID, & Bus Address	 * -------------------------------------	 */	acpi_device_set_id(device,parent,handle,type);	/*	 * Power Management	 * ----------------	 */	if (device->flags.power_manageable) {		result = acpi_bus_get_power_flags(device);		if (result)			goto end;	} 	/*	 * Wakeup device management	 *-----------------------	 */	if (device->flags.wake_capable) {		result = acpi_bus_get_wakeup_device_flags(device);		if (result)			goto end;	}	/*	 * Performance Management	 * ----------------------	 */	if (device->flags.performance_manageable) {		result = acpi_bus_get_perf_flags(device);		if (result)			goto end;	}	if ((result = acpi_device_set_context(device,type)))		goto end;	acpi_device_get_debug_info(device,handle,type);	acpi_device_register(device,parent);	/*	 * Bind _ADR-Based Devices	 * -----------------------	 * If there's a a bus address (_ADR) then we utilize the parent's 	 * 'bind' function (if exists) to bind the ACPI- and natively-	 * enumerated device representations.	 */	if (device->flags.bus_address) {		if (device->parent && device->parent->ops.bind)			device->parent->ops.bind(device);	}	/*	 * Locate & Attach Driver	 * ----------------------	 * If there's a hardware id (_HID) or compatible ids (_CID) we check	 * to see if there's a driver installed for this kind of device.  Note	 * that drivers can install before or after a device is enumerated.	 *	 * TBD: Assumes LDM provides driver hot-plug capability.	 */	acpi_bus_find_driver(device);end:	if (!result)		*child = device;	else {		if (device->pnp.cid_list)			kfree(device->pnp.cid_list);		kfree(device);	}	return_VALUE(result);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/3fb02738b0fd36f47710a2bf207129efd2f5daa2/scan.c/buggy/drivers/acpi/scan.c