[PATCH] aoe: Use min() to simplify code in probe()

wangyufei posted 1 patch 3 months, 2 weeks ago
drivers/block/aoe/aoecmd.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH] aoe: Use min() to simplify code in probe()
Posted by wangyufei 3 months, 2 weeks ago
Use min() to simplify probe() and improve its readability.

Signed-off-by: wangyufei <wangyufei@vivo.com>
---
 drivers/block/aoe/aoecmd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 6298f8e27..d6fd83245 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -16,6 +16,7 @@
 #include <net/net_namespace.h>
 #include <linux/unaligned.h>
 #include <linux/uio.h>
+#include <linux/minmax.h>
 #include "aoe.h"
 
 #define MAXIOC (8192)	/* default meant to avoid most soft lockups */
@@ -607,10 +608,7 @@ probe(struct aoetgt *t)
 	ata_rw_frameinit(f);
 	skb = f->skb;
 	for (frag = 0, n = f->iter.bi_size; n > 0; ++frag, n -= m) {
-		if (n < PAGE_SIZE)
-			m = n;
-		else
-			m = PAGE_SIZE;
+		m = min(n, PAGE_SIZE);
 		skb_fill_page_desc(skb, frag, empty_page, 0, m);
 	}
 	skb->len += f->iter.bi_size;
-- 
2.39.0