aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
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 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