linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: break loop when getting target major number in blkdev_show()
@ 2019-02-08 10:22 Chengguang Xu
  0 siblings, 0 replies; only message in thread
From: Chengguang Xu @ 2019-02-08 10:22 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Chengguang Xu

The entry in major_names table has unique major number,
so there is no need to continue to search after getting
target major number in blkdev_show().

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 block/genhd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/genhd.c b/block/genhd.c
index 1dd8fd6613b8..908e3b4399a3 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -324,8 +324,10 @@ void blkdev_show(struct seq_file *seqf, off_t offset)
 
 	mutex_lock(&block_class_lock);
 	for (dp = major_names[major_to_index(offset)]; dp; dp = dp->next)
-		if (dp->major == offset)
+		if (dp->major == offset) {
 			seq_printf(seqf, "%3d %s\n", dp->major, dp->name);
+			break;
+		}
 	mutex_unlock(&block_class_lock);
 }
 #endif /* CONFIG_PROC_FS */
-- 
2.17.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-08 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 10:22 [PATCH] block: break loop when getting target major number in blkdev_show() Chengguang Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).