if (stat) return stat; 
if (stat) return stat; 
static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense){	int stat, ntracks, i;	struct cdrom_info *info = drive->driver_data;	struct cdrom_device_info *cdi = &info->devinfo;	struct atapi_toc *toc = info->toc;	struct {		struct atapi_toc_header hdr;		struct atapi_toc_entry  ent;	} ms_tmp;	long last_written;	unsigned long sectors_per_frame = SECTORS_PER_FRAME;	if (toc == NULL) {		/* Try to allocate space. */		toc = (struct atapi_toc *) kmalloc (sizeof (struct atapi_toc),						    GFP_KERNEL);		info->toc = toc;		if (toc == NULL) {			printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name);			return -ENOMEM;		}	}	/* Check to see if the existing data is still valid.	   If it is, just return. */	(void) cdrom_check_status(drive, sense);	if (CDROM_STATE_FLAGS(drive)->toc_valid)		return 0;	/* Try to get the total cdrom capacity and sector size. */	stat = cdrom_read_capacity(drive, &toc->capacity, &sectors_per_frame,				   sense);	if (stat)		toc->capacity = 0x1fffff;	set_capacity(info->disk, toc->capacity * sectors_per_frame);	blk_queue_hardsect_size(drive->queue,				sectors_per_frame << SECTOR_BITS);	/* First read just the header, so we know how long the TOC is. */	stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,				    sizeof(struct atapi_toc_header), sense);	if (stat) return stat;#if ! STANDARD_ATAPI	if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {		toc->hdr.first_track = bcd2bin(toc->hdr.first_track);		toc->hdr.last_track  = bcd2bin(toc->hdr.last_track);	}#endif  /* not STANDARD_ATAPI */	ntracks = toc->hdr.last_track - toc->hdr.first_track + 1;	if (ntracks <= 0)		return -EIO;	if (ntracks > MAX_TRACKS)		ntracks = MAX_TRACKS;	/* Now read the whole schmeer. */	stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0,				  (char *)&toc->hdr,				   sizeof(struct atapi_toc_header) +				   (ntracks + 1) *				   sizeof(struct atapi_toc_entry), sense);	if (stat && toc->hdr.first_track > 1) {		/* Cds with CDI tracks only don't have any TOC entries,		   despite of this the returned values are		   first_track == last_track = number of CDI tracks + 1,		   so that this case is indistinguishable from the same		   layout plus an additional audio track.		   If we get an error for the regular case, we assume		   a CDI without additional audio tracks. In this case		   the readable TOC is empty (CDI tracks are not included)		   and only holds the Leadout entry. Heiko Eifeldt */		ntracks = 0;		stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0,					   (char *)&toc->hdr,					   sizeof(struct atapi_toc_header) +					   (ntracks + 1) *					   sizeof(struct atapi_toc_entry),					   sense);		if (stat) {			return stat;		}#if ! STANDARD_ATAPI		if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {			toc->hdr.first_track = bin2bcd(CDROM_LEADOUT);			toc->hdr.last_track = bin2bcd(CDROM_LEADOUT);		} else#endif  /* not STANDARD_ATAPI */		{			toc->hdr.first_track = CDROM_LEADOUT;			toc->hdr.last_track = CDROM_LEADOUT;		}	}	if (stat)		return stat;	toc->hdr.toc_length = ntohs (toc->hdr.toc_length);#if ! STANDARD_ATAPI	if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {		toc->hdr.first_track = bcd2bin(toc->hdr.first_track);		toc->hdr.last_track  = bcd2bin(toc->hdr.last_track);	}#endif  /* not STANDARD_ATAPI */	for (i=0; i<=ntracks; i++) {#if ! STANDARD_ATAPI		if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) {			if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd)				toc->ent[i].track = bcd2bin(toc->ent[i].track);			msf_from_bcd(&toc->ent[i].addr.msf);		}#endif  /* not STANDARD_ATAPI */		toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute,						   toc->ent[i].addr.msf.second,						   toc->ent[i].addr.msf.frame);	}	/* Read the multisession information. */	if (toc->hdr.first_track != CDROM_LEADOUT) {		/* Read the multisession information. */		stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp,					   sizeof(ms_tmp), sense);		if (stat) return stat;		toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba);	} else {		ms_tmp.hdr.first_track = ms_tmp.hdr.last_track = CDROM_LEADOUT;		toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */	}#if ! STANDARD_ATAPI	if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) {		/* Re-read multisession information using MSF format */		stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,					   sizeof(ms_tmp), sense);		if (stat)			return stat;		msf_from_bcd (&ms_tmp.ent.addr.msf);		toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute,					  	   ms_tmp.ent.addr.msf.second,						   ms_tmp.ent.addr.msf.frame);	}#endif  /* not STANDARD_ATAPI */	toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);	/* Now try to get the total cdrom capacity. */	stat = cdrom_get_last_written(cdi, &last_written);	if (!stat && (last_written > toc->capacity)) {		toc->capacity = last_written;		set_capacity(info->disk, toc->capacity * sectors_per_frame);	}	/* Remember that we've read this stuff. */	CDROM_STATE_FLAGS(drive)->toc_valid = 1;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/2a91f3e54ff27c6002597f689ba51c5fa657ddbd/ide-cd.c/buggy/drivers/ide/ide-cd.c