Merge master.kernel.org:/home/rmk/linux-2.6-arm
[sfrench/cifs-2.6.git] / block / genhd.c
index d84a7df1e2a094e663f7e1683bb941f1c3562e2d..e1eadcc9546a72ec0d1c76d933143767dd357536 100644 (file)
@@ -1084,9 +1084,17 @@ dev_t blk_lookup_devt(const char *name, int partno)
                struct gendisk *disk = dev_to_disk(dev);
                struct hd_struct *part;
 
-               if (strcmp(dev->bus_id, name))
+               if (strcmp(dev_name(dev), name))
                        continue;
 
+               if (partno < disk->minors) {
+                       /* We need to return the right devno, even
+                        * if the partition doesn't exist yet.
+                        */
+                       devt = MKDEV(MAJOR(dev->devt),
+                                    MINOR(dev->devt) + partno);
+                       break;
+               }
                part = disk_get_part(disk, partno);
                if (part) {
                        devt = part_devt(part);