Skip to content

Commit

Permalink
block: partition: introduce hd_free_part()
Browse files Browse the repository at this point in the history
So the helper can be used in both generic partition
case and part0 case.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Ming Lei authored and Jens Axboe committed Jul 17, 2015
1 parent 21bdb58 commit b54e5ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,7 @@ static void disk_release(struct device *dev)
disk_release_events(disk);
kfree(disk->random);
disk_replace_part_tbl(disk, NULL);
free_part_stats(&disk->part0);
free_part_info(&disk->part0);
hd_free_part(&disk->part0);
if (disk->queue)
blk_put_queue(disk->queue);
kfree(disk);
Expand Down
3 changes: 1 addition & 2 deletions block/partition-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ static void part_release(struct device *dev)
{
struct hd_struct *p = dev_to_part(dev);
blk_free_devt(dev->devt);
free_part_stats(p);
free_part_info(p);
hd_free_part(p);
kfree(p);
}

Expand Down
6 changes: 6 additions & 0 deletions include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@ static inline void hd_struct_put(struct hd_struct *part)
__delete_partition(part);
}

static inline void hd_free_part(struct hd_struct *part)
{
free_part_stats(part);
free_part_info(part);
}

/*
* Any access of part->nr_sects which is not protected by partition
* bd_mutex or gendisk bdev bd_mutex, should be done using this
Expand Down

0 comments on commit b54e5ed

Please sign in to comment.