Commit 4a17ca93 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sr template

	Ditto for sr.c
parent 1061e346
...@@ -177,6 +177,11 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot) ...@@ -177,6 +177,11 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot)
} }
return retval; return retval;
} }
static inline struct scsi_cd *scsi_cd(struct gendisk *disk)
{
return container_of(disk->private_data, struct scsi_cd, driver);
}
/* /*
* rw_intr is the interrupt routine for the device driver. * rw_intr is the interrupt routine for the device driver.
...@@ -190,7 +195,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt) ...@@ -190,7 +195,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt)
int this_count = SCpnt->bufflen >> 9; int this_count = SCpnt->bufflen >> 9;
int good_sectors = (result == 0 ? this_count : 0); int good_sectors = (result == 0 ? this_count : 0);
int block_sectors = 0; int block_sectors = 0;
struct scsi_cd *cd = SCpnt->request->rq_disk->private_data; struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
#ifdef DEBUG #ifdef DEBUG
printk("sr.c done: %x %p\n", result, SCpnt->request->bh->b_data); printk("sr.c done: %x %p\n", result, SCpnt->request->bh->b_data);
...@@ -243,7 +248,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt) ...@@ -243,7 +248,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt)
static int sr_init_command(struct scsi_cmnd * SCpnt) static int sr_init_command(struct scsi_cmnd * SCpnt)
{ {
int block=0, this_count, s_size, timeout = SR_TIMEOUT; int block=0, this_count, s_size, timeout = SR_TIMEOUT;
struct scsi_cd *cd = SCpnt->request->rq_disk->private_data; struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
SCSI_LOG_HLQUEUE(1, printk("Doing sr request, dev = %s, block = %d\n", SCSI_LOG_HLQUEUE(1, printk("Doing sr request, dev = %s, block = %d\n",
cd->disk->disk_name, block)); cd->disk->disk_name, block));
...@@ -395,26 +400,26 @@ static int sr_init_command(struct scsi_cmnd * SCpnt) ...@@ -395,26 +400,26 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
static int sr_block_open(struct inode *inode, struct file *file) static int sr_block_open(struct inode *inode, struct file *file)
{ {
struct scsi_cd *cd = inode->i_bdev->bd_disk->private_data; struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
return cdrom_open(&cd->cdi, inode, file); return cdrom_open(&cd->cdi, inode, file);
} }
static int sr_block_release(struct inode *inode, struct file *file) static int sr_block_release(struct inode *inode, struct file *file)
{ {
struct scsi_cd *cd = inode->i_bdev->bd_disk->private_data; struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
return cdrom_release(&cd->cdi, file); return cdrom_release(&cd->cdi, file);
} }
static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
unsigned long arg) unsigned long arg)
{ {
struct scsi_cd *cd = inode->i_bdev->bd_disk->private_data; struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
return cdrom_ioctl(&cd->cdi, inode, cmd, arg); return cdrom_ioctl(&cd->cdi, inode, cmd, arg);
} }
static int sr_block_media_changed(struct gendisk *disk) static int sr_block_media_changed(struct gendisk *disk)
{ {
struct scsi_cd *cd = disk->private_data; struct scsi_cd *cd = scsi_cd(disk);
return cdrom_media_changed(&cd->cdi); return cdrom_media_changed(&cd->cdi);
} }
...@@ -766,6 +771,7 @@ static int sr_init_one(struct scsi_cd *cd, int first_minor) ...@@ -766,6 +771,7 @@ static int sr_init_one(struct scsi_cd *cd, int first_minor)
strcpy(disk->disk_name, cd->cdi.name); strcpy(disk->disk_name, cd->cdi.name);
disk->fops = &sr_bdops; disk->fops = &sr_bdops;
disk->flags = GENHD_FL_CD; disk->flags = GENHD_FL_CD;
cd->driver = &sr_template;
cd->disk = disk; cd->disk = disk;
cd->capacity = 0x1fffff; cd->capacity = 0x1fffff;
cd->device->sector_size = 2048;/* A guess, just in case */ cd->device->sector_size = 2048;/* A guess, just in case */
...@@ -798,7 +804,7 @@ static int sr_init_one(struct scsi_cd *cd, int first_minor) ...@@ -798,7 +804,7 @@ static int sr_init_one(struct scsi_cd *cd, int first_minor)
disk->driverfs_dev = &cd->device->sdev_driverfs_dev; disk->driverfs_dev = &cd->device->sdev_driverfs_dev;
register_cdrom(&cd->cdi); register_cdrom(&cd->cdi);
set_capacity(disk, cd->capacity); set_capacity(disk, cd->capacity);
disk->private_data = cd; disk->private_data = &cd->driver;
disk->queue = &cd->device->request_queue; disk->queue = &cd->device->request_queue;
add_disk(disk); add_disk(disk);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define IOCTL_TIMEOUT 30*HZ #define IOCTL_TIMEOUT 30*HZ
typedef struct scsi_cd { typedef struct scsi_cd {
struct Scsi_Device_Template *driver;
unsigned capacity; /* size in blocks */ unsigned capacity; /* size in blocks */
Scsi_Device *device; Scsi_Device *device;
unsigned int vendor; /* vendor code, see sr_vendor.c */ unsigned int vendor; /* vendor code, see sr_vendor.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment