From patchwork Fri Nov 11 12:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 624456 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E478C4332F for ; Fri, 11 Nov 2022 12:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233788AbiKKMPA (ORCPT ); Fri, 11 Nov 2022 07:15:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232968AbiKKMO7 (ORCPT ); Fri, 11 Nov 2022 07:14:59 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9BD532C0; Fri, 11 Nov 2022 04:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668168898; x=1699704898; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4wRoo7N3PTMuyyFIGGkVMosd0G1YfaK6CY2wTW3dWT4=; b=lkRAXUfpN0lZBBtBTw3+AtfLYQiYCq8bQnGX6GKF574/EjTD2+5vsOO0 x0k7a8xJvpae8GIDIKFJZQCCbgYDyrTOO7PGBK7H8Eu5hrj4cl7XsgR6f 7VUDd5jJIllHDw4tQOi6SGqJvjCcWI6r7ee7XPFoVk/j2G0E0nbmHAE/4 Z6uezAod5MoJJmaoyq44W3d++YJa90D6QqAExHhRGVzpyFKFD8SGxka0R Rsu8rfZgJdo9bA5W47lDCx6Aclc1zl5OGx1UMK+gxfH4HO232Re/u/+D0 nGldqSZ1of7VXsaX2flva52UJkJ/ScHlZX6bIB6NHc9rdVbEW/IkqeSJl g==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="291990239" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="291990239" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 04:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="639997733" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="639997733" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 11 Nov 2022 04:14:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6DC32155; Fri, 11 Nov 2022 14:15:20 +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" , Greg Kroah-Hartman Subject: [PATCH v2 1/2] device property: Get rid of __PROPERTY_ENTRY_ARRAY_EL*SIZE*() Date: Fri, 11 Nov 2022 14:15:17 +0200 Message-Id: <20221111121518.44145-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- v2: rebased on latest Linux Next, fixed anon union assignment 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 5d840299146d..aa58d4e8a21c 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -12,6 +12,7 @@ #include #include +#include #include struct device; @@ -311,24 +312,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_) \ @@ -340,9 +331,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_)) @@ -360,7 +354,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 11 12:15:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 623836 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D7C5C433FE for ; Fri, 11 Nov 2022 12:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233725AbiKKMPA (ORCPT ); Fri, 11 Nov 2022 07:15:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233338AbiKKMO7 (ORCPT ); Fri, 11 Nov 2022 07:14:59 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E7C5B5A9; Fri, 11 Nov 2022 04:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668168898; x=1699704898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yWRgWmi8NjhGKKd/wqtAvGh6FPQuBCvnh+N8Hl3B3To=; b=mB5QFE2SYpIEg5wowOPOxSIvvJUzxiGDlIq1GATn66oXEFL3kgJqrwMK tNx5Dp+SYDgYsQVmo2SgTdRVL5+MXdT2xrxt2Jnchjs6LkUxNuCjEeFgC LplHCxX2ssH4MxZpnvy/g/KA71Q9PjN7ScneAtxM5OmlAU+3fe04kQN1I 1zK12bNoORbap6azk5/R+vgIowxF9PeL9Dqp9WByRLc1RGxwrLKHqsCq4 sswhQBsxNWF8+W/8smoyiXUdP2JYMLk4ztfMiQ2zgPiwp4qCm5z9FbcPA bRA4hgLPrxiBDmoNBbn8alhQm7veWLfZ5fSerRxtn8Pdk9w3fTc2kd/FS A==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="309212355" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="309212355" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 04:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="670730485" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="670730485" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 11 Nov 2022 04:14:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7B5F7F7; Fri, 11 Nov 2022 14:15:20 +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" , Greg Kroah-Hartman Subject: [PATCH v2 2/2] device property: Move PROPERTY_ENTRY_BOOL() a bit down Date: Fri, 11 Nov 2022 14:15:18 +0200 Message-Id: <20221111121518.44145-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221111121518.44145-1-andriy.shevchenko@linux.intel.com> References: <20221111121518.44145-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- v2: rebased on latest Linux Next include/linux/property.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/property.h b/include/linux/property.h index aa58d4e8a21c..b8357397242b 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -330,6 +330,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_, \ @@ -371,12 +372,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_, \ @@ -385,9 +380,14 @@ 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); bool device_dma_supported(const struct device *dev);