mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
block: make /proc/partitions and /proc/diskstats use 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>
This commit is contained in:
parent
66c64afec1
commit
27f3025191
1 changed files with 13 additions and 12 deletions
|
@ -317,17 +317,21 @@ static void *part_start(struct seq_file *part, loff_t *pos)
|
||||||
return NULL;
|
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)
|
static void *part_next(struct seq_file *part, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct gendisk *gp = v;
|
struct gendisk *gp = v;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
++*pos;
|
++*pos;
|
||||||
list_for_each_entry(dev, &gp->dev.node, node) {
|
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
||||||
if (&dev->node == &block_class.devices)
|
if (dev)
|
||||||
return NULL;
|
return dev_to_disk(dev);
|
||||||
if (dev->type == &disk_type)
|
|
||||||
return dev_to_disk(dev);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
++*pos;
|
++*pos;
|
||||||
list_for_each_entry(dev, &gp->dev.node, node) {
|
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
||||||
if (&dev->node == &block_class.devices)
|
if (dev)
|
||||||
return NULL;
|
return dev_to_disk(dev);
|
||||||
if (dev->type == &disk_type)
|
|
||||||
return dev_to_disk(dev);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue