login
Header Space

 
 

[PATCH 34/79] block: make printk_partition use the class iterator function

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Greg Kroah-Hartman <gregkh@...>, Kay Sievers <kay.sievers@...>
Date: Tuesday, July 22, 2008 - 1:18 am

Use the proper class iterator function instead of mucking around in the
internals of the class structures.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 block/genhd.c |   95 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 51 insertions(+), 44 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 3ccf5c0..10b9ac4 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -227,58 +227,65 @@ struct gendisk *get_gendisk(dev_t devt, int *part)
 }
 
 /*
- * print a full list of all partitions - intended for places where the root
- * filesystem can't be mounted and thus to give the victim some idea of what
- * went wrong
+ * print a partitions - intended for places where the root filesystem can't be
+ * mounted and thus to give the victim some idea of what went wrong
  */
-void __init printk_all_partitions(void)
+static int printk_partition(struct device *dev, void *data)
 {
-	struct device *dev;
 	struct gendisk *sgp;
 	char buf[BDEVNAME_SIZE];
 	int n;
 
-	mutex_lock(&block_class_lock);
-	/* For each block device... */
-	list_for_each_entry(dev, &block_class.devices, node) {
-		if (dev->type != &disk_type)
-			continue;
-		sgp = dev_to_disk(dev);
-		/*
-		 * Don't show empty devices or things that have been surpressed
-		 */
-		if (get_capacity(sgp) == 0 ||
-		    (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
-			continue;
+	if (dev->type != &disk_type)
+		goto exit;
 
-		/*
-		 * Note, unlike /proc/partitions, I am showing the numbers in
-		 * hex - the same format as the root= option takes.
-		 */
-		printk("%02x%02x %10llu %s",
-			sgp->major, sgp->first_minor,
-			(unsigned long long)get_capacity(sgp) >> 1,
-			disk_name(sgp, 0, buf));
-		if (sgp->driverfs_dev != NULL &&
-		    sgp->driverfs_dev->driver != NULL)
-			printk(" driver: %s\n",
-				sgp->driverfs_dev->driver->name);
-		else
-			printk(" (driver?)\n");
-
-		/* now show the partitions */
-		for (n = 0; n < sgp->minors - 1; ++n) {
-			if (sgp->part[n] == NULL)
-				continue;
-			if (sgp->part[n]->nr_sects == 0)
-				continue;
-			printk("  %02x%02x %10llu %s\n",
-				sgp->major, n + 1 + sgp->first_minor,
-				(unsigned long long)sgp->part[n]->nr_sects >> 1,
-				disk_name(sgp, n + 1, buf));
-		}
+	sgp = dev_to_disk(dev);
+	/*
+	 * Don't show empty devices or things that have been surpressed
+	 */
+	if (get_capacity(sgp) == 0 ||
+	    (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
+		goto exit;
+
+	/*
+	 * Note, unlike /proc/partitions, I am showing the numbers in
+	 * hex - the same format as the root= option takes.
+	 */
+	printk("%02x%02x %10llu %s",
+		sgp->major, sgp->first_minor,
+		(unsigned long long)get_capacity(sgp) >> 1,
+		disk_name(sgp, 0, buf));
+	if (sgp->driverfs_dev != NULL &&
+	    sgp->driverfs_dev->driver != NULL)
+		printk(" driver: %s\n",
+			sgp->driverfs_dev->driver->name);
+	else
+		printk(" (driver?)\n");
+
+	/* now show the partitions */
+	for (n = 0; n < sgp->minors - 1; ++n) {
+		if (sgp->part[n] == NULL)
+			goto exit;
+		if (sgp->part[n]->nr_sects == 0)
+			goto exit;
+		printk("  %02x%02x %10llu %s\n",
+			sgp->major, n + 1 + sgp->first_minor,
+			(unsigned long long)sgp->part[n]->nr_sects >> 1,
+			disk_name(sgp, n + 1, buf));
 	}
+exit:
+	return 0;
+}
 
+/*
+ * print a full list of all partitions - intended for places where the root
+ * filesystem can't be mounted and thus to give the victim some idea of what
+ * went wrong
+ */
+void __init printk_all_partitions(void)
+{
+	mutex_lock(&block_class_lock);
+	class_for_each_device(&block_class, NULL, NULL, printk_partition);
 	mutex_unlock(&block_class_lock);
 }
 
-- 
1.5.6.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PATCH] driver core patches against 2.6.26, Greg KH, (Tue Jul 22, 1:18 am)
[PATCH 79/79] arm: bus_id -&gt; dev_name() and dev_set_name(..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 78/79] sparc64: fix up bus_id changes in sparc core c..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 77/79] 3c59x: handle pci_name() being const, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 76/79] MTD: handle pci_name() being const, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 75/79] HP iLO driver, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
RE: [PATCH 75/79] HP iLO driver, Altobelli, David, (Tue Jul 22, 1:11 pm)
Re: [PATCH 75/79] HP iLO driver, Greg KH, (Tue Jul 22, 1:16 pm)
[PATCH 74/79] sysdev: Convert the x86 mce tolerant sysdev at..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 73/79] sysdev: Add utility functions for simple int/u..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 72/79] sysdev: Pass the attribute to the low level sy..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
Re: [PATCH 72/79] sysdev: Pass the attribute to the low leve..., Stephen Rothwell, (Tue Jul 22, 11:04 pm)
[PATCH 71/79] driver core: Suppress sysfs warnings for devic..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 70/79] kobject: Transmit return value of call_usermod..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 69/79] sysfs-rules.txt: reword API stability statement, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 68/79] debugfs: Implement debugfs_remove_recursive(), Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 67/79] HOWTO: change email addresses of James in HOWTO, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 66/79] always enable FW_LOADER unless EMBEDDED=y, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 65/79] uio-howto.tmpl: use unique output names, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 64/79] uio-howto.tmpl: use standard copyright/legal m..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 63/79] sysfs: don't call notify_change, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 62/79] sysdev: fix debugging statements in registrati..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 61/79] kobject: should use kobject_put() in kset-exam..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 60/79] kobject: reorder kobject to save space on 64 b..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 59/79] UIO: minor style and comment fixes, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 58/79] UIO: add generic UIO platform driver, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 57/79] UIO: Add write function to allow irq masking, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 56/79] UIO: fix UIO Kconfig dependencies, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 55/79] pnp: add acpi:* modalias entries, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 54/79] driver core: fix a lot of printk usages of bus..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 53/79] driver core: remove DEVICE_ID_SIZE define, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 52/79] driver core: remove DEVICE_NAME_SIZE define, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 51/79] driver core: remove KOBJ_NAME_LEN define, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 50/79] class: change internal semaphore to a mutex, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 49/79] class: add lockdep infrastructure, Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 48/79] class: fix docbook comments for class_private ..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 47/79] class: rename "sem" to "class_sem" in internal..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 46/79] class: rename "subsys" to "class_subsys" in in..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 45/79] class: rename "interfaces" to "class_interface..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 44/79] class: rename "devices" to "class_devices" in ..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 43/79] class: move driver core specific parts to a pr..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 42/79] bluetooth: remove improper bluetooth class sym..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 41/79] infiniband: make cm_device use a struct device..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 40/79] infiniband: rename "device" to "ib_device" in ..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 39/79] block: make /proc/partitions and /proc/disksta..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 38/79] block: move header for /proc/partitions to seq..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 37/79] block: make proc files seq_start use the class..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 36/79] block: make /proc/diskstats only build if CONF..., Greg Kroah-Hartman, (Tue Jul 22, 1:19 am)
[PATCH 35/79] block: make blk_lookup_devt use the class iter..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 34/79] block: make printk_partition use the class ite..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 33/79] block: fix compiler warning in genhd.c, Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 32/79] Driver Core: add ability for class_find_device..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 31/79] Driver Core: add ability for class_for_each_de..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 30/79] device create: convert device_create_drvdata t..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 29/79] driver core: remove device_create(), Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 28/79] device create: x86: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 27/79] device create: usb: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 26/79] device create: spi: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 25/79] device create: sound: convert device_create to..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 24/79] device create: scsi: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 23/79] device create: s390: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 22/79] device create: net: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 21/79] device create: mtd: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 20/79] device create: misc: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 19/79] device create: mips: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 18/79] device create: macintosh: convert device_creat..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
Re: [PATCH 18/79] device create: macintosh: convert device_c..., Benjamin Herrenschmidt, (Tue Jul 22, 6:00 pm)
[PATCH 17/79] device create: isdn: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 16/79] device create: infiniband: convert device_crea..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 15/79] device create: ieee1394: convert device_create..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 14/79] device create: ide: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 13/79] device create: i2c: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 12/79] device create: hwmon: convert device_create to..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 11/79] device create: hid: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 10/79] device create: framebuffer: convert device_cre..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 09/79] device create: dvb: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 08/79] device create: dca: convert device_create to d..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 07/79] device create: coda: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 06/79] device create: char: convert device_create to ..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 05/79] device create: block: convert device_create to..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 04/79] Firmware: fix typo in example code, Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 03/79] debugfs: Add a reference to the debugfs API do..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 02/79] kobject: replace '/' with '!' in name, Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
[PATCH 01/79] sysfs: add /sys/dev/{char,block} to lookup sys..., Greg Kroah-Hartman, (Tue Jul 22, 1:18 am)
speck-geostationary