Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c6f35c5 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

block: make printk_partition use the class iterator function



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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6ffeea77
Loading
Loading
Loading
Loading
+50 −43
Original line number Diff line number Diff line
@@ -227,29 +227,25 @@ 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;
		goto exit;

	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;
		goto exit;

	/*
	 * Note, unlike /proc/partitions, I am showing the numbers in
@@ -269,16 +265,27 @@ void __init printk_all_partitions(void)
	/* now show the partitions */
	for (n = 0; n < sgp->minors - 1; ++n) {
		if (sgp->part[n] == NULL)
				continue;
			goto exit;
		if (sgp->part[n]->nr_sects == 0)
				continue;
			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);
}