aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-04-30 09:23:42 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-16 00:30:25 -0400
commitb03f38b685e2e1db174fb8982930e789a516f414 (patch)
tree8ad84738e433409647a1450a991dba1ba90d7921
parentf7a386c5b8ff34cd84ae922603d1c6f9d234edee (diff)
Driver Core: block: add nodename support for block drivers.
This adds support for block drivers to report their requested nodename to userspace. It also updates a number of block drivers to provide the needed subdirectory and device name to be used for them. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Jan Blunck <jblunck@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--block/genhd.c10
-rw-r--r--drivers/block/pktcdvd.c7
-rw-r--r--include/linux/genhd.h2
3 files changed, 18 insertions, 1 deletions
diff --git a/block/genhd.c b/block/genhd.c
index fe7ccc0a618f..f4c64c2b303a 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -996,10 +996,20 @@ struct class block_class = {
996 .name = "block", 996 .name = "block",
997}; 997};
998 998
999static char *block_nodename(struct device *dev)
1000{
1001 struct gendisk *disk = dev_to_disk(dev);
1002
1003 if (disk->nodename)
1004 return disk->nodename(disk);
1005 return NULL;
1006}
1007
999static struct device_type disk_type = { 1008static struct device_type disk_type = {
1000 .name = "disk", 1009 .name = "disk",
1001 .groups = disk_attr_groups, 1010 .groups = disk_attr_groups,
1002 .release = disk_release, 1011 .release = disk_release,
1012 .nodename = block_nodename,
1003}; 1013};
1004 1014
1005#ifdef CONFIG_PROC_FS 1015#ifdef CONFIG_PROC_FS
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index d57f11759480..37e0f81cada2 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2855,6 +2855,11 @@ static struct block_device_operations pktcdvd_ops = {
2855 .media_changed = pkt_media_changed, 2855 .media_changed = pkt_media_changed,
2856}; 2856};
2857 2857
2858static char *pktcdvd_nodename(struct gendisk *gd)
2859{
2860 return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
2861}
2862
2858/* 2863/*
2859 * Set up mapping from pktcdvd device to CD-ROM device. 2864 * Set up mapping from pktcdvd device to CD-ROM device.
2860 */ 2865 */
@@ -2907,6 +2912,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
2907 disk->fops = &pktcdvd_ops; 2912 disk->fops = &pktcdvd_ops;
2908 disk->flags = GENHD_FL_REMOVABLE; 2913 disk->flags = GENHD_FL_REMOVABLE;
2909 strcpy(disk->disk_name, pd->name); 2914 strcpy(disk->disk_name, pd->name);
2915 disk->nodename = pktcdvd_nodename;
2910 disk->private_data = pd; 2916 disk->private_data = pd;
2911 disk->queue = blk_alloc_queue(GFP_KERNEL); 2917 disk->queue = blk_alloc_queue(GFP_KERNEL);
2912 if (!disk->queue) 2918 if (!disk->queue)
@@ -3062,6 +3068,7 @@ static const struct file_operations pkt_ctl_fops = {
3062static struct miscdevice pkt_misc = { 3068static struct miscdevice pkt_misc = {
3063 .minor = MISC_DYNAMIC_MINOR, 3069 .minor = MISC_DYNAMIC_MINOR,
3064 .name = DRIVER_NAME, 3070 .name = DRIVER_NAME,
3071 .name = "pktcdvd/control",
3065 .fops = &pkt_ctl_fops 3072 .fops = &pkt_ctl_fops
3066}; 3073};
3067 3074
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 7cbd38d363a2..45fc320a53c6 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -142,7 +142,7 @@ struct gendisk {
142 * disks that can't be partitioned. */ 142 * disks that can't be partitioned. */
143 143
144 char disk_name[DISK_NAME_LEN]; /* name of major driver */ 144 char disk_name[DISK_NAME_LEN]; /* name of major driver */
145 145 char *(*nodename)(struct gendisk *gd);
146 /* Array of pointers to partitions indexed by partno. 146 /* Array of pointers to partitions indexed by partno.
147 * Protected with matching bdev lock but stat and other 147 * Protected with matching bdev lock but stat and other
148 * non-critical accesses use RCU. Always access through 148 * non-critical accesses use RCU. Always access through