Commit 46f12960 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Andrew Morton
Browse files

drm/i915: Move abs_diff() to math.h

abs_diff() belongs to math.h.  Move it there.  This will allow others to
use it.

[andriy.shevchenko@linux.intel.com: add abs_diff() documentation]
  Link: https://lkml.kernel.org/r/20230804050934.83223-1-andriy.shevchenko@linux.intel.com
[akpm@linux-foundation.org: fix comment, per Randy]
Link: https://lkml.kernel.org/r/20230803131918.53727-1-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org> # tty/serial
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> # gpu/ipu-v3
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@gmail.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 84c10951
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
 * DEALINGS IN THE SOFTWARE.
 */

#include <linux/math.h>
#include <linux/string_helpers.h>

#include "i915_reg.h"
+0 −7
Original line number Diff line number Diff line
@@ -29,13 +29,6 @@

#include "intel_wakeref.h"

/*FIXME: Move this to a more appropriate place. */
#define abs_diff(a, b) ({			\
	typeof(a) __a = (a);			\
	typeof(b) __b = (b);			\
	(void) (&__a == &__b);			\
	__a > __b ? (__a - __b) : (__b - __a); })

enum tc_port;
struct drm_i915_private;
struct intel_atomic_state;
+7 −8
Original line number Diff line number Diff line
@@ -7,7 +7,10 @@

#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/math.h>

#include <video/imx-ipu-image-convert.h>

#include "ipu-prv.h"

/*
@@ -543,7 +546,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
		unsigned int in_pos;
		unsigned int in_pos_aligned;
		unsigned int in_pos_rounded;
		unsigned int abs_diff;
		unsigned int diff;

		/*
		 * Tiles in the right row / bottom column may not be allowed to
@@ -575,15 +578,11 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
		    (in_edge - in_pos_rounded) % in_burst)
			continue;

		if (in_pos < in_pos_aligned)
			abs_diff = in_pos_aligned - in_pos;
		else
			abs_diff = in_pos - in_pos_aligned;

		if (abs_diff < min_diff) {
		diff = abs_diff(in_pos, in_pos_aligned);
		if (diff < min_diff) {
			in_seam = in_pos_rounded;
			out_seam = out_pos;
			min_diff = abs_diff;
			min_diff = diff;
		}
	}

+1 −6
Original line number Diff line number Diff line
@@ -222,16 +222,11 @@ static inline int calculate_baud_abs_diff(struct uart_port *port,
				unsigned int baud, unsigned int mode)
{
	unsigned int n = port->uartclk / (mode * baud);
	int abs_diff;

	if (n == 0)
		n = 1;

	abs_diff = baud - (port->uartclk / (mode * n));
	if (abs_diff < 0)
		abs_diff = -abs_diff;

	return abs_diff;
	return abs_diff(baud, port->uartclk / (mode * n));
}

/*
+1 −6
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/fb.h>
#include <linux/math.h>
#include <linux/svga.h>
#include <asm/types.h>
#include <asm/io.h>
@@ -372,12 +373,6 @@ EXPORT_SYMBOL(svga_get_caps);
 *  F_VCO = (F_BASE * M) / N
 *  F_OUT = F_VCO / (2^R)
 */

static inline u32 abs_diff(u32 a, u32 b)
{
	return (a > b) ? (a - b) : (b - a);
}

int svga_compute_pll(const struct svga_pll *pll, u32 f_wanted, u16 *m, u16 *n, u16 *r, int node)
{
	u16 am, an, ar;
Loading