From patchwork Tue Aug 15 11:35:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 136202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2202764vqi; Sat, 19 Aug 2023 14:31:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFw7LtAtkKjTGseZO3sFN3QrSuHQUF4Jge53mZ/Ey0GnDLhiUGtH9yXQvemcz6TaAxRNnB X-Received: by 2002:a17:903:2346:b0:1bf:148b:58fb with SMTP id c6-20020a170903234600b001bf148b58fbmr4242459plh.20.1692480694818; Sat, 19 Aug 2023 14:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692480694; cv=none; d=google.com; s=arc-20160816; b=e9sHXh0YHxu85MoDTmQ60tbcAcrDOjVnqXdsHhAuSDiWCtGeOQ6ASFnL+B8ewVL0Y9 idiYDiuPYbTN3fa8IAP9trgl2on04Eb3yRYiiz8ilXRbiK6h3GJtx+oAz5lMtr9gpjem bAh55dZqNRpBrcFgCWwt9CqDTj3zUep9xL4dXyYXNCii/eIwwftLAQYbmh05CCe+8OAy g1X4DyY1QOImBLEs8+HcVQxVfOY/JzAKGPmSGKyd/C0wF3eXDf7ekD3GgJB85fVkB7EU mnhwu6xtt2BY3MHpgp4bb+zNxGir9QKUDDtJc6lsNoFFSIh80QmfewH2dA/nxy5SY4Li syMA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Z/GQvhvmACCIEtzZ2+zeFnGS6MosBVIBSus+CO8UZew=; fh=Xi6BF3ir/FUdPHneYRDtH12Jzgn+avj5XWczGBth4xI=; b=pMJ6lgpvmpvYPbDVBbuLK26yhgjcXBa37EprUTnNHLa9Knrr4ZtVYPO7butJZGsD8i QUWT65Ba6FgHCifh9C7nbCQxAnS12jg1IjpKDrRA9oCTUBHd562mM2fGCD6cf9G5E4A7 H6gJJp3uc7DWmaA/hhXmWsij8msp9iG6FEAtMF9EblkUoaN0tSDQ8GaF4pIk3/03AFmz Zdfnyh+C71O6fTpSpHzl5jVf7wHWd7DkxKHwlcv0vo/NM+2m+SsoKIS0J27QxyrNsPtw PeiEXfpDHsF3hkVf+/KZN7q1Hm1H+C4R2w6BsFo9VGdD5RQb/na6jhoLaFXi2WEifKHp 55xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hZ/pvIAs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d13-20020a170902cecd00b001b9ffdd9488si4254806plg.624.2023.08.19.14.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 14:31:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hZ/pvIAs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A7F85DD1CB; Sat, 19 Aug 2023 01:46:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235714AbjHOL1x (ORCPT + 99 others); Tue, 15 Aug 2023 07:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236251AbjHOL1o (ORCPT ); Tue, 15 Aug 2023 07:27:44 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7629E73 for ; Tue, 15 Aug 2023 04:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692098863; x=1723634863; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=c0UQwalrepMpq1VW/SpIyUAEXIcvIN5UafwiPH6RW2c=; b=hZ/pvIAsmLClJV6Kzk3ttcmV0Bc3Ei8z6haN1JzWacazeHKiEqTxHbQm DWcQFX7e75gPCBpRKrZUVZfIZAAFX58wwvrndta583IePG1TF1ttiw1nl 3xoc93MFVs4JC8OnNoUXFZxzICoMJxjHVte+uZJviwt73Y13p8x3JzFO/ /gqJKWZgaSdRDnJlDwe6tVxdX+L/H4yofmEX3n9R7eR3mxrMppWhI2yzN 1pT88weKmNVu81pNQ/RtXGGMNGqc07FqcXPB7NnhtKaIxooTZXDGy/nh5 dqHAuY5kpIzbO6iC59pvhV+kD3gN1eVR0rINfph2IO4D/8nQFDnLWFuip Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="351844540" X-IronPort-AV: E=Sophos;i="6.01,174,1684825200"; d="scan'208";a="351844540" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2023 04:27:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="980338041" X-IronPort-AV: E=Sophos;i="6.01,174,1684825200"; d="scan'208";a="980338041" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 15 Aug 2023 04:27:38 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3C520350; Tue, 15 Aug 2023 14:35:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Herve Codina , Mark Brown , alsa-devel@alsa-project.org Subject: [PATCH v1 1/1] minmax: Deduplicate __unconst_integer_typeof() Date: Tue, 15 Aug 2023 14:35:34 +0300 Message-Id: <20230815113534.10592-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774694637169069563 X-GMAIL-MSGID: 1774694637169069563 It appears that compiler_types.h already have an implementation of the __unconst_integer_typeof() called __unqual_scalar_typeof(). Use it instead of the copy. Signed-off-by: Andy Shevchenko --- As the initial code is in Linux Next via ASoC tree, it's assumed to go via that tree as well. include/linux/minmax.h | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 83aebc244cba..69bbe987fa87 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MINMAX_H #define _LINUX_MINMAX_H +#include #include #include @@ -134,27 +135,6 @@ */ #define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >) -/* - * Remove a const qualifier from integer types - * _Generic(foo, type-name: association, ..., default: association) performs a - * comparison against the foo type (not the qualified type). - * Do not use the const keyword in the type-name as it will not match the - * unqualified type of foo. - */ -#define __unconst_integer_type_cases(type) \ - unsigned type: (unsigned type)0, \ - signed type: (signed type)0 - -#define __unconst_integer_typeof(x) typeof( \ - _Generic((x), \ - char: (char)0, \ - __unconst_integer_type_cases(char), \ - __unconst_integer_type_cases(short), \ - __unconst_integer_type_cases(int), \ - __unconst_integer_type_cases(long), \ - __unconst_integer_type_cases(long long), \ - default: (x))) - /* * Do not check the array parameter using __must_be_array(). * In the following legit use-case where the "array" passed is a simple pointer, @@ -169,13 +149,13 @@ * 'int *buff' and 'int buff[N]' types. * * The array can be an array of const items. - * typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order + * typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order * to discard the const qualifier for the __element variable. */ #define __minmax_array(op, array, len) ({ \ typeof(&(array)[0]) __array = (array); \ typeof(len) __len = (len); \ - __unconst_integer_typeof(__array[0]) __element = __array[--__len]; \ + __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\ while (__len--) \ __element = op(__element, __array[__len]); \ __element; })