mdsk_term_io(device); 
dasd_diag_check_device(struct dasd_device *device){	struct dasd_diag_private *private;	struct dasd_diag_characteristics *rdc_data;	struct dasd_diag_bio bio;	struct dasd_diag_cms_label *label;	blocknum_t end_block;	unsigned int sb, bsize;	int rc;	private = (struct dasd_diag_private *) device->private;	if (private == NULL) {		private = kmalloc(sizeof(struct dasd_diag_private),GFP_KERNEL);		if (private == NULL) {			DEV_MESSAGE(KERN_WARNING, device, "%s",				"memory allocation failed for private data");			return -ENOMEM;		}		device->private = (void *) private;	}	/* Read Device Characteristics */	rdc_data = (void *) &(private->rdc_data);	rdc_data->dev_nr = _ccw_device_get_device_number(device->cdev);	rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics);	rc = diag210((struct diag210 *) rdc_data);	if (rc) {		DEV_MESSAGE(KERN_WARNING, device, "failed to retrieve device "			    "information (rc=%d)", rc);		return -ENOTSUPP;	}	/* Figure out position of label block */	switch (private->rdc_data.vdev_class) {	case DEV_CLASS_FBA:		private->pt_block = 1;		break;	case DEV_CLASS_ECKD:		private->pt_block = 2;		break;	default:		DEV_MESSAGE(KERN_WARNING, device, "unsupported device class "			    "(class=%d)", private->rdc_data.vdev_class);		return -ENOTSUPP;	}	DBF_DEV_EVENT(DBF_INFO, device,		      "%04X: %04X on real %04X/%02X",		      rdc_data->dev_nr,		      rdc_data->vdev_type,		      rdc_data->rdev_type, rdc_data->rdev_model);	/* terminate all outstanding operations */	mdsk_term_io(device);	/* figure out blocksize of device */	label = (struct dasd_diag_cms_label *) get_zeroed_page(GFP_KERNEL);	if (label == NULL)  {		DEV_MESSAGE(KERN_WARNING, device, "%s",			    "No memory to allocate initialization request");		return -ENOMEM;	}	rc = 0;	end_block = 0;	/* try all sizes - needed for ECKD devices */	for (bsize = 512; bsize <= PAGE_SIZE; bsize <<= 1) {		mdsk_init_io(device, bsize, 0, &end_block);		memset(&bio, 0, sizeof (struct dasd_diag_bio));		bio.type = MDSK_READ_REQ;		bio.block_number = private->pt_block + 1;		bio.buffer = label;		memset(&private->iob, 0, sizeof (struct dasd_diag_rw_io));		private->iob.dev_nr = rdc_data->dev_nr;		private->iob.key = 0;		private->iob.flags = 0;	/* do synchronous io */		private->iob.block_count = 1;		private->iob.interrupt_params = 0;		private->iob.bio_list = &bio;		private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;		rc = dia250(&private->iob, RW_BIO);		if (rc == 0 || rc == 3)			break;		mdsk_term_io(device);	}	if (rc == 3) {		DEV_MESSAGE(KERN_WARNING, device, "%s", "DIAG call failed");		rc = -EOPNOTSUPP;	} else if (rc != 0) {		DEV_MESSAGE(KERN_WARNING, device, "device access failed "			    "(rc=%d)", rc);		rc = -EIO;	} else {		if (memcmp(label->label_id, DASD_DIAG_CMS1,			  sizeof(DASD_DIAG_CMS1)) == 0) {			/* get formatted blocksize from label block */			bsize = (unsigned int) label->block_size;			device->blocks = (unsigned long) label->block_count;		} else			device->blocks = end_block;		device->bp_block = bsize;		device->s2b_shift = 0;	/* bits to shift 512 to get a block */		for (sb = 512; sb < bsize; sb = sb << 1)			device->s2b_shift++;				DEV_MESSAGE(KERN_INFO, device,			    "(%ld B/blk): %ldkB",			    (unsigned long) device->bp_block,			    (unsigned long) (device->blocks <<				device->s2b_shift) >> 1);		rc = 0;	}	free_page((long) label);	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/1e0291bade7678efe4d3ab70ed14bd7bd216bcef/dasd_diag.c/buggy/drivers/s390/block/dasd_diag.c