Skip to content

Commit b54e5ed

Browse files
ming1axboe
authored andcommitted
block: partition: introduce hd_free_part()
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>
1 parent 21bdb58 commit b54e5ed

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

block/genhd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,7 @@ static void disk_release(struct device *dev)
11101110
disk_release_events(disk);
11111111
kfree(disk->random);
11121112
disk_replace_part_tbl(disk, NULL);
1113-
free_part_stats(&disk->part0);
1114-
free_part_info(&disk->part0);
1113+
hd_free_part(&disk->part0);
11151114
if (disk->queue)
11161115
blk_put_queue(disk->queue);
11171116
kfree(disk);

block/partition-generic.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ static void part_release(struct device *dev)
212212
{
213213
struct hd_struct *p = dev_to_part(dev);
214214
blk_free_devt(dev->devt);
215-
free_part_stats(p);
216-
free_part_info(p);
215+
hd_free_part(p);
217216
kfree(p);
218217
}
219218

include/linux/genhd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,12 @@ static inline void hd_struct_put(struct hd_struct *part)
663663
__delete_partition(part);
664664
}
665665

666+
static inline void hd_free_part(struct hd_struct *part)
667+
{
668+
free_part_stats(part);
669+
free_part_info(part);
670+
}
671+
666672
/*
667673
* Any access of part->nr_sects which is not protected by partition
668674
* bd_mutex or gendisk bdev bd_mutex, should be done using this

0 commit comments

Comments
 (0)