Commit 4768ac6a authored by Gerd Knorr's avatar Gerd Knorr Committed by Linus Torvalds

[PATCH] uml: sysfs support for the uml block devices.

Signed-off-by: default avatarGerd Knorr <kraxel@bytesex.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c8580e79
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
#include "mem.h" #include "mem.h"
#include "mem_kern.h" #include "mem_kern.h"
#define DRIVER_NAME "uml-blkdev"
static spinlock_t ubd_io_lock = SPIN_LOCK_UNLOCKED; static spinlock_t ubd_io_lock = SPIN_LOCK_UNLOCKED;
static spinlock_t ubd_lock = SPIN_LOCK_UNLOCKED; static spinlock_t ubd_lock = SPIN_LOCK_UNLOCKED;
...@@ -117,6 +119,7 @@ struct ubd { ...@@ -117,6 +119,7 @@ struct ubd {
struct openflags openflags; struct openflags openflags;
int no_cow; int no_cow;
struct cow cow; struct cow cow;
struct platform_device pdev;
int map_writes; int map_writes;
int map_reads; int map_reads;
...@@ -585,6 +588,14 @@ static int ubd_new_disk(int major, u64 size, int unit, ...@@ -585,6 +588,14 @@ static int ubd_new_disk(int major, u64 size, int unit,
sprintf(disk->devfs_name, "ubd_fake/disc%d", unit); sprintf(disk->devfs_name, "ubd_fake/disc%d", unit);
} }
/* sysfs register (not for ide fake devices) */
if (major == MAJOR_NR) {
ubd_dev[unit].pdev.id = unit;
ubd_dev[unit].pdev.name = DRIVER_NAME;
platform_device_register(&ubd_dev[unit].pdev);
disk->driverfs_dev = &ubd_dev[unit].pdev.dev;
}
disk->private_data = &ubd_dev[unit]; disk->private_data = &ubd_dev[unit];
disk->queue = ubd_queue; disk->queue = ubd_queue;
add_disk(disk); add_disk(disk);
...@@ -718,6 +729,7 @@ static int ubd_remove(char *str) ...@@ -718,6 +729,7 @@ static int ubd_remove(char *str)
fake_gendisk[n] = NULL; fake_gendisk[n] = NULL;
} }
platform_device_unregister(&dev->pdev);
*dev = ((struct ubd) DEFAULT_UBD); *dev = ((struct ubd) DEFAULT_UBD);
err = 0; err = 0;
out: out:
...@@ -740,6 +752,11 @@ static int ubd_mc_init(void) ...@@ -740,6 +752,11 @@ static int ubd_mc_init(void)
__initcall(ubd_mc_init); __initcall(ubd_mc_init);
static struct device_driver ubd_driver = {
.name = DRIVER_NAME,
.bus = &platform_bus_type,
};
int ubd_init(void) int ubd_init(void)
{ {
int i; int i;
...@@ -762,6 +779,7 @@ int ubd_init(void) ...@@ -762,6 +779,7 @@ int ubd_init(void)
if (register_blkdev(fake_major, "ubd")) if (register_blkdev(fake_major, "ubd"))
return -1; return -1;
} }
driver_register(&ubd_driver);
for (i = 0; i < MAX_DEV; i++) for (i = 0; i < MAX_DEV; i++)
ubd_add(i); ubd_add(i);
return 0; return 0;
......
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