Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5816826rwb; Tue, 22 Nov 2022 05:24:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kOveo7owxunHpQ3/ZmP1Gyr4cLf8jZYY/IzzilunIVpoTZryYKTbP+4A9euk7FEAFJvFo X-Received: by 2002:a17:907:874f:b0:7b5:e91:adf9 with SMTP id qo15-20020a170907874f00b007b50e91adf9mr5929986ejc.277.1669123497076; Tue, 22 Nov 2022 05:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669123497; cv=none; d=google.com; s=arc-20160816; b=nbeapgg7yzuUB7jI13TFHM1m4e9HxqhMcrzlQI7VhaN4g3pvh3rfj/ESCFIEAstsBv 2j1u9F6KGbFU90064H1kqaTQs5sAf5hEruAYRLDQvwflq1i9bqjl5mvcsjJ4JkiadYge UsMZHMgV89gCfg9gjgweGVC1cd3JObsOI2snAOVc74qKYJHujbaw7vef4pkG/8iVfWBi oUoAeED0jO0JIWhDdlrRCsNq7tAAQYaS2IM2tzQlFLG47j3JxlMqMfOLc2iSDjJD1ynt DIwZARUQjrWwtdWxMwPP774C9tQEmEO3VjP2mgzMhPlJ+jfZ3ZdJajEetS/L9OqNRydl CDoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KSf/XKjI1pvIc+mUpWRYgvcYnYq/tifVYYgJsJpX0Sc=; b=XsZZBzhYEILj7HkTVt8s4OZWlvTJyD0Wfxkw7OMGFO1Y6i+8Auc7b4hsqBPHKQbnUI gtJTpxKhE+rX5iVyzMCe2sxHtn0zq9tzal9nlOmiy+kuT+R1VeiVaXVc6VVDOL6ksR9M VvGszWtwfRC89OJBE1z/l1ccHffYbWi+52uHKjS2J+6n2M6syOXw2oz4lGHuxBVf9XV9 zTLIteDA4lwLSMmcdAh5aPnqC0BEj4mq97FqIW03O8bvwqchr/FA+kFVEgqCzzt1WfJZ MG/VUDnsgijFYnIG5wnyzw3+cOsH8BW857XAoVLZck6NDq18Zv0MZUKxeS+QmCjzP2py 73dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MuWiMaLS; 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 xe8-20020a170907318800b007adf3067a4esi13026052ejb.490.2022.11.22.05.24.34; Tue, 22 Nov 2022 05:24:57 -0800 (PST) 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=MuWiMaLS; 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 S233069AbiKVNL2 (ORCPT + 90 others); Tue, 22 Nov 2022 08:11:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233394AbiKVNLS (ORCPT ); Tue, 22 Nov 2022 08:11:18 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D335963B85; Tue, 22 Nov 2022 05:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669122674; x=1700658674; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uDAbUmrJSxyGSM1AaF/SoNBLvIhsZuamrriTLiE8KOs=; b=MuWiMaLSBJptCHxPKR2RleH0+dp0ctnOENLyrUGewAUYzC4MvCSAceXl G3YQyufJBsaBmUYdEfUf/k9FIvJ7lXnC6onHjAmM/QV186lmwt4YeQRny J7/2Z3i25bic5sGwMB0D8V4npIkxcRFlCXOV5/k1afUAppfmOV5c1L0+k a+ySr2z6HUZBaFuWlXXDd7Af7wBIF1d+pFdbcOLlmfGSGFmkkXhy/d9p5 qJpxlxTJOtyEqyBW1iwJ4R449n3AAvQgixvHcxM16+a5Y4F7A0QSHw83C VbxJZchRMlUiAcvTFDcpaFSexmfzomrO2cfQF1Jf83v6C8Ud8X46VW1Lu w==; X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="293519263" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="293519263" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 05:11:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="783834220" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="783834220" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 22 Nov 2022 05:11:10 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 22 Nov 2022 15:11:09 +0200 Date: Tue, 22 Nov 2022 15:11:09 +0200 From: Heikki Krogerus To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Daniel Scally , Sakari Ailus Subject: Re: [PATCH v3 1/3] device property: Get rid of __PROPERTY_ENTRY_ARRAY_EL*SIZE*() Message-ID: References: <20221111154621.15941-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221111154621.15941-1-andriy.shevchenko@linux.intel.com> 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_PASS, 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 On Fri, Nov 11, 2022 at 05:46:19PM +0200, Andy Shevchenko wrote: > 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 For the series: Acked-by: Heikki Krogerus > --- > v3: fixed typo in PROPERTY_ENTRY_REF_ARRAY_LEN() impl (LKP) > 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..0eab13a5c7df 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_REF, \ > + { .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_ } }, \ > -- > 2.35.1 -- heikki