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,104 +124,68 @@ static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL); ...@@ -124,104 +124,68 @@ 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)
parent = hd->driverfs_dev_arr[0]; parent = hd->driverfs_dev_arr[0];
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 (parent) {
if (hd->de_arr) { sprintf(name, "%s", parent->name);
dir = hd->de_arr[0]; sprintf(bus_id, "%s:", parent->bus_id);
if (dir) } else {
pos = devfs_generate_path (dir, dirname, *name = *bus_id = '\0';
sizeof dirname);
} }
if (pos < 0) { dev = &p[0].hd_driverfs_dev;
disk_name(hd, 0, dirname); dev->driver_data = (void *)(long)__mkdev(hd->major, hd->first_minor);
pos = 0; sprintf(dev->name, "%sdisc", name);
sprintf(dev->bus_id, "%sdisc", bus_id);
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);
} }
max_p = (1 << hd->minor_shift); for (part=0; part < max_p; part++) {
dev = &p[part].hd_driverfs_dev;
/* for all partitions setup parents and device node names */ if (!dev->driver_data)
for(part=0; part < max_p; part++) { continue;
if ((part == 0) || (p[part].nr_sects >= 1)) { dev->parent = parent;
struct device * current_driverfs_dev = if (parent)
&p[part].hd_driverfs_dev; dev->bus = parent->bus;
current_driverfs_dev->parent = parent; device_register(dev);
/* handle disc case */ device_create_file(dev, &dev_attr_type);
current_driverfs_dev->driver_data = device_create_file(dev, &dev_attr_kdev);
(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) {
sprintf(current_driverfs_dev->name,
"%spart%d", parent->name, part);
sprintf(current_driverfs_dev->bus_id,
"%s:p%d", parent->bus_id, part);
} else {
sprintf(current_driverfs_dev->name,
"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);
device_create_file(current_driverfs_dev,
&dev_attr_type);
device_create_file(current_driverfs_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; for (part=0, p = hd->part; part < max_p; part++, p++) {
struct device *dev = &p->hd_driverfs_dev;
max_p=(1 << hd->minor_shift); if (dev->driver_data) {
device_remove_file(dev, &dev_attr_type);
/* for all parts setup parent relationships and device node names */ device_remove_file(dev, &dev_attr_kdev);
for(part=1; part < max_p; part++) { put_device(dev);
if ((p[part].nr_sects >= 1)) { dev->driver_data = NULL;
current_driverfs_dev = &p[part].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);
} }
} }
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