Commit 106a92d1 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] switch blk_register_area() to kobject

preparation to cdev-cidr - the lookup mechanism for gendisks is switched
to dealing with disk->kobj instead of disk.
parent 93e0e677
...@@ -1513,7 +1513,7 @@ static struct block_device_operations floppy_fops = ...@@ -1513,7 +1513,7 @@ static struct block_device_operations floppy_fops =
.revalidate_disk= floppy_revalidate, .revalidate_disk= floppy_revalidate,
}; };
static struct gendisk *floppy_find(dev_t dev, int *part, void *data) static struct kobject *floppy_find(dev_t dev, int *part, void *data)
{ {
int drive = *part & 3; int drive = *part & 3;
if ((*part >> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS) if ((*part >> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS)
......
...@@ -1730,7 +1730,7 @@ static int __init fd_probe_drives(void) ...@@ -1730,7 +1730,7 @@ static int __init fd_probe_drives(void)
return -ENOMEM; return -ENOMEM;
} }
static struct gendisk *floppy_find(dev_t dev, int *part, void *data) static struct kobject *floppy_find(dev_t dev, int *part, void *data)
{ {
int drive = *part & 3; int drive = *part & 3;
if (unit[drive].type->code == FD_NODRIVE) if (unit[drive].type->code == FD_NODRIVE)
......
...@@ -1896,7 +1896,7 @@ static struct block_device_operations floppy_fops = { ...@@ -1896,7 +1896,7 @@ static struct block_device_operations floppy_fops = {
.revalidate_disk= floppy_revalidate, .revalidate_disk= floppy_revalidate,
}; };
static struct gendisk *floppy_find(dev_t dev, int *part, void *data) static struct kobject *floppy_find(dev_t dev, int *part, void *data)
{ {
int drive = *part & 3; int drive = *part & 3;
int type = *part >> 2; int type = *part >> 2;
......
...@@ -4212,7 +4212,7 @@ static struct platform_device floppy_device = { ...@@ -4212,7 +4212,7 @@ static struct platform_device floppy_device = {
}, },
}; };
static struct gendisk *floppy_find(dev_t dev, int *part, void *data) static struct kobject *floppy_find(dev_t dev, int *part, void *data)
{ {
int drive = (*part&3) | ((*part&0x80) >> 5); int drive = (*part&3) | ((*part&0x80) >> 5);
if (drive >= N_DRIVE || if (drive >= N_DRIVE ||
......
...@@ -4246,7 +4246,7 @@ static struct platform_device floppy_device = { ...@@ -4246,7 +4246,7 @@ static struct platform_device floppy_device = {
}, },
}; };
static struct gendisk *floppy_find(dev_t dev, int *part, void *data) static struct kobject *floppy_find(dev_t dev, int *part, void *data)
{ {
int drive = (*part&3) | ((*part&0x80) >> 5); int drive = (*part&3) | ((*part&0x80) >> 5);
if (drive >= N_DRIVE || if (drive >= N_DRIVE ||
......
...@@ -36,7 +36,7 @@ static struct blk_probe { ...@@ -36,7 +36,7 @@ static struct blk_probe {
dev_t dev; dev_t dev;
unsigned long range; unsigned long range;
struct module *owner; struct module *owner;
struct gendisk *(*get)(dev_t dev, int *part, void *data); struct kobject *(*get)(dev_t dev, int *part, void *data);
int (*lock)(dev_t, void *); int (*lock)(dev_t, void *);
void *data; void *data;
} *probes[MAX_PROBE_HASH]; } *probes[MAX_PROBE_HASH];
...@@ -162,7 +162,7 @@ int unregister_blkdev(unsigned int major, const char *name) ...@@ -162,7 +162,7 @@ int unregister_blkdev(unsigned int major, const char *name)
* The hash chain is sorted on range, so that subranges can override. * The hash chain is sorted on range, so that subranges can override.
*/ */
void blk_register_region(dev_t dev, unsigned long range, struct module *module, void blk_register_region(dev_t dev, unsigned long range, struct module *module,
struct gendisk *(*probe)(dev_t, int *, void *), struct kobject *(*probe)(dev_t, int *, void *),
int (*lock)(dev_t, void *), void *data) int (*lock)(dev_t, void *), void *data)
{ {
int index = dev_to_index(dev); int index = dev_to_index(dev);
...@@ -206,9 +206,10 @@ void blk_unregister_region(dev_t dev, unsigned long range) ...@@ -206,9 +206,10 @@ void blk_unregister_region(dev_t dev, unsigned long range)
EXPORT_SYMBOL(blk_register_region); EXPORT_SYMBOL(blk_register_region);
EXPORT_SYMBOL(blk_unregister_region); EXPORT_SYMBOL(blk_unregister_region);
static struct gendisk *exact_match(dev_t dev, int *part, void *data) static struct kobject *exact_match(dev_t dev, int *part, void *data)
{ {
return data; struct gendisk *p = data;
return &p->kobj;
} }
static int exact_lock(dev_t dev, void *data) static int exact_lock(dev_t dev, void *data)
...@@ -246,6 +247,8 @@ void unlink_gendisk(struct gendisk *disk) ...@@ -246,6 +247,8 @@ void unlink_gendisk(struct gendisk *disk)
disk->minors); disk->minors);
} }
#define to_disk(obj) container_of(obj,struct gendisk,kobj)
/** /**
* get_gendisk - get partitioning information for a given device * get_gendisk - get partitioning information for a given device
* @dev: device to get partitioning information for * @dev: device to get partitioning information for
...@@ -257,14 +260,14 @@ struct gendisk * ...@@ -257,14 +260,14 @@ struct gendisk *
get_gendisk(dev_t dev, int *part) get_gendisk(dev_t dev, int *part)
{ {
int index = dev_to_index(dev); int index = dev_to_index(dev);
struct gendisk *disk; struct kobject *kobj;
struct blk_probe *p; struct blk_probe *p;
unsigned best = ~0U; unsigned best = ~0U;
retry: retry:
down_read(&block_subsys.rwsem); down_read(&block_subsys.rwsem);
for (p = probes[index]; p; p = p->next) { for (p = probes[index]; p; p = p->next) {
struct gendisk *(*probe)(dev_t, int *, void *); struct kobject *(*probe)(dev_t, int *, void *);
struct module *owner; struct module *owner;
void *data; void *data;
...@@ -284,11 +287,11 @@ get_gendisk(dev_t dev, int *part) ...@@ -284,11 +287,11 @@ get_gendisk(dev_t dev, int *part)
continue; continue;
} }
up_read(&block_subsys.rwsem); up_read(&block_subsys.rwsem);
disk = probe(dev, part, data); kobj = probe(dev, part, data);
/* Currently ->owner protects _only_ ->probe() itself. */ /* Currently ->owner protects _only_ ->probe() itself. */
module_put(owner); module_put(owner);
if (disk) if (kobj)
return disk; return to_disk(kobj);
goto retry; /* this terminates: best decreases */ goto retry; /* this terminates: best decreases */
} }
up_read(&block_subsys.rwsem); up_read(&block_subsys.rwsem);
...@@ -365,7 +368,7 @@ struct seq_operations partitions_op = { ...@@ -365,7 +368,7 @@ struct seq_operations partitions_op = {
extern int blk_dev_init(void); extern int blk_dev_init(void);
static struct gendisk *base_probe(dev_t dev, int *part, void *data) static struct kobject *base_probe(dev_t dev, int *part, void *data)
{ {
request_module("block-major-%d", MAJOR(dev)); request_module("block-major-%d", MAJOR(dev));
return NULL; return NULL;
...@@ -394,8 +397,6 @@ subsys_initcall(device_init); ...@@ -394,8 +397,6 @@ subsys_initcall(device_init);
* kobject & sysfs bindings for block devices * kobject & sysfs bindings for block devices
*/ */
#define to_disk(obj) container_of(obj,struct gendisk,kobj)
struct disk_attribute { struct disk_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct gendisk *, char *); ssize_t (*show)(struct gendisk *, char *);
...@@ -632,7 +633,7 @@ struct gendisk *alloc_disk(int minors) ...@@ -632,7 +633,7 @@ struct gendisk *alloc_disk(int minors)
return disk; return disk;
} }
struct gendisk *get_disk(struct gendisk *disk) struct kobject *get_disk(struct gendisk *disk)
{ {
struct module *owner; struct module *owner;
struct kobject *kobj; struct kobject *kobj;
...@@ -647,7 +648,7 @@ struct gendisk *get_disk(struct gendisk *disk) ...@@ -647,7 +648,7 @@ struct gendisk *get_disk(struct gendisk *disk)
module_put(owner); module_put(owner);
return NULL; return NULL;
} }
return to_disk(kobj); return kobj;
} }
......
...@@ -322,7 +322,7 @@ static struct block_device_operations z2_fops = ...@@ -322,7 +322,7 @@ static struct block_device_operations z2_fops =
.release = z2_release, .release = z2_release,
}; };
static struct gendisk *z2_find(dev_t dev, int *part, void *data) static struct kobject *z2_find(dev_t dev, int *part, void *data)
{ {
*part = 0; *part = 0;
return get_disk(z2ram_gendisk); return get_disk(z2ram_gendisk);
......
...@@ -1226,7 +1226,7 @@ static int ata_lock(dev_t dev, void *data) ...@@ -1226,7 +1226,7 @@ static int ata_lock(dev_t dev, void *data)
return 0; return 0;
} }
struct gendisk *ata_probe(dev_t dev, int *part, void *data) struct kobject *ata_probe(dev_t dev, int *part, void *data)
{ {
ide_hwif_t *hwif = data; ide_hwif_t *hwif = data;
int unit = *part >> PARTN_BITS; int unit = *part >> PARTN_BITS;
......
...@@ -1438,7 +1438,7 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1438,7 +1438,7 @@ static int analyze_sbs(mddev_t * mddev)
} }
static struct gendisk *md_probe(dev_t dev, int *part, void *data) static struct kobject *md_probe(dev_t dev, int *part, void *data)
{ {
static DECLARE_MUTEX(disks_sem); static DECLARE_MUTEX(disks_sem);
int unit = MINOR(dev); int unit = MINOR(dev);
......
...@@ -862,7 +862,7 @@ void nftl_request(struct request_queue *q) ...@@ -862,7 +862,7 @@ void nftl_request(struct request_queue *q)
} }
} }
static struct gendisk *nftl_probe(dev_t dev, int *part, void *data) static struct kobject *nftl_probe(dev_t dev, int *part, void *data)
{ {
request_module("docprobe"); request_module("docprobe");
return NULL; return NULL;
......
...@@ -365,12 +365,12 @@ extern void add_partition(struct gendisk *, int, sector_t, sector_t); ...@@ -365,12 +365,12 @@ extern void add_partition(struct gendisk *, int, sector_t, sector_t);
extern void delete_partition(struct gendisk *, int); extern void delete_partition(struct gendisk *, int);
extern struct gendisk *alloc_disk(int minors); extern struct gendisk *alloc_disk(int minors);
extern struct gendisk *get_disk(struct gendisk *disk); extern struct kobject *get_disk(struct gendisk *disk);
extern void put_disk(struct gendisk *disk); extern void put_disk(struct gendisk *disk);
extern void blk_register_region(dev_t dev, unsigned long range, extern void blk_register_region(dev_t dev, unsigned long range,
struct module *module, struct module *module,
struct gendisk *(*probe)(dev_t, int *, void *), struct kobject *(*probe)(dev_t, int *, void *),
int (*lock)(dev_t, void *), int (*lock)(dev_t, void *),
void *data); void *data);
extern void blk_unregister_region(dev_t dev, unsigned long range); extern void blk_unregister_region(dev_t dev, unsigned long range);
......
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