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:48 -0400
commita142be856f060ae8106512c0e81a8d6f8746ab0b (patch)
tree4a90f897816a5b506bf1cced5413bb4a4326a67d /block/genhd.c
parent5c6f35c5ece8f130cd8ec9ba0d71dc146b46a0f1 (diff)
block: make blk_lookup_devt use the class iterator function
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.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 10b9ac46c2da..e8c42bfd12be 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -677,24 +677,38 @@ void genhd_media_change_notify(struct gendisk *disk)
677EXPORT_SYMBOL_GPL(genhd_media_change_notify); 677EXPORT_SYMBOL_GPL(genhd_media_change_notify);
678#endif /* 0 */ 678#endif /* 0 */
679 679
680struct find_block {
681 const char *name;
682 int part;
683};
684
685static int match_id(struct device *dev, void *data)
686{
687 struct find_block *find = data;
688
689 if (dev->type != &disk_type)
690 return 0;
691 if (strcmp(dev->bus_id, find->name) == 0) {
692 struct gendisk *disk = dev_to_disk(dev);
693 if (find->part < disk->minors)
694 return 1;
695 }
696 return 0;
697}
698
680dev_t blk_lookup_devt(const char *name, int part) 699dev_t blk_lookup_devt(const char *name, int part)
681{ 700{
682 struct device *dev; 701 struct device *dev;
683 dev_t devt = MKDEV(0, 0); 702 dev_t devt = MKDEV(0, 0);
703 struct find_block find;
684 704
685 mutex_lock(&block_class_lock); 705 mutex_lock(&block_class_lock);
686 list_for_each_entry(dev, &block_class.devices, node) { 706 find.name = name;
687 if (dev->type != &disk_type) 707 find.part = part;
688 continue; 708 dev = class_find_device(&block_class, NULL, (void *)&find, match_id);
689 if (strcmp(dev->bus_id, name) == 0) { 709 if (dev)
690 struct gendisk *disk = dev_to_disk(dev); 710 devt = MKDEV(MAJOR(dev->devt),
691 711 MINOR(dev->devt) + part);
692 if (part < disk->minors)
693 devt = MKDEV(MAJOR(dev->devt),
694 MINOR(dev->devt) + part);
695 break;
696 }
697 }
698 mutex_unlock(&block_class_lock); 712 mutex_unlock(&block_class_lock);
699 713
700 return devt; 714 return devt;