Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936542AbZFPF5z (ORCPT ); Tue, 16 Jun 2009 01:57:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S935669AbZFPFvT (ORCPT ); Tue, 16 Jun 2009 01:51:19 -0400 Received: from kroah.org ([198.145.64.141]:48376 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935634AbZFPFvP (ORCPT ); Tue, 16 Jun 2009 01:51:15 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Kay Sievers , Jan Blunck , Greg Kroah-Hartman Subject: [PATCH 28/64] Driver Core: block: add nodename support for block drivers. Date: Mon, 15 Jun 2009 22:46:17 -0700 Message-Id: <1245131213-24168-28-git-send-email-gregkh@suse.de> X-Mailer: git-send-email 1.6.3.1 In-Reply-To: <20090616051351.GA23627@kroah.com> References: <20090616051351.GA23627@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2901 Lines: 93 From: Kay Sievers 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 Signed-off-by: Jan Blunck Signed-off-by: Greg Kroah-Hartman --- block/genhd.c | 10 ++++++++++ drivers/block/pktcdvd.c | 7 +++++++ include/linux/genhd.h | 2 +- 3 files changed, 18 insertions(+), 1 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index fe7ccc0..f4c64c2 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -996,10 +996,20 @@ struct class block_class = { .name = "block", }; +static char *block_nodename(struct device *dev) +{ + struct gendisk *disk = dev_to_disk(dev); + + if (disk->nodename) + return disk->nodename(disk); + return NULL; +} + static struct device_type disk_type = { .name = "disk", .groups = disk_attr_groups, .release = disk_release, + .nodename = block_nodename, }; #ifdef CONFIG_PROC_FS diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index d57f117..37e0f81 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2855,6 +2855,11 @@ static struct block_device_operations pktcdvd_ops = { .media_changed = pkt_media_changed, }; +static char *pktcdvd_nodename(struct gendisk *gd) +{ + return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name); +} + /* * Set up mapping from pktcdvd device to CD-ROM device. */ @@ -2907,6 +2912,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) disk->fops = &pktcdvd_ops; disk->flags = GENHD_FL_REMOVABLE; strcpy(disk->disk_name, pd->name); + disk->nodename = pktcdvd_nodename; disk->private_data = pd; disk->queue = blk_alloc_queue(GFP_KERNEL); if (!disk->queue) @@ -3062,6 +3068,7 @@ static const struct file_operations pkt_ctl_fops = { static struct miscdevice pkt_misc = { .minor = MISC_DYNAMIC_MINOR, .name = DRIVER_NAME, + .name = "pktcdvd/control", .fops = &pkt_ctl_fops }; diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 7cbd38d..45fc320 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -142,7 +142,7 @@ struct gendisk { * disks that can't be partitioned. */ char disk_name[DISK_NAME_LEN]; /* name of major driver */ - + char *(*nodename)(struct gendisk *gd); /* Array of pointers to partitions indexed by partno. * Protected with matching bdev lock but stat and other * non-critical accesses use RCU. Always access through -- 1.6.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/