if (dev->flags & ATA_DFLAG_LBA48) { if (n_block > (64 * 1024)) goto invalid_fld; 
if (lba_28_ok(block, n_block)) { /* use LBA28 */ tf->command = ATA_CMD_VERIFY; tf->device |= (block >> 24) & 0xf; } else if (lba_48_ok(block, n_block)) { if (!(dev->flags & ATA_DFLAG_LBA48)) goto out_of_range; 
static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd){	struct ata_taskfile *tf = &qc->tf;	struct ata_device *dev = qc->dev;	u64 dev_sectors = qc->dev->n_sectors;	u64 block;	u32 n_block;	tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;	tf->protocol = ATA_PROT_NODATA;	if (scsicmd[0] == VERIFY)		scsi_10_lba_len(scsicmd, &block, &n_block);	else if (scsicmd[0] == VERIFY_16)		scsi_16_lba_len(scsicmd, &block, &n_block);	else		goto invalid_fld;	if (!n_block)		goto nothing_to_do;	if (block >= dev_sectors)		goto out_of_range;	if ((block + n_block) > dev_sectors)		goto out_of_range;	if (dev->flags & ATA_DFLAG_LBA) {		tf->flags |= ATA_TFLAG_LBA;		if (dev->flags & ATA_DFLAG_LBA48) {			if (n_block > (64 * 1024))				goto invalid_fld;			/* use LBA48 */			tf->flags |= ATA_TFLAG_LBA48;			tf->command = ATA_CMD_VERIFY_EXT;			tf->hob_nsect = (n_block >> 8) & 0xff;			tf->hob_lbah = (block >> 40) & 0xff;			tf->hob_lbam = (block >> 32) & 0xff;			tf->hob_lbal = (block >> 24) & 0xff;		} else {			if (n_block > 256)				goto invalid_fld;			/* use LBA28 */			tf->command = ATA_CMD_VERIFY;			tf->device |= (block >> 24) & 0xf;		}		tf->nsect = n_block & 0xff;		tf->lbah = (block >> 16) & 0xff;		tf->lbam = (block >> 8) & 0xff;		tf->lbal = block & 0xff;		tf->device |= ATA_LBA;	} else {		/* CHS */		u32 sect, head, cyl, track;		if (n_block > 256)			goto invalid_fld;		/* Convert LBA to CHS */		track = (u32)block / dev->sectors;		cyl   = track / dev->heads;		head  = track % dev->heads;		sect  = (u32)block % dev->sectors + 1;		DPRINTK("block %u track %u cyl %u head %u sect %u\n",			(u32)block, track, cyl, head, sect);				/* Check whether the converted CHS can fit. 		   Cylinder: 0-65535 		   Head: 0-15		   Sector: 1-255*/		if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) 			goto out_of_range;				tf->command = ATA_CMD_VERIFY;		tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */		tf->lbal = sect;		tf->lbam = cyl;		tf->lbah = cyl >> 8;		tf->device |= head;	}	return 0;invalid_fld:	ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0);	/* "Invalid field in cbd" */	return 1;out_of_range:	ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0);	/* "Logical Block Address out of range" */	return 1;nothing_to_do:	qc->scsicmd->result = SAM_STAT_GOOD;	return 1;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/c6a33e2464edd87f8c12cc2d11369a5b44c65b77/libata-scsi.c/buggy/drivers/scsi/libata-scsi.c