Commit a01154a6 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] umem

	* switched to private queue
	* set ->queue and ->private_data
	* switched to new methods
	* switched to use of ->bd_disk
parent 54c10328
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
#define MM_BLKSIZE 1024 /* 1k blocks */ #define MM_BLKSIZE 1024 /* 1k blocks */
#define MM_HARDSECT 512 /* 512-byte hardware sectors */ #define MM_HARDSECT 512 /* 512-byte hardware sectors */
#define MM_SHIFT 6 /* max 64 partitions on 4 cards */ #define MM_SHIFT 6 /* max 64 partitions on 4 cards */
#define DEVICE_NR(device) (minor(device)>>MM_SHIFT)
/* /*
* Version Information * Version Information
...@@ -812,10 +811,10 @@ static void del_battery_timer(void) ...@@ -812,10 +811,10 @@ static void del_battery_timer(void)
* That's crap, since doing that while some partitions are opened * That's crap, since doing that while some partitions are opened
* or mounted will give you really nasty results. * or mounted will give you really nasty results.
*/ */
static int mm_revalidate(kdev_t i_rdev) static int mm_revalidate(struct gendisk *disk)
{ {
int card_number = DEVICE_NR(i_rdev); struct cardinfo *card = disk->private_data;
set_capacity(mm_gendisk[card_number], cards[card_number].mm_size << 1); set_capacity(disk, card->mm_size << 1);
return 0; return 0;
} }
/* /*
...@@ -826,17 +825,14 @@ static int mm_revalidate(kdev_t i_rdev) ...@@ -826,17 +825,14 @@ static int mm_revalidate(kdev_t i_rdev)
static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg) static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg)
{ {
if (cmd == HDIO_GETGEO) { if (cmd == HDIO_GETGEO) {
unsigned int minor = minor(i->i_rdev); struct cardinfo *card = i->i_bdev->bd_disk->private_data;
int err, size, card_number = (minor >> MM_SHIFT); int size = card->mm_size * (1024 / MM_HARDSECT);
struct hd_geometry geo; struct hd_geometry geo;
/* /*
* get geometry: we have to fake one... trim the size to a * get geometry: we have to fake one... trim the size to a
* multiple of 2048 (1M): tell we have 32 sectors, 64 heads, * multiple of 2048 (1M): tell we have 32 sectors, 64 heads,
* whatever cylinders. * whatever cylinders.
*/ */
err = ! access_ok(VERIFY_WRITE, arg, sizeof(geo));
if (err) return -EFAULT;
size = cards[card_number].mm_size * (1024 / MM_HARDSECT);
geo.heads = 64; geo.heads = 64;
geo.sectors = 32; geo.sectors = 32;
geo.start = get_start_sect(i->i_bdev); geo.start = get_start_sect(i->i_bdev);
...@@ -855,13 +851,9 @@ static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned ...@@ -855,13 +851,9 @@ static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
Future support for removable devices Future support for removable devices
*/ */
static int mm_check_change(kdev_t i_rdev) static int mm_check_change(struct gendisk *disk)
{ {
int card_number = DEVICE_NR(i_rdev); /* struct cardinfo *dev = disk->private_data; */
/* struct cardinfo *dev = cards + card_number; */
if (card_number >= num_cards) /* paranoid */
return 0;
return 0; return 0;
} }
/* /*
...@@ -870,10 +862,10 @@ static int mm_check_change(kdev_t i_rdev) ...@@ -870,10 +862,10 @@ static int mm_check_change(kdev_t i_rdev)
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
*/ */
static struct block_device_operations mm_fops = { static struct block_device_operations mm_fops = {
owner: THIS_MODULE, .owner = THIS_MODULE,
ioctl: mm_ioctl, .ioctl = mm_ioctl,
revalidate: mm_revalidate, .revalidate_disk= mm_revalidate,
check_media_change: mm_check_change, .media_changed = mm_check_change,
}; };
/* /*
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
...@@ -1149,16 +1141,6 @@ static struct pci_driver mm_pci_driver = { ...@@ -1149,16 +1141,6 @@ static struct pci_driver mm_pci_driver = {
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
*/ */
static request_queue_t * mm_queue_proc(kdev_t dev)
{
int c = DEVICE_NR(dev);
if (c < MM_MAXCARDS)
return &cards[c].queue;
else
return BLK_DEFAULT_QUEUE(MAJOR_NR);
}
int __init mm_init(void) int __init mm_init(void)
{ {
int retval, i; int retval, i;
...@@ -1183,7 +1165,6 @@ int __init mm_init(void) ...@@ -1183,7 +1165,6 @@ int __init mm_init(void)
} }
devfs_handle = devfs_mk_dir(NULL, "umem", NULL); devfs_handle = devfs_mk_dir(NULL, "umem", NULL);
blk_dev[MAJOR_NR].queue = mm_queue_proc;
for (i = 0; i < num_cards; i++) { for (i = 0; i < num_cards; i++) {
struct gendisk *disk = mm_gendisk[i]; struct gendisk *disk = mm_gendisk[i];
sprintf(disk->disk_name, "umem%c", 'a'+i); sprintf(disk->disk_name, "umem%c", 'a'+i);
...@@ -1191,6 +1172,8 @@ int __init mm_init(void) ...@@ -1191,6 +1172,8 @@ int __init mm_init(void)
disk->major = major_nr; disk->major = major_nr;
disk->first_minor = i << MM_SHIFT; disk->first_minor = i << MM_SHIFT;
disk->fops = &mm_fops; disk->fops = &mm_fops;
disk->private_data = &cards[i];
disk->queue = &cards[i].queue;
set_capacity(disk, cards[i].mm_size << 1); set_capacity(disk, cards[i].mm_size << 1);
add_disk(disk); add_disk(disk);
} }
......
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