/* Remove device from block device layer. Destroy dirty buffers. Forget format information. Check if the target level is basic and if it is create fake disk for formatting.  */
static int dasd_state_ready_to_basic(struct dasd_device *device)
/* Remove device from block device layer. Destroy dirty buffers. Forget format information. Check if the target level is basic and if it is create fake disk for formatting.  */
static int dasd_state_ready_to_basic(struct dasd_device *device)
{
	int rc;
	device->state = DASD_STATE_BASIC;
	if (device->block) {
		struct dasd_block *block = device->block;
		rc = dasd_flush_block_queue(block);
		if (rc) {
			device->state = DASD_STATE_READY;
			return rc;
		}
		dasd_destroy_partitions(block);
		dasd_flush_request_queue(block);
		block->blocks = 0;
		block->bp_block = 0;
		block->s2b_shift = 0;
	}
	return 0;
}