Release 4.12 drivers/scsi/sr_ioctl.c
  
  
  
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/blkdev.h>
#include <linux/module.h>
#include <linux/blkpg.h>
#include <linux/cdrom.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <asm/io.h>
#include <linux/uaccess.h>
#include <scsi/scsi.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsi_cmnd.h>
#include "sr.h"
#if 0
#define DEBUG
#endif
/* The sr_is_xa() seems to trigger firmware bugs with some drives :-(
 * It is off by default and can be turned on with this module parameter */
static int xa_test = 0;
module_param(xa_test, int, S_IRUGO | S_IWUSR);
/* primitive to determine whether we need to have GFP_DMA set based on
 * the status of the unchecked_isa_dma flag in the host structure */
#define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0)
static int sr_read_tochdr(struct cdrom_device_info *cdi,
		struct cdrom_tochdr *tochdr)
{
	struct scsi_cd *cd = cdi->handle;
	struct packet_command cgc;
	int result;
	unsigned char *buffer;
	buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
	if (!buffer)
		return -ENOMEM;
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.timeout = IOCTL_TIMEOUT;
	cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
	cgc.cmd[8] = 12;		/* LSB of length */
	cgc.buffer = buffer;
	cgc.buflen = 12;
	cgc.quiet = 1;
	cgc.data_direction = DMA_FROM_DEVICE;
	result = sr_do_ioctl(cd, &cgc);
	tochdr->cdth_trk0 = buffer[2];
	tochdr->cdth_trk1 = buffer[3];
	kfree(buffer);
	return result;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 71 | 44.65% | 1 | 25.00% | 
| Linus Torvalds (pre-git) | 49 | 30.82% | 1 | 25.00% | 
| Alan Cox | 37 | 23.27% | 1 | 25.00% | 
| Al Viro | 2 | 1.26% | 1 | 25.00% | 
| Total | 159 | 100.00% | 4 | 100.00% | 
static int sr_read_tocentry(struct cdrom_device_info *cdi,
		struct cdrom_tocentry *tocentry)
{
	struct scsi_cd *cd = cdi->handle;
	struct packet_command cgc;
	int result;
	unsigned char *buffer;
	buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
	if (!buffer)
		return -ENOMEM;
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.timeout = IOCTL_TIMEOUT;
	cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
	cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0;
	cgc.cmd[6] = tocentry->cdte_track;
	cgc.cmd[8] = 12;		/* LSB of length */
	cgc.buffer = buffer;
	cgc.buflen = 12;
	cgc.data_direction = DMA_FROM_DEVICE;
	result = sr_do_ioctl(cd, &cgc);
	tocentry->cdte_ctrl = buffer[5] & 0xf;
	tocentry->cdte_adr = buffer[5] >> 4;
	tocentry->cdte_datamode = (tocentry->cdte_ctrl & 0x04) ? 1 : 0;
	if (tocentry->cdte_format == CDROM_MSF) {
		tocentry->cdte_addr.msf.minute = buffer[9];
		tocentry->cdte_addr.msf.second = buffer[10];
		tocentry->cdte_addr.msf.frame = buffer[11];
	} else
		tocentry->cdte_addr.lba = (((((buffer[8] << 8) + buffer[9]) << 8)
			+ buffer[10]) << 8) + buffer[11];
	kfree(buffer);
	return result;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 216 | 73.22% | 3 | 18.75% | 
| Linus Torvalds (pre-git) | 43 | 14.58% | 8 | 50.00% | 
| James Bottomley | 17 | 5.76% | 1 | 6.25% | 
| Alan Cox | 7 | 2.37% | 1 | 6.25% | 
| Linus Torvalds | 6 | 2.03% | 1 | 6.25% | 
| Al Viro | 6 | 2.03% | 2 | 12.50% | 
| Total | 295 | 100.00% | 16 | 100.00% | 
#define IOCTL_RETRIES 3
/* ATAPI drives don't have a SCMD_PLAYAUDIO_TI command.  When these drives
   are emulating a SCSI device via the idescsi module, they need to have
   CDROMPLAYTRKIND commands translated into CDROMPLAYMSF commands for them */
static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti)
{
	struct cdrom_tocentry trk0_te, trk1_te;
	struct cdrom_tochdr tochdr;
	struct packet_command cgc;
	int ntracks, ret;
	ret = sr_read_tochdr(cdi, &tochdr);
	if (ret)
		return ret;
	ntracks = tochdr.cdth_trk1 - tochdr.cdth_trk0 + 1;
	
	if (ti->cdti_trk1 == ntracks) 
		ti->cdti_trk1 = CDROM_LEADOUT;
	else if (ti->cdti_trk1 != CDROM_LEADOUT)
		ti->cdti_trk1 ++;
	trk0_te.cdte_track = ti->cdti_trk0;
	trk0_te.cdte_format = CDROM_MSF;
	trk1_te.cdte_track = ti->cdti_trk1;
	trk1_te.cdte_format = CDROM_MSF;
	
	ret = sr_read_tocentry(cdi, &trk0_te);
	if (ret)
		return ret;
	ret = sr_read_tocentry(cdi, &trk1_te);
	if (ret)
		return ret;
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.cmd[0] = GPCMD_PLAY_AUDIO_MSF;
	cgc.cmd[3] = trk0_te.cdte_addr.msf.minute;
	cgc.cmd[4] = trk0_te.cdte_addr.msf.second;
	cgc.cmd[5] = trk0_te.cdte_addr.msf.frame;
	cgc.cmd[6] = trk1_te.cdte_addr.msf.minute;
	cgc.cmd[7] = trk1_te.cdte_addr.msf.second;
	cgc.cmd[8] = trk1_te.cdte_addr.msf.frame;
	cgc.data_direction = DMA_NONE;
	cgc.timeout = IOCTL_TIMEOUT;
	return sr_do_ioctl(cdi->handle, &cgc);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 215 | 74.14% | 2 | 16.67% | 
| Linus Torvalds (pre-git) | 39 | 13.45% | 6 | 50.00% | 
| Alan Cox | 30 | 10.34% | 1 | 8.33% | 
| James Bottomley | 3 | 1.03% | 1 | 8.33% | 
| Al Viro | 3 | 1.03% | 2 | 16.67% | 
| Total | 290 | 100.00% | 12 | 100.00% | 
static int sr_play_trkind(struct cdrom_device_info *cdi,
		struct cdrom_ti *ti)
{
	struct scsi_cd *cd = cdi->handle;
	struct packet_command cgc;
	int result;
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.timeout = IOCTL_TIMEOUT;
	cgc.cmd[0] = GPCMD_PLAYAUDIO_TI;
	cgc.cmd[4] = ti->cdti_trk0;
	cgc.cmd[5] = ti->cdti_ind0;
	cgc.cmd[7] = ti->cdti_trk1;
	cgc.cmd[8] = ti->cdti_ind1;
	cgc.data_direction = DMA_NONE;
	result = sr_do_ioctl(cd, &cgc);
	if (result == -EDRIVE_CANT_DO_THIS)
		result = sr_fake_playtrkind(cdi, ti);
	return result;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 79 | 56.43% | 2 | 25.00% | 
| Alan Cox | 31 | 22.14% | 1 | 12.50% | 
| Linus Torvalds (pre-git) | 26 | 18.57% | 2 | 25.00% | 
| Al Viro | 4 | 2.86% | 3 | 37.50% | 
| Total | 140 | 100.00% | 8 | 100.00% | 
/* We do our own retries because we want to know what the specific
   error code is.  Normally the UNIT_ATTENTION code will automatically
   clear after one error */
int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
{
	struct scsi_device *SDev;
	struct scsi_sense_hdr sshdr;
	int result, err = 0, retries = 0;
	SDev = cd->device;
      retry:
	if (!scsi_block_when_processing_errors(SDev)) {
		err = -ENODEV;
		goto out;
	}
	result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
			      cgc->buffer, cgc->buflen,
			      (unsigned char *)cgc->sense, &sshdr,
			      cgc->timeout, IOCTL_RETRIES, 0, 0, NULL);
	/* Minimal error checking.  Ignore cases we know about, and report the rest. */
	if (driver_byte(result) != 0) {
		switch (sshdr.sense_key) {
		case UNIT_ATTENTION:
			SDev->changed = 1;
			if (!cgc->quiet)
				sr_printk(KERN_INFO, cd,
					  "disc change detected.\n");
			if (retries++ < 10)
				goto retry;
			err = -ENOMEDIUM;
			break;
		case NOT_READY:	/* This happens if there is no disc in drive */
			if (sshdr.asc == 0x04 &&
			    sshdr.ascq == 0x01) {
				/* sense: Logical unit is in process of becoming ready */
				if (!cgc->quiet)
					sr_printk(KERN_INFO, cd,
						  "CDROM not ready yet.\n");
				if (retries++ < 10) {
					/* sleep 2 sec and try again */
					ssleep(2);
					goto retry;
				} else {
					/* 20 secs are enough? */
					err = -ENOMEDIUM;
					break;
				}
			}
			if (!cgc->quiet)
				sr_printk(KERN_INFO, cd,
					  "CDROM not ready.  Make sure there "
					  "is a disc in the drive.\n");
			err = -ENOMEDIUM;
			break;
		case ILLEGAL_REQUEST:
			err = -EIO;
			if (sshdr.asc == 0x20 &&
			    sshdr.ascq == 0x00)
				/* sense: Invalid command operation code */
				err = -EDRIVE_CANT_DO_THIS;
			break;
		default:
			err = -EIO;
		}
	}
	/* Wake up a process waiting for device */
      out:
	cgc->stat = err;
	return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 246 | 81.19% | 3 | 33.33% | 
| Linus Torvalds (pre-git) | 45 | 14.85% | 3 | 33.33% | 
| Hannes Reinecke | 10 | 3.30% | 1 | 11.11% | 
| FUJITA Tomonori | 1 | 0.33% | 1 | 11.11% | 
| Al Viro | 1 | 0.33% | 1 | 11.11% | 
| Total | 303 | 100.00% | 9 | 100.00% | 
/* ---------------------------------------------------------------------- */
/* interface to cdrom.c                                                   */
int sr_tray_move(struct cdrom_device_info *cdi, int pos)
{
	Scsi_CD *cd = cdi->handle;
	struct packet_command cgc;
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.cmd[0] = GPCMD_START_STOP_UNIT;
	cgc.cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ;
	cgc.data_direction = DMA_NONE;
	cgc.timeout = IOCTL_TIMEOUT;
	return sr_do_ioctl(cd, &cgc);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Linus Torvalds (pre-git) | 34 | 38.64% | 2 | 22.22% | 
| Alan Cox | 27 | 30.68% | 1 | 11.11% | 
| Christoph Hellwig | 23 | 26.14% | 3 | 33.33% | 
| Al Viro | 4 | 4.55% | 3 | 33.33% | 
| Total | 88 | 100.00% | 9 | 100.00% | 
int sr_lock_door(struct cdrom_device_info *cdi, int lock)
{
	Scsi_CD *cd = cdi->handle;
	return scsi_set_medium_removal(cd->device, lock ?
		       SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 32 | 91.43% | 1 | 50.00% | 
| Linus Torvalds (pre-git) | 3 | 8.57% | 1 | 50.00% | 
| Total | 35 | 100.00% | 2 | 100.00% | 
int sr_drive_status(struct cdrom_device_info *cdi, int slot)
{
	struct scsi_cd *cd = cdi->handle;
	struct scsi_sense_hdr sshdr;
	struct media_event_desc med;
	if (CDSL_CURRENT != slot) {
		/* we have no changer support */
		return -EINVAL;
	}
	if (!scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
		return CDS_DISC_OK;
	/* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */
	if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY
			&& sshdr.asc == 0x04 && sshdr.ascq == 0x01)
		return CDS_DRIVE_NOT_READY;
	if (!cdrom_get_media_event(cdi, &med)) {
		if (med.media_present)
			return CDS_DISC_OK;
		else if (med.door_open)
			return CDS_TRAY_OPEN;
		else
			return CDS_NO_DISC;
	}
	/*
         * SK/ASC/ASCQ of 2/4/2 means "initialization required"
         * Using CD_TRAY_OPEN results in an START_STOP_UNIT to close
         * the tray, which resolves the initialization requirement.
         */
	if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY
			&& sshdr.asc == 0x04 && sshdr.ascq == 0x02)
		return CDS_TRAY_OPEN;
	/*
         * 0x04 is format in progress .. but there must be a disc present!
         */
	if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04)
		return CDS_DISC_OK;
	/*
         * If not using Mt Fuji extended media tray reports,
         * just return TRAY_OPEN since ATAPI doesn't provide
         * any other way to detect this...
         */
	if (scsi_sense_valid(&sshdr) &&
	    /* 0x3a is medium not present */
	    sshdr.asc == 0x3a)
		return CDS_NO_DISC;
	else
		return CDS_TRAY_OPEN;
	return CDS_DRIVE_NOT_READY;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| James Bottomley | 99 | 48.77% | 1 | 20.00% | 
| Christoph Hellwig | 38 | 18.72% | 1 | 20.00% | 
| Robert Jennings | 30 | 14.78% | 1 | 20.00% | 
| Peter Jones | 30 | 14.78% | 1 | 20.00% | 
| Tejun Heo | 6 | 2.96% | 1 | 20.00% | 
| Total | 203 | 100.00% | 5 | 100.00% | 
int sr_disk_status(struct cdrom_device_info *cdi)
{
	Scsi_CD *cd = cdi->handle;
	struct cdrom_tochdr toc_h;
	struct cdrom_tocentry toc_e;
	int i, rc, have_datatracks = 0;
	/* look for data tracks */
	rc = sr_read_tochdr(cdi, &toc_h);
	if (rc)
		return (rc == -ENOMEDIUM) ? CDS_NO_DISC : CDS_NO_INFO;
	for (i = toc_h.cdth_trk0; i <= toc_h.cdth_trk1; i++) {
		toc_e.cdte_track = i;
		toc_e.cdte_format = CDROM_LBA;
		if (sr_read_tocentry(cdi, &toc_e))
			return CDS_NO_INFO;
		if (toc_e.cdte_ctrl & CDROM_DATA_TRACK) {
			have_datatracks = 1;
			break;
		}
	}
	if (!have_datatracks)
		return CDS_AUDIO;
	if (cd->xa_flag)
		return CDS_XA_2_1;
	else
		return CDS_DATA_1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 107 | 75.35% | 2 | 18.18% | 
| Linus Torvalds (pre-git) | 14 | 9.86% | 5 | 45.45% | 
| Alan Cox | 10 | 7.04% | 1 | 9.09% | 
| Andrew Morton | 6 | 4.23% | 1 | 9.09% | 
| James Bottomley | 4 | 2.82% | 1 | 9.09% | 
| Al Viro | 1 | 0.70% | 1 | 9.09% | 
| Total | 142 | 100.00% | 11 | 100.00% | 
int sr_get_last_session(struct cdrom_device_info *cdi,
			struct cdrom_multisession *ms_info)
{
	Scsi_CD *cd = cdi->handle;
	ms_info->addr.lba = cd->ms_offset;
	ms_info->xa_flag = cd->xa_flag || cd->ms_offset > 0;
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 41 | 82.00% | 1 | 16.67% | 
| Linus Torvalds (pre-git) | 7 | 14.00% | 3 | 50.00% | 
| Alan Cox | 1 | 2.00% | 1 | 16.67% | 
| Al Viro | 1 | 2.00% | 1 | 16.67% | 
| Total | 50 | 100.00% | 6 | 100.00% | 
int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
{
	Scsi_CD *cd = cdi->handle;
	struct packet_command cgc;
	char *buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
	int result;
	if (!buffer)
		return -ENOMEM;
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.cmd[0] = GPCMD_READ_SUBCHANNEL;
	cgc.cmd[2] = 0x40;	/* I do want the subchannel info */
	cgc.cmd[3] = 0x02;	/* Give me medium catalog number info */
	cgc.cmd[8] = 24;
	cgc.buffer = buffer;
	cgc.buflen = 24;
	cgc.data_direction = DMA_FROM_DEVICE;
	cgc.timeout = IOCTL_TIMEOUT;
	result = sr_do_ioctl(cd, &cgc);
	memcpy(mcn->medium_catalog_number, buffer + 9, 13);
	mcn->medium_catalog_number[13] = 0;
	kfree(buffer);
	return result;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 103 | 60.23% | 2 | 18.18% | 
| Linus Torvalds (pre-git) | 37 | 21.64% | 7 | 63.64% | 
| Alan Cox | 30 | 17.54% | 1 | 9.09% | 
| Al Viro | 1 | 0.58% | 1 | 9.09% | 
| Total | 171 | 100.00% | 11 | 100.00% | 
int sr_reset(struct cdrom_device_info *cdi)
{
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 12 | 92.31% | 1 | 50.00% | 
| Linus Torvalds (pre-git) | 1 | 7.69% | 1 | 50.00% | 
| Total | 13 | 100.00% | 2 | 100.00% | 
int sr_select_speed(struct cdrom_device_info *cdi, int speed)
{
	Scsi_CD *cd = cdi->handle;
	struct packet_command cgc;
	if (speed == 0)
		speed = 0xffff;	/* set to max */
	else
		speed *= 177;	/* Nx to kbyte/s */
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.cmd[0] = GPCMD_SET_SPEED;	/* SET CD SPEED */
	cgc.cmd[2] = (speed >> 8) & 0xff;	/* MSB for speed (in kbytes/sec) */
	cgc.cmd[3] = speed & 0xff;	/* LSB */
	cgc.data_direction = DMA_NONE;
	cgc.timeout = IOCTL_TIMEOUT;
	if (sr_do_ioctl(cd, &cgc))
		return -EIO;
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 78 | 63.41% | 2 | 33.33% | 
| Linus Torvalds (pre-git) | 26 | 21.14% | 2 | 33.33% | 
| Alan Cox | 18 | 14.63% | 1 | 16.67% | 
| Al Viro | 1 | 0.81% | 1 | 16.67% | 
| Total | 123 | 100.00% | 6 | 100.00% | 
/* ----------------------------------------------------------------------- */
/* this is called by the generic cdrom driver. arg is a _kernel_ pointer,  */
/* because the generic cdrom driver does the user access stuff for us.     */
/* only cdromreadtochdr and cdromreadtocentry are left - for use with the  */
/* sr_disk_status interface for the generic cdrom driver.                  */
int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
{
	switch (cmd) {
	case CDROMREADTOCHDR:
		return sr_read_tochdr(cdi, arg);
	case CDROMREADTOCENTRY:
		return sr_read_tocentry(cdi, arg);
	case CDROMPLAYTRKIND:
		return sr_play_trkind(cdi, arg);
	default:
		return -EINVAL;
	}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 52 | 83.87% | 1 | 20.00% | 
| Linus Torvalds (pre-git) | 8 | 12.90% | 3 | 60.00% | 
| James Bottomley | 2 | 3.23% | 1 | 20.00% | 
| Total | 62 | 100.00% | 5 | 100.00% | 
/* -----------------------------------------------------------------------
 * a function to read all sorts of funny cdrom sectors using the READ_CD
 * scsi-3 mmc command
 *
 * lba:     linear block address
 * format:  0 = data (anything)
 *          1 = audio
 *          2 = data (mode 1)
 *          3 = data (mode 2)
 *          4 = data (mode 2 form1)
 *          5 = data (mode 2 form2)
 * blksize: 2048 | 2336 | 2340 | 2352
 */
static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int blksize)
{
	struct packet_command cgc;
#ifdef DEBUG
	sr_printk(KERN_INFO, cd, "sr_read_cd lba=%d format=%d blksize=%d\n",
		  lba, format, blksize);
#endif
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.cmd[0] = GPCMD_READ_CD;	/* READ_CD */
	cgc.cmd[1] = ((format & 7) << 2);
	cgc.cmd[2] = (unsigned char) (lba >> 24) & 0xff;
	cgc.cmd[3] = (unsigned char) (lba >> 16) & 0xff;
	cgc.cmd[4] = (unsigned char) (lba >> 8) & 0xff;
	cgc.cmd[5] = (unsigned char) lba & 0xff;
	cgc.cmd[8] = 1;
	switch (blksize) {
	case 2336:
		cgc.cmd[9] = 0x58;
		break;
	case 2340:
		cgc.cmd[9] = 0x78;
		break;
	case 2352:
		cgc.cmd[9] = 0xf8;
		break;
	default:
		cgc.cmd[9] = 0x10;
		break;
	}
	cgc.buffer = dest;
	cgc.buflen = blksize;
	cgc.data_direction = DMA_FROM_DEVICE;
	cgc.timeout = IOCTL_TIMEOUT;
	return sr_do_ioctl(cd, &cgc);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Linus Torvalds (pre-git) | 191 | 73.75% | 8 | 57.14% | 
| Alan Cox | 55 | 21.24% | 1 | 7.14% | 
| Al Viro | 8 | 3.09% | 3 | 21.43% | 
| Hannes Reinecke | 4 | 1.54% | 1 | 7.14% | 
| Christoph Hellwig | 1 | 0.39% | 1 | 7.14% | 
| Total | 259 | 100.00% | 14 | 100.00% | 
/*
 * read sectors with blocksizes other than 2048
 */
static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest)
{
	struct packet_command cgc;
	int rc;
	/* we try the READ CD command first... */
	if (cd->readcd_known) {
		rc = sr_read_cd(cd, dest, lba, 0, blksize);
		if (-EDRIVE_CANT_DO_THIS != rc)
			return rc;
		cd->readcd_known = 0;
		sr_printk(KERN_INFO, cd,
			  "CDROM does'nt support READ CD (0xbe) command\n");
		/* fall & retry the other way */
	}
	/* ... if this fails, we switch the blocksize using MODE SELECT */
	if (blksize != cd->device->sector_size) {
		if (0 != (rc = sr_set_blocklength(cd, blksize)))
			return rc;
	}
#ifdef DEBUG
	sr_printk(KERN_INFO, cd, "sr_read_sector lba=%d blksize=%d\n",
		  lba, blksize);
#endif
	memset(&cgc, 0, sizeof(struct packet_command));
	cgc.cmd[0] = GPCMD_READ_10;
	cgc.cmd[2] = (unsigned char) (lba >> 24) & 0xff;
	cgc.cmd[3] = (unsigned char) (lba >> 16) & 0xff;
	cgc.cmd[4] = (unsigned char) (lba >> 8) & 0xff;
	cgc.cmd[5] = (unsigned char) lba & 0xff;
	cgc.cmd[8] = 1;
	cgc.buffer = dest;
	cgc.buflen = blksize;
	cgc.data_direction = DMA_FROM_DEVICE;
	cgc.timeout = IOCTL_TIMEOUT;
	rc = sr_do_ioctl(cd, &cgc);
	return rc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Linus Torvalds (pre-git) | 197 | 73.51% | 8 | 53.33% | 
| Alan Cox | 45 | 16.79% | 1 | 6.67% | 
| Al Viro | 13 | 4.85% | 3 | 20.00% | 
| Hannes Reinecke | 9 | 3.36% | 1 | 6.67% | 
| Christoph Hellwig | 4 | 1.49% | 2 | 13.33% | 
| Total | 268 | 100.00% | 15 | 100.00% | 
/*
 * read a sector in raw mode to check the sector format
 * ret: 1 == mode2 (XA), 0 == mode1, <0 == error 
 */
int sr_is_xa(Scsi_CD *cd)
{
	unsigned char *raw_sector;
	int is_xa;
	if (!xa_test)
		return 0;
	raw_sector = kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd));
	if (!raw_sector)
		return -ENOMEM;
	if (0 == sr_read_sector(cd, cd->ms_offset + 16,
				CD_FRAMESIZE_RAW1, raw_sector)) {
		is_xa = (raw_sector[3] == 0x02) ? 1 : 0;
	} else {
		/* read a raw sector failed for some reason. */
		is_xa = -1;
	}
	kfree(raw_sector);
#ifdef DEBUG
	sr_printk(KERN_INFO, cd, "sr_is_xa: %d\n", is_xa);
#endif
	return is_xa;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Linus Torvalds (pre-git) | 97 | 82.91% | 4 | 40.00% | 
| Al Viro | 6 | 5.13% | 2 | 20.00% | 
| James Bottomley | 5 | 4.27% | 1 | 10.00% | 
| Linus Torvalds | 4 | 3.42% | 1 | 10.00% | 
| Hannes Reinecke | 4 | 3.42% | 1 | 10.00% | 
| Christoph Hellwig | 1 | 0.85% | 1 | 10.00% | 
| Total | 117 | 100.00% | 10 | 100.00% | 
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Christoph Hellwig | 1354 | 47.83% | 7 | 12.96% | 
| Linus Torvalds (pre-git) | 866 | 30.59% | 22 | 40.74% | 
| Alan Cox | 291 | 10.28% | 1 | 1.85% | 
| James Bottomley | 133 | 4.70% | 4 | 7.41% | 
| Al Viro | 51 | 1.80% | 4 | 7.41% | 
| Robert Jennings | 30 | 1.06% | 1 | 1.85% | 
| Peter Jones | 30 | 1.06% | 1 | 1.85% | 
| Hannes Reinecke | 27 | 0.95% | 1 | 1.85% | 
| Jan Dittmer | 11 | 0.39% | 1 | 1.85% | 
| Linus Torvalds | 11 | 0.39% | 3 | 5.56% | 
| Tejun Heo | 9 | 0.32% | 2 | 3.70% | 
| Andrew Morton | 6 | 0.21% | 1 | 1.85% | 
| Paul Gortmaker | 3 | 0.11% | 1 | 1.85% | 
| Richard Henderson | 3 | 0.11% | 1 | 1.85% | 
| Jeff Garzik | 3 | 0.11% | 1 | 1.85% | 
| FUJITA Tomonori | 1 | 0.04% | 1 | 1.85% | 
| Adrian Bunk | 1 | 0.04% | 1 | 1.85% | 
| Arjan van de Ven | 1 | 0.04% | 1 | 1.85% | 
| Total | 2831 | 100.00% | 54 | 100.00% | 
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.