aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-22 17:21:08 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 00:54:49 -0400
commit68c4d4a7875c59f2e4b72901ab11ba978e75bde0 (patch)
tree92c8024e282b4e5a18b156998c2efa3bc1783e32 /block/genhd.c
parenta6e2ba88774bc5870ab3d9664cb86d70415f7402 (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/genhd.c')
-rw-r--r--block/genhd.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 68a5f28007e4..f03bdadc52ac 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -291,18 +291,25 @@ void __init printk_all_partitions(void)
291 291
292#ifdef CONFIG_PROC_FS 292#ifdef CONFIG_PROC_FS
293/* iterator */ 293/* iterator */
294static int find_start(struct device *dev, void *data)
295{
296 loff_t k = *(loff_t *)data;
297
298 if (dev->type != &disk_type)
299 return 0;
300 if (!k--)
301 return 1;
302 return 0;
303}
304
294static void *part_start(struct seq_file *part, loff_t *pos) 305static void *part_start(struct seq_file *part, loff_t *pos)
295{ 306{
296 loff_t k = *pos;
297 struct device *dev; 307 struct device *dev;
298 308
299 mutex_lock(&block_class_lock); 309 mutex_lock(&block_class_lock);
300 list_for_each_entry(dev, &block_class.devices, node) { 310 dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
301 if (dev->type != &disk_type) 311 if (dev)
302 continue; 312 return dev_to_disk(dev);
303 if (!k--)
304 return dev_to_disk(dev);
305 }
306 return NULL; 313 return NULL;
307} 314}
308 315
@@ -555,16 +562,12 @@ static struct device_type disk_type = {
555 562
556static void *diskstats_start(struct seq_file *part, loff_t *pos) 563static void *diskstats_start(struct seq_file *part, loff_t *pos)
557{ 564{
558 loff_t k = *pos;
559 struct device *dev; 565 struct device *dev;
560 566
561 mutex_lock(&block_class_lock); 567 mutex_lock(&block_class_lock);
562 list_for_each_entry(dev, &block_class.devices, node) { 568 dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
563 if (dev->type != &disk_type) 569 if (dev)
564 continue; 570 return dev_to_disk(dev);
565 if (!k--)
566 return dev_to_disk(dev);
567 }
568 return NULL; 571 return NULL;
569} 572}
570 573