Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 110485
b: refs/heads/master
c: 548b10e
h: refs/heads/master
i:
  110483: a879859
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Oct 9, 2008
1 parent ed97664 commit ec31b20
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 80795aefb76d10c5d698e60c7e7750b5330787da
refs/heads/master: 548b10eb2959c96cef6fc29fc96e0931eeb53bc5
40 changes: 12 additions & 28 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,22 +537,15 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
*/
extern struct block_device *bdget_disk(struct gendisk *disk, int partno)
{
dev_t devt = MKDEV(0, 0);
struct hd_struct *part;
struct block_device *bdev = NULL;

if (partno == 0)
devt = disk_devt(disk);
else {
struct hd_struct *part;
part = disk_get_part(disk, partno);
if (part && (part->nr_sects || partno == 0))
bdev = bdget(part_devt(part));
disk_put_part(part);

part = disk_get_part(disk, partno);
if (part && part->nr_sects)
devt = part_devt(part);
disk_put_part(part);
}

if (likely(devt != MKDEV(0, 0)))
return bdget(devt);
return NULL;
return bdev;
}
EXPORT_SYMBOL(bdget_disk);

Expand Down Expand Up @@ -1000,27 +993,18 @@ dev_t blk_lookup_devt(const char *name, int partno)
class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
while ((dev = class_dev_iter_next(&iter))) {
struct gendisk *disk = dev_to_disk(dev);
struct hd_struct *part;

if (strcmp(dev->bus_id, name))
continue;
if (partno < 0 || partno >= disk_max_parts(disk))
continue;

if (partno == 0)
devt = disk_devt(disk);
else {
struct hd_struct *part;

part = disk_get_part(disk, partno);
if (!part || !part->nr_sects) {
disk_put_part(part);
continue;
}

part = disk_get_part(disk, partno);
if (part && (part->nr_sects || partno == 0)) {
devt = part_devt(part);
disk_put_part(part);
break;
}
break;
disk_put_part(part);
}
class_dev_iter_exit(&iter);
return devt;
Expand Down
13 changes: 8 additions & 5 deletions trunk/include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#ifdef CONFIG_BLOCK

#define kobj_to_dev(k) container_of((k), struct device, kobj)
#define dev_to_disk(device) container_of((device), struct gendisk, __dev)
#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
#define disk_to_dev(disk) (&((disk)->__dev))
#define disk_to_dev(disk) (&(disk)->part0.__dev)
#define part_to_dev(part) (&((part)->__dev))

extern struct device_type part_type;
Expand Down Expand Up @@ -141,7 +141,6 @@ struct gendisk {

int flags;
struct device *driverfs_dev; // FIXME: remove
struct device __dev;
struct kobject *holder_dir;
struct kobject *slave_dir;

Expand All @@ -164,8 +163,12 @@ struct gendisk {

static inline struct gendisk *part_to_disk(struct hd_struct *part)
{
if (likely(part))
return dev_to_disk(part_to_dev(part)->parent);
if (likely(part)) {
if (part->partno)
return dev_to_disk(part_to_dev(part)->parent);
else
return dev_to_disk(part_to_dev(part));
}
return NULL;
}

Expand Down

0 comments on commit ec31b20

Please sign in to comment.