In preparation for implementing cached report zone, split the main part
of the code of blkdev_report_zones() into the helper function
blkdev_do_report_zones(), with this new helper taking as argument a
struct blk_report_zones_args pointer instead of a report callback
function and its private argument.

No functional changes.

Signed-off-by: Damien Le Moal <[email protected]>
---
 block/blk-zoned.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index e43ae56b19c3..6b4639f11896 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -204,6 +204,21 @@ struct blk_report_zones_args {
        void            *data;
 };
 
+static int blkdev_do_report_zones(struct block_device *bdev, sector_t sector,
+                                 unsigned int nr_zones,
+                                 struct blk_report_zones_args *args)
+{
+       struct gendisk *disk = bdev->bd_disk;
+
+       if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones))
+               return -EOPNOTSUPP;
+
+       if (!nr_zones || sector >= get_capacity(disk))
+               return 0;
+
+       return disk->fops->report_zones(disk, sector, nr_zones, args);
+}
+
 /**
  * blkdev_report_zones - Get zones information
  * @bdev:      Target block device
@@ -226,19 +241,12 @@ struct blk_report_zones_args {
 int blkdev_report_zones(struct block_device *bdev, sector_t sector,
                        unsigned int nr_zones, report_zones_cb cb, void *data)
 {
-       struct gendisk *disk = bdev->bd_disk;
        struct blk_report_zones_args args = {
                .cb = cb,
                .data = data,
        };
 
-       if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones))
-               return -EOPNOTSUPP;
-
-       if (!nr_zones || sector >= get_capacity(disk))
-               return 0;
-
-       return disk->fops->report_zones(disk, sector, nr_zones, &args);
+       return blkdev_do_report_zones(bdev, sector, nr_zones, &args);
 }
 EXPORT_SYMBOL_GPL(blkdev_report_zones);
 
-- 
2.51.0


Reply via email to