Commit 097b3217 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (4/25) Unexporting driverfs_remove_partitions()

	call of driverfs_remove_partitions() pulled into del_gendisk();
function isn't exported anymore.  Both it and driverfs_create_partitions()
cleaned up.
parent 36bd834b
...@@ -81,6 +81,7 @@ del_gendisk(struct gendisk *disk) ...@@ -81,6 +81,7 @@ del_gendisk(struct gendisk *disk)
{ {
struct gendisk **p; struct gendisk **p;
driverfs_remove_partitions(disk);
wipe_partitions(disk); wipe_partitions(disk);
write_lock(&gendisk_lock); write_lock(&gendisk_lock);
for (p = &gendisk_head; *p; p = &((*p)->next)) for (p = &gendisk_head; *p; p = &((*p)->next))
......
...@@ -1422,7 +1422,6 @@ static void sd_detach(Scsi_Device * sdp) ...@@ -1422,7 +1422,6 @@ static void sd_detach(Scsi_Device * sdp)
if (sdkp->has_been_registered) { if (sdkp->has_been_registered) {
sdkp->has_been_registered = 0; sdkp->has_been_registered = 0;
dev = MKDEV_SD(dsk_nr); dev = MKDEV_SD(dsk_nr);
driverfs_remove_partitions(sd_disks[dsk_nr]);
del_gendisk(sd_disks[dsk_nr]); del_gendisk(sd_disks[dsk_nr]);
} }
sdp->attached--; sdp->attached--;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "efi.h" #include "efi.h"
#if CONFIG_BLK_DEV_MD #if CONFIG_BLK_DEV_MD
extern void md_autodetect_dev(kdev_t dev); extern void md_autodetect_dev(dev_t dev);
#endif #endif
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
...@@ -87,7 +87,7 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) = ...@@ -87,7 +87,7 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) =
* a pointer to that same buffer (for convenience). * a pointer to that same buffer (for convenience).
*/ */
char *disk_name (struct gendisk *hd, int part, char *buf) char *disk_name(struct gendisk *hd, int part, char *buf)
{ {
if (part < 1<<hd->minor_shift && hd->part[part].de) { if (part < 1<<hd->minor_shift && hd->part[part].de) {
int pos; int pos;
...@@ -124,13 +124,12 @@ static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL); ...@@ -124,13 +124,12 @@ static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL);
static void driverfs_create_partitions(struct gendisk *hd) static void driverfs_create_partitions(struct gendisk *hd)
{ {
int pos = -1; int max_p = 1<<hd->minor_shift;
char dirname[256];
struct device *parent = 0;
int max_p;
int part;
devfs_handle_t dir = 0;
struct hd_struct *p = hd->part; struct hd_struct *p = hd->part;
char name[DEVICE_NAME_SIZE];
char bus_id[BUS_ID_SIZE];
struct device *dev, *parent;
int part;
/* get parent driverfs device structure */ /* get parent driverfs device structure */
if (hd->driverfs_dev_arr) if (hd->driverfs_dev_arr)
...@@ -138,90 +137,55 @@ static void driverfs_create_partitions(struct gendisk *hd) ...@@ -138,90 +137,55 @@ static void driverfs_create_partitions(struct gendisk *hd)
else /* if driverfs not supported by subsystem, skip partitions */ else /* if driverfs not supported by subsystem, skip partitions */
return; return;
/* get parent device node directory name */
if (hd->de_arr) {
dir = hd->de_arr[0];
if (dir)
pos = devfs_generate_path (dir, dirname,
sizeof dirname);
}
if (pos < 0) {
disk_name(hd, 0, dirname);
pos = 0;
}
max_p = (1 << hd->minor_shift);
/* for all partitions setup parents and device node names */
for(part=0; part < max_p; part++) {
if ((part == 0) || (p[part].nr_sects >= 1)) {
struct device * current_driverfs_dev =
&p[part].hd_driverfs_dev;
current_driverfs_dev->parent = parent;
/* handle disc case */
current_driverfs_dev->driver_data =
(void *)(long)__mkdev(hd->major, hd->first_minor+part);
if (part == 0) {
if (parent) {
sprintf(current_driverfs_dev->name,
"%sdisc", parent->name);
sprintf(current_driverfs_dev->bus_id,
"%s:disc", parent->bus_id);
} else {
sprintf(current_driverfs_dev->name,
"disc");
sprintf(current_driverfs_dev->bus_id,
"disc");
}
} else { /* this is a partition */
if (parent) { if (parent) {
sprintf(current_driverfs_dev->name, sprintf(name, "%s", parent->name);
"%spart%d", parent->name, part); sprintf(bus_id, "%s:", parent->bus_id);
sprintf(current_driverfs_dev->bus_id,
"%s:p%d", parent->bus_id, part);
} else { } else {
sprintf(current_driverfs_dev->name, *name = *bus_id = '\0';
"part%d", part);
sprintf(current_driverfs_dev->bus_id,
"p%d" ,part);
}
} }
if (parent) current_driverfs_dev->bus = parent->bus;
device_register(current_driverfs_dev); dev = &p[0].hd_driverfs_dev;
device_create_file(current_driverfs_dev, dev->driver_data = (void *)(long)__mkdev(hd->major, hd->first_minor);
&dev_attr_type); sprintf(dev->name, "%sdisc", name);
device_create_file(current_driverfs_dev, sprintf(dev->bus_id, "%sdisc", bus_id);
&dev_attr_kdev); for (part=1; part < max_p; part++) {
if (!p[part].nr_sects)
continue;
dev = &p[part].hd_driverfs_dev;
dev->driver_data =
(void *)(long)__mkdev(hd->major, hd->first_minor+part);
sprintf(dev->name, "%spart%d", name, part);
sprintf(dev->bus_id, "%s:p%d", bus_id, part);
} }
for (part=0; part < max_p; part++) {
dev = &p[part].hd_driverfs_dev;
if (!dev->driver_data)
continue;
dev->parent = parent;
if (parent)
dev->bus = parent->bus;
device_register(dev);
device_create_file(dev, &dev_attr_type);
device_create_file(dev, &dev_attr_kdev);
} }
} }
void driverfs_remove_partitions(struct gendisk *hd) void driverfs_remove_partitions(struct gendisk *hd)
{ {
int max_p; int max_p = 1<<hd->minor_shift;
struct hd_struct *p;
int part; int part;
struct device * current_driverfs_dev;
struct hd_struct *p = hd->part;
max_p=(1 << hd->minor_shift); for (part=0, p = hd->part; part < max_p; part++, p++) {
struct device *dev = &p->hd_driverfs_dev;
/* for all parts setup parent relationships and device node names */ if (dev->driver_data) {
for(part=1; part < max_p; part++) { device_remove_file(dev, &dev_attr_type);
if ((p[part].nr_sects >= 1)) { device_remove_file(dev, &dev_attr_kdev);
current_driverfs_dev = &p[part].hd_driverfs_dev; put_device(dev);
device_remove_file(current_driverfs_dev, dev->driver_data = NULL;
&dev_attr_type);
device_remove_file(current_driverfs_dev,
&dev_attr_kdev);
put_device(current_driverfs_dev);
} }
} }
current_driverfs_dev = &p->hd_driverfs_dev;
device_remove_file(current_driverfs_dev, &dev_attr_type);
device_remove_file(current_driverfs_dev, &dev_attr_kdev);
put_device(current_driverfs_dev);
return;
} }
/* /*
...@@ -230,7 +194,7 @@ void driverfs_remove_partitions(struct gendisk *hd) ...@@ -230,7 +194,7 @@ void driverfs_remove_partitions(struct gendisk *hd)
void check_partition(struct gendisk *hd, struct block_device *bdev) void check_partition(struct gendisk *hd, struct block_device *bdev)
{ {
devfs_handle_t de = NULL; devfs_handle_t de = NULL;
kdev_t dev = to_kdev_t(bdev->bd_dev); dev_t dev = bdev->bd_dev;
char buf[64]; char buf[64];
struct parsed_partitions *state; struct parsed_partitions *state;
int i; int i;
...@@ -246,10 +210,9 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -246,10 +210,9 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
printk(KERN_INFO " /dev/%s:", buf + i); printk(KERN_INFO " /dev/%s:", buf + i);
sprintf(state->name, "p"); sprintf(state->name, "p");
} else { } else {
unsigned n = hd->major;
disk_name(hd, 0, state->name); disk_name(hd, 0, state->name);
printk(KERN_INFO " %s:", state->name); printk(KERN_INFO " %s:", state->name);
if (n - COMPAQ_SMART2_MAJOR <= 7 || n - COMPAQ_CISS_MAJOR <= 7) if (isdigit(state->name[strlen(state->name)-1]))
sprintf(state->name, "p"); sprintf(state->name, "p");
} }
state->limit = 1<<hd->minor_shift; state->limit = 1<<hd->minor_shift;
...@@ -272,7 +235,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -272,7 +235,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
#if CONFIG_BLK_DEV_MD #if CONFIG_BLK_DEV_MD
if (!state->parts[j].flags) if (!state->parts[j].flags)
continue; continue;
md_autodetect_dev(mk_kdev(major(dev),minor(dev)+j)); md_autodetect_dev(dev+j);
#endif #endif
} }
goto out; goto out;
......
...@@ -335,7 +335,6 @@ EXPORT_SYMBOL(blk_dev); ...@@ -335,7 +335,6 @@ EXPORT_SYMBOL(blk_dev);
EXPORT_SYMBOL(bdev_read_only); EXPORT_SYMBOL(bdev_read_only);
EXPORT_SYMBOL(set_device_ro); EXPORT_SYMBOL(set_device_ro);
EXPORT_SYMBOL(bmap); EXPORT_SYMBOL(bmap);
EXPORT_SYMBOL(driverfs_remove_partitions);
EXPORT_SYMBOL(blkdev_open); EXPORT_SYMBOL(blkdev_open);
EXPORT_SYMBOL(blkdev_get); EXPORT_SYMBOL(blkdev_get);
EXPORT_SYMBOL(blkdev_put); EXPORT_SYMBOL(blkdev_put);
......
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