From mboxrd@z Thu Jan 1 00:00:00 1970 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 8853CC433EF for ; Fri, 20 May 2022 14:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244844AbiETOZP (ORCPT ); Fri, 20 May 2022 10:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239775AbiETOZO (ORCPT ); Fri, 20 May 2022 10:25:14 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221F0169E0B for ; Fri, 20 May 2022 07:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653056714; x=1684592714; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=RBLuajRoKS4IdfHNySDykeDo5BeoiSi7Ao6GdtNh9Ng=; b=RG416YgGWcpi6hClX9g7NOPPiRp6cnTFqYgZJLEJCYQPX5zzsi5V5HqT W+waf/KAD5BR7tQtB75+b9QQBI4ZrO5tEl6Vn1PS2otapPCKhNBMgCOl2 MLWR5K7mYDuy9Fv+Co57cv8jNMd0dcW4rweKVfKd6dQxd7BBzofBIQ1Ep oLhRuTxAAPfDSxad8O5o8XSCV+/dyKaAWbiZ3vSdm8lNdknCLjNk1tixP cngxpTmnQkg16YMH2crdGjnaMj7tAebFYvqoVdUP4BJMy12dr7lejByW6 nz2DqP5JOtdzEcorFjYqA/QD/Gm1NAlP5ETbwm6+T53q4+AtVU/8ETbUu A==; X-IronPort-AV: E=McAfee;i="6400,9594,10353"; a="297929210" X-IronPort-AV: E=Sophos;i="5.91,239,1647327600"; d="scan'208";a="297929210" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2022 07:25:12 -0700 X-IronPort-AV: E=Sophos;i="5.91,239,1647327600"; d="scan'208";a="662284143" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2022 07:25:11 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1ns3Yz-000Gqf-BW; Fri, 20 May 2022 17:25:09 +0300 Date: Fri, 20 May 2022 17:25:09 +0300 From: Andy Shevchenko To: Sakari Ailus Cc: linux-acpi@vger.kernel.org, rafael@kernel.org Subject: Re: [PATCH v2 6/8] ACPI: property: Unify integer value reading functions Message-ID: References: <20220520061148.21366-1-sakari.ailus@linux.intel.com> <20220520061148.21366-7-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220520061148.21366-7-sakari.ailus@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Fri, May 20, 2022 at 09:11:46AM +0300, Sakari Ailus wrote: > Unify functions reading ACPI property integer values into a single macro, > and call that macro to generate the functions for each bit depth. > > Also use size_t for the counter instead of int. ... > +#define DECLARE_ACPI_PROPERTY_COPY(bits) \ > + static int \ > + acpi_copy_property_array_u##bits(const union acpi_object *items, \ Personally I find much better if function templates in macros are not indented additionally. > + u##bits *val, size_t nval) \ > + { \ > + size_t i; \ > + \ > + for (i = 0; i < nval; i++) { \ > + if (items[i].type != ACPI_TYPE_INTEGER) \ > + return -EPROTO; \ > + if (items[i].integer.value > U##bits##_MAX) \ > + return -EOVERFLOW; \ > + \ > + val[i] = items[i].integer.value; \ > + } \ > + return 0; \ > } On top of that, we use a minimum compiler that supports _Generic(). Why not to use it? -- With Best Regards, Andy Shevchenko