Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7028430rwi; Mon, 24 Oct 2022 08:59:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM55iM8KEvHksR/VoaYBRMQGq4TT5yr95xrXwKrIA4t7cbsyz2HEJiSMG3LqZVf/62TY6/pH X-Received: by 2002:aa7:c302:0:b0:461:85d7:b82 with SMTP id l2-20020aa7c302000000b0046185d70b82mr11281912edq.354.1666627180893; Mon, 24 Oct 2022 08:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627180; cv=none; d=google.com; s=arc-20160816; b=p2NF8n538mEcK3k0uttm695cecpbq5k+ge3SKfGNn4L6HaP2sA5WuGOP/9ZySGYj2A plM69mXksoOIQhRsrxpOtyR2ZOcCoXjq9YH+CKKfHRkgA1tgEAyOn7LMpIirQWh6zltu SyVy1mEj5O0wHp/u86nj/J1ie9vvBonJB4zhHpA+b9aKgWeSBdsS0cIrlmaWtTZIGkbC TxJaGLnOGzGWimTXjGbv0D+ARf0tW6CWpX+4cRVMQUGfya/GDGZRKOo5NePK0JWaNdEB hlIN2vqU9empwuXYHK8BmxaASU25cuGobZOgf2fFubXPSzshu68HPQ9725hOmw/A/x9q hNqg== 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:date:subject:cc:to:from :dkim-signature; bh=EyvlQZdvuD23TDjlBP1kR3iHPRTaVvqMk687cZskHEg=; b=ucWd5uUjDQHqq3T6DB9q9oWSByHJBlgbEGKfe5ZaSr3nMOJQlY2GGgBLWU33qauohg toCJalcycCxKSKzLxwkKXIHgUShH8ru5xUngT+feCFxnpFomZMCXIGG9HiZoNtfhfoxK bzK1kHNMm68j5I7TA/cI3b4SAmxuGsLIZcRZYCuFd9UqOvS9jLCBR0MvB70GYN5alDGt sXxaCKctxGl38fOEwxYiEO+FNCsdNOW3VhPNtL9C0iUmeH4mZ5znxe/w6DqpII4DW4FF 0Zq8KVOtnj7D8+WyN/Sl0ENgHgQFEFoXUMbPG4vvnAEBhpaXBJLbtm6j6ijYfBxoeuDb kL/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jZRJCgO2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id et11-20020a056402378b00b0045d5a712e82si82953edb.586.2022.10.24.08.59.16; Mon, 24 Oct 2022 08:59:40 -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=@intel.com header.s=Intel header.b=jZRJCgO2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231916AbiJXPWN (ORCPT + 99 others); Mon, 24 Oct 2022 11:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231522AbiJXPVd (ORCPT ); Mon, 24 Oct 2022 11:21:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1062DC06A6 for ; Mon, 24 Oct 2022 07:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666620322; x=1698156322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ILbdB+RzuchUOaY6BHrudvHVo6rj5y46FZuOl8iY9NA=; b=jZRJCgO2/AvAX49jgMEPCwtTPw3oSPO76bm84xi6V+feh3z6nSAfJgOY JflJvA1hJxEiSQPjM5HfA7u4iYLgyUc9yEuae5fuNT1dzUyy9SclMxSX9 sUlyDjn9U7z/BcvehQJnTtWYzFMVNJRXZndj9dJtbloPS185c9k+VFcEq LmAZQd63u6x/f8KOYHz035bkqG3d/bpVVn04zplpZ80bYv9br8wITzOEr X8GyP/dX4Emx2Xo88FM124+vO4B6YMcmmu54fQ1HSN+sJRmbuXxjWoT++ nq61RnUs14F21yLTxoaJvm80wiefVMz0+HckKJbD0K1UzpVAV3hS7xKiZ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="309101790" X-IronPort-AV: E=Sophos;i="5.95,209,1661842800"; d="scan'208";a="309101790" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 06:24:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="806302275" X-IronPort-AV: E=Sophos;i="5.95,209,1661842800"; d="scan'208";a="806302275" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 24 Oct 2022 06:24:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5139E6DA; Mon, 24 Oct 2022 16:24:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Ingo Molnar , linux-kernel@vger.kernel.org Cc: Andrew Morton Subject: [rft, PATCH v1 4/4] kernel.h: Split out ARRAY_SZIE() Date: Mon, 24 Oct 2022 16:24:34 +0300 Message-Id: <20221024132434.47057-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221024132434.47057-1-andriy.shevchenko@linux.intel.com> References: <20221024132434.47057-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 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 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 kernel.h is being used as a dump for all kinds of stuff for a long time. ARRAY_SIZE() is used in many drivers without need of the full kernel.h dependency train with it. Here is the attempt on cleaning it up by splitting out ARRAY_SIZE(). Signed-off-by: Andy Shevchenko --- include/linux/array_size.h | 13 +++++++++++++ include/linux/kernel.h | 8 +------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 include/linux/array_size.h diff --git a/include/linux/array_size.h b/include/linux/array_size.h new file mode 100644 index 000000000000..c9cdba26555f --- /dev/null +++ b/include/linux/array_size.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_ARRAY_SIZE_H +#define _LINUX_ARRAY_SIZE_H + +#include + +/** + * ARRAY_SIZE - get the number of elements in array @arr + * @arr: array to be sized + */ +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + +#endif /* _LINUX_ARRAY_SIZE_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 7e9612de01b8..011eab2b0e93 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,12 +46,6 @@ */ #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) -/** - * ARRAY_SIZE - get the number of elements in array @arr - * @arr: array to be sized - */ -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) - #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL) #define u64_to_user_ptr(x) ( \ -- 2.35.1