Skip to content

Commit

Permalink
block: introduce device_add_disk()
Browse files Browse the repository at this point in the history
In preparation for removing the ->driverfs_dev member of a gendisk, add
an api that takes the parent device as a parameter to add_disk().  For
now this maintains the status quo of WARN()ing on failure, but not
return a error code.

Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
djbw committed Jun 16, 2016
1 parent 1b57e66 commit e63a46b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 11 additions & 6 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,15 @@ static int exact_lock(dev_t devt, void *data)
return 0;
}

static void register_disk(struct gendisk *disk)
static void register_disk(struct device *parent, struct gendisk *disk)
{
struct device *ddev = disk_to_dev(disk);
struct block_device *bdev;
struct disk_part_iter piter;
struct hd_struct *part;
int err;

ddev->parent = disk->driverfs_dev;
ddev->parent = parent;

dev_set_name(ddev, "%s", disk->disk_name);

Expand Down Expand Up @@ -573,15 +573,16 @@ static void register_disk(struct gendisk *disk)
}

/**
* add_disk - add partitioning information to kernel list
* device_add_disk - add partitioning information to kernel list
* @parent: parent device for the disk
* @disk: per-device partitioning information
*
* This function registers the partitioning information in @disk
* with the kernel.
*
* FIXME: error handling
*/
void add_disk(struct gendisk *disk)
void device_add_disk(struct device *parent, struct gendisk *disk)
{
struct backing_dev_info *bdi;
dev_t devt;
Expand Down Expand Up @@ -617,7 +618,11 @@ void add_disk(struct gendisk *disk)

blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
register_disk(disk);

/* temporary while we convert usages to use disk_to_dev(disk)->parent */
disk->driverfs_dev = parent;

register_disk(parent, disk);
blk_register_queue(disk);

/*
Expand All @@ -633,7 +638,7 @@ void add_disk(struct gendisk *disk)
disk_add_events(disk);
blk_integrity_add(disk);
}
EXPORT_SYMBOL(add_disk);
EXPORT_SYMBOL(device_add_disk);

void del_gendisk(struct gendisk *disk)
{
Expand Down
8 changes: 7 additions & 1 deletion include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,13 @@ static inline void free_part_info(struct hd_struct *part)
extern void part_round_stats(int cpu, struct hd_struct *part);

/* block/genhd.c */
extern void add_disk(struct gendisk *disk);
extern void device_add_disk(struct device *parent, struct gendisk *disk);
static inline void add_disk(struct gendisk *disk)
{
/* temporary while we convert callers to device_add_disk */
device_add_disk(disk->driverfs_dev, disk);
}

extern void del_gendisk(struct gendisk *gp);
extern struct gendisk *get_gendisk(dev_t dev, int *partno);
extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
Expand Down

0 comments on commit e63a46b

Please sign in to comment.