Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2545643rwo; Thu, 3 Aug 2023 10:57:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlFxWYdwEMMhUDwF9mIRXRc4PRz3ruPKTPhgp/H9cmoJWjsK7AfjZlqJDAWvvVWXwnRQDg7C X-Received: by 2002:a2e:7003:0:b0:2b9:f1ad:94f5 with SMTP id l3-20020a2e7003000000b002b9f1ad94f5mr7587823ljc.40.1691085420461; Thu, 03 Aug 2023 10:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691085420; cv=none; d=google.com; s=arc-20160816; b=qd3M0ti8xk6WL/9IiUnMpUKOq0VN4Gg1xQ9q6kKeogeabHEOTNsvDAWCJbvslhwXE6 aVn0c9z6oG1s9Ac+PeE/ThfmHLk9J641wcdwizl3OSixQSgSSiPwGeaPzr5dP36tgYPs yvB0wUDHZWq7EoXcBKicGs1MQsm8nqMPJp8t4ysVPnAnIF9cv1BYwVHPPRHqpzh2o9ah eExCGwvCLb26Eoz9Fy/BB7Oqi8uX7wTiZep2uOE6LhD6HyWCUhbjKI98dFE8kV4JuSiz oi5UtpOnEmswAkhsxuh6Sqh/fpXNst9L900OxbeFUk++1y0z35hHaXmkNUL30cQraHKp z7bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=68qI46/SQDC6vCq1dljNFBZgIsl6M44JfKG7mrpt50E=; fh=Z47XXiblquPWAu2Oh3BgdK5+pu83LkPjqUNcApJbJ+c=; b=UUR/Nn8UixZ38g2WFqOu2hgGFHRJyTaL5UkQkjzoJCW1PF+K3/nih8KbsXeBpnhh3w lc+rnp3fTOxleDpnDyhNqUzLjkqm531+VnXj+c5dplx6EGLvYlO1xeS7sj9SHKgjfF5M 6g44T6/4xMwZEwwRYCeHIKef1cIrv9blTIO3hp97T78R6elIRXKCdHRsr5DnfyHoRpps eR0UfgwvrsrQvkh/YQBnQuiv+tmkz2pfk/5sHG16CRvAegbRnHuQFabhxbtMTSwZpiUj Trh2i+k9PqL0fWzYAfQ77eGn0rvUQBSTs6XOSLF++wCOquPVMPgTdRlby+mR7ywPZYfT 7Rpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=eMUBImiK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a1709060ad100b0096ae15237a1si177902ejf.486.2023.08.03.10.56.30; Thu, 03 Aug 2023 10:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=eMUBImiK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234578AbjHCRYv (ORCPT + 99 others); Thu, 3 Aug 2023 13:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbjHCRYt (ORCPT ); Thu, 3 Aug 2023 13:24:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E686430C2; Thu, 3 Aug 2023 10:24:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83BD261E4A; Thu, 3 Aug 2023 17:24:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2680EC433C8; Thu, 3 Aug 2023 17:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1691083487; bh=oIo8w6drezvDhvrXgj4j0LpRAgS/qxGC1oMH8Yk1tvw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eMUBImiK3nx9CnEb8dGmTePWdUsS7g5uZigscN46OZefvAG3cHSY2c1TSsAcLKC40 zPxEuHVQWiL5/mNhVTLbA8ihaNKKMYztp8m3nTQYBzC0NmOSQDQIdWjQg3Y7lhAX8W XkhnUZWaEsgnvMagICmJ859HiRc9GHDBYBWe6kXc= Date: Thu, 3 Aug 2023 10:24:46 -0700 From: Andrew Morton To: Andy Shevchenko Cc: Jani Nikula , Imre Deak , Philipp Zabel , Andi Shyti , Jiri Slaby , Greg Kroah-Hartman , Alexey Dobriyan , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-fbdev@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Helge Deller , Rasmus Villemoes Subject: Re: [PATCH v4 1/1] drm/i915: Move abs_diff() to math.h Message-Id: <20230803102446.8edf94acc77e81ab2e09cee3@linux-foundation.org> In-Reply-To: <20230803131918.53727-1-andriy.shevchenko@linux.intel.com> References: <20230803131918.53727-1-andriy.shevchenko@linux.intel.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 Aug 2023 16:19:18 +0300 Andy Shevchenko wrote: > 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) > __builtin_types_compatible_p(typeof(x), unsigned type), \ > ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other) > > +#define abs_diff(a, b) ({ \ > + typeof(a) __a = (a); \ > + typeof(b) __b = (b); \ > + (void)(&__a == &__b); \ > + __a > __b ? (__a - __b) : (__b - __a); \ > +}) Can we document it please? Also, the open-coded type comparison could be replaced with __typecheck()? And why the heck isn't __typecheck() in typecheck.h, to be included by minmax.h. etcetera. Sigh. I'll grab it, but please at least send along some kerneldoc?