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_ } }, \