Ejemplo n.º 1
0
void sim_unregistered( ide_bus_info *bus )
{
	sem_delete( bus->scan_device_sem );
	sem_delete( bus->sync_wait_sem );
	xpt->free_dpc( bus->irq_dpc );
	uninit_synced_pc( &bus->scan_bus_syncinfo );
	uninit_synced_pc( &bus->disconnect_syncinfo );
	
	kfree( bus );
}
Ejemplo n.º 2
0
static void
destroy_device(ide_device_info *device)
{
	TRACE("destroy_device: device %p\n", device);

	// paranoia
	device->exec_io = NULL;
	cancel_timer(&device->reconnect_timer.te);

	scsi->free_dpc(device->reconnect_timeout_dpc);

	cleanup_device_links(device);

	destroy_qreq_array(device);

	uninit_synced_pc(&device->reconnect_timeout_synced_pc);

	free(device);
}
Ejemplo n.º 3
0
int connect_channel( const char *name, 
	ide_controller_interface *controller,
	ide_channel_cookie channel,
	ide_controller_params *controller_params,
	ide_bus_info **bus_out )
{
	ide_bus_info *bus;
	xpt_bus_cookie xpt_cookie;
	int res;
	
	SHOW_FLOW0( 3, "" );
	
	bus = kmalloc( sizeof( *bus ));
	if( bus == NULL )
		return ERR_NO_MEMORY;
		
	SHOW_FLOW0( 3, "1" );
		
	memset( bus, 0, sizeof( *bus ));
	memcpy( &bus->controller_params, controller_params, sizeof( *controller_params ));
	bus->lock = 0;
	bus->num_running_reqs = 0;
	bus->controller = controller;
	bus->channel = channel;
	bus->active_qrequest = NULL;
	bus->disconnected = false;
	
	init_synced_pc( &bus->scan_bus_syncinfo, scan_device_worker );
	init_synced_pc( &bus->disconnect_syncinfo, disconnect_worker );
	
	bus->wait_id = bus->dpc_id = 0;
	bus->xpt_cookie = NULL;
	timer_setup_timer( ide_timeout, bus, &bus->timer );
	
	bus->state = ide_state_idle;
	bus->device_to_reconnect = NULL;
	
	bus->synced_pc_list = NULL;
	if( (res = xpt->alloc_dpc( &bus->irq_dpc )) < 0 )
		goto err1;
		
	SHOW_FLOW0( 3, "2" );
		
	bus->active_device = NULL;
	bus->sync_wait_sem = sem_create( 0, "ide_sync_wait" );
	if( bus->sync_wait_sem < 0 ) {
		res = bus->sync_wait_sem;
		goto err2;
	}
		
	SHOW_FLOW0( 3, "3" );
		
	bus->devices[0] = bus->devices[1] = NULL;
	
	bus->scan_device_sem = sem_create( 0, "ide_scan_finished" );
	if( bus->scan_device_sem < 0 ) {
		res = bus->scan_device_sem;
		goto err3;
	}
		
	SHOW_FLOW0( 3, "4" );
		
	bus->first_device = NULL;
	strncpy( bus->controller_name, name, HBA_ID );
	
	res = xpt->register_SIM( &ide_sim_interface, (cam_sim_cookie) bus, 
		&xpt_cookie );
		
	if( res < 0 )
		goto err4;
		
	SHOW_FLOW0( 3, "5" );
		
	bus->path_id = res;
	// do assignment very last as the irq handler uses this value, so it
	// must be either NULL or valid
	bus->xpt_cookie = xpt_cookie;
	
	// after this, the bus must be fully functional
	*bus_out = bus;

	call_xpt_bus_scan( bus );
		
	return NO_ERROR;
	
err4:
	sem_delete( bus->scan_device_sem );
	
err3:
	sem_delete( bus->sync_wait_sem );

err2:	
	xpt->free_dpc( bus->irq_dpc );

err1:	
	uninit_synced_pc( &bus->scan_bus_syncinfo );
	uninit_synced_pc( &bus->disconnect_syncinfo );
	kfree( bus );
	
	return res;
}