Skip to contentSkip to conversation

dma-buf: heaps: use max3 in dma_heap_ioctl

PATCH RESEND In review Thorsten Blum 2 participants 3 messages May 17 – Jun 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 dma-buf: heaps: use max3 in dma_heap_ioctl

Replace two nested max() calls with a single max3() in dma_heap_ioctl().

---
Changes in v2:
- Include minmax.h as suggested by T.J. Mercier
- v1: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/dma-buf/dma-heap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma-buf/dma-heap.c +2 -1
index ac5f8685a649..d49188893608 100644
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/list.h>
+#include <linux/minmax.h>
 #include <linux/nospec.h>
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
@@ -153,7 +154,7 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
 		in_size = 0;
 	if ((ucmd & kcmd & IOC_OUT) == 0)
 		out_size = 0;
-	ksize = max(max(in_size, out_size), drv_size);
+	ksize = max3(in_size, out_size, drv_size);
 
 	/* If necessary, allocate buffer for ioctl argument */
 	if (ksize > sizeof(stack_kdata)) {
#1 lore raw

Gentle ping?

Quoted 33 lines · Thorsten Blum

Replace two nested max() calls with a single max3() in dma_heap_ioctl().

---
Changes in v2:
- Include minmax.h as suggested by T.J. Mercier
- v1: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/dma-buf/dma-heap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma-buf/dma-heap.c +2 -1
index ac5f8685a649..d49188893608 100644
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/list.h>
+#include <linux/minmax.h>
 #include <linux/nospec.h>
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
@@ -153,7 +154,7 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
 		in_size = 0;
 	if ((ucmd & kcmd & IOC_OUT) == 0)
 		out_size = 0;
-	ksize = max(max(in_size, out_size), drv_size);
+	ksize = max3(in_size, out_size, drv_size);
 
 	/* If necessary, allocate buffer for ioctl argument */
 	if (ksize > sizeof(stack_kdata)) {
maintainer
#2 lore raw

Hello Thorsten,

Quoted 8 lines · Thorsten Blum

Gentle ping?

Quoted 4 lines · Thorsten Blum

Replace two nested max() calls with a single max3() in dma_heap_ioctl().

Apologies for the delay; its now pushed to drm-misc-next.

Quoted 27 lines
Quoted 27 lines

---
Changes in v2:
- Include minmax.h as suggested by T.J. Mercier
- v1: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/dma-buf/dma-heap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma-buf/dma-heap.c +2 -1
index ac5f8685a649..d49188893608 100644
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/list.h>
+#include <linux/minmax.h>
 #include <linux/nospec.h>
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
@@ -153,7 +154,7 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
              in_size = 0;
      if ((ucmd & kcmd & IOC_OUT) == 0)
              out_size = 0;
-     ksize = max(max(in_size, out_size), drv_size);
+     ksize = max3(in_size, out_size, drv_size);
 
Quoted 2 lines

drivers/dma-buf/dma-heap.c static long dma_heap_ioctl(struct file *file, unsigned int ucmd, · line 160

Quoted 2 lines
drivers/dma-buf/dma-heap.c +0 -0
      /* If necessary, allocate buffer for ioctl argument */
      if (ksize > sizeof(stack_kdata)) {

Best,
Sumit.