Skip to content

Commit

Permalink
block: make /proc/partitions and /proc/diskstats use class_find_device()
Browse files Browse the repository at this point in the history
Use the proper class iterator function instead of mucking around in the
internals of the class structures.

Cc: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Jul 22, 2008
1 parent 66c64af commit 27f3025
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,21 @@ static void *part_start(struct seq_file *part, loff_t *pos)
return NULL;
}

static int find_next(struct device *dev, void *data)
{
if (dev->type == &disk_type)
return 1;
return 0;
}

static void *part_next(struct seq_file *part, void *v, loff_t *pos)
{
struct gendisk *gp = v;
struct device *dev;
++*pos;
list_for_each_entry(dev, &gp->dev.node, node) {
if (&dev->node == &block_class.devices)
return NULL;
if (dev->type == &disk_type)
return dev_to_disk(dev);
}
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
if (dev)
return dev_to_disk(dev);
return NULL;
}

Expand Down Expand Up @@ -578,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
struct device *dev;

++*pos;
list_for_each_entry(dev, &gp->dev.node, node) {
if (&dev->node == &block_class.devices)
return NULL;
if (dev->type == &disk_type)
return dev_to_disk(dev);
}
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
if (dev)
return dev_to_disk(dev);
return NULL;
}

Expand Down

0 comments on commit 27f3025

Please sign in to comment.