Commit 2988ef57 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cdrom helpers

	cdrom_open(), cdrom_release(), cdrom_ioctl() and cdrom_media_changed()
got an additional argument - struct cdrom_device_info *.  Drivers that used
to have them as methods are using wrappers that pass right cdrom_device_info.
Existing callers (in ide-cd.c) updated.  pcd.c, mcdx.c, sbpcd.c and sr.c
got ->private_data in their disks pointing to relevant objects.  Since all
callers of cdrom_find_device() are gone, it got removed.  Since all users
of cdrom_device_info->dev are gone, it's not set anymore (and got removed).
parent 6b388653
...@@ -249,12 +249,37 @@ static int pcd_warned; /* Have we logged a phase warning ? */ ...@@ -249,12 +249,37 @@ static int pcd_warned; /* Have we logged a phase warning ? */
/* kernel glue structures */ /* kernel glue structures */
static int pcd_block_open(struct inode *inode, struct file *file)
{
struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_open(&cd->info, inode, file);
}
static int pcd_block_release(struct inode *inode, struct file *file)
{
struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_release(&cd->info, file);
}
static int pcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(&cd->info, inode, cmd, arg);
}
static int pcd_block_media_changed(struct gendisk *disk)
{
struct pcd_unit *cd = disk->private_data;
return cdrom_media_changed(&cd->info);
}
static struct block_device_operations pcd_bdops = { static struct block_device_operations pcd_bdops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = cdrom_open, .open = pcd_block_open,
.release = cdrom_release, .release = pcd_block_release,
.ioctl = cdrom_ioctl, .ioctl = pcd_block_ioctl,
.check_media_change = cdrom_media_changed, .media_changed = pcd_block_media_changed,
}; };
static struct cdrom_device_ops pcd_dops = { static struct cdrom_device_ops pcd_dops = {
...@@ -297,7 +322,6 @@ static void pcd_init_units(void) ...@@ -297,7 +322,6 @@ static void pcd_init_units(void)
snprintf(cd->name, sizeof(cd->info.name), "%s%d", name, unit); snprintf(cd->name, sizeof(cd->info.name), "%s%d", name, unit);
cd->info.ops = &pcd_dops; cd->info.ops = &pcd_dops;
cd->info.handle = cd; cd->info.handle = cd;
cd->info.dev = mk_kdev(major, unit);
cd->info.speed = 0; cd->info.speed = 0;
cd->info.capacity = 1; cd->info.capacity = 1;
cd->info.mask = 0; cd->info.mask = 0;
...@@ -937,6 +961,7 @@ static int __init pcd_init(void) ...@@ -937,6 +961,7 @@ static int __init pcd_init(void)
for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) { for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {
if (cd->present) { if (cd->present) {
register_cdrom(&cd->info); register_cdrom(&cd->info);
cd->disk->private_data = cd;
add_disk(cd->disk); add_disk(cd->disk);
} }
} }
......
...@@ -338,14 +338,11 @@ static struct cdrom_device_info *topCdromPtr; ...@@ -338,14 +338,11 @@ static struct cdrom_device_info *topCdromPtr;
int register_cdrom(struct cdrom_device_info *cdi) int register_cdrom(struct cdrom_device_info *cdi)
{ {
static char banner_printed; static char banner_printed;
int major = major(cdi->dev);
struct cdrom_device_ops *cdo = cdi->ops; struct cdrom_device_ops *cdo = cdi->ops;
int *change_capability = (int *)&cdo->capability; /* hack */ int *change_capability = (int *)&cdo->capability; /* hack */
cdinfo(CD_OPEN, "entering register_cdrom\n"); cdinfo(CD_OPEN, "entering register_cdrom\n");
if (major < 0 || major >= MAX_BLKDEV)
return -1;
if (cdo->open == NULL || cdo->release == NULL) if (cdo->open == NULL || cdo->release == NULL)
return -2; return -2;
if ( !banner_printed ) { if ( !banner_printed ) {
...@@ -389,16 +386,11 @@ int register_cdrom(struct cdrom_device_info *cdi) ...@@ -389,16 +386,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
int unregister_cdrom(struct cdrom_device_info *unreg) int unregister_cdrom(struct cdrom_device_info *unreg)
{ {
struct cdrom_device_info *cdi, *prev; struct cdrom_device_info *cdi, *prev;
int major = major(unreg->dev);
cdinfo(CD_OPEN, "entering unregister_cdrom\n"); cdinfo(CD_OPEN, "entering unregister_cdrom\n");
if (major < 0 || major >= MAX_BLKDEV)
return -1;
prev = NULL; prev = NULL;
cdi = topCdromPtr; cdi = topCdromPtr;
while (cdi != NULL && !kdev_same(cdi->dev, unreg->dev)) { while (cdi && cdi != unreg) {
prev = cdi; prev = cdi;
cdi = cdi->next; cdi = cdi->next;
} }
...@@ -414,17 +406,6 @@ int unregister_cdrom(struct cdrom_device_info *unreg) ...@@ -414,17 +406,6 @@ int unregister_cdrom(struct cdrom_device_info *unreg)
return 0; return 0;
} }
static struct cdrom_device_info *cdrom_find_device(kdev_t dev)
{
struct cdrom_device_info *cdi;
cdi = topCdromPtr;
while (cdi != NULL && !kdev_same(cdi->dev, dev))
cdi = cdi->next;
return cdi;
}
/* We use the open-option O_NONBLOCK to indicate that the /* We use the open-option O_NONBLOCK to indicate that the
* purpose of opening is only for subsequent ioctl() calls; no device * purpose of opening is only for subsequent ioctl() calls; no device
* integrity checks are performed. * integrity checks are performed.
...@@ -433,16 +414,11 @@ static struct cdrom_device_info *cdrom_find_device(kdev_t dev) ...@@ -433,16 +414,11 @@ static struct cdrom_device_info *cdrom_find_device(kdev_t dev)
* is in their own interest: device control becomes a lot easier * is in their own interest: device control becomes a lot easier
* this way. * this way.
*/ */
int cdrom_open(struct inode *ip, struct file *fp) int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
{ {
struct cdrom_device_info *cdi;
kdev_t dev = ip->i_rdev;
int ret; int ret;
cdinfo(CD_OPEN, "entering cdrom_open\n"); cdinfo(CD_OPEN, "entering cdrom_open\n");
if ((cdi = cdrom_find_device(dev)) == NULL)
return -ENODEV;
/* if this was a O_NONBLOCK open and we should honor the flags, /* if this was a O_NONBLOCK open and we should honor the flags,
* do a quick open without drive/disc integrity checks. */ * do a quick open without drive/disc integrity checks. */
if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS)) if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
...@@ -627,10 +603,8 @@ int check_for_audio_disc(struct cdrom_device_info * cdi, ...@@ -627,10 +603,8 @@ int check_for_audio_disc(struct cdrom_device_info * cdi,
/* Admittedly, the logic below could be performed in a nicer way. */ /* Admittedly, the logic below could be performed in a nicer way. */
int cdrom_release(struct inode *ip, struct file *fp) int cdrom_release(struct cdrom_device_info *cdi, struct file *fp)
{ {
kdev_t dev = ip->i_rdev;
struct cdrom_device_info *cdi = cdrom_find_device(dev);
struct cdrom_device_ops *cdo = cdi->ops; struct cdrom_device_ops *cdo = cdi->ops;
int opened_for_data; int opened_for_data;
...@@ -843,9 +817,8 @@ int media_changed(struct cdrom_device_info *cdi, int queue) ...@@ -843,9 +817,8 @@ int media_changed(struct cdrom_device_info *cdi, int queue)
return ret; return ret;
} }
int cdrom_media_changed(kdev_t dev) int cdrom_media_changed(struct cdrom_device_info *cdi)
{ {
struct cdrom_device_info *cdi = cdrom_find_device(dev);
/* This talks to the VFS, which doesn't like errors - just 1 or 0. /* This talks to the VFS, which doesn't like errors - just 1 or 0.
* Returning "0" is always safe (media hasn't been changed). Do that * Returning "0" is always safe (media hasn't been changed). Do that
* if the low-level cdrom driver dosn't support media changed. */ * if the low-level cdrom driver dosn't support media changed. */
...@@ -1457,11 +1430,9 @@ static int cdrom_read_block(struct cdrom_device_info *cdi, ...@@ -1457,11 +1430,9 @@ static int cdrom_read_block(struct cdrom_device_info *cdi,
* these days. ATAPI / SCSI specific code now mainly resides in * these days. ATAPI / SCSI specific code now mainly resides in
* mmc_ioct(). * mmc_ioct().
*/ */
int cdrom_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
kdev_t dev = ip->i_rdev;
struct cdrom_device_info *cdi = cdrom_find_device(dev);
struct cdrom_device_ops *cdo = cdi->ops; struct cdrom_device_ops *cdo = cdi->ops;
int ret; int ret;
...@@ -1614,7 +1585,7 @@ int cdrom_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1614,7 +1585,7 @@ int cdrom_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n"); cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
if (!CDROM_CAN(CDC_RESET)) if (!CDROM_CAN(CDC_RESET))
return -ENOSYS; return -ENOSYS;
invalidate_buffers(dev); invalidate_bdev(ip->i_bdev, 0);
return cdo->reset(cdi); return cdo->reset(cdi);
} }
......
...@@ -3151,15 +3151,6 @@ static void scd_release(struct cdrom_device_info *cdi) ...@@ -3151,15 +3151,6 @@ static void scd_release(struct cdrom_device_info *cdi)
sony_usage--; sony_usage--;
} }
struct block_device_operations scd_bdops =
{
.owner = THIS_MODULE,
.open = cdrom_open,
.release = cdrom_release,
.ioctl = cdrom_ioctl,
.check_media_change = cdrom_media_changed,
};
static struct cdrom_device_ops scd_dops = { static struct cdrom_device_ops scd_dops = {
.open = scd_open, .open = scd_open,
.release = scd_release, .release = scd_release,
...@@ -3188,6 +3179,36 @@ static struct cdrom_device_info scd_info = { ...@@ -3188,6 +3179,36 @@ static struct cdrom_device_info scd_info = {
.name = "cdu31a" .name = "cdu31a"
}; };
static int scd_block_open(struct inode *inode, struct file *file)
{
return cdrom_open(&scd_info, inode, file);
}
static int scd_block_release(struct inode *inode, struct file *file)
{
return cdrom_release(&scd_info, file);
}
static int scd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
return cdrom_ioctl(&scd_info, inode, cmd, arg);
}
static int scd_block_media_changed(struct gendisk *disk)
{
return cdrom_media_changed(&scd_info);
}
struct block_device_operations scd_bdops =
{
.owner = THIS_MODULE,
.open = scd_block_open,
.release = scd_block_release,
.ioctl = scd_block_ioctl,
.media_changed = scd_block_media_changed,
};
static struct gendisk *scd_gendisk; static struct gendisk *scd_gendisk;
/* The different types of disc loading mechanisms supported */ /* The different types of disc loading mechanisms supported */
...@@ -3437,7 +3458,6 @@ int __init cdu31a_init(void) ...@@ -3437,7 +3458,6 @@ int __init cdu31a_init(void)
init_timer(&cdu31a_abort_timer); init_timer(&cdu31a_abort_timer);
cdu31a_abort_timer.function = handle_abort_timeout; cdu31a_abort_timer.function = handle_abort_timeout;
scd_info.dev = mk_kdev(MAJOR_NR, 0);
scd_info.mask = deficiency; scd_info.mask = deficiency;
scd_gendisk = disk; scd_gendisk = disk;
if (register_cdrom(&scd_info)) if (register_cdrom(&scd_info))
......
...@@ -770,15 +770,6 @@ void get_disc_status(void) ...@@ -770,15 +770,6 @@ void get_disc_status(void)
} }
} }
struct block_device_operations cm206_bdops =
{
.owner = THIS_MODULE,
.open = cdrom_open,
.release = cdrom_release,
.ioctl = cdrom_ioctl,
.check_media_change = cdrom_media_changed,
};
/* The new open. The real opening strategy is defined in cdrom.c. */ /* The new open. The real opening strategy is defined in cdrom.c. */
static int cm206_open(struct cdrom_device_info *cdi, int purpose) static int cm206_open(struct cdrom_device_info *cdi, int purpose)
...@@ -1357,6 +1348,36 @@ static struct cdrom_device_info cm206_info = { ...@@ -1357,6 +1348,36 @@ static struct cdrom_device_info cm206_info = {
.name = "cm206", .name = "cm206",
}; };
static int cm206_block_open(struct inode *inode, struct file *file)
{
return cdrom_open(&cm206_info, inode, file);
}
static int cm206_block_release(struct inode *inode, struct file *file)
{
return cdrom_release(&cm206_info, file);
}
static int cm206_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
return cdrom_ioctl(&cm206_info, inode, cmd, arg);
}
static int cm206_block_media_changed(struct gendisk *disk)
{
return cdrom_media_changed(&cm206_info);
}
static struct block_device_operations cm206_bdops =
{
.owner = THIS_MODULE,
.open = cm206_block_open,
.release = cm206_block_release,
.ioctl = cm206_block_ioctl,
.media_changed = cm206_block_media_changed,
};
static struct gendisk *cm206_gendisk; static struct gendisk *cm206_gendisk;
/* This function probes for the adapter card. It returns the base /* This function probes for the adapter card. It returns the base
...@@ -1479,7 +1500,6 @@ int __init cm206_init(void) ...@@ -1479,7 +1500,6 @@ int __init cm206_init(void)
disk->fops = &cm206_bdops; disk->fops = &cm206_bdops;
disk->flags = GENHD_FL_CD; disk->flags = GENHD_FL_CD;
cm206_gendisk = disk; cm206_gendisk = disk;
cm206_info.dev = mk_kdev(MAJOR_NR, 0);
if (register_cdrom(&cm206_info) != 0) { if (register_cdrom(&cm206_info) != 0) {
printk(KERN_INFO "Cannot register for cdrom %d!\n", MAJOR_NR); printk(KERN_INFO "Cannot register for cdrom %d!\n", MAJOR_NR);
goto out_cdrom; goto out_cdrom;
......
...@@ -192,15 +192,6 @@ int mcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, ...@@ -192,15 +192,6 @@ int mcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
void *arg); void *arg);
int mcd_drive_status(struct cdrom_device_info *cdi, int slot_nr); int mcd_drive_status(struct cdrom_device_info *cdi, int slot_nr);
struct block_device_operations mcd_bdops =
{
.owner = THIS_MODULE,
.open = cdrom_open,
.release = cdrom_release,
.ioctl = cdrom_ioctl,
.check_media_change = cdrom_media_changed,
};
static struct timer_list mcd_timer; static struct timer_list mcd_timer;
static struct cdrom_device_ops mcd_dops = { static struct cdrom_device_ops mcd_dops = {
...@@ -221,6 +212,36 @@ static struct cdrom_device_info mcd_info = { ...@@ -221,6 +212,36 @@ static struct cdrom_device_info mcd_info = {
.name = "mcd", .name = "mcd",
}; };
static int mcd_block_open(struct inode *inode, struct file *file)
{
return cdrom_open(&mcd_info, inode, file);
}
static int mcd_block_release(struct inode *inode, struct file *file)
{
return cdrom_release(&mcd_info, file);
}
static int mcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
return cdrom_ioctl(&mcd_info, inode, cmd, arg);
}
static int mcd_block_media_changed(struct gendisk *disk)
{
return cdrom_media_changed(&mcd_info);
}
static struct block_device_operations mcd_bdops =
{
.owner = THIS_MODULE,
.open = mcd_block_open,
.release = mcd_block_release,
.ioctl = mcd_block_ioctl,
.media_changed = mcd_block_media_changed,
};
static struct gendisk *mcd_gendisk; static struct gendisk *mcd_gendisk;
#ifndef MODULE #ifndef MODULE
...@@ -1128,7 +1149,6 @@ int __init mcd_init(void) ...@@ -1128,7 +1149,6 @@ int __init mcd_init(void)
disk->fops = &mcd_bdops; disk->fops = &mcd_bdops;
disk->flags = GENHD_FL_CD; disk->flags = GENHD_FL_CD;
mcd_gendisk = disk; mcd_gendisk = disk;
mcd_info.dev = mk_kdev(MAJOR_NR, 0);
if (register_cdrom(&mcd_info) != 0) { if (register_cdrom(&mcd_info) != 0) {
printk(KERN_ERR "mcd: Unable to register Mitsumi CD-ROM.\n"); printk(KERN_ERR "mcd: Unable to register Mitsumi CD-ROM.\n");
......
...@@ -220,13 +220,38 @@ struct s_drive_stuff { ...@@ -220,13 +220,38 @@ struct s_drive_stuff {
int mcdx_init(void); int mcdx_init(void);
void do_mcdx_request(request_queue_t * q); void do_mcdx_request(request_queue_t * q);
struct block_device_operations mcdx_bdops = static int mcdx_block_open(struct inode *inode, struct file *file)
{ {
owner: THIS_MODULE, struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
open: cdrom_open, return cdrom_open(&p->info, inode, file);
release: cdrom_release, }
ioctl: cdrom_ioctl,
check_media_change: cdrom_media_changed, static int mcdx_block_release(struct inode *inode, struct file *file)
{
struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
return cdrom_release(&p->info, file);
}
static int mcdx_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(&p->info, inode, cmd, arg);
}
static int mcdx_block_media_changed(struct gendisk *disk)
{
struct s_drive_stuff *p = disk->private_data;
return cdrom_media_changed(&p->info);
}
static struct block_device_operations mcdx_bdops =
{
.owner = THIS_MODULE,
.open = mcdx_block_open,
.release = mcdx_block_release,
.ioctl = mcdx_block_ioctl,
.media_changed = mcdx_block_media_changed,
}; };
...@@ -1218,7 +1243,6 @@ int __init mcdx_init_drive(int drive) ...@@ -1218,7 +1243,6 @@ int __init mcdx_init_drive(int drive)
stuffp->info.capacity = 1; stuffp->info.capacity = 1;
stuffp->info.handle = stuffp; stuffp->info.handle = stuffp;
sprintf(stuffp->info.name, "mcdx%d", drive); sprintf(stuffp->info.name, "mcdx%d", drive);
stuffp->info.dev = mk_kdev(MAJOR_NR, drive);
disk->major = MAJOR_NR; disk->major = MAJOR_NR;
disk->first_minor = drive; disk->first_minor = drive;
strcpy(disk->disk_name, stuffp->info.name); strcpy(disk->disk_name, stuffp->info.name);
...@@ -1243,6 +1267,7 @@ int __init mcdx_init_drive(int drive) ...@@ -1243,6 +1267,7 @@ int __init mcdx_init_drive(int drive)
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
return 2; return 2;
} }
disk->private_data = stuffp;
add_disk(disk); add_disk(disk);
printk(msg); printk(msg);
return 0; return 0;
......
...@@ -5351,13 +5351,38 @@ static int sbp_data(struct request *req) ...@@ -5351,13 +5351,38 @@ static int sbp_data(struct request *req)
} }
/*==========================================================================*/ /*==========================================================================*/
static int sbpcd_block_open(struct inode *inode, struct file *file)
{
struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
return cdrom_open(p->sbpcd_infop, inode, file);
}
static int sbpcd_block_release(struct inode *inode, struct file *file)
{
struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
return cdrom_release(p->sbpcd_infop, file);
}
static int sbpcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(p->sbpcd_infop, inode, cmd, arg);
}
static int sbpcd_block_media_changed(struct gendisk *disk)
{
struct sbpcd_drive *p = disk->private_data;
return cdrom_media_changed(p->sbpcd_infop);
}
static struct block_device_operations sbpcd_bdops = static struct block_device_operations sbpcd_bdops =
{ {
owner: THIS_MODULE, .owner = THIS_MODULE,
open: cdrom_open, .open = sbpcd_block_open,
release: cdrom_release, .release = sbpcd_block_release,
ioctl: cdrom_ioctl, .ioctl = sbpcd_block_ioctl,
check_media_change: cdrom_media_changed, .media_changed = sbpcd_block_media_changed,
}; };
/*==========================================================================*/ /*==========================================================================*/
/* /*
...@@ -5828,7 +5853,6 @@ int __init sbpcd_init(void) ...@@ -5828,7 +5853,6 @@ int __init sbpcd_init(void)
sbpcd_infop->speed = 2; sbpcd_infop->speed = 2;
sbpcd_infop->capacity = 1; sbpcd_infop->capacity = 1;
sprintf(sbpcd_infop->name, "sbpcd%d", j); sprintf(sbpcd_infop->name, "sbpcd%d", j);
sbpcd_infop->dev = mk_kdev(MAJOR_NR, j);
sbpcd_infop->handle = p; sbpcd_infop->handle = p;
p->sbpcd_infop = sbpcd_infop; p->sbpcd_infop = sbpcd_infop;
disk = alloc_disk(1); disk = alloc_disk(1);
...@@ -5844,6 +5868,7 @@ int __init sbpcd_init(void) ...@@ -5844,6 +5868,7 @@ int __init sbpcd_init(void)
{ {
printk(" sbpcd: Unable to register with Uniform CD-ROm driver\n"); printk(" sbpcd: Unable to register with Uniform CD-ROm driver\n");
} }
disk->private_data = p;
add_disk(disk); add_disk(disk);
} }
blk_queue_hardsect_size(BLK_DEFAULT_QUEUE(MAJOR_NR), CD_FRAMESIZE); blk_queue_hardsect_size(BLK_DEFAULT_QUEUE(MAJOR_NR), CD_FRAMESIZE);
...@@ -5874,7 +5899,6 @@ void sbpcd_exit(void) ...@@ -5874,7 +5899,6 @@ void sbpcd_exit(void)
put_disk(D_S[j].disk); put_disk(D_S[j].disk);
vfree(D_S[j].sbp_buf); vfree(D_S[j].sbp_buf);
if (D_S[j].sbp_audsiz>0) vfree(D_S[j].aud_buf); if (D_S[j].sbp_audsiz>0) vfree(D_S[j].aud_buf);
devfs_unregister(D_S[j].disk.de);
if ((unregister_cdrom(D_S[j].sbpcd_infop) == -EINVAL)) if ((unregister_cdrom(D_S[j].sbpcd_infop) == -EINVAL))
{ {
msg(DBG_INF, "What's that: can't unregister info %s.\n", major_name); msg(DBG_INF, "What's that: can't unregister info %s.\n", major_name);
......
...@@ -1585,7 +1585,7 @@ static int __init sony535_init(void) ...@@ -1585,7 +1585,7 @@ static int __init sony535_init(void)
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_cdu535_request, blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_cdu535_request,
&sonycd535_lock); &sonycd535_lock);
blk_queue_hardsect_size(BLK_DEFAULT_QUEUE(MAJOR_NR), CDU535_BLOCK_SIZE); blk_queue_hardsect_size(BLK_DEFAULT_QUEUE(MAJOR_NR), CDU535_BLOCK_SIZE);
sony_toc = kamlloc(sizeof(struct s535_sony_toc), GFP_KERNEL); sony_toc = kmalloc(sizeof(struct s535_sony_toc), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (!sony_toc) if (!sony_toc)
goto out2; goto out2;
......
...@@ -2647,7 +2647,6 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) ...@@ -2647,7 +2647,6 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo; struct cdrom_device_info *devinfo = &info->devinfo;
devinfo->dev = mk_kdev(drive->disk->major, drive->disk->first_minor);
devinfo->ops = &ide_cdrom_dops; devinfo->ops = &ide_cdrom_dops;
devinfo->mask = 0; devinfo->mask = 0;
devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed; devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed;
...@@ -3026,6 +3025,7 @@ int ide_cdrom_ioctl (ide_drive_t *drive, ...@@ -3026,6 +3025,7 @@ int ide_cdrom_ioctl (ide_drive_t *drive,
struct inode *inode, struct file *file, struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct cdrom_info *info = drive->driver_data;
int error; int error;
/* Try the generic SCSI command ioctl's first.. */ /* Try the generic SCSI command ioctl's first.. */
...@@ -3034,7 +3034,7 @@ int ide_cdrom_ioctl (ide_drive_t *drive, ...@@ -3034,7 +3034,7 @@ int ide_cdrom_ioctl (ide_drive_t *drive,
return error; return error;
/* Then the generic cdrom ioctl's.. */ /* Then the generic cdrom ioctl's.. */
return cdrom_ioctl(inode, file, cmd, arg); return cdrom_ioctl(&info->devinfo, inode, cmd, arg);
} }
static static
...@@ -3044,9 +3044,9 @@ int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive) ...@@ -3044,9 +3044,9 @@ int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive)
int rc = -ENOMEM; int rc = -ENOMEM;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if (info->buffer == NULL) if (!info->buffer)
info->buffer = (char *) kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL); info->buffer = (char *) kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL);
if ((info->buffer == NULL) || (rc = cdrom_open(ip, fp))) { if (!info->buffer || (rc = cdrom_open(&info->devinfo, ip, fp))) {
drive->usage--; drive->usage--;
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
} }
...@@ -3057,15 +3057,16 @@ static ...@@ -3057,15 +3057,16 @@ static
void ide_cdrom_release (struct inode *inode, struct file *file, void ide_cdrom_release (struct inode *inode, struct file *file,
ide_drive_t *drive) ide_drive_t *drive)
{ {
cdrom_release (inode, file); struct cdrom_info *info = drive->driver_data;
cdrom_release (&info->devinfo, file);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
} }
static static
int ide_cdrom_check_media_change (ide_drive_t *drive) int ide_cdrom_check_media_change (ide_drive_t *drive)
{ {
return cdrom_media_changed(mk_kdev(drive->disk->major, struct cdrom_info *info = drive->driver_data;
drive->disk->first_minor)); return cdrom_media_changed(&info->devinfo);
} }
static static
......
...@@ -386,13 +386,38 @@ static int sr_init_command(Scsi_Cmnd * SCpnt) ...@@ -386,13 +386,38 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
return 1; return 1;
} }
static int sr_block_open(struct inode *inode, struct file *file)
{
Scsi_CD *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_open(&cd->cdi, inode, file);
}
static int sr_block_release(struct inode *inode, struct file *file)
{
Scsi_CD *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_release(&cd->cdi, file);
}
static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
unsigned long arg)
{
Scsi_CD *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(&cd->cdi, inode, cmd, arg);
}
static int sr_block_media_changed(struct gendisk *disk)
{
Scsi_CD *cd = disk->private_data;
return cdrom_media_changed(&cd->cdi);
}
struct block_device_operations sr_bdops = struct block_device_operations sr_bdops =
{ {
owner: THIS_MODULE, .owner = THIS_MODULE,
open: cdrom_open, .open = sr_block_open,
release: cdrom_release, .release = sr_block_release,
ioctl: cdrom_ioctl, .ioctl = sr_block_ioctl,
check_media_change: cdrom_media_changed, .media_changed = sr_block_media_changed,
}; };
static int sr_open(struct cdrom_device_info *cdi, int purpose) static int sr_open(struct cdrom_device_info *cdi, int purpose)
...@@ -757,7 +782,6 @@ void sr_finish() ...@@ -757,7 +782,6 @@ void sr_finish()
cd->cdi.ops = &sr_dops; cd->cdi.ops = &sr_dops;
cd->cdi.handle = cd; cd->cdi.handle = cd;
cd->cdi.dev = mk_kdev(MAJOR_NR, i);
cd->cdi.mask = 0; cd->cdi.mask = 0;
cd->cdi.capacity = 1; cd->cdi.capacity = 1;
/* /*
...@@ -770,6 +794,7 @@ void sr_finish() ...@@ -770,6 +794,7 @@ void sr_finish()
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;
add_disk(disk); add_disk(disk);
} }
} }
......
...@@ -731,7 +731,6 @@ struct cdrom_device_info { ...@@ -731,7 +731,6 @@ struct cdrom_device_info {
struct cdrom_device_info *next; /* next device_info for this major */ struct cdrom_device_info *next; /* next device_info for this major */
void *handle; /* driver-dependent data */ void *handle; /* driver-dependent data */
/* specifications */ /* specifications */
kdev_t dev; /* device number */
int mask; /* mask of capability: disables them */ int mask; /* mask of capability: disables them */
int speed; /* maximum speed for reading data */ int speed; /* maximum speed for reading data */
int capacity; /* number of discs in jukebox */ int capacity; /* number of discs in jukebox */
...@@ -776,10 +775,10 @@ struct cdrom_device_ops { ...@@ -776,10 +775,10 @@ struct cdrom_device_ops {
}; };
/* the general block_device operations structure: */ /* the general block_device operations structure: */
extern int cdrom_open(struct inode *, struct file *); extern int cdrom_open(struct cdrom_device_info *, struct inode *, struct file *);
extern int cdrom_release(struct inode *, struct file *); extern int cdrom_release(struct cdrom_device_info *, struct file *);
extern int cdrom_ioctl(struct inode *, struct file *, unsigned, unsigned long); extern int cdrom_ioctl(struct cdrom_device_info *, struct inode *, unsigned, unsigned long);
extern int cdrom_media_changed(kdev_t); extern int cdrom_media_changed(struct cdrom_device_info *);
extern int register_cdrom(struct cdrom_device_info *cdi); extern int register_cdrom(struct cdrom_device_info *cdi);
extern int unregister_cdrom(struct cdrom_device_info *cdi); extern int unregister_cdrom(struct cdrom_device_info *cdi);
......
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