summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-22 17:21:08 -0400
committerStephen Rothwell <sfr@canb.auug.org.au>2008-06-16 09:58:11 +1000
commitb93fefb212988180323515250dd3c754f396bf02 (patch)
treeaf12c05a68477a58a3bdbcffe40bf89b8f5aa235 /block
parentdbad1d20aa7236e86f6878ea50eed6f1b45f8a22 (diff)
block: make proc files seq_start use the class_find_device()
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>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 18ac3313f1a1..cc8d7fef7c3a 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -289,18 +289,25 @@ void __init printk_all_partitions(void)
#ifdef CONFIG_PROC_FS
/* iterator */
+static int find_start(struct device *dev, void *data)
+{
+ loff_t k = *(loff_t *)data;
+
+ if (dev->type != &disk_type)
+ return 0;
+ if (!k--)
+ return 1;
+ return 0;
+}
+
static void *part_start(struct seq_file *part, loff_t *pos)
{
- loff_t k = *pos;
struct device *dev;
mutex_lock(&block_class_lock);
- list_for_each_entry(dev, &block_class.devices, node) {
- if (dev->type != &disk_type)
- continue;
- if (!k--)
- return dev_to_disk(dev);
- }
+ dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
+ if (dev)
+ return dev_to_disk(dev);
return NULL;
}
@@ -543,16 +550,12 @@ static struct device_type disk_type = {
static void *diskstats_start(struct seq_file *part, loff_t *pos)
{
- loff_t k = *pos;
struct device *dev;
mutex_lock(&block_class_lock);
- list_for_each_entry(dev, &block_class.devices, node) {
- if (dev->type != &disk_type)
- continue;
- if (!k--)
- return dev_to_disk(dev);
- }
+ dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
+ if (dev)
+ return dev_to_disk(dev);
return NULL;
}