Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp221069rbe; Wed, 28 Feb 2024 18:46:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZklAenOJq0FqicC/5CgF0XflgW/3OqBTIfw0bpt8aA4+ycauQM3tMQhBahoxc5bBu/ptEDoc6zByNcBo4GdM5KkukuMPbbLgmDGJT0g== X-Google-Smtp-Source: AGHT+IHN/U7lhIxZN90s4sOIzbcJWUSlvOgmajE1XSBu8c8JBqcV0IWoD2gNONextchmjbm+hnA/ X-Received: by 2002:a05:6402:520c:b0:565:b4ca:72f3 with SMTP id s12-20020a056402520c00b00565b4ca72f3mr669714edd.35.1709174804710; Wed, 28 Feb 2024 18:46:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709174804; cv=pass; d=google.com; s=arc-20160816; b=OgC4Fj2k2ls84cpB36wcBsUCJsl60p4NrJd/Ul6GnO5qfqjy4NGzoRtAnkW0qdznBH puvAe1vFGXSo9/7guSxM+wZGf3lnzwkw8rT+LhKG68cyPNU+2ZKG3IfLxQZ41xHKFIY1 locKADD/yF1YmggVEz+ROO/0lumpSBVzPxO3C9b7fsVhKpjTg2ir5bAOIWH77GH98DBJ nka6ciOOIRXq42j0VJ+XYmZDCQP9JI+x5203cn0JXul4b1VznBeRxU3nRYJL37yup5dV ElrciaqLaTrB3ZrSPgnX3yr9pr7EmCmyigbRxyxxtqgQkygLVc9a5JflI8x1lix29tht rC2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=In2F4CcBTcy4RqfaLJ0KEkRlRxTiV+hdqV94xLLXIOk=; fh=SDJEwBjUOHB9dr3Xf35E782n6oCWBirh57Q+2DGhRIA=; b=AfLdj+2qcyhqZ4qQ15Q0MUM8SbYwqbB3D1jERLnSKuhgT86FUcwRO5pbNela9p4Dui U4sY0mleigVAvwYeNNEjoK7EYsapJq63MRkWTSXQKHsUMuWoHXN9QRK4ol8nA712H1o/ mMpsgl5gmMDiYei5V6AdY/RDiGXsgUEceOLQALL7uV+27GPFcDWCyuEuJH2TmFOwSeFK 3/NycHUmXnYuNJHWQi/l6l6fMCCntNVnOrKNChEOnGiEbcYKtcrO071FnLBBa9O6WyeW E0its6sdWaabRbP8OsV6BY8d8fkQyI2XDJr8RIpIOUrNQfZkcDOiEwz3daIUoAdC9Zsb KmHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=meZNFtV5; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y2-20020a056402440200b00565d035f48esi157283eda.158.2024.02.28.18.46.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 18:46:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=meZNFtV5; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 239131F29229 for ; Wed, 28 Feb 2024 20:49:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 714C315E5BE; Wed, 28 Feb 2024 20:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="meZNFtV5" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF7571ECC; Wed, 28 Feb 2024 20:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709153383; cv=none; b=m8LSTPq2wBCb7SoxzMBdwHmD4HKdIRMRgjnUljy+EllwmqCQxmYpFEczQ6dPAB8lyLo9Tjsuv5Vu/CToM8NT4KALhZxGdMavdQPhrXDgN5hYI4m7neyJUoww9E2LxjEFeIt/gcMb7UWcdDawxa67/+PuFdmaRBAO4B2zLOZ1qoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709153383; c=relaxed/simple; bh=bSX7yIwX43d/OsXwr5kkmyf++rin8N4VYe4LXrJgvRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfKuravMgxafUKTyd1bSNrP7z9CSkQKTfapA3lpVUzW/BS6a5rFcvRwX3NSSpSUrnkbXL6Cn55zjbEHbdOST9st7yM37fMflg64HOWytexJ6YEFrij6IrVaXPP2FM3qwKJNp4KPYgM04gbCUlYekSgRS4yOpPX/WtMxToJ7UJIU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=meZNFtV5; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709153382; x=1740689382; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bSX7yIwX43d/OsXwr5kkmyf++rin8N4VYe4LXrJgvRQ=; b=meZNFtV5g+j2wCZ08yPnnZHrTFvEiDWp9jjC61JRCsnEULFXkiNEavbI 9jqeyrq5Rk3jXXyXTLchwtDQ815eC6XDhpnM17zuX7pic5EjWRmD+SHI8 mEkfkJExm+OrXeiIzWEpVd/88roMLXerSGV8nGK06kt6Eb1pPf/OIL4Co PbGBZv+/5zIzpp3dunlKn1tvARMViE7499Ehu1YqftNnQGlSrPnr/YKmI YldSbMsb6LS+SjwrZty8giyYaQ+g6MJp7kplrA6aj9zfPCjR4KryQdAJZ Pxxu5KCkJ4H6NZ71jUX1CeNRCTkPfHrTrr9FMS6HJX/7qw1iii/XCiJ31 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3428674" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3428674" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 12:49:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="937034659" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="937034659" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 28 Feb 2024 12:49:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3AD28524; Wed, 28 Feb 2024 22:49:34 +0200 (EET) From: Andy Shevchenko To: Vinod Koul , Linus Walleij , Jonathan Cameron , Andy Shevchenko , Mark Brown , Kees Cook , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-spi@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" Subject: [PATCH v4 4/8] iio: core: Calculate alloc_size only once in iio_device_alloc() Date: Wed, 28 Feb 2024 22:41:34 +0200 Message-ID: <20240228204919.3680786-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240228204919.3680786-1-andriy.shevchenko@linux.intel.com> References: <20240228204919.3680786-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit No need to rewrite the value, instead use 'else' branch. This will also help further refactoring the code later on. Signed-off-by: Andy Shevchenko --- drivers/iio/industrialio-core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index bd305fa87093..1986b3386307 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1643,11 +1643,10 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) struct iio_dev *indio_dev; size_t alloc_size; - alloc_size = sizeof(struct iio_dev_opaque); - if (sizeof_priv) { - alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN); - alloc_size += sizeof_priv; - } + if (sizeof_priv) + alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN) + sizeof_priv; + else + alloc_size = sizeof(struct iio_dev_opaque); iio_dev_opaque = kzalloc(alloc_size, GFP_KERNEL); if (!iio_dev_opaque) -- 2.43.0.rc1.1.gbec44491f096