From patchwork Fri Nov 4 15:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 15648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp488848wru; Fri, 4 Nov 2022 08:56:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fV9PHuUA3S0lGDObLMLXvK5mm5F9WzpOfv/yFRSN5VvOYnMKI6a2tVnwGdkuyVZ5fwL46 X-Received: by 2002:a17:906:fe45:b0:788:15a5:7495 with SMTP id wz5-20020a170906fe4500b0078815a57495mr35470685ejb.633.1667577369159; Fri, 04 Nov 2022 08:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667577369; cv=none; d=google.com; s=arc-20160816; b=abYfYrLzdyeosU64UzaMZPup9lPYlVoihwl7f8rplvmZhsho/pgOF4+Az60yebFcn9 UInTto3EjJIAxLWPFJpF4IDITCIMhWEuszylr/0WhCY+feCEbPMBbwhVHppAELKuDrtZ 2Rg2fPjGvHl5QNrVxoqPwF3znlWmpPvNz4sUIz3IJyJOhwiTfzV33F8G7CuPd2uO1p3o Y+mn5rBBHC5mJ3lMykAYV1oJAXwUSHMMlvht7DM6m7EibcOIdUKsYZ2y99sCYSBfCDiy tAkLHaP61GhHoOTwO3YDwx9Yo3JueBvRwVsHlSRykYvcrc+67y3pRVDrEq0OXfMeoOS0 Vx5Q== 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=utMfXun6gqMvjMgFJ/pmisXfwveSzS0GqUb9Dha1ILo=; b=D/2TE6+ksnQblgxgPDsM474IbGEgHsY8gTW4anbU4wyHMZnTKifBK2P0afzx5f2Lrf 0DPy9UiPvuYfC8TEbZu3FlCwv18vTl4ntzKdcWEZzgO/fx0udXYOeHm4+q0nZxeMxfHl N5/vqvnlmgKYMMrHLHjNqpWdmk9QZ2r93ppKmxIMpajJFMhNZ0yoi0U82ZXrnwzpXq7A nxyJKDhWgYJLh0vXtEufmZNcIxF7ekTRxYQJgphvLXGTpaLbscqqXFeYo8tmNcmFnuSV tCVRIyHLkcqfoc9cOeCDmR1oiu6qO5YOoi2VTsZoIEaZ/dd634os3a/MPEoqAcrHczhd oDMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="AjxD/W7Y"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa3-20020a1709076d0300b0078d85177210si5650954ejc.756.2022.11.04.08.55.45; Fri, 04 Nov 2022 08:56:09 -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="AjxD/W7Y"; 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 S232094AbiKDPs4 (ORCPT + 99 others); Fri, 4 Nov 2022 11:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbiKDPsp (ORCPT ); Fri, 4 Nov 2022 11:48:45 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 863733206F; Fri, 4 Nov 2022 08:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667576915; x=1699112915; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Xla2swd4QMnSDMynVbVtEHhVjw6ggpJidpVuDm6dIHA=; b=AjxD/W7YbChPmEHRcWjw2lE8aleEDi8yjnFFRINGuNxekTyQEBd546Rj Erc3wctdFXQ1mO8WeX7jnkQPav5Yckfu9/B0m7dJlfDFTp3QspBp7Lhpl eWBRkz5IboAPcHzu+65GrvLY9Pc7bnKjBuXHL8cj35sSX8f7CuxGWqkaA ql7lfjiVBTDh2Q9D/fEbs35IqCOCh0iSadt3YsI8R5B+znI6osUMUPQuU 2yj/XBA5uWQl5bmpcJepbmmBsDd3Ur2aK8WIDiPEofyql4wZWkxr39gjQ 0kmwX/F6NwzAL+v9j7CXvR1fbZ2vgpjBo04rh7soDxBeNpIpFHlkRqZbP A==; X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="293325440" X-IronPort-AV: E=Sophos;i="5.96,137,1665471600"; d="scan'208";a="293325440" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 08:48:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="724394198" X-IronPort-AV: E=Sophos;i="5.96,137,1665471600"; d="scan'208";a="724394198" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 04 Nov 2022 08:48:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D97E1F7; Fri, 4 Nov 2022 17:48:51 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" Subject: [PATCH v1 1/2] device property: Get rid of __PROPERTY_ENTRY_ARRAY_EL*SIZE*() Date: Fri, 4 Nov 2022 17:48:48 +0200 Message-Id: <20221104154849.35177-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748581607819525704?= X-GMAIL-MSGID: =?utf-8?q?1748581607819525704?= First of all, _ELEMENT_SIZE() repeats existing sizeof_field() macro. Second, usage of _ARRAY_ELSIZE_LEN() adds unnecessary indirection to the data layout. It's more understandable when the data structure is placed explicitly. That said, get rid of those macros by replacing them with the existing helper and explicit data structure layout. Signed-off-by: Andy Shevchenko --- include/linux/property.h | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/include/linux/property.h b/include/linux/property.h index ccc73399c9ea..df3f16d23d0c 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -12,6 +12,7 @@ #include #include +#include #include struct device; @@ -310,24 +311,14 @@ struct property_entry { * crafted to avoid gcc-4.4.4's problems with initialization of anon unions * and structs. */ - -#define __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_) \ - sizeof(((struct property_entry *)NULL)->value._elem_[0]) - -#define __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, _elsize_, _Type_, \ - _val_, _len_) \ -(struct property_entry) { \ - .name = _name_, \ - .length = (_len_) * (_elsize_), \ - .type = DEV_PROP_##_Type_, \ - { .pointer = _val_ }, \ +#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_) \ +(struct property_entry) { \ + .name = _name_, \ + .length = (_len_) * sizeof_field(struct property_entry, value._elem_[0]), \ + .type = DEV_PROP_##_Type_, \ + { .pointer = _val_ }, \ } -#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)\ - __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, \ - __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \ - _Type_, _val_, _len_) - #define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_) \ __PROPERTY_ENTRY_ARRAY_LEN(_name_, u8_data, U8, _val_, _len_) #define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_) \ @@ -339,9 +330,12 @@ struct property_entry { #define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_) \ __PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_) #define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_) \ - __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, \ - sizeof(struct software_node_ref_args), \ - REF, _val_, _len_) +(struct property_entry) { \ + .name = _name_, \ + .length = (_len_) * sizeof(struct software_node_ref_args), \ + .type = DEV_PROP_##_Type_, \ + .pointer = _val_, \ +} #define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \ PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) @@ -359,7 +353,7 @@ struct property_entry { #define __PROPERTY_ENTRY_ELEMENT(_name_, _elem_, _Type_, _val_) \ (struct property_entry) { \ .name = _name_, \ - .length = __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \ + .length = sizeof_field(struct property_entry, value._elem_[0]), \ .is_inline = true, \ .type = DEV_PROP_##_Type_, \ { .value = { ._elem_[0] = _val_ } }, \ From patchwork Fri Nov 4 15:48:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 15647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp488779wru; Fri, 4 Nov 2022 08:56:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7wZpL+FTdmkd2W96UlP7orgb//1HABoSb4kULn9HX2MZMOavsF7c0ujD2U48nCH/fvhOP8 X-Received: by 2002:a17:906:5dda:b0:78d:ed96:2127 with SMTP id p26-20020a1709065dda00b0078ded962127mr33776217ejv.373.1667577362008; Fri, 04 Nov 2022 08:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667577362; cv=none; d=google.com; s=arc-20160816; b=0H0QFuEIp2lWNgZVojaRYCaiLz8DN8u99sWca/NHroMMF0Nw+LOKTzYDRUHc4auqIK 5H2aFbNa8kqCKdbcAJi45xpOSIKN7g2YnAxgVC8oTIJMzcS+K7tcHcNEYtZicDqvNy5y FBDvNffwwSP4UBbr89BRYeHlz+27NLt65GZDPv7fX0Q8oqquCjZhNmY+8VC/vtDoEyIR 8h9b7pzDj4naPOkHQ3cHy7OdUpiXPMUs1Yfk84bu0OFq5ciyOBh1Qce0SS5iRfdkQmZJ v7Qejbzooh0I14kiqFVRWe4HGG0SWYG+8ssxLriHTr6jBE6ws7x7qJWVYTfcRBco+KXJ Jxbw== 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=WLoKmAQ1v6x26K7tV+EHkUWMOCAhT5ioESZnhmpkvyI=; b=fYS/qTOvn00LRdahrcTJJaJRoK/LOs4Q82zdpQQP01ABPjWdBcQ8TIf0yz1Q503BU6 akAxeBw4ijkwHWFqe47SFTlRr4kiPX6QTpUn1Dg/8oHmy9Oz2e20KceOkx0D8EvmsXh8 FHOxJ7fcpxtbJ7ZwwAYH9cM73dPH5yfZY7kSLhFxNMgPR9z3QxWpZoKwx6A4kGp57G5j gCvPm+E++fMGWc6/jZPG6NVNRboNoacxczto90GSbR1KI25lsczfInlwYNVNuqprFzFI B2AKKTi1lD7VJKgUxnbzxQpA25T66AtdROhl9tFEZQAumgPgazGcUAJYm3ISETSujNfv l1ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iLuyocZL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv9-20020a17090760c900b007877eb5687csi6227534ejc.249.2022.11.04.08.55.37; Fri, 04 Nov 2022 08:56:01 -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=iLuyocZL; 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 S231775AbiKDPsx (ORCPT + 99 others); Fri, 4 Nov 2022 11:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231852AbiKDPsp (ORCPT ); Fri, 4 Nov 2022 11:48:45 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 770B62EF7B; Fri, 4 Nov 2022 08:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667576913; x=1699112913; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A2gdfuPaRpBvqBCsNXkl/QJS5l+GX3I2znrraPGDPzI=; b=iLuyocZLWkUwVUQDdrNFTWyoYDH5nmRnj0LhmyLzzKR1YaHYefhF+Ihv nR6OrRTUpAJk5Xtw0x1fMYGJFq7vJsJsODWsLzW97asLNOFyG4nsPtSBf ZZkm44bAZmuft5C2zAIz0CQqPptJdF/BMMpTQyTL/+HC7eS1Hv3kGx6xP SBqbc7cJap2ouc/0nAviKbacRP19PtFo/Y9DlgQzgfxRvF3XTV/QFTiwv dj4soaZW584nTQjQgM62gUmhI2stjzjVTsoohD5Jx02geUEDr7WQrH7BU VXa9OVG9GaHWwKS0MbevwNroMVvbiv06AkoIy/hvXophPblWS3vo+6K1a Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="293325439" X-IronPort-AV: E=Sophos;i="5.96,137,1665471600"; d="scan'208";a="293325439" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 08:48:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="724394199" X-IronPort-AV: E=Sophos;i="5.96,137,1665471600"; d="scan'208";a="724394199" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 04 Nov 2022 08:48:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id EA6F8D0; Fri, 4 Nov 2022 17:48:51 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" Subject: [PATCH v1 2/2] device property: Move PROPERTY_ENTRY_BOOL() a bit down Date: Fri, 4 Nov 2022 17:48:49 +0200 Message-Id: <20221104154849.35177-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221104154849.35177-1-andriy.shevchenko@linux.intel.com> References: <20221104154849.35177-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748581600341755936?= X-GMAIL-MSGID: =?utf-8?q?1748581600341755936?= Let's order ARRAY and non-ARRAY macros in the same way. The PROPERTY_ENTRY_BOOL() is special, move it a bit down in the code so it won't break ordering of the rest. Signed-off-by: Andy Shevchenko --- include/linux/property.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/property.h b/include/linux/property.h index df3f16d23d0c..20b4a2edf28d 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -329,6 +329,7 @@ struct property_entry { __PROPERTY_ENTRY_ARRAY_LEN(_name_, u64_data, U64, _val_, _len_) #define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_) \ __PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_) + #define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_) \ (struct property_entry) { \ .name = _name_, \ @@ -370,12 +371,6 @@ struct property_entry { #define PROPERTY_ENTRY_STRING(_name_, _val_) \ __PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, _val_) -#define PROPERTY_ENTRY_BOOL(_name_) \ -(struct property_entry) { \ - .name = _name_, \ - .is_inline = true, \ -} - #define PROPERTY_ENTRY_REF(_name_, _ref_, ...) \ (struct property_entry) { \ .name = _name_, \ @@ -384,6 +379,12 @@ struct property_entry { { .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), }, \ } +#define PROPERTY_ENTRY_BOOL(_name_) \ +(struct property_entry) { \ + .name = _name_, \ + .is_inline = true, \ +} + struct property_entry *property_entries_dup(const struct property_entry *properties); void property_entries_free(const struct property_entry *properties);