else { 
else if (dev->class == ATA_DEV_ATAPI) { 
static void ata_dev_identify(struct ata_port *ap, unsigned int device){	struct ata_device *dev = &ap->device[device];	unsigned int major_version;	u16 tmp;	unsigned long xfer_modes;	unsigned int using_edd;	DECLARE_COMPLETION(wait);	struct ata_queued_cmd *qc;	unsigned long flags;	int rc;	if (!ata_dev_present(dev)) {		DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",			ap->id, device);		return;	}	if (ap->flags & (ATA_FLAG_SRST | ATA_FLAG_SATA_RESET))		using_edd = 0;	else		using_edd = 1;	DPRINTK("ENTER, host %u, dev %u\n", ap->id, device);	assert (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ATAPI ||		dev->class == ATA_DEV_NONE);	ata_dev_select(ap, device, 1, 1); /* select device 0/1 */	qc = ata_qc_new_init(ap, dev);	BUG_ON(qc == NULL);	ata_sg_init_one(qc, dev->id, sizeof(dev->id));	qc->dma_dir = DMA_FROM_DEVICE;	qc->tf.protocol = ATA_PROT_PIO;	qc->nsect = 1;retry:	if (dev->class == ATA_DEV_ATA) {		qc->tf.command = ATA_CMD_ID_ATA;		DPRINTK("do ATA identify\n");	} else {		qc->tf.command = ATA_CMD_ID_ATAPI;		DPRINTK("do ATAPI identify\n");	}	qc->waiting = &wait;	qc->complete_fn = ata_qc_complete_noop;	spin_lock_irqsave(&ap->host_set->lock, flags);	rc = ata_qc_issue(qc);	spin_unlock_irqrestore(&ap->host_set->lock, flags);	if (rc)		goto err_out;	else		wait_for_completion(&wait);	spin_lock_irqsave(&ap->host_set->lock, flags);	ap->ops->tf_read(ap, &qc->tf);	spin_unlock_irqrestore(&ap->host_set->lock, flags);	if (qc->tf.command & ATA_ERR) {		/*		 * arg!  EDD works for all test cases, but seems to return		 * the ATA signature for some ATAPI devices.  Until the		 * reason for this is found and fixed, we fix up the mess		 * here.  If IDENTIFY DEVICE returns command aborted		 * (as ATAPI devices do), then we issue an		 * IDENTIFY PACKET DEVICE.		 *		 * ATA software reset (SRST, the default) does not appear		 * to have this problem.		 */		if ((using_edd) && (dev->class == ATA_DEV_ATA)) {			u8 err = qc->tf.feature;			if (err & ATA_ABORTED) {				dev->class = ATA_DEV_ATAPI;				qc->cursg = 0;				qc->cursg_ofs = 0;				qc->cursect = 0;				qc->nsect = 1;				goto retry;			}		}		goto err_out;	}	swap_buf_le16(dev->id, ATA_ID_WORDS);	/* print device capabilities */	printk(KERN_DEBUG "ata%u: dev %u cfg "	       "49:%04x 82:%04x 83:%04x 84:%04x 85:%04x 86:%04x 87:%04x 88:%04x\n",	       ap->id, device, dev->id[49],	       dev->id[82], dev->id[83], dev->id[84],	       dev->id[85], dev->id[86], dev->id[87],	       dev->id[88]);	/*	 * common ATA, ATAPI feature tests	 */	/* we require DMA support (bits 8 of word 49) */	if (!ata_id_has_dma(dev->id)) {		printk(KERN_DEBUG "ata%u: no dma\n", ap->id);		goto err_out_nosup;	}	/* quick-n-dirty find max transfer mode; for printk only */	xfer_modes = dev->id[ATA_ID_UDMA_MODES];	if (!xfer_modes)		xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA;	if (!xfer_modes)		xfer_modes = ata_pio_modes(dev);	ata_dump_id(dev);	/* ATA-specific feature tests */	if (dev->class == ATA_DEV_ATA) {		if (!ata_id_is_ata(dev->id))	/* sanity check */			goto err_out_nosup;		/* get major version */		tmp = dev->id[ATA_ID_MAJOR_VER];		for (major_version = 14; major_version >= 1; major_version--)			if (tmp & (1 << major_version))				break;		/*		 * The exact sequence expected by certain pre-ATA4 drives is:		 * SRST RESET		 * IDENTIFY		 * INITIALIZE DEVICE PARAMETERS		 * anything else..		 * Some drives were very specific about that exact sequence.		 */		if (major_version < 4 || (!ata_id_has_lba(dev->id))) {			ata_dev_init_params(ap, dev);			/* current CHS translation info (id[53-58]) might be			 * changed. reread the identify device info.			 */			ata_dev_reread_id(ap, dev);		}		if (ata_id_has_lba(dev->id)) {			dev->flags |= ATA_DFLAG_LBA;			if (ata_id_has_lba48(dev->id)) {				dev->flags |= ATA_DFLAG_LBA48;				dev->n_sectors = ata_id_u64(dev->id, 100);			} else {				dev->n_sectors = ata_id_u32(dev->id, 60);			}			/* print device info to dmesg */			printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n",			       ap->id, device,			       major_version,			       ata_mode_string(xfer_modes),			       (unsigned long long)dev->n_sectors,			       dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA");		} else { 			/* CHS */			/* Default translation */			dev->cylinders	= dev->id[1];			dev->heads	= dev->id[3];			dev->sectors	= dev->id[6];			dev->n_sectors	= dev->cylinders * dev->heads * dev->sectors;			if (ata_id_current_chs_valid(dev->id)) {				/* Current CHS translation is valid. */				dev->cylinders = dev->id[54];				dev->heads     = dev->id[55];				dev->sectors   = dev->id[56];								dev->n_sectors = ata_id_u32(dev->id, 57);			}			/* print device info to dmesg */			printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n",			       ap->id, device,			       major_version,			       ata_mode_string(xfer_modes),			       (unsigned long long)dev->n_sectors,			       (int)dev->cylinders, (int)dev->heads, (int)dev->sectors);		}		ap->host->max_cmd_len = 16;	}	/* ATAPI-specific feature tests */	else {		if (ata_id_is_ata(dev->id))		/* sanity check */			goto err_out_nosup;		rc = atapi_cdb_len(dev->id);		if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {			printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id);			goto err_out_nosup;		}		ap->cdb_len = (unsigned int) rc;		ap->host->max_cmd_len = (unsigned char) ap->cdb_len;		/* print device info to dmesg */		printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",		       ap->id, device,		       ata_mode_string(xfer_modes));	}	DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap));	return;err_out_nosup:	printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n",	       ap->id, device);err_out:	dev->class++;	/* converts ATA_DEV_xxx into ATA_DEV_xxx_UNSUP */	DPRINTK("EXIT, err\n");}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/2c13b7cee045af689b36349c2bc6a9ed6e3d73fa/libata-core.c/buggy/drivers/scsi/libata-core.c