Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp81075rbe; Wed, 28 Feb 2024 12:52:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+v1i64eHeITR5uOcbuuRtEyzcA0JaZ16bXFj7MWT9YuCjyiFl20AyNXm6BhTJnPYcPWayMyL4QvE+Hvy3TOYfJ7YkXV/6z212jrGYoA== X-Google-Smtp-Source: AGHT+IGecU1vRMfUCLjpCX3KXE3zbWdHyqr+08E8JQ4g0suDz9fPs2vk2y0a608BaP8nUSjMNIHs X-Received: by 2002:a1f:ed43:0:b0:4d3:2f29:fdf4 with SMTP id l64-20020a1fed43000000b004d32f29fdf4mr32233vkh.2.1709153540621; Wed, 28 Feb 2024 12:52:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709153540; cv=pass; d=google.com; s=arc-20160816; b=IuM/UzRlH6B/wNeaRJDuB/Ae/GfVaKIr+eQ/WhAYTa8BDelEX6mL4UHXiSZFp/IjAM xRotbMhm2GWQBahd+cf/+QJZNU38FB5tO+rpDKLyWM8yLLkFZCwzmbAntso+FsaAnPaz ffqYErsF39iQJimuMw+R6X3/BMOsSsJOwFsP9MmFem7d8RFNeGeE3wIdOnxSWrKgTztT lgNgMMNjcHZMyL2VsVWAAPhxNeMb6Va+H8AMjyKcqbvlESBxA4d40hGHDW55CRm+0q6a KD2UsatsskEC/pLWN1Pj+tondOd4DcdR1OMDMTcD2SymgrfhvjM5WFlS90YUIqIQVlEq 5WMg== 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=9VI+tzy9q3a5cGA3aUoO+hv/XHY7hHOuGFLHfSDNihs=; fh=bBcueXoyYQ/4owtJ51rB6UqpyJY1f++Rn9/MV1CTR2g=; b=BFptpXU3oIDgOHkxJ5BPDd6paHP/7CiqTRrm97DsCPkVRys+UangU0NYt+3dnu1+0Y +WA6BgTNOo0Mv+3yyhNmqwN4EG88ti8HB6sWiV4U+zF0shJlsDjGHIN+N2WTIuDf7A3m JERxoCOSWqTKhygRR0J6S96K9pPXjoZtFkbdeCuDsqwmZNFmA5lgA109/in7F+0gS3EE PPFlbbuHH+L4lUOFEZdUj5b3MMlUiVWclyKxO0sPffXWR5H9PnU5TYo83tT64OqIA0yS +DDAcIBEuKeIoeR50ndbt3NucNrVxt28jpwUS6zMgWzkNORboiwbqQ1KDjAzJb+NzDlk e3Ng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lzvgQX7d; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85695-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j17-20020ac84051000000b0042eb413ce89si260496qtl.30.2024.02.28.12.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 12:52:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85695-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lzvgQX7d; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85695-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85695-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 49B7B1C27052 for ; Wed, 28 Feb 2024 20:52:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91EED7D096; Wed, 28 Feb 2024 20:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lzvgQX7d" 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 ED8A17290F; Wed, 28 Feb 2024 20:49:47 +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=1709153389; cv=none; b=rhP3ApDz/Ut0GxEWgtkJTe3fF/aZ992W+SYgqpgLgDDDg2AAs0dV27FiLS7DlKpFaUjnpaf6PSqDmyM2YlPEVhuEJWAZuXUNdmhfM2Q+pweWhy+qb3IW9OB+lE4sO2tebiU18hy1YQQtFXKWmDun4agWA48TmbOJ7D6D0Tx3MAM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709153389; c=relaxed/simple; bh=R9j+Q0D/kA76h1U7UfPAGebwhkhuz8MuAm681KRIxuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pwd96xwLoNVNWozv/agsIctPrz9W6rsbSGv9lgeu2evaJvuBJCNdhVjx9K+7KZvgtpz67g+JOujc97Tg88wfAVIN0lem4kaBj9sXYkLKFvurFzQRAxRSMsqG+yfEmX6vV0G/7hZFJsE1OuuzHixBfbe7VkJgWwvLcNi8XbXRegg= 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=lzvgQX7d; 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=1709153388; x=1740689388; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R9j+Q0D/kA76h1U7UfPAGebwhkhuz8MuAm681KRIxuM=; b=lzvgQX7dZu4f6YrJlOMYTKNoU18zl/LQvhBde5z6BP4SO+LBslH0Fvbf pL4rbYBwVqNPOZ2JlK3pIQIPJxStuQU8OxlKiZtJMooZUYnUQjHmnKS5R E5eMdUm8JMnfhDPGwZUpnJ6KX3UVosgLsfnJsvX20pCNneksEQiVIvrAi uhGqLQ+7q6H4zVBdJMDevYpIDSqYhIWIL6yj3QUWYFNSdRF5zR+oNyI9J 1f58ogcsphCl5RI/q1XoMm7KKUWLPTM1SyEG1/wg2o6+3ndrfm+tbcTDh Zbq5Ykk5mqZZSd8S+O5TSysmz/aFpsyWhBxMLubj59+ptIGc4EPeb1Qkp A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3428774" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3428774" 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:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="937034662" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="937034662" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 28 Feb 2024 12:49:41 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 47C0A537; 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" , Nuno Sa Subject: [PATCH v4 5/8] iio: core: Use new helpers from overflow.h in iio_device_alloc() Date: Wed, 28 Feb 2024 22:41:35 +0200 Message-ID: <20240228204919.3680786-6-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 We have two new helpers struct_size_with_data() and struct_data_pointer() that we can utilize in iio_device_alloc(). Do it so. Signed-off-by: Andy Shevchenko Reviewed-by: Nuno Sa --- drivers/iio/industrialio-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 1986b3386307..223013725e32 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1644,7 +1644,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) size_t alloc_size; if (sizeof_priv) - alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN) + sizeof_priv; + alloc_size = struct_size_with_data(iio_dev_opaque, IIO_DMA_MINALIGN, sizeof_priv); else alloc_size = sizeof(struct iio_dev_opaque); @@ -1655,8 +1655,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) indio_dev = &iio_dev_opaque->indio_dev; if (sizeof_priv) - indio_dev->priv = (char *)iio_dev_opaque + - ALIGN(sizeof(struct iio_dev_opaque), IIO_DMA_MINALIGN); + indio_dev->priv = struct_data_pointer(iio_dev_opaque, IIO_DMA_MINALIGN); else indio_dev->priv = NULL; -- 2.43.0.rc1.1.gbec44491f096