Skip to contentSkip to conversation

Staging: media: davinci_vpfe: Convert macro into an inline function

PATCH Superseded Madhumitha Prabakaran 2 participants 3 messages Mar 27, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: media: davinci_vpfe: Convert macro into an inline function

COnvert macro into an inline function in order to maintain Linux kernel coding style based on which the inline function is preferable over the macro.

---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.h   | 5 ++++-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +4 -1
index 174334b53f96..32dce3c95304 100644
@@ -27,7 +27,10 @@
 #include "davinci_vpfe_user.h"
 #include "vpfe_video.h"
 
-#define CEIL(a, b)	(((a) + (b-1)) / (b))
+inline unsigned int ceil(unsigned int a, unsigned int b)
+{
+	return ((a + (b - 1)) / b);
+}
 
 enum ipipe_noise_filter {
 	IPIPE_D2F_1ST = 0,
drivers/staging/media/davinci_vpfe/dm365_resizer.c +2 -2
index 9d726298b406..395c66520932 100644
@@ -386,7 +386,7 @@ resizer_calculate_down_scale_f_div_param(struct device *dev,
 	}
 	o = 10 + (two_power << 2);
 	if (((input_width << 7) / rsz) % 2)
-		o += (((CEIL(rsz, 1024)) << 1) << n);
+		o += ((ceil(rsz, 1024) << 1) << n);
 	h2 = output_width - h1;
 	/* phi */
 	val = (h1 * rsz) - (((upper_h1 - (o - 10)) / two_power) << 8);
@@ -630,7 +630,7 @@ resizer_calculate_normal_f_div_param(struct device *dev, int input_width,
 		val /= rsz << 1;
 		val <<= 1;
 		val += 2;
-		o += ((CEIL(rsz, 1024)) << 1);
+		o += (ceil(rsz, 1024) << 1);
 		h1 = val;
 	}
 	h2 = output_width - h1;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Madhumitha Prabakaran

COnvert macro into an inline function in order to maintain Linux kernel coding style based on which the inline function is preferable over the macro.

---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.h   | 5 ++++-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +0 -0
index 174334b53f96..32dce3c95304 100644

drivers/staging/media/davinci_vpfe/dm365_ipipe.h line 33

Quoted 8 lines
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +4 -1
@@ -27,7 +27,10 @@
 #include "davinci_vpfe_user.h"
 #include "vpfe_video.h"
 
-#define CEIL(a, b)	(((a) + (b-1)) / (b))
+inline unsigned int ceil(unsigned int a, unsigned int b)
+{
+	return ((a + (b - 1)) / b);
+}

You could check around perhaps in kernel.h and see if this already exists.

julia

Quoted 35 lines
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +0 -0
 enum ipipe_noise_filter {
 	IPIPE_D2F_1ST = 0,
drivers/staging/media/davinci_vpfe/dm365_resizer.c +2 -3
index 9d726298b406..395c66520932 100644
@@ -386,7 +386,7 @@ resizer_calculate_down_scale_f_div_param(struct device *dev,
 	}
 	o = 10 + (two_power << 2);
 	if (((input_width << 7) / rsz) % 2)
-		o += (((CEIL(rsz, 1024)) << 1) << n);
+		o += ((ceil(rsz, 1024) << 1) << n);
 	h2 = output_width - h1;
 	/* phi */
 	val = (h1 * rsz) - (((upper_h1 - (o - 10)) / two_power) << 8);
@@ -630,7 +630,7 @@ resizer_calculate_normal_f_div_param(struct device *dev, int input_width,
 		val /= rsz << 1;
 		val <<= 1;
 		val += 2;
-		o += ((CEIL(rsz, 1024)) << 1);
+		o += (ceil(rsz, 1024) << 1);
 		h1 = val;
 	}
 	h2 = output_width - h1;
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190327175648.29538-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw

Quoted 22 lines · Julia Lawall
Quoted 18 lines · Madhumitha Prabakaran

COnvert macro into an inline function in order to maintain Linux kernel coding style based on which the inline function is preferable over the macro.

---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.h   | 5 ++++-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +0 -0
index 174334b53f96..32dce3c95304 100644
@@ -27,7 +27,10 @@
 #include "davinci_vpfe_user.h"
 #include "vpfe_video.h"
 
Quoted 8 lines

drivers/staging/media/davinci_vpfe/dm365_ipipe.h line 33

Quoted 5 lines
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +4 -1
-#define CEIL(a, b)	(((a) + (b-1)) / (b))
+inline unsigned int ceil(unsigned int a, unsigned int b)
+{
+	return ((a + (b - 1)) / b);
+}

You could check around perhaps in kernel.h and see if this already exists.

I can't find any ceil function in the kernel.h, though I can find the function in math.h

Thanks

Quoted 37 lines

julia

Quoted 35 lines
drivers/staging/media/davinci_vpfe/dm365_ipipe.h +0 -0
 enum ipipe_noise_filter {
 	IPIPE_D2F_1ST = 0,
drivers/staging/media/davinci_vpfe/dm365_resizer.c +2 -3
index 9d726298b406..395c66520932 100644
@@ -386,7 +386,7 @@ resizer_calculate_down_scale_f_div_param(struct device *dev,
 	}
 	o = 10 + (two_power << 2);
 	if (((input_width << 7) / rsz) % 2)
-		o += (((CEIL(rsz, 1024)) << 1) << n);
+		o += ((ceil(rsz, 1024) << 1) << n);
 	h2 = output_width - h1;
 	/* phi */
 	val = (h1 * rsz) - (((upper_h1 - (o - 10)) / two_power) << 8);
@@ -630,7 +630,7 @@ resizer_calculate_normal_f_div_param(struct device *dev, int input_width,
 		val /= rsz << 1;
 		val <<= 1;
 		val += 2;
-		o += ((CEIL(rsz, 1024)) << 1);
+		o += (ceil(rsz, 1024) << 1);
 		h1 = val;
 	}
 	h2 = output_width - h1;
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190327175648.29538-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.