From: Christoph Hellwig Date: Tue, 6 Apr 2021 06:23:02 +0000 (+0200) Subject: block: remove disk_part_iter X-Git-Tag: accepted/tizen/unified/20230118.172025~7358^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3212135a718b06be38811f2d9a320ae842e76409;p=platform%2Fkernel%2Flinux-rpi.git block: remove disk_part_iter Just open code the xa_for_each in the remaining user. Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20210406062303.811835-12-hch@lst.de Signed-off-by: Jens Axboe --- diff --git a/block/genhd.c b/block/genhd.c index cbfe1ff..39ca97b 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -161,81 +161,6 @@ static void part_in_flight_rw(struct block_device *part, inflight[1] = 0; } -/** - * disk_part_iter_init - initialize partition iterator - * @piter: iterator to initialize - * @disk: disk to iterate over - * @flags: DISK_PITER_* flags - * - * Initialize @piter so that it iterates over partitions of @disk. - * - * CONTEXT: - * Don't care. - */ -void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk, - unsigned int flags) -{ - piter->disk = disk; - piter->part = NULL; - if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0)) - piter->idx = 0; - else - piter->idx = 1; - piter->flags = flags; -} - -/** - * disk_part_iter_next - proceed iterator to the next partition and return it - * @piter: iterator of interest - * - * Proceed @piter to the next partition and return it. - * - * CONTEXT: - * Don't care. - */ -struct block_device *disk_part_iter_next(struct disk_part_iter *piter) -{ - struct block_device *part; - unsigned long idx; - - /* put the last partition */ - disk_part_iter_exit(piter); - - rcu_read_lock(); - xa_for_each_start(&piter->disk->part_tbl, idx, part, piter->idx) { - if (!bdev_nr_sectors(part) && - !(piter->flags & DISK_PITER_INCL_EMPTY) && - !(piter->flags & DISK_PITER_INCL_EMPTY_PART0 && - piter->idx == 0)) - continue; - - piter->part = bdgrab(part); - if (!piter->part) - continue; - piter->idx = idx + 1; - break; - } - rcu_read_unlock(); - - return piter->part; -} - -/** - * disk_part_iter_exit - finish up partition iteration - * @piter: iter of interest - * - * Called when iteration is over. Cleans up @piter. - * - * CONTEXT: - * Don't care. - */ -void disk_part_iter_exit(struct disk_part_iter *piter) -{ - if (piter->part) - bdput(piter->part); - piter->part = NULL; -} - /* * Can be deleted altogether. Later. * @@ -472,13 +397,22 @@ static char *bdevt_str(dev_t devt, char *buf) void disk_uevent(struct gendisk *disk, enum kobject_action action) { - struct disk_part_iter piter; struct block_device *part; + unsigned long idx; + + rcu_read_lock(); + xa_for_each(&disk->part_tbl, idx, part) { + if (bdev_is_partition(part) && !bdev_nr_sectors(part)) + continue; + if (!bdgrab(part)) + continue; - disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY_PART0); - while ((part = disk_part_iter_next(&piter))) + rcu_read_unlock(); kobject_uevent(bdev_kobj(part), action); - disk_part_iter_exit(&piter); + bdput(part); + rcu_read_lock(); + } + rcu_read_unlock(); } EXPORT_SYMBOL_GPL(disk_uevent); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 16178a9..7e9660e 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -204,25 +204,6 @@ static inline dev_t disk_devt(struct gendisk *disk) void disk_uevent(struct gendisk *disk, enum kobject_action action); -/* - * Smarter partition iterator without context limits. - */ -#define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */ -#define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */ -#define DISK_PITER_INCL_EMPTY_PART0 (1 << 3) /* include empty partition 0 */ - -struct disk_part_iter { - struct gendisk *disk; - struct block_device *part; - unsigned long idx; - unsigned int flags; -}; - -extern void disk_part_iter_init(struct disk_part_iter *piter, - struct gendisk *disk, unsigned int flags); -struct block_device *disk_part_iter_next(struct disk_part_iter *piter); -extern void disk_part_iter_exit(struct disk_part_iter *piter); - /* block/genhd.c */ extern void device_add_disk(struct device *parent, struct gendisk *disk, const struct attribute_group **groups);