aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@trik.(none)>2005-04-02 19:49:01 +0200
committerBartlomiej Zolnierkiewicz <bzolnier@trik.(none)>2005-04-02 19:49:01 +0200
commitdbb3dc01862b4121a09a4624d820bbe2e1cc24a0 (patch)
tree5bdc8bf3b3ec41649a2aba38989dcff42c188aeb
parent4de9793a90e10d132275915066194a6bc20895bb (diff)
downloadhistory-dbb3dc01862b4121a09a4624d820bbe2e1cc24a0.tar.gz
[ide] kill ide_drive_t->disk
* move ->disk from ide_drive_t to driver specific objects * make drivers allocate struct gendisk and setup rq->rq_disk (there is no need to do this for REQ_DRIVE_TASKFILE requests) * add ide_init_disk() helper and kill alloc_disks() in ide-probe.c * kill no longer needed ide_open() and ide_fops[] in ide.c ide_init_disk() fixed by Andrew Morton <akpm@osdl.org>. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-cd.c60
-rw-r--r--drivers/ide/ide-cd.h1
-rw-r--r--drivers/ide/ide-disk.c22
-rw-r--r--drivers/ide/ide-floppy.c40
-rw-r--r--drivers/ide/ide-io.c2
-rw-r--r--drivers/ide/ide-probe.c52
-rw-r--r--drivers/ide/ide-tape.c31
-rw-r--r--drivers/ide/ide.c17
-rw-r--r--drivers/scsi/ide-scsi.c23
-rw-r--r--include/linux/ide.h3
10 files changed, 143 insertions, 108 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index dfa50ef0ad29b3..df13295189014d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -556,10 +556,13 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
/*
* Initialize a ide-cd packet command request
*/
-static void cdrom_prepare_request(struct request *rq)
+static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq)
{
+ struct cdrom_info *cd = drive->driver_data;
+
ide_init_drive_cmd(rq);
rq->flags = REQ_PC;
+ rq->rq_disk = cd->disk;
}
static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
@@ -572,7 +575,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
sense = &info->sense_data;
/* stuff the sense request in front of our current request */
- cdrom_prepare_request(rq);
+ cdrom_prepare_request(drive, rq);
rq->data = sense;
rq->cmd[0] = GPCMD_REQUEST_SENSE;
@@ -1856,7 +1859,7 @@ static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive)
static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
{
struct cdrom_info *info = drive->driver_data;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = info->disk;
unsigned short sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS;
/*
@@ -2048,7 +2051,7 @@ static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *cdi = &info->devinfo;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = sense;
req.cmd[0] = GPCMD_TEST_UNIT_READY;
@@ -2080,7 +2083,7 @@ cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense)
if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) {
stat = 0;
} else {
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = sense;
req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
req.cmd[4] = lockflag ? 1 : 0;
@@ -2124,7 +2127,7 @@ static int cdrom_eject(ide_drive_t *drive, int ejectflag,
if (CDROM_STATE_FLAGS(drive)->door_locked && ejectflag)
return 0;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
/* only tell drive to close tray if open, if it can do that */
if (ejectflag && !CDROM_CONFIG_FLAGS(drive)->close_tray)
@@ -2148,7 +2151,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
int stat;
struct request req;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = sense;
req.cmd[0] = GPCMD_READ_CDVD_CAPACITY;
@@ -2171,7 +2174,7 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
{
struct request req;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = sense;
req.data = buf;
@@ -2228,7 +2231,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
if (stat)
toc->capacity = 0x1fffff;
- set_capacity(drive->disk, toc->capacity * sectors_per_frame);
+ set_capacity(info->disk, toc->capacity * sectors_per_frame);
blk_queue_hardsect_size(drive->queue,
sectors_per_frame << SECTOR_BITS);
@@ -2348,7 +2351,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
stat = cdrom_get_last_written(cdi, &last_written);
if (!stat && (last_written > toc->capacity)) {
toc->capacity = last_written;
- set_capacity(drive->disk, toc->capacity * sectors_per_frame);
+ set_capacity(info->disk, toc->capacity * sectors_per_frame);
}
/* Remember that we've read this stuff. */
@@ -2363,7 +2366,7 @@ static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
{
struct request req;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = sense;
req.data = buf;
@@ -2383,7 +2386,7 @@ static int cdrom_select_speed(ide_drive_t *drive, int speed,
struct request_sense *sense)
{
struct request req;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = sense;
if (speed == 0)
@@ -2413,7 +2416,7 @@ static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end)
struct request_sense sense;
struct request req;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.sense = &sense;
req.cmd[0] = GPCMD_PLAY_AUDIO_MSF;
@@ -2463,7 +2466,7 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
/* here we queue the commands from the uniform CD-ROM
layer. the packet must be complete, as we do not
touch it at all. */
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE);
if (cgc->sense)
memset(cgc->sense, 0, sizeof(struct request_sense));
@@ -2613,7 +2616,7 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi)
struct request req;
int ret;
- cdrom_prepare_request(&req);
+ cdrom_prepare_request(drive, &req);
req.flags = REQ_SPECIAL | REQ_QUIET;
ret = ide_do_drive_cmd(drive, &req, ide_wait);
@@ -2857,7 +2860,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
if (!CDROM_CONFIG_FLAGS(drive)->mo_drive)
devinfo->mask |= CDC_MO_DRIVE;
- devinfo->disk = drive->disk;
+ devinfo->disk = info->disk;
return register_cdrom(devinfo);
}
@@ -3262,7 +3265,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive)
return 1;
}
- del_gendisk(drive->disk);
+ del_gendisk(info->disk);
ide_cd_put(info);
@@ -3274,7 +3277,7 @@ static void ide_cd_release(struct kref *kref)
struct cdrom_info *info = to_ide_cd(kref);
struct cdrom_device_info *devinfo = &info->devinfo;
ide_drive_t *drive = info->drive;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = info->disk;
if (info->buffer != NULL)
kfree(info->buffer);
@@ -3289,7 +3292,7 @@ static void ide_cd_release(struct kref *kref)
drive->driver_data = NULL;
blk_queue_prep_rq(drive->queue, NULL);
g->private_data = NULL;
- g->fops = ide_fops;
+ put_disk(g);
kfree(info);
}
@@ -3417,7 +3420,7 @@ MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static int ide_cdrom_attach (ide_drive_t *drive)
{
struct cdrom_info *info;
- struct gendisk *g = drive->disk;
+ struct gendisk *g;
struct request_sense sense;
if (!strstr("ide-cdrom", drive->driver_req))
@@ -3442,17 +3445,25 @@ static int ide_cdrom_attach (ide_drive_t *drive)
printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
goto failed;
}
+
+ g = alloc_disk(1 << PARTN_BITS);
+ if (!g)
+ goto out_free_cd;
+
+ ide_init_disk(g, drive);
+
if (ide_register_subdriver(drive, &ide_cdrom_driver)) {
printk(KERN_ERR "%s: Failed to register the driver with ide.c\n",
drive->name);
- kfree(info);
- goto failed;
+ goto out_put_disk;
}
memset(info, 0, sizeof (struct cdrom_info));
kref_init(&info->kref);
info->drive = drive;
+ info->disk = g;
+
drive->driver_data = info;
DRIVER(drive)->busy++;
@@ -3485,6 +3496,11 @@ static int ide_cdrom_attach (ide_drive_t *drive)
g->flags |= GENHD_FL_REMOVABLE;
add_disk(g);
return 0;
+
+out_put_disk:
+ put_disk(g);
+out_free_cd:
+ kfree(info);
failed:
return 1;
}
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 171c65eb313852..ee97600a1f312d 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -461,6 +461,7 @@ struct atapi_changer_info {
/* Extra per-device info for cdrom drives. */
struct cdrom_info {
ide_drive_t *drive;
+ struct gendisk *disk;
struct kref kref;
/* Buffer for table of contents. NULL if we haven't allocated
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 9636135ee07790..78733d395d6659 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -73,6 +73,7 @@
struct ide_disk_obj {
ide_drive_t *drive;
+ struct gendisk *disk;
struct kref kref;
};
@@ -1024,7 +1025,7 @@ static void ide_cacheflush_p(ide_drive_t *drive)
static int idedisk_cleanup (ide_drive_t *drive)
{
struct ide_disk_obj *idkp = drive->driver_data;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = idkp->disk;
ide_cacheflush_p(drive);
if (ide_unregister_subdriver(drive))
@@ -1040,12 +1041,12 @@ static void ide_disk_release(struct kref *kref)
{
struct ide_disk_obj *idkp = to_ide_disk(kref);
ide_drive_t *drive = idkp->drive;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = idkp->disk;
drive->driver_data = NULL;
drive->devfs_name[0] = '\0';
g->private_data = NULL;
- g->fops = ide_fops;
+ put_disk(g);
kfree(idkp);
}
@@ -1199,7 +1200,7 @@ MODULE_DESCRIPTION("ATA DISK Driver");
static int idedisk_attach(ide_drive_t *drive)
{
struct ide_disk_obj *idkp;
- struct gendisk *g = drive->disk;
+ struct gendisk *g;
/* strstr("foo", "") is non-NULL */
if (!strstr("ide-disk", drive->driver_req))
@@ -1213,9 +1214,15 @@ static int idedisk_attach(ide_drive_t *drive)
if (!idkp)
goto failed;
+ g = alloc_disk(1 << PARTN_BITS);
+ if (!g)
+ goto out_free_idkp;
+
+ ide_init_disk(g, drive);
+
if (ide_register_subdriver(drive, &idedisk_driver)) {
printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
- goto out_free_idkp;
+ goto out_put_disk;
}
memset(idkp, 0, sizeof(*idkp));
@@ -1223,6 +1230,8 @@ static int idedisk_attach(ide_drive_t *drive)
kref_init(&idkp->kref);
idkp->drive = drive;
+ idkp->disk = g;
+
drive->driver_data = idkp;
DRIVER(drive)->busy++;
@@ -1243,6 +1252,9 @@ static int idedisk_attach(ide_drive_t *drive)
g->private_data = idkp;
add_disk(g);
return 0;
+
+out_put_disk:
+ put_disk(g);
out_free_idkp:
kfree(idkp);
failed:
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 0e9421b57cc5a7..1b7d172febf730 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -276,6 +276,7 @@ typedef struct {
*/
typedef struct ide_floppy_obj {
ide_drive_t *drive;
+ struct gendisk *disk;
struct kref kref;
/* Current packet command */
@@ -680,9 +681,12 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc)
*/
static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq)
{
+ struct ide_floppy_obj *floppy = drive->driver_data;
+
ide_init_drive_cmd(rq);
rq->buffer = (char *) pc;
rq->flags = REQ_SPECIAL; //rq->cmd = IDEFLOPPY_PC_RQ;
+ rq->rq_disk = floppy->disk;
(void) ide_do_drive_cmd(drive, rq, ide_preempt);
}
@@ -1274,7 +1278,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
unsigned long block = (unsigned long)block_s;
debug_log(KERN_INFO "rq_status: %d, dev: %s, flags: %lx, errors: %d\n",
- rq->rq_status, rq->rq_disk->disk_name,
+ rq->rq_status,
+ rq->rq_disk ? rq->rq_disk->disk_name ? "?",
rq->flags, rq->errors);
debug_log(KERN_INFO "sector: %ld, nr_sectors: %ld, "
"current_nr_sectors: %d\n", (long)rq->sector,
@@ -1329,11 +1334,13 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
*/
static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc)
{
+ struct ide_floppy_obj *floppy = drive->driver_data;
struct request rq;
ide_init_drive_cmd (&rq);
rq.buffer = (char *) pc;
rq.flags = REQ_SPECIAL; // rq.cmd = IDEFLOPPY_PC_RQ;
+ rq.rq_disk = floppy->disk;
return ide_do_drive_cmd(drive, &rq, ide_wait);
}
@@ -1358,7 +1365,7 @@ static int idefloppy_get_flexible_disk_page (ide_drive_t *drive)
}
header = (idefloppy_mode_parameter_header_t *) pc.buffer;
floppy->wp = header->wp;
- set_disk_ro(drive->disk, floppy->wp);
+ set_disk_ro(floppy->disk, floppy->wp);
page = (idefloppy_flexible_disk_page_t *) (header + 1);
page->transfer_rate = ntohs(page->transfer_rate);
@@ -1424,7 +1431,7 @@ static int idefloppy_get_capacity (ide_drive_t *drive)
drive->bios_cyl = 0;
drive->bios_head = drive->bios_sect = 0;
floppy->blocks = floppy->bs_factor = 0;
- set_capacity(drive->disk, 0);
+ set_capacity(floppy->disk, 0);
idefloppy_create_read_capacity_cmd(&pc);
if (idefloppy_queue_pc_tail(drive, &pc)) {
@@ -1498,7 +1505,7 @@ static int idefloppy_get_capacity (ide_drive_t *drive)
(void) idefloppy_get_flexible_disk_page(drive);
}
- set_capacity(drive->disk, floppy->blocks * floppy->bs_factor);
+ set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor);
return rc;
}
@@ -1859,7 +1866,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
static int idefloppy_cleanup (ide_drive_t *drive)
{
idefloppy_floppy_t *floppy = drive->driver_data;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = floppy->disk;
if (ide_unregister_subdriver(drive))
return 1;
@@ -1875,11 +1882,11 @@ static void ide_floppy_release(struct kref *kref)
{
struct ide_floppy_obj *floppy = to_ide_floppy(kref);
ide_drive_t *drive = floppy->drive;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = floppy->disk;
drive->driver_data = NULL;
g->private_data = NULL;
- g->fops = ide_fops;
+ put_disk(g);
kfree(floppy);
}
@@ -2116,7 +2123,8 @@ static struct block_device_operations idefloppy_ops = {
static int idefloppy_attach (ide_drive_t *drive)
{
idefloppy_floppy_t *floppy;
- struct gendisk *g = drive->disk;
+ struct gendisk *g;
+
if (!strstr("ide-floppy", drive->driver_req))
goto failed;
if (!drive->present)
@@ -2135,10 +2143,16 @@ static int idefloppy_attach (ide_drive_t *drive)
printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
goto failed;
}
+
+ g = alloc_disk(1 << PARTN_BITS);
+ if (!g)
+ goto out_free_floppy;
+
+ ide_init_disk(g, drive);
+
if (ide_register_subdriver(drive, &idefloppy_driver)) {
printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree (floppy);
- goto failed;
+ goto out_put_disk;
}
memset(floppy, 0, sizeof(*floppy));
@@ -2146,6 +2160,7 @@ static int idefloppy_attach (ide_drive_t *drive)
kref_init(&floppy->kref);
floppy->drive = drive;
+ floppy->disk = g;
drive->driver_data = floppy;
@@ -2161,6 +2176,11 @@ static int idefloppy_attach (ide_drive_t *drive)
drive->attach = 1;
add_disk(g);
return 0;
+
+out_put_disk:
+ put_disk(g);
+out_free_floppy:
+ kfree(floppy);
failed:
return 1;
}
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 65f5267992dc9c..94f5744c62d746 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -1616,8 +1616,6 @@ int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t actio
rq->errors = 0;
rq->rq_status = RQ_ACTIVE;
- rq->rq_disk = drive->disk;
-
/*
* we need to hold an extra reference to request for safe inspection
* after completion
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 4f25501bc758b8..554473a95cf747 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1011,10 +1011,8 @@ static int ide_init_queue(ide_drive_t *drive)
blk_queue_max_hw_segments(q, max_sg_entries);
blk_queue_max_phys_segments(q, max_sg_entries);
- /* assign drive and gendisk queue */
+ /* assign drive queue */
drive->queue = q;
- if (drive->disk)
- drive->disk->queue = drive->queue;
/* needs drive->queue to be set */
ide_toggle_bounce(drive, 1);
@@ -1268,34 +1266,19 @@ void ide_unregister_region(struct gendisk *disk)
EXPORT_SYMBOL_GPL(ide_unregister_region);
-static int alloc_disks(ide_hwif_t *hwif)
+void ide_init_disk(struct gendisk *disk, ide_drive_t *drive)
{
- unsigned int unit;
- struct gendisk *disks[MAX_DRIVES];
+ ide_hwif_t *hwif = drive->hwif;
+ unsigned int unit = (drive->select.all >> 4) & 1;
- for (unit = 0; unit < MAX_DRIVES; unit++) {
- disks[unit] = alloc_disk(1 << PARTN_BITS);
- if (!disks[unit])
- goto Enomem;
- }
- for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
- struct gendisk *disk = disks[unit];
- disk->major = hwif->major;
- disk->first_minor = unit << PARTN_BITS;
- sprintf(disk->disk_name,"hd%c",'a'+hwif->index*MAX_DRIVES+unit);
- disk->fops = ide_fops;
- disk->private_data = drive;
- drive->disk = disk;
- }
- return 0;
-Enomem:
- printk(KERN_WARNING "(ide::init_gendisk) Out of memory\n");
- while (unit--)
- put_disk(disks[unit]);
- return -ENOMEM;
+ disk->major = hwif->major;
+ disk->first_minor = unit << PARTN_BITS;
+ sprintf(disk->disk_name, "hd%c", 'a' + hwif->index * MAX_DRIVES + unit);
+ disk->queue = drive->queue;
}
+EXPORT_SYMBOL_GPL(ide_init_disk);
+
static void drive_release_dev (struct device *dev)
{
ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
@@ -1336,7 +1319,7 @@ static void init_gendisk (ide_hwif_t *hwif)
static int hwif_init(ide_hwif_t *hwif)
{
- int old_irq, unit;
+ int old_irq;
/* Return success if no device is connected */
if (!hwif->present)
@@ -1372,9 +1355,6 @@ static int hwif_init(ide_hwif_t *hwif)
printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
goto out;
}
-
- if (alloc_disks(hwif) < 0)
- goto out;
if (init_irq(hwif) == 0)
goto done;
@@ -1387,12 +1367,12 @@ static int hwif_init(ide_hwif_t *hwif)
if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) {
printk("%s: Disabled unable to get IRQ %d.\n",
hwif->name, old_irq);
- goto out_disks;
+ goto out;
}
if (init_irq(hwif)) {
printk("%s: probed IRQ %d and default IRQ %d failed.\n",
hwif->name, old_irq, hwif->irq);
- goto out_disks;
+ goto out;
}
printk("%s: probed IRQ %d failed, using default.\n",
hwif->name, hwif->irq);
@@ -1402,12 +1382,6 @@ done:
hwif->present = 1; /* success */
return 1;
-out_disks:
- for (unit = 0; unit < MAX_DRIVES; unit++) {
- struct gendisk *disk = hwif->drives[unit].disk;
- hwif->drives[unit].disk = NULL;
- put_disk(disk);
- }
out:
unregister_blkdev(hwif->major, hwif->name);
return 0;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 41513c4b27fe7f..a394afa8467157 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -783,6 +783,7 @@ typedef struct {
*/
typedef struct ide_tape_obj {
ide_drive_t *drive;
+ struct gendisk *disk;
struct kref kref;
/*
@@ -1543,6 +1544,7 @@ static void idetape_active_next_stage (ide_drive_t *drive)
}
#endif /* IDETAPE_DEBUG_BUGS */
+ rq->rq_disk = tape->disk;
rq->buffer = NULL;
rq->special = (void *)stage->bh;
tape->active_data_request = rq;
@@ -1795,8 +1797,11 @@ static void idetape_init_rq(struct request *rq, u8 cmd)
*/
static void idetape_queue_pc_head (ide_drive_t *drive, idetape_pc_t *pc,struct request *rq)
{
+ struct ide_tape_obj *tape = drive->driver_data;
+
idetape_init_rq(rq, REQ_IDETAPE_PC1);
rq->buffer = (char *) pc;
+ rq->rq_disk = tape->disk;
(void) ide_do_drive_cmd(drive, rq, ide_preempt);
}
@@ -2852,10 +2857,12 @@ static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc)
*/
static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc)
{
+ struct ide_tape_obj *tape = drive->driver_data;
struct request rq;
idetape_init_rq(&rq, REQ_IDETAPE_PC1);
rq.buffer = (char *) pc;
+ rq.rq_disk = tape->disk;
return ide_do_drive_cmd(drive, &rq, ide_wait);
}
@@ -3079,6 +3086,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct
#endif /* IDETAPE_DEBUG_BUGS */
idetape_init_rq(&rq, cmd);
+ rq.rq_disk = tape->disk;
rq.special = (void *)bh;
rq.sector = tape->first_frame_position;
rq.nr_sectors = rq.current_nr_sectors = blocks;
@@ -4687,7 +4695,7 @@ static int idetape_cleanup (ide_drive_t *drive)
DRIVER(drive)->busy = 0;
(void) ide_unregister_subdriver(drive);
- ide_unregister_region(drive->disk);
+ ide_unregister_region(tape->disk);
ide_tape_put(tape);
@@ -4698,7 +4706,7 @@ static void ide_tape_release(struct kref *kref)
{
struct ide_tape_obj *tape = to_ide_tape(kref);
ide_drive_t *drive = tape->drive;
- struct gendisk *g = drive->disk;
+ struct gendisk *g = tape->disk;
drive->dsc_overlap = 0;
drive->driver_data = NULL;
@@ -4707,7 +4715,7 @@ static void ide_tape_release(struct kref *kref)
devfs_unregister_tape(g->number);
idetape_devs[tape->minor] = NULL;
g->private_data = NULL;
- g->fops = ide_fops;
+ put_disk(g);
kfree(tape);
}
@@ -4822,7 +4830,7 @@ static struct block_device_operations idetape_block_ops = {
static int idetape_attach (ide_drive_t *drive)
{
idetape_tape_t *tape;
- struct gendisk *g = drive->disk;
+ struct gendisk *g;
int minor;
if (!strstr("ide-tape", drive->driver_req))
@@ -4848,10 +4856,16 @@ static int idetape_attach (ide_drive_t *drive)
printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
goto failed;
}
+
+ g = alloc_disk(1 << PARTN_BITS);
+ if (!g)
+ goto out_free_tape;
+
+ ide_init_disk(g, drive);
+
if (ide_register_subdriver(drive, &idetape_driver)) {
printk(KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree(tape);
- goto failed;
+ goto out_put_disk;
}
memset(tape, 0, sizeof(*tape));
@@ -4859,6 +4873,7 @@ static int idetape_attach (ide_drive_t *drive)
kref_init(&tape->kref);
tape->drive = drive;
+ tape->disk = g;
drive->driver_data = tape;
@@ -4883,6 +4898,10 @@ static int idetape_attach (ide_drive_t *drive)
ide_register_region(g);
return 0;
+out_put_disk:
+ put_disk(g);
+out_free_tape:
+ kfree(tape);
failed:
return 1;
}
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 9990e2294308f0..3087a565e6bbc4 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -359,11 +359,6 @@ static int ide_system_bus_speed(void)
return system_bus_speed;
}
-static int ide_open (struct inode * inode, struct file * filp)
-{
- return -ENXIO;
-}
-
/*
* drives_lock protects the list of drives, drivers_lock the
* list of drivers. Currently nobody takes both at once.
@@ -763,11 +758,6 @@ void ide_unregister(unsigned int index)
* Remove us from the kernel's knowledge
*/
blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
- for (i = 0; i < MAX_DRIVES; i++) {
- struct gendisk *disk = hwif->drives[i].disk;
- hwif->drives[i].disk = NULL;
- put_disk(disk);
- }
kfree(hwif->sg_table);
unregister_blkdev(hwif->major, hwif->name);
spin_lock_irq(&ide_lock);
@@ -2164,13 +2154,6 @@ void ide_unregister_driver(ide_driver_t *driver)
EXPORT_SYMBOL(ide_unregister_driver);
-struct block_device_operations ide_fops[] = {{
- .owner = THIS_MODULE,
- .open = ide_open,
-}};
-
-EXPORT_SYMBOL(ide_fops);
-
/*
* Probe module
*/
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index fc7e999ec46310..2fa6834a911b19 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -98,6 +98,7 @@ typedef struct idescsi_pc_s {
typedef struct ide_scsi_obj {
ide_drive_t *drive;
+ struct gendisk *disk;
struct Scsi_Host *host;
idescsi_pc_t *pc; /* Current packet command */
@@ -323,6 +324,7 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co
printk ("ide-scsi: %s: queue cmd = ", drive->name);
hexdump(pc->c, 6);
}
+ rq->rq_disk = scsi->disk;
return ide_do_drive_cmd(drive, rq, ide_preempt);
}
@@ -718,7 +720,8 @@ static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
static int idescsi_cleanup (ide_drive_t *drive)
{
struct Scsi_Host *scsihost = drive->driver_data;
- struct gendisk *g = drive->disk;
+ struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost);
+ struct gendisk *g = scsi->disk;
if (ide_unregister_subdriver(drive))
return 1;
@@ -727,10 +730,10 @@ static int idescsi_cleanup (ide_drive_t *drive)
drive->driver_data = NULL;
g->private_data = NULL;
- g->fops = ide_fops;
+ put_disk(g);
scsi_remove_host(scsihost);
- ide_scsi_put(scsihost_to_idescsi(scsihost));
+ ide_scsi_put(scsi);
return 0;
}
@@ -912,6 +915,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
rq->special = (char *) pc;
rq->flags = REQ_SPECIAL;
spin_unlock_irq(host->host_lock);
+ rq->rq_disk = scsi->disk;
(void) ide_do_drive_cmd (drive, rq, ide_end);
spin_lock_irq(host->host_lock);
return 0;
@@ -1087,9 +1091,9 @@ static int idescsi_attach(ide_drive_t *drive)
{
idescsi_scsi_t *idescsi;
struct Scsi_Host *host;
- struct gendisk *g = drive->disk;
+ struct gendisk *g;
static int warned;
- int err;
+ int err = -ENOMEM;
if (!warned && drive->media == ide_cdrom) {
printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n");
@@ -1102,6 +1106,12 @@ static int idescsi_attach(ide_drive_t *drive)
!(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))
return 1;
+ g = alloc_disk(1 << PARTN_BITS);
+ if (!g)
+ goto out_host_put;
+
+ ide_init_disk(g, drive);
+
host->max_id = 1;
#if IDESCSI_DEBUG_LOG
@@ -1117,6 +1127,7 @@ static int idescsi_attach(ide_drive_t *drive)
idescsi = scsihost_to_idescsi(host);
idescsi->drive = drive;
idescsi->host = host;
+ idescsi->disk = g;
err = ide_register_subdriver(drive, &idescsi_driver);
if (!err) {
idescsi_setup (drive, idescsi);
@@ -1133,6 +1144,8 @@ static int idescsi_attach(ide_drive_t *drive)
ide_unregister_subdriver(drive);
}
+ put_disk(g);
+out_host_put:
scsi_host_put(host);
return err;
}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 329dcc754d868a..9cfc0999becba7 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -756,7 +756,6 @@ typedef struct ide_drive_s {
struct list_head list;
struct device gendev;
struct semaphore gendev_rel_sem; /* to deal with device release() */
- struct gendisk *disk;
} ide_drive_t;
#define IDE_CHIPSET_PCI_MASK \
@@ -1327,7 +1326,7 @@ extern irqreturn_t ide_intr(int irq, void *dev_id, struct pt_regs *regs);
extern void do_ide_request(request_queue_t *);
extern void ide_init_subdrivers(void);
-extern struct block_device_operations ide_fops[];
+void ide_init_disk(struct gendisk *, ide_drive_t *);
extern int ata_attach(ide_drive_t *);