There is no need for bdev_nr_zones() to be an exported function calculating the number of zones of a block device. Instead, given that all callers use this helper with a fully initialized block device that has a gendisk, we can redefine this function as an inline helper in blkdev.h.
Unified · Split
| @@ -115,24 +115,6 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond) · 114 unmodified lines | ||
| 115 | 115 | } |
| 116 | 116 | EXPORT_SYMBOL_GPL(blk_zone_cond_str); |
| 117 | 117 | |
| 118 | −/** | |
| 119 | − * bdev_nr_zones - Get number of zones | |
| 120 | − * @bdev: Target device | |
| 121 | − * | |
| 122 | − * Return the total number of zones of a zoned block device. For a block | |
| 123 | − * device without zone capabilities, the number of zones is always 0. | |
| 124 | − */ | |
| 125 | −unsigned int bdev_nr_zones(struct block_device *bdev) | |
| 126 | −{ | |
| 127 | − sector_t zone_sectors = bdev_zone_sectors(bdev); | |
| 128 | − | |
| 129 | − if (!bdev_is_zoned(bdev)) | |
| 130 | − return 0; | |
| 131 | − return (bdev_nr_sectors(bdev) + zone_sectors - 1) >> | |
| 132 | − ilog2(zone_sectors); | |
| 133 | −} | |
| 134 | −EXPORT_SYMBOL_GPL(bdev_nr_zones); | |
| 135 | − | |
| 136 | 118 | /** |
| 137 | 119 | * blkdev_report_zones - Get zones information |
| 138 | 120 | * @bdev: Target block device |
| @@ -673,7 +673,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q) · 672 unmodified lines | ||
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | #ifdef CONFIG_BLK_DEV_ZONED |
| 676 | −unsigned int bdev_nr_zones(struct block_device *bdev); | |
| 677 | 676 | |
| 678 | 677 | static inline unsigned int disk_nr_zones(struct gendisk *disk) |
| 679 | 678 | { |
| @@ -687,6 +686,11 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) · 7 unmodified lines | ||
| 687 | 686 | return sector >> ilog2(disk->queue->limits.chunk_sectors); |
| 688 | 687 | } |
| 689 | 688 | |
| 689 | +static inline unsigned int bdev_nr_zones(struct block_device *bdev) | |
| 690 | +{ | |
| 691 | + return disk_nr_zones(bdev->bd_disk); | |
| 692 | +} | |
| 693 | + | |
| 690 | 694 | static inline unsigned int bdev_max_open_zones(struct block_device *bdev) |
| 691 | 695 | { |
| 692 | 696 | return bdev->bd_disk->queue->limits.max_open_zones; |