From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EF67C001DE for ; Fri, 4 Aug 2023 15:57:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78D2B10E72F; Fri, 4 Aug 2023 15:57:08 +0000 (UTC) X-Greylist: delayed 302 seconds by postgrey-1.36 at gabe; Fri, 04 Aug 2023 15:57:05 UTC Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAB0110E72F for ; Fri, 4 Aug 2023 15:57:04 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-76-qm7ktrQ9OHKl6gBtn9SNaQ-1; Fri, 04 Aug 2023 16:50:20 +0100 X-MC-Unique: qm7ktrQ9OHKl6gBtn9SNaQ-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 4 Aug 2023 16:50:18 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 4 Aug 2023 16:50:18 +0100 From: David Laight To: 'Andrew Morton' , Andy Shevchenko Thread-Topic: [PATCH v4 1/1] drm/i915: Move abs_diff() to math.h Thread-Index: AQHZxi9qpYx0cq9pFEOYLGUrdsezOq/aSRTQ Date: Fri, 4 Aug 2023 15:50:18 +0000 Message-ID: <7c1885528d474c719bb4d4e0cf985753@AcuMS.aculab.com> References: <20230803131918.53727-1-andriy.shevchenko@linux.intel.com> <20230803102446.8edf94acc77e81ab2e09cee3@linux-foundation.org> In-Reply-To: <20230803102446.8edf94acc77e81ab2e09cee3@linux-foundation.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Intel-gfx] [PATCH v4 1/1] drm/i915: Move abs_diff() to math.h X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-fbdev@vger.kernel.org" , Philipp Zabel , "linux-serial@vger.kernel.org" , Jani Nikula , Greg Kroah-Hartman , Rasmus Villemoes , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Rodrigo Vivi , "intel-gfx@lists.freedesktop.org" , Daniel Vetter , David Airlie , Jiri Slaby , Alexey Dobriyan , Helge Deller Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Andrew Morton > Sent: 03 August 2023 18:25 >=20 > On Thu, 3 Aug 2023 16:19:18 +0300 Andy Shevchenko wrote: >=20 > > abs_diff() belongs to math.h. Move it there. > > This will allow others to use it. > > > > ... > > > > --- a/include/linux/math.h > > +++ b/include/linux/math.h > > @@ -155,6 +155,13 @@ __STRUCT_FRACT(u32) > > =09__builtin_types_compatible_p(typeof(x), unsigned type),=09=09\ > > =09({ signed type __x =3D (x); __x < 0 ? -__x : __x; }), other) > > > > +#define abs_diff(a, b) ({=09=09=09\ > > +=09typeof(a) __a =3D (a);=09=09=09\ > > +=09typeof(b) __b =3D (b);=09=09=09\ > > +=09(void)(&__a =3D=3D &__b);=09=09=09\ > > +=09__a > __b ? (__a - __b) : (__b - __a);=09\ > > +}) >=20 > Can we document it please? >=20 > Also, the open-coded type comparison could be replaced with __typecheck()= ? >=20 > And why the heck isn't __typecheck() in typecheck.h, to be included by > minmax.h. And why would you want to use __typecheck() anyway? It pretty much isn't the test you are looking for. If you are trying to explicitly avoid converting negative value to large positive unsigned ones then you want something like: =09is_signed_type(typeof(a)) =3D=3D is_signed_type(typeof(b)) but it isn't even that simple :-) =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)