* [PATCH v1 1/1] math.h: Document abs_diff()
@ 2023-08-04 5:09 Andy Shevchenko
2023-08-04 5:23 ` Randy Dunlap
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-08-04 5:09 UTC (permalink / raw)
To: Alexey Dobriyan, linux-kernel; +Cc: Andy Shevchenko, Andrew Morton
Initially abs_diff() has lack of documentation. Add it.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/math.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/math.h b/include/linux/math.h
index 336e3e3678e7..dfba59b59998 100644
--- a/include/linux/math.h
+++ b/include/linux/math.h
@@ -155,6 +155,18 @@ __STRUCT_FRACT(u32)
__builtin_types_compatible_p(typeof(x), unsigned type), \
({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
+/**
+ * abs_diff - return absolute value of the difference between the arguments
+ * @a: the first argument
+ * @b: the second argument
+ *
+ * @a and @b has to be of the same type. With this restriction we compare
+ * signed to signed and unsigned to unsigned. The result is the subtraction
+ * the smaller of the two from the bigger, hence result is always a positive
+ * value.
+ *
+ * Return: an absolute value of the difference between the @a and @b.
+ */
#define abs_diff(a, b) ({ \
typeof(a) __a = (a); \
typeof(b) __b = (b); \
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] math.h: Document abs_diff()
2023-08-04 5:09 [PATCH v1 1/1] math.h: Document abs_diff() Andy Shevchenko
@ 2023-08-04 5:23 ` Randy Dunlap
2023-08-04 5:36 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2023-08-04 5:23 UTC (permalink / raw)
To: Andy Shevchenko, Alexey Dobriyan, linux-kernel; +Cc: Andrew Morton
On 8/3/23 22:09, Andy Shevchenko wrote:
> Initially abs_diff() has lack of documentation. Add it.
>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> include/linux/math.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/linux/math.h b/include/linux/math.h
> index 336e3e3678e7..dfba59b59998 100644
> --- a/include/linux/math.h
> +++ b/include/linux/math.h
> @@ -155,6 +155,18 @@ __STRUCT_FRACT(u32)
> __builtin_types_compatible_p(typeof(x), unsigned type), \
> ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
>
> +/**
> + * abs_diff - return absolute value of the difference between the arguments
> + * @a: the first argument
> + * @b: the second argument
> + *
> + * @a and @b has to be of the same type. With this restriction we compare
Preferably s/has/have/.
> + * signed to signed and unsigned to unsigned. The result is the subtraction
> + * the smaller of the two from the bigger, hence result is always a positive
> + * value.
> + *
> + * Return: an absolute value of the difference between the @a and @b.
> + */
> #define abs_diff(a, b) ({ \
> typeof(a) __a = (a); \
> typeof(b) __b = (b); \
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] math.h: Document abs_diff()
2023-08-04 5:23 ` Randy Dunlap
@ 2023-08-04 5:36 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-08-04 5:36 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Alexey Dobriyan, linux-kernel, Andrew Morton
On Thu, Aug 03, 2023 at 10:23:48PM -0700, Randy Dunlap wrote:
> On 8/3/23 22:09, Andy Shevchenko wrote:
...
> > +/**
> > + * abs_diff - return absolute value of the difference between the arguments
> > + * @a: the first argument
> > + * @b: the second argument
> > + *
> > + * @a and @b has to be of the same type. With this restriction we compare
> Preferably s/has/have/.
Thank you! I fixed it locally, I hope Andrew can update this, but if needed
I will send a v2 with the proposed correction.
> > + * signed to signed and unsigned to unsigned. The result is the subtraction
> > + * the smaller of the two from the bigger, hence result is always a positive
> > + * value.
> > + *
> > + * Return: an absolute value of the difference between the @a and @b.
> > + */
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-04 5:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 5:09 [PATCH v1 1/1] math.h: Document abs_diff() Andy Shevchenko
2023-08-04 5:23 ` Randy Dunlap
2023-08-04 5:36 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox