Commit 165088f9 authored by Linus Torvalds's avatar Linus Torvalds

Merge home.transmeta.com:/home/torvalds/v2.5/viro

into home.transmeta.com:/home/torvalds/v2.5/linux
parents b340c708 e86a3786
......@@ -193,8 +193,6 @@ struct mfm_info {
#define MFM_DRV_INFO mfm_info[raw_cmd.dev]
static struct hd_struct mfm[MFM_MAXDRIVES << 6];
/* Stuff from the assembly routines */
extern unsigned int hdc63463_baseaddress; /* Controller base address */
extern unsigned int hdc63463_irqpolladdress; /* Address to read to test for int */
......@@ -882,6 +880,20 @@ static void mfm_rerequest(void)
mfm_request();
}
static struct gendisk mfm_gendisk[2] = {
{
.major = MAJOR_NR,
.first_minor = 0,
.major_name = "mfma",
.minor_shift = 6,
},
{
.major = MAJOR_NR,
.first_minor = 64,
.major_name = "mfmb",
.minor_shift = 6,
};
static void mfm_request(void)
{
DBG("mfm_request CURRENT=%p Busy=%d\n", CURRENT, Busy);
......@@ -895,7 +907,7 @@ static void mfm_request(void)
Busy = 1;
while (1) {
unsigned int dev, block, nsect;
unsigned int dev, block, nsect, unit;
DBG("mfm_request: loop start\n");
sti();
......@@ -912,26 +924,26 @@ static void mfm_request(void)
DBG("mfm_request: before arg extraction\n");
dev = minor(CURRENT->rq_dev);
unit = dev>>6;
block = CURRENT->sector;
nsect = CURRENT->nr_sectors;
#ifdef DEBUG
/*if ((dev>>6)==1) */ console_printf("mfm_request: raw vals: dev=%d (block=512 bytes) block=%d nblocks=%d\n", dev, block, nsect);
/*if (unit==1) */ console_printf("mfm_request: raw vals: dev=%d (block=512 bytes) block=%d nblocks=%d\n", dev, block, nsect);
#endif
if (dev >= (mfm_drives << 6) ||
block >= mfm[dev].nr_sects || ((block+nsect) > mfm[dev].nr_sects)) {
if (dev >= (mfm_drives << 6))
if (unit >= mfm_drives ||
block >= get_capacity(mfm_gendisk + unit) ||
((block+nsect) > get_capacity(mfm_gendisk + unit))) {
if (unit >= mfm_drives)
printk("mfm: bad minor number: device=%s\n", kdevname(CURRENT->rq_dev));
else
printk("mfm%c: bad access: block=%d, count=%d, nr_sects=%ld\n", (dev >> 6)+'a',
block, nsect, mfm[dev].nr_sects);
printk("mfm%c: bad access: block=%d, count=%d, nr_sects=%ld\n", unit+'a',
block, nsect, get_capacity(mfm_gendisk+unit));
printk("mfm: continue 1\n");
end_request(CURRENT, 0);
Busy = 0;
continue;
}
block += mfm[dev].start_sect;
/* DAG: Linux doesn't cope with this - even though it has an array telling
it the hardware block size - silly */
block <<= 1; /* Now in 256 byte sectors */
......@@ -1163,18 +1175,9 @@ static int mfm_initdrives(void)
static int mfm_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg)
{
struct hd_geometry *geo = (struct hd_geometry *) arg;
kdev_t dev;
int device, minor, err;
if (!inode || !(dev = inode->i_rdev))
return -EINVAL;
minor = minor(dev);
device = DEVICE_NR(minor(inode->i_rdev)), err;
int device = DEVICE_NR(minor(inode->i_rdev));
if (device >= mfm_drives)
return -EINVAL;
if (cmd != HDIO_GETGEO)
return -EINVAL;
if (!arg)
......@@ -1185,7 +1188,8 @@ static int mfm_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long a
return -EFAULT;
if (put_user (mfm_info[device].cylinders, &geo->cylinders))
return -EFAULT;
if (put_user (mfm[minor].start_sect, &geo->start))
start = get_start_sect(inode->i_bdev);
if (put_user (get_start_sect(inode->i_bdev), &geo->start))
return -EFAULT;
return 0;
}
......@@ -1237,27 +1241,10 @@ void xd_set_geometry(struct block_device *bdev, unsigned char secsptrack,
if (raw_cmd.dev == drive)
mfm_specify ();
mfm_geometry (drive);
mfm[drive << 6].start_sect = 0;
mfm[drive << 6].nr_sects = mfm_info[drive].cylinders * mfm_info[drive].heads * mfm_info[drive].sectors / 2;
set_capacity(&mfm_gendisk[drive], mfm_info[drive].cylinders * mfm_info[drive].heads * mfm_info[drive].sectors / 2);
}
}
static struct gendisk mfm_gendisk[2] = {
{
.major = MAJOR_NR,
.first_minor = 0,
.major_name = "mfma",
.minor_shift = 6,
.part = mfm,
},
{
.major = MAJOR_NR,
.first_minor = 64,
.major_name = "mfmb",
.minor_shift = 6,
.part = mfm + 64,
};
static struct block_device_operations mfm_fops =
{
.owner = THIS_MODULE,
......@@ -1280,7 +1267,6 @@ static void mfm_geninit (void)
outw(0x80, mfm_irqenable); /* Required to enable IRQs from MFM podule */
for (i = 0; i < mfm_drives; i++) {
mfm_gendisk[i].nr_real = 1;
add_gendisk(mfm_gendisk + i);
mfm_geometry (i);
register_disk(mfm_gendisk + i, mk_kdev(MAJOR_NR,i<<6), 1<<6,
......
......@@ -1968,12 +1968,10 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
struct gendisk *disk = &Controller->disks[n];
memset(disk, 0, sizeof(struct gendisk));
sprintf(names + 9 * n, "rd/c%dd%d", Controller->ControllerNumber, n);
disk->part = Controller->DiskPartitions + (n<<DAC960_MaxPartitionsBits);
disk->major = MajorNumber;
disk->first_minor = n << DAC960_MaxPartitionsBits;
disk->major_name = names + 9 * n;
disk->minor_shift = DAC960_MaxPartitionsBits;
disk->nr_real = 1;
disk->fops = &DAC960_BlockDeviceOperations;
add_gendisk(disk);
}
......@@ -2034,10 +2032,9 @@ static long disk_size(DAC960_Controller_T *Controller, int disk)
static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
{
struct gendisk *disks = Controller->disks;
int disk;
for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
disks->part[0].nr_sects = disk_size(Controller, disk);
set_capacity(Controller->disks + disk, disk_size(Controller, disk));
}
static int DAC960_revalidate(kdev_t dev)
......@@ -2045,7 +2042,7 @@ static int DAC960_revalidate(kdev_t dev)
int ctlr = DAC960_ControllerNumber(dev);
int disk = DAC960_LogicalDriveNumber(dev);
DAC960_Controller_T *p = DAC960_Controllers[ctlr];
p->disks[disk].part[0].nr_sects = disk_size(p, disk);
set_capacity(&p->disks[disk], disk_size(p, disk));
return 0;
}
......@@ -5277,7 +5274,7 @@ static int DAC960_Open(Inode_T *Inode, File_T *File)
DAC960_KernelDevice(Controller->ControllerNumber, LogicalDriveNumber, 0),
DAC960_MaxPartitions, &DAC960_BlockDeviceOperations, size);
}
if (Controller->disks[LogicalDriveNumber].part[0].nr_sects == 0)
if (!get_capacity(&Controller->disks[LogicalDriveNumber]))
return -ENXIO;
/*
Increment Controller and Logical Drive Usage Counts.
......
......@@ -2196,7 +2196,6 @@ typedef struct file File_T;
typedef struct block_device_operations BlockDeviceOperations_T;
typedef struct completion Completion_T;
typedef struct hd_geometry DiskGeometry_T;
typedef struct hd_struct DiskPartition_T;
typedef struct inode Inode_T;
typedef struct inode_operations InodeOperations_T;
typedef kdev_t KernelDevice_T;
......@@ -2472,7 +2471,6 @@ typedef struct DAC960_Controller
boolean LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives];
} V2;
} FW;
DiskPartition_T DiskPartitions[DAC960_MinorCount];
unsigned char ProgressBuffer[DAC960_ProgressBufferSize];
unsigned char UserStatusBuffer[DAC960_UserMessageSize];
}
......
......@@ -245,7 +245,6 @@ char *acsi_buffer;
unsigned long phys_acsi_buffer;
static int NDevices;
static struct hd_struct acsi_part[MAX_DEV<<4];
static char acsi_names[MAX_DEV*4];
static int access_count[MAX_DEV];
......@@ -783,7 +782,7 @@ static void read_intr( void )
status = acsi_getstatus();
if (status != 0) {
int dev = minor(CURRENT->rq_dev);
int dev = DEVICE_NR(CURRENT->rq_dev);
printk( KERN_ERR "ad%c: ", dev+'a' );
if (!acsi_reqsense( acsi_buffer, acsi_info[dev].target,
acsi_info[dev].lun))
......@@ -814,7 +813,7 @@ static void write_intr(void)
status = acsi_getstatus();
if (status != 0) {
int dev = minor(CURRENT->rq_dev);
int dev = DEVICE_NR(CURRENT->rq_dev);
printk( KERN_ERR "ad%c: ", dev+'a' );
if (!acsi_reqsense( acsi_buffer, acsi_info[dev].target,
acsi_info[dev].lun))
......@@ -973,15 +972,15 @@ static void redo_acsi_request( void )
panic(DEVICE_NAME ": block not locked");
}
dev = minor(CURRENT->rq_dev);
dev = DEVICE_NR(CURRENT->rq_dev);
block = CURRENT->sector;
if (dev >= NDevices ||
block+CURRENT->nr_sectors >= acsi_part[dev].nr_sects) {
block+CURRENT->nr_sectors >= get_capacity(acsi_gendisk + dev)) {
#ifdef DEBUG
printk( "ad%c: attempted access for blocks %d...%ld past end of device at block %ld.\n",
dev+'a',
block, block + CURRENT->nr_sectors - 1,
acsi_part[dev].nr_sects);
get_capacity(acsi_gendisk + dev));
#endif
end_request(CURRENT, 0);
goto repeat;
......@@ -1088,11 +1087,7 @@ static void redo_acsi_request( void )
static int acsi_ioctl( struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg )
{
dev_t dev;
if (!inode)
return -EINVAL;
dev = minor(inode->i_rdev);
int dev = DEVICE_NR(inode->i_rdev);
if (dev >= NDevices)
return -EINVAL;
switch (cmd) {
......@@ -1140,7 +1135,7 @@ static int acsi_open( struct inode * inode, struct file * filp )
int device;
struct acsi_info_struct *aip;
device = minor(inode->i_rdev);
device = DEVICE_NR(inode->i_rdev);
if (device >= NDevices)
return -ENXIO;
aip = &acsi_info[device];
......@@ -1176,7 +1171,7 @@ static int acsi_open( struct inode * inode, struct file * filp )
static int acsi_release( struct inode * inode, struct file * file )
{
int device = minor(inode->i_rdev);
int device = DEVICE_NR(inode->i_rdev);
if (--access_count[device] == 0 && acsi_info[device].removable)
acsi_prevent_removal(device, 0);
return( 0 );
......@@ -1204,7 +1199,7 @@ static void acsi_prevent_removal(int device, int flag)
static int acsi_media_change (kdev_t dev)
{
int device = minor(dev);
int device = DEVICE_NR(dev);
struct acsi_info_struct *aip;
aip = &acsi_info[device];
......@@ -1702,9 +1697,7 @@ static void acsi_geninit(void)
disk->first_minor = i << 4;
disk->major_name = acsi_names + 4*i;
disk->minor_shift = (acsi_info[i].type==HARDDISK)?4:0;
disk->part = acsi_part + (i<<4);
disk->fops = &acsi_fops;
disk->nr_real = 1;
add_gendisk(disk);
register_disk(disk, mk_kdev(disk->major, disk->first_minor),
1<<disk->minor_shift,
......@@ -1808,7 +1801,7 @@ void cleanup_module(void)
static int acsi_revalidate(kdev_t dev)
{
int unit = DEVICE_NR(minor(dev));
int unit = DEVICE_NR(dev);
struct acsi_info_struct *aip = &acsi_info[unit];
stdma_lock( NULL, NULL );
if (acsi_devinit(aip) != DEV_SUPPORTED) {
......@@ -1822,6 +1815,6 @@ static int acsi_revalidate(kdev_t dev)
ENABLE_IRQ();
stdma_release();
acsi_part[minor(dev)].nr_sects = aip->size;
set_capacity(acsi_gendisk + unit, aip->size);
return 0;
}
......@@ -71,7 +71,6 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p)
long pstart, plength;
int i;
kdev_t dev = to_kdev_t(bdev->bd_dev);
struct hd_struct *part;
/* convert bytes to sectors, check for fit in a hd_struct */
ppstart = (p->start >> 9);
......@@ -86,7 +85,6 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p)
g = get_gendisk(dev);
if (!g)
return -ENXIO;
part = g->part + minor(dev) - g->first_minor;
/* existing drive? */
......@@ -97,19 +95,19 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p)
return -EINVAL;
/* partition number in use? */
if (part[p->pno].nr_sects != 0)
if (g->part[p->pno - 1].nr_sects != 0)
return -EBUSY;
/* overlap? */
for (i = 1; i < (1<<g->minor_shift); i++)
if (!(pstart+plength <= part[i].start_sect ||
pstart >= part[i].start_sect + part[i].nr_sects))
for (i = 0; i < (1<<g->minor_shift) - 1; i++)
if (!(pstart+plength <= g->part[i].start_sect ||
pstart >= g->part[i].start_sect + g->part[i].nr_sects))
return -EBUSY;
/* all seems OK */
part[p->pno].start_sect = pstart;
part[p->pno].nr_sects = plength;
devfs_register_partitions (g, minor(dev), 0);
g->part[p->pno - 1].start_sect = pstart;
g->part[p->pno - 1].nr_sects = plength;
update_partition(g, p->pno);
return 0;
}
......@@ -128,22 +126,19 @@ int del_partition(struct block_device *bdev, struct blkpg_partition *p)
kdev_t dev = to_kdev_t(bdev->bd_dev);
struct gendisk *g;
struct block_device *bdevp;
struct hd_struct *part;
int holder;
/* find the drive major */
g = get_gendisk(dev);
if (!g)
return -ENXIO;
part = g->part + minor(dev) - g->first_minor;
if (bdev != bdev->bd_contains)
return -EINVAL;
if (p->pno <= 0 || p->pno >= (1 << g->minor_shift))
return -EINVAL;
/* existing drive and partition? */
if (part[p->pno].nr_sects == 0)
if (g->part[p->pno - 1].nr_sects == 0)
return -ENXIO;
/* partition in use? Incomplete check for now. */
......@@ -159,9 +154,9 @@ int del_partition(struct block_device *bdev, struct blkpg_partition *p)
fsync_bdev(bdevp);
invalidate_bdev(bdevp, 0);
part[p->pno].start_sect = 0;
part[p->pno].nr_sects = 0;
devfs_register_partitions (g, minor(dev), 0);
g->part[p->pno - 1].start_sect = 0;
g->part[p->pno - 1].nr_sects = 0;
update_partition(g, p->pno);
bd_release(bdevp);
bdput(bdevp);
......
......@@ -407,8 +407,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
driver_geo.sectors = 0x3f;
driver_geo.cylinders = hba[ctlr]->drv[dsk].nr_blocks / (0xff*0x3f);
}
driver_geo.start=
hba[ctlr]->hd[minor(inode->i_rdev)].start_sect;
driver_geo.start= get_start_sect(inode->i_bdev);
if (copy_to_user((void *) arg, &driver_geo,
sizeof( struct hd_geometry)))
return -EFAULT;
......@@ -705,7 +704,7 @@ static int cciss_revalidate(kdev_t dev)
int ctlr = major(dev) - MAJOR_NR;
int target = minor(dev) >> NWD_SHIFT;
struct gendisk *disk = &hba[ctlr]->gendisk[target];
disk->part[0].nr_sects = hba[ctlr]->drv[target].nr_blocks;
set_capacity(disk, hba[ctlr]->drv[target].nr_blocks);
return 0;
}
......@@ -742,7 +741,6 @@ static int revalidate_allvol(kdev_t dev)
for(i=0; i< NWD; i++) {
struct gendisk *disk = &hba[ctlr]->gendisk[i];
if (disk->major_name) {
wipe_partitions(mk_kdev(disk->major, disk->first_minor));
del_gendisk(disk);
disk->major_name = NULL;
}
......@@ -752,7 +750,6 @@ static int revalidate_allvol(kdev_t dev)
* Set the partition and block size structures for all volumes
* on this controller to zero. We will reread all of this data
*/
memset(hba[ctlr]->hd, 0, sizeof(struct hd_struct) * 256);
memset(hba[ctlr]->drv, 0, sizeof(drive_info_struct)
* CISS_MAX_LUN);
/*
......@@ -802,7 +799,6 @@ static int deregister_disk(int ctlr, int logvol)
/* invalidate the devices and deregister the disk */
if (disk->major_name) {
wipe_partitions(mk_kdev(disk->major, disk->first_minor));
del_gendisk(disk);
disk->major_name = NULL;
}
......@@ -2448,8 +2444,6 @@ static int __init cciss_init_one(struct pci_dev *pdev,
disk->first_minor = j << NWD_SHIFT;
disk->major_name = NULL;
disk->minor_shift = NWD_SHIFT;
disk->part = hba[i]->hd + (j << NWD_SHIFT);
disk->nr_real = 1;
if( !(drv->nr_blocks))
continue;
(BLK_DEFAULT_QUEUE(MAJOR_NR + i))->hardsect_size = drv->block_size;
......
......@@ -83,9 +83,6 @@ struct ctlr_info
// Disk structures we need to pass back
struct gendisk gendisk[NWD];
char names[12 * NWD];
// indexed by minor numbers
struct hd_struct hd[256];
int sizes[256];
#ifdef CONFIG_CISS_SCSI_TAPE
void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
#endif
......
......@@ -75,7 +75,6 @@ MODULE_LICENSE("GPL");
static int nr_ctlr;
static ctlr_info_t *hba[MAX_CTLR];
static devfs_handle_t de_arr[MAX_CTLR][NWD];
static int eisa[8];
......@@ -103,7 +102,6 @@ static struct board_type products[] = {
{ 0x40580E11, "Smart Array 431", &smart4_access },
};
static struct hd_struct * ida;
static char *ida_names;
static struct gendisk ida_gendisk[MAX_CTLR * NWD];
......@@ -321,7 +319,6 @@ void cleanup_module(void)
}
devfs_find_and_unregister(NULL, "ida", 0, 0, 0, 0);
remove_proc_entry("cpqarray", proc_root_driver);
kfree(ida);
kfree(ida_names);
}
#endif /* MODULE */
......@@ -347,15 +344,12 @@ int __init cpqarray_init(void)
printk("Found %d controller(s)\n", nr_ctlr);
/* allocate space for disk structs */
ida = kmalloc(sizeof(struct hd_struct)*nr_ctlr*NWD*16, GFP_KERNEL);
ida_names = kmalloc(nr_ctlr*NWD*10, GFP_KERNEL);
if (!ida || !ida_names) {
if (!ida_names) {
printk( KERN_ERR "cpqarray: out of memory");
kfree(ida);
kfree(ida_names);
return(num_cntlrs_reg);
}
memset(ida, 0, sizeof(struct hd_struct)*nr_ctlr*NWD*16);
/*
* register block devices
* Find disks and fill in structs
......@@ -408,7 +402,6 @@ int __init cpqarray_init(void)
if (num_cntlrs_reg == 0)
{
kfree(ida);
kfree(ida_names);
}
return(num_cntlrs_reg);
......@@ -450,9 +443,7 @@ int __init cpqarray_init(void)
disk->major = MAJOR_NR + i;
disk->first_minor = j<<NWD_SHIFT;
disk->minor_shift = NWD_SHIFT;
disk->part = ida + i*256 + (j<<NWD_SHIFT);
disk->nr_real = 1;
disk->de_arr = &de_arr[i][j];
disk->flags = GENHD_FL_DEVFS;
disk->fops = &ida_fops;
if (!drv->nr_blks)
continue;
......@@ -1461,11 +1452,9 @@ static int revalidate_allvol(kdev_t dev)
struct gendisk *disk = ida_gendisk + ctlr*NWD + i;
if (!disk->major_name)
continue;
wipe_partitions(mk_kdev(disk->major, disk->first_minor));
del_gendisk(disk);
disk->major_name = NULL;
}
memset(ida+(ctlr*256), 0, sizeof(struct hd_struct)*NWD*16);
memset(hba[ctlr]->drv, 0, sizeof(drv_info_t)*NWD);
/*
......@@ -1500,7 +1489,7 @@ static int ida_revalidate(kdev_t dev)
int ctlr = major(dev) - MAJOR_NR;
int target = DEVICE_NR(dev);
struct gendisk *gdev = &ida_gendisk[ctlr*NWD+target];
gdev->part[minor(dev)].nr_sects = hba[ctlr]->drv[target].nr_blks;
set_capacity(gdev, hba[ctlr]->drv[target].nr_blks);
return 0;
}
......@@ -1667,6 +1656,7 @@ static void getgeometry(int ctlr)
(log_index < id_ctlr_buf->nr_drvs)
&& (log_unit < NWD);
log_unit++) {
struct gendisk *disk = ida_gendisk + ctlr * NWD + log_unit;
size = sizeof(sense_log_drv_stat_t);
......@@ -1731,13 +1721,10 @@ static void getgeometry(int ctlr)
return;
}
if (!de_arr[ctlr][log_unit]) {
if (!disk->de) {
char txt[16];
sprintf(txt, "ida/c%dd%d", ctlr,
log_unit);
de_arr[ctlr][log_unit] =
devfs_mk_dir(NULL, txt, NULL);
sprintf(txt,"ida/c%dd%d",ctlr,log_unit);
disk->de = devfs_mk_dir(NULL,txt,NULL);
}
info_p->phys_drives =
sense_config_buf->ctlr_phys_drv;
......
......@@ -23,6 +23,7 @@
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
static rwlock_t gendisk_lock;
......@@ -43,6 +44,19 @@ void
add_gendisk(struct gendisk *gp)
{
struct gendisk *sgp;
struct hd_struct *p = NULL;
if (gp->minor_shift) {
size_t size = sizeof(struct hd_struct)*((1<<gp->minor_shift)-1);
p = kmalloc(size, GFP_KERNEL);
if (!p) {
printk(KERN_ERR "out of memory; no partitions for %s\n",
gp->major_name);
gp->minor_shift = 0;
} else
memset(p, 0, size);
}
gp->part = p;
write_lock(&gendisk_lock);
......@@ -67,32 +81,20 @@ add_gendisk(struct gendisk *gp)
}
EXPORT_SYMBOL(add_gendisk);
EXPORT_SYMBOL(del_gendisk);
/**
* del_gendisk - remove partitioning information from kernel list
* @gp: per-device partitioning information
*
* This function unregisters the partitioning information in @gp
* with the kernel.
*/
void
del_gendisk(struct gendisk *gp)
void unlink_gendisk(struct gendisk *disk)
{
struct gendisk **gpp;
struct gendisk **p;
write_lock(&gendisk_lock);
for (gpp = &gendisk_head; *gpp; gpp = &((*gpp)->next))
if (*gpp == gp)
for (p = &gendisk_head; *p; p = &((*p)->next))
if (*p == disk)
break;
if (*gpp)
*gpp = (*gpp)->next;
if (*p)
*p = (*p)->next;
write_unlock(&gendisk_lock);
}
EXPORT_SYMBOL(del_gendisk);
/**
* get_gendisk - get partitioning information for a given device
* @dev: device to get partitioning information for
......@@ -160,14 +162,17 @@ static int show_partition(struct seq_file *part, void *v)
seq_puts(part, "major minor #blocks name\n\n");
/* show the full disk and all non-0 size partitions of it */
for (n = 0; n < (sgp->nr_real << sgp->minor_shift); n++) {
int minormask = (1<<sgp->minor_shift) - 1;
if ((n & minormask) && sgp->part[n].nr_sects == 0)
seq_printf(part, "%4d %4d %10ld %s\n",
sgp->major, sgp->first_minor,
get_capacity(sgp) >> 1,
disk_name(sgp, 0, buf));
for (n = 0; n < (1<<sgp->minor_shift) - 1; n++) {
if (sgp->part[n].nr_sects == 0)
continue;
seq_printf(part, "%4d %4d %10ld %s\n",
sgp->major, n + sgp->first_minor,
sgp->major, n + 1 + sgp->first_minor,
sgp->part[n].nr_sects >> 1 ,
disk_name(sgp, n + sgp->first_minor, buf));
disk_name(sgp, n + 1, buf));
}
return 0;
......
This diff is collapsed.
......@@ -271,8 +271,6 @@ static void pd_doorlock(int unit, int func);
static int pd_check_media(kdev_t dev);
static void pd_eject( int unit);
static struct hd_struct pd_hd[PD_DEVS];
#define PD_NAMELEN 8
struct pd_unit {
......@@ -438,9 +436,9 @@ static int pd_revalidate(kdev_t dev)
if ((unit >= PD_UNITS) || !PD.present)
return -ENODEV;
if (pd_identify(unit))
pd_hd[minor(dev)].nr_sects = PD.capacity;
set_capacity(&PD.gd, PD.capacity);
else
pd_hd[minor(dev)].nr_sects = 0;
set_capacity(&PD.gd, 0);
return 0;
}
......@@ -687,10 +685,8 @@ static int pd_detect( void )
PD.gd.major_name = PD.name;
PD.gd.minor_shift = PD_BITS;
PD.gd.fops = &pd_fops;
PD.gd.nr_real = 1;
PD.gd.major = major;
PD.gd.first_minor = unit << PD_BITS;
PD.gd.part = pd_hd + (unit << PD_BITS);
add_gendisk(&PD.gd);
register_disk(&PD.gd,mk_kdev(MAJOR_NR,unit<<PD_BITS),
PD_PARTNS,&pd_fops,
......@@ -728,7 +724,7 @@ static void do_pd_request (request_queue_t * q)
pd_count = CURRENT->current_nr_sectors;
if ((pd_dev >= PD_DEVS) ||
((pd_block+pd_count) > pd_hd[pd_dev].nr_sects)) {
((pd_block+pd_count) > get_capacity(&pd[unit].gd))) {
end_request(CURRENT, 0);
goto repeat;
}
......
......@@ -109,7 +109,6 @@ static DECLARE_WAIT_QUEUE_HEAD(ps2esdi_int);
static int no_int_yet;
static int ps2esdi_drives;
static struct hd_struct ps2esdi[MAX_HD << 6];
static u_short io_base;
static struct timer_list esdi_timer = { function: ps2esdi_reset_timer };
static int reset_status;
......@@ -152,17 +151,13 @@ static struct gendisk ps2esdi_gendisk[2] = {
major_name: "eda",
first_minor: 0,
minor_shift: 6,
part: ps2esdi,
fops: &ps2esdi_fops,
nr_real: 1
},{
major: MAJOR_NR,
first_minor: 64,
major_name: "edb",
minor_shift: 6,
part: ps2esdi+64,
fops: &ps2esdi_fops,
nr_real: 1
}
};
......@@ -489,6 +484,7 @@ static void __init ps2esdi_get_device_cfg(void)
static void do_ps2esdi_request(request_queue_t * q)
{
u_int block, count;
int unit;
/* since, this routine is called with interrupts cleared - they
must be before it finishes */
......@@ -505,18 +501,19 @@ static void do_ps2esdi_request(request_queue_t * q)
if (blk_queue_empty(QUEUE))
return;
unit = DEVICE_NR(CURRENT->rq_dev);
if (isa_virt_to_bus(CURRENT->buffer + CURRENT->current_nr_sectors * 512) > 16 * MB) {
printk("%s: DMA above 16MB not supported\n", DEVICE_NAME);
end_request(CURRENT, FAIL);
} /* check for above 16Mb dmas */
else if ((DEVICE_NR(CURRENT->rq_dev) < ps2esdi_drives) &&
else if ((unit < ps2esdi_drives) &&
(CURRENT->sector + CURRENT->current_nr_sectors <=
ps2esdi[minor(CURRENT->rq_dev)].nr_sects) &&
get_capacity(&ps2esdi_gendisk[unit])) &&
CURRENT->flags & REQ_CMD) {
#if 0
printk("%s:got request. device : %d minor : %d command : %d sector : %ld count : %ld\n",
DEVICE_NAME,
DEVICE_NR(CURRENT->rq_dev), minor(CURRENT->rq_dev),
unit, minor(CURRENT->rq_dev),
CURRENT->cmd, CURRENT->sector,
CURRENT->current_nr_sectors);
#endif
......@@ -526,10 +523,10 @@ static void do_ps2esdi_request(request_queue_t * q)
switch (rq_data_dir(CURRENT)) {
case READ:
ps2esdi_readwrite(READ, DEVICE_NR(CURRENT->rq_dev), block, count);
ps2esdi_readwrite(READ, unit, block, count);
break;
case WRITE:
ps2esdi_readwrite(WRITE, DEVICE_NR(CURRENT->rq_dev), block, count);
ps2esdi_readwrite(WRITE, unit, block, count);
break;
default:
printk("%s: Unknown command\n", DEVICE_NAME);
......@@ -540,7 +537,7 @@ static void do_ps2esdi_request(request_queue_t * q)
/* is request is valid */
else {
printk("Grrr. error. ps2esdi_drives: %d, %lu %lu\n", ps2esdi_drives,
CURRENT->sector, ps2esdi[minor(CURRENT->rq_dev)].nr_sects);
CURRENT->sector, get_capacity(&ps2esdi_gendisk[unit]));
end_request(CURRENT, FAIL);
}
......
......@@ -159,9 +159,6 @@ static struct cardinfo cards[MM_MAXCARDS];
static struct block_device_operations mm_fops;
static struct timer_list battery_timer;
static struct hd_struct mm_partitions[MM_MAXCARDS << MM_SHIFT];
static int num_cards = 0;
static struct gendisk mm_gendisk[MM_MAXCARDS];
......@@ -812,7 +809,7 @@ static void del_battery_timer(void)
static int mm_revalidate(kdev_t i_rdev)
{
int card_number = DEVICE_NR(i_rdev);
mm_partitions[minor(i_rdev)].nr_sects = cards[card_number].mm_size << 1;
set_capacity(mm_gendisk + card_number, cards[card_number].mm_size << 1);
return 0;
}
/*
......@@ -1192,8 +1189,6 @@ int __init mm_init(void)
struct gendisk *disk = mm_gendisk + i;
sprintf(mm_names + i*6, "umem%c", 'a'+i);
spin_lock_init(&cards[i].lock);
disk->part = mm_partitions + (i << MM_SHIFT);
disk->nr_real = 1;
disk->major = major_nr;
disk->first_minor = i << MM_SHIFT;
disk->major_name = mm_names + i*6;
......@@ -1222,10 +1217,8 @@ void __exit mm_cleanup(void)
del_battery_timer();
for (i=0; i < num_cards ; i++) {
devfs_register_partitions(mm_gendisk + i, i<<MM_SHIFT, 1);
for (i=0; i < num_cards ; i++)
del_gendisk(mm_gendisk + i);
}
if (devfs_handle)
devfs_unregister(devfs_handle);
devfs_handle = NULL;
......
......@@ -121,8 +121,6 @@ static unsigned int xd_bases[] __initdata =
0xE0000
};
static struct hd_struct xd_struct[XD_MAXDRIVES << 6];
static spinlock_t xd_lock = SPIN_LOCK_UNLOCKED;
extern struct block_device_operations xd_fops;
......@@ -133,17 +131,13 @@ static struct gendisk xd_gendisk[2] = {
.first_minor = 0,
.major_name = "xda",
.minor_shift = 6,
.part = xd_struct,
.fops = &xd_fops,
.nr_real = 1
},{
.major = MAJOR_NR,
.first_minor = 64,
.major_name = "xdb",
.minor_shift = 6,
.part = xd_struct + 64,
.fops = &xd_fops,
.nr_real = 1
}
};
......@@ -281,15 +275,17 @@ static void do_xd_request (request_queue_t * q)
return;
while (1) {
int unit;
code = 0;
/* do some checking on the request structure */
if (blk_queue_empty(QUEUE))
return;
if (DEVICE_NR(CURRENT->rq_dev) < xd_drives
unit = DEVICE_NR(CURRENT->rq_dev);
if (unit < xd_drives
&& (CURRENT->flags & REQ_CMD)
&& CURRENT->sector + CURRENT->nr_sectors
<= xd_struct[minor(CURRENT->rq_dev)].nr_sects) {
<= get_capacity(xd_gendisk + unit)) {
block = CURRENT->sector;
count = CURRENT->nr_sectors;
......@@ -297,7 +293,7 @@ static void do_xd_request (request_queue_t * q)
case READ:
case WRITE:
for (retry = 0; (retry < XD_RETRIES) && !code; retry++)
code = xd_readwrite(rq_data_dir(CURRENT),DEVICE_NR(CURRENT->rq_dev),
code = xd_readwrite(rq_data_dir(CURRENT),unit,
CURRENT->buffer,block,count);
break;
default:
......
......@@ -254,6 +254,7 @@
#include <linux/config.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/buffer_head.h>
#include <linux/major.h>
#include <linux/types.h>
#include <linux/errno.h>
......@@ -1608,6 +1609,7 @@ int cdrom_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
if (!CDROM_CAN(CDC_RESET))
return -ENOSYS;
invalidate_buffers(dev);
return cdo->reset(cdi);
}
......
......@@ -331,12 +331,11 @@ static struct timer_list cdu31a_abort_timer;
from the abort read. */
static int abort_read_started = 0;
/*
* This routine returns 1 if the disk has been changed since the last
* check or 0 if it hasn't.
* Uniform cdrom interface function
* report back, if disc has changed from time of last request.
*/
static int scd_disk_change(kdev_t full_dev)
static int scd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
{
int retval;
......@@ -346,15 +345,6 @@ static int scd_disk_change(kdev_t full_dev)
return retval;
}
/*
* Uniform cdrom interface function
* report back, if disc has changed from time of last request.
*/
static int scd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
{
return scd_disk_change(cdi->dev);
}
/*
* Uniform cdrom interface function
* report back, if drive is ready
......
......@@ -73,7 +73,6 @@ static const char *mcdx_c_version
#include <linux/major.h>
#define MAJOR_NR MITSUMI_X_CDROM_MAJOR
#define DEVICE_NR(device) (minor(device))
#include <linux/blk.h>
#include <linux/devfs_fs_kernel.h>
......@@ -197,7 +196,6 @@ struct s_drive_stuff {
void *rreg_status; /* r status */
int irq; /* irq used by this drive */
int minor; /* minor number of this drive */
int present; /* drive present and its capabilities */
unsigned char readcmd; /* read cmd depends on single/double speed */
unsigned char playcmd; /* play should always be single speed */
......@@ -207,6 +205,7 @@ struct s_drive_stuff {
int lastsector; /* last block accessible */
int status; /* last operation's error / status */
int readerrs; /* # of blocks read w/o error */
struct cdrom_device_info info;
};
......@@ -305,21 +304,13 @@ static struct cdrom_device_ops mcdx_dops = {
CDC_PLAY_AUDIO | CDC_DRIVE_STATUS,
};
static struct cdrom_device_info mcdx_info = {
ops:&mcdx_dops,
speed:2,
capacity:1,
name:"mcdx",
};
/* KERNEL INTERFACE FUNCTIONS **************************************/
static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
unsigned int cmd, void *arg)
{
struct s_drive_stuff *stuffp = mcdx_stuffp[minor(cdi->dev)];
struct s_drive_stuff *stuffp = cdi->handle;
if (!stuffp->present)
return -ENXIO;
......@@ -627,7 +618,7 @@ static int mcdx_open(struct cdrom_device_info *cdi, int purpose)
{
struct s_drive_stuff *stuffp;
xtrace(OPENCLOSE, "open()\n");
stuffp = mcdx_stuffp[minor(cdi->dev)];
stuffp = cdi->handle;
if (!stuffp->present)
return -ENXIO;
......@@ -776,7 +767,7 @@ static void mcdx_close(struct cdrom_device_info *cdi)
xtrace(OPENCLOSE, "close()\n");
stuffp = mcdx_stuffp[minor(cdi->dev)];
stuffp = cdi->handle;
--stuffp->users;
}
......@@ -787,10 +778,9 @@ static int mcdx_media_changed(struct cdrom_device_info *cdi, int disc_nr)
{
struct s_drive_stuff *stuffp;
xinfo("mcdx_media_changed called for device %s\n",
kdevname(cdi->dev));
xinfo("mcdx_media_changed called for device %s\n", cdi->name);
stuffp = mcdx_stuffp[minor(cdi->dev)];
stuffp = cdi->handle;
mcdx_getstatus(stuffp, 1);
if (stuffp->yyy == 0)
......@@ -1027,14 +1017,13 @@ void __exit mcdx_exit(void)
xinfo("cleanup_module called\n");
for (i = 0; i < MCDX_NDRIVES; i++) {
struct s_drive_stuff *stuffp;
if (unregister_cdrom(&mcdx_info)) {
struct s_drive_stuff *stuffp = mcdx_stuffp[i];
if (!stuffp)
continue;
if (unregister_cdrom(&stuffp->info)) {
printk(KERN_WARNING "Can't unregister cdrom mcdx\n");
return;
}
stuffp = mcdx_stuffp[i];
if (!stuffp)
continue;
release_region((unsigned long) stuffp->wreg_data,
MCDX_IO_SIZE);
free_irq(stuffp->irq, NULL);
......@@ -1208,15 +1197,19 @@ int __init mcdx_init_drive(int drive)
xtrace(INIT, "init() set non dma but irq mode\n");
mcdx_config(stuffp, 1);
stuffp->minor = drive;
stuffp->info.ops = &mcdx_dops;
stuffp->info.speed = 2;
stuffp->info.capacity = 1;
stuffp->info.handle = stuffp;
sprintf(stuffp->info.name, "mcdx%d", drive);
stuffp->info.dev = mk_kdev(MAJOR_NR, drive);
sprintf(msg, " mcdx: Mitsumi CD-ROM installed at 0x%3p, irq %d."
" (Firmware version %c %x)\n",
stuffp->wreg_data, stuffp->irq, version.code, version.ver);
mcdx_stuffp[drive] = stuffp;
xtrace(INIT, "init() mcdx_stuffp[%d] = %p\n", drive, stuffp);
mcdx_info.dev = mk_kdev(MAJOR_NR, 0);
if (register_cdrom(&mcdx_info) != 0) {
if (register_cdrom(&stuffp->info) != 0) {
printk("Cannot register Mitsumi CD-ROM!\n");
release_region((unsigned long) stuffp->wreg_data,
MCDX_IO_SIZE);
......@@ -1227,7 +1220,7 @@ int __init mcdx_init_drive(int drive)
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
return 2;
}
devfs_plain_cdrom(&mcdx_info, &mcdx_bdops);
devfs_plain_cdrom(&stuffp->info, &mcdx_bdops);
printk(msg);
return 0;
}
......@@ -1685,7 +1678,7 @@ mcdx_playtrk(struct s_drive_stuff *stuffp, const struct cdrom_ti *ti)
static int mcdx_tray_move(struct cdrom_device_info *cdi, int position)
{
struct s_drive_stuff *stuffp = mcdx_stuffp[minor(cdi->dev)];
struct s_drive_stuff *stuffp = cdi->handle;
if (!stuffp->present)
return -ENXIO;
......@@ -1875,7 +1868,7 @@ static int mcdx_reset(struct s_drive_stuff *stuffp, enum resetmodes mode, int tr
static int mcdx_lockdoor(struct cdrom_device_info *cdi, int lock)
{
struct s_drive_stuff *stuffp = mcdx_stuffp[minor(cdi->dev)];
struct s_drive_stuff *stuffp = cdi->handle;
char cmd[2] = { 0xfe };
if (!(stuffp->present & DOOR))
......
This diff is collapsed.
......@@ -242,12 +242,12 @@
/*
* disk states (bits of diskstate_flags):
*/
#define upc_valid (D_S[d].diskstate_flags&upc_bit)
#define volume_valid (D_S[d].diskstate_flags&volume_bit)
#define toc_valid (D_S[d].diskstate_flags&toc_bit)
#define cd_size_valid (D_S[d].diskstate_flags&cd_size_bit)
#define subq_valid (D_S[d].diskstate_flags&subq_bit)
#define frame_size_valid (D_S[d].diskstate_flags&frame_size_bit)
#define upc_valid (current_drive->diskstate_flags&upc_bit)
#define volume_valid (current_drive->diskstate_flags&volume_bit)
#define toc_valid (current_drive->diskstate_flags&toc_bit)
#define cd_size_valid (current_drive->diskstate_flags&cd_size_bit)
#define subq_valid (current_drive->diskstate_flags&subq_bit)
#define frame_size_valid (current_drive->diskstate_flags&frame_size_bit)
/*
* the status_bits variable
......@@ -324,13 +324,13 @@
/*
* used drive states:
*/
#define st_door_closed (D_S[d].status_bits&p_door_closed)
#define st_caddy_in (D_S[d].status_bits&p_caddy_in)
#define st_spinning (D_S[d].status_bits&p_spinning)
#define st_check (D_S[d].status_bits&p_check)
#define st_busy (D_S[d].status_bits&p_busy_new)
#define st_door_locked (D_S[d].status_bits&p_door_locked)
#define st_diskok (D_S[d].status_bits&p_disk_ok)
#define st_door_closed (current_drive->status_bits&p_door_closed)
#define st_caddy_in (current_drive->status_bits&p_caddy_in)
#define st_spinning (current_drive->status_bits&p_spinning)
#define st_check (current_drive->status_bits&p_check)
#define st_busy (current_drive->status_bits&p_busy_new)
#define st_door_locked (current_drive->status_bits&p_door_locked)
#define st_diskok (current_drive->status_bits&p_disk_ok)
/*
* bits of the CDi_status register:
......@@ -372,22 +372,22 @@
#define drv_famV 0x2000 /* ECS-AT (vertos-100) family */
#define drv_at (drv_famV+0x01) /* ECS-AT, firmware "1.00" */
#define fam0_drive (D_S[d].drv_type&drv_fam0)
#define famL_drive (D_S[d].drv_type&drv_famL)
#define famV_drive (D_S[d].drv_type&drv_famV)
#define fam1_drive (D_S[d].drv_type&drv_fam1)
#define fam2_drive (D_S[d].drv_type&drv_fam2)
#define famT_drive (D_S[d].drv_type&drv_famT)
#define fam0L_drive (D_S[d].drv_type&(drv_fam0|drv_famL))
#define fam0V_drive (D_S[d].drv_type&(drv_fam0|drv_famV))
#define famLV_drive (D_S[d].drv_type&(drv_famL|drv_famV))
#define fam0LV_drive (D_S[d].drv_type&(drv_fam0|drv_famL|drv_famV))
#define fam1L_drive (D_S[d].drv_type&(drv_fam1|drv_famL))
#define fam1V_drive (D_S[d].drv_type&(drv_fam1|drv_famV))
#define fam1LV_drive (D_S[d].drv_type&(drv_fam1|drv_famL|drv_famV))
#define fam01_drive (D_S[d].drv_type&(drv_fam0|drv_fam1))
#define fam12_drive (D_S[d].drv_type&(drv_fam1|drv_fam2))
#define fam2T_drive (D_S[d].drv_type&(drv_fam2|drv_famT))
#define fam0_drive (current_drive->drv_type&drv_fam0)
#define famL_drive (current_drive->drv_type&drv_famL)
#define famV_drive (current_drive->drv_type&drv_famV)
#define fam1_drive (current_drive->drv_type&drv_fam1)
#define fam2_drive (current_drive->drv_type&drv_fam2)
#define famT_drive (current_drive->drv_type&drv_famT)
#define fam0L_drive (current_drive->drv_type&(drv_fam0|drv_famL))
#define fam0V_drive (current_drive->drv_type&(drv_fam0|drv_famV))
#define famLV_drive (current_drive->drv_type&(drv_famL|drv_famV))
#define fam0LV_drive (current_drive->drv_type&(drv_fam0|drv_famL|drv_famV))
#define fam1L_drive (current_drive->drv_type&(drv_fam1|drv_famL))
#define fam1V_drive (current_drive->drv_type&(drv_fam1|drv_famV))
#define fam1LV_drive (current_drive->drv_type&(drv_fam1|drv_famL|drv_famV))
#define fam01_drive (current_drive->drv_type&(drv_fam0|drv_fam1))
#define fam12_drive (current_drive->drv_type&(drv_fam1|drv_fam2))
#define fam2T_drive (current_drive->drv_type&(drv_fam2|drv_famT))
/*
* audio states:
......
......@@ -145,8 +145,6 @@ static struct hd_i_struct hd_info[MAX_HD];
static int NR_HD;
#endif
static struct hd_struct hd[MAX_HD<<6];
static struct timer_list device_timer;
#define TIMEOUT_VALUE (6*HZ)
......@@ -596,22 +594,21 @@ static void hd_request(void)
reset_hd();
return;
}
dev = minor(CURRENT->rq_dev);
dev = DEVICE_NR(CURRENT->rq_dev);
block = CURRENT->sector;
nsect = CURRENT->nr_sectors;
if (dev >= (NR_HD<<6) || (dev & 0x3f) ||
block >= hd[dev].nr_sects || ((block+nsect) > hd[dev].nr_sects)) {
if (dev >= (NR_HD<<6) || (dev & 0x3f))
if (dev >= NR_HD || block >= get_capacity(hd_gendisk+dev) ||
((block+nsect) > get_capacity(hd_gendisk+unit))) {
if (dev >= NR_HD)
printk("hd: bad minor number: device=%s\n",
kdevname(CURRENT->rq_dev));
else
printk("hd%c: bad access: block=%d, count=%d\n",
(minor(CURRENT->rq_dev)>>6)+'a', block, nsect);
dev+'a', block, nsect);
end_request(CURRENT, 0);
goto repeat;
}
dev >>= 6;
if (special_op[dev]) {
if (do_special_op(dev))
goto repeat;
......@@ -707,14 +704,12 @@ static struct gendisk hd_gendisk[2] = {
.first_minor = 0,
.major_name = "hda",
.minor_shift = 6,
.part = hd,
.fops = &hd_fops,
},{
.major = MAJOR_NR,
.first_minor = 64,
.major_name = "hdb",
.minor_shift = 6,
.part = hd + 64,
.fops = &hd_fops,
}
};
......@@ -819,10 +814,11 @@ static void __init hd_geninit(void)
#endif
for (drive=0 ; drive < NR_HD ; drive++) {
hd[drive<<6].nr_sects = hd_info[drive].head *
sector_t size = hd_info[drive].head *
hd_info[drive].sect * hd_info[drive].cyl;
printk ("hd%c: %ldMB, CHS=%d/%d/%d\n", drive+'a',
hd[drive<<6].nr_sects / 2048, hd_info[drive].cyl,
set_capacity(hd_gendisk + drive, size);
printk ("%s: %ldMB, CHS=%d/%d/%d\n", hd_gendisk[drive].major_name,
size / 2048, hd_info[drive].cyl,
hd_info[drive].head, hd_info[drive].sect);
}
if (!NR_HD)
......@@ -849,7 +845,6 @@ static void __init hd_geninit(void)
}
for(drive=0; drive < NR_HD; drive++) {
hd_gendisk[drive].nr_real = 1;
add_gendisk(hd_gendisk + drive);
register_disk(hd_gendisk + drive,
mk_kdev(MAJOR_NR,drive<<6), 1<<6,
......
......@@ -2138,7 +2138,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
if (stat)
toc->capacity = 0x1fffff;
drive->part[0].nr_sects = toc->capacity * SECTORS_PER_FRAME;
set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
/* Remember that we've read this stuff. */
CDROM_STATE_FLAGS (drive)->toc_valid = 1;
......@@ -2593,9 +2593,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
{
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo;
int minor = (drive->select.b.unit) << PARTN_BITS;
devinfo->dev = mk_kdev(HWIF(drive)->major, minor);
devinfo->dev = mk_kdev(drive->disk->major, drive->disk->first_minor);
devinfo->ops = &ide_cdrom_dops;
devinfo->mask = 0;
*(int *)&devinfo->speed = CDROM_STATE_FLAGS (drive)->current_speed;
......@@ -2622,7 +2621,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
devinfo->mask |= CDC_CLOSE_TRAY;
devinfo->de = devfs_register(drive->de, "cd", DEVFS_FL_DEFAULT,
HWIF(drive)->major, minor,
drive->disk->major,
drive->disk->first_minor,
S_IFBLK | S_IRUGO | S_IWUGO,
ide_fops, NULL);
......@@ -2823,13 +2823,12 @@ int ide_cdrom_setup (ide_drive_t *drive)
{
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *cdi = &info->devinfo;
int minor = drive->select.b.unit << PARTN_BITS;
int nslots;
/*
* default to read-only always and fix latter at the bottom
*/
set_device_ro(mk_kdev(HWIF(drive)->major, minor), 1);
set_device_ro(mk_kdev(drive->disk->major, drive->disk->first_minor), 1);
blk_queue_hardsect_size(&drive->queue, CD_FRAMESIZE);
blk_queue_prep_rq(&drive->queue, ll_10byte_cmd_build);
......@@ -2951,7 +2950,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
nslots = ide_cdrom_probe_capabilities (drive);
if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
set_device_ro(mk_kdev(HWIF(drive)->major, minor), 0);
set_device_ro(mk_kdev(drive->disk->major, drive->disk->first_minor), 0);
if (ide_cdrom_register (drive, nslots)) {
printk ("%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
......@@ -2998,8 +2997,8 @@ void ide_cdrom_release (struct inode *inode, struct file *file,
static
int ide_cdrom_check_media_change (ide_drive_t *drive)
{
return cdrom_media_changed(mk_kdev(HWIF (drive)->major,
(drive->select.b.unit) << PARTN_BITS));
return cdrom_media_changed(mk_kdev(drive->disk->major,
drive->disk->first_minor));
}
static
......@@ -3025,9 +3024,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive)
{
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo;
ide_hwif_t *hwif = HWIF(drive);
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
struct gendisk *g = drive->disk;
if (ide_unregister_subdriver (drive))
return 1;
......@@ -3092,9 +3089,7 @@ MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static int ide_cdrom_reinit (ide_drive_t *drive)
{
struct cdrom_info *info;
ide_hwif_t *hwif = HWIF(drive);
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
struct gendisk *g = drive->disk;
struct request_sense sense;
if (!strstr("ide-cdrom", drive->driver_req))
......@@ -3147,10 +3142,13 @@ static int ide_cdrom_reinit (ide_drive_t *drive)
cdrom_read_toc(drive, &sense);
g->minor_shift = 0;
/* probably bogus, but that's the old behaviour */
g->de = NULL;
g->flags = GENHD_FL_DEVFS;
add_gendisk(g);
register_disk(g, mk_kdev(g->major,g->first_minor),
1<<g->minor_shift, ide_fops,
g->part[0].nr_sects);
get_capacity(g));
return 0;
failed:
return 1;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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