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>
This commit is contained in:
parent
a6e2ba8877
commit
68c4d4a787
1 changed files with 17 additions and 14 deletions
|
@ -291,18 +291,25 @@ void __init printk_all_partitions(void)
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
/* iterator */
|
/* 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)
|
static void *part_start(struct seq_file *part, loff_t *pos)
|
||||||
{
|
{
|
||||||
loff_t k = *pos;
|
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
mutex_lock(&block_class_lock);
|
mutex_lock(&block_class_lock);
|
||||||
list_for_each_entry(dev, &block_class.devices, node) {
|
dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
|
||||||
if (dev->type != &disk_type)
|
if (dev)
|
||||||
continue;
|
return dev_to_disk(dev);
|
||||||
if (!k--)
|
|
||||||
return dev_to_disk(dev);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,16 +562,12 @@ static struct device_type disk_type = {
|
||||||
|
|
||||||
static void *diskstats_start(struct seq_file *part, loff_t *pos)
|
static void *diskstats_start(struct seq_file *part, loff_t *pos)
|
||||||
{
|
{
|
||||||
loff_t k = *pos;
|
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
mutex_lock(&block_class_lock);
|
mutex_lock(&block_class_lock);
|
||||||
list_for_each_entry(dev, &block_class.devices, node) {
|
dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
|
||||||
if (dev->type != &disk_type)
|
if (dev)
|
||||||
continue;
|
return dev_to_disk(dev);
|
||||||
if (!k--)
|
|
||||||
return dev_to_disk(dev);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue