Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp211099rbe; Wed, 28 Feb 2024 18:17:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVSf2b32LRUy0ayDAyvCsAZRGNT5Qat0+5ZbE+lZPZz1wpRbM9S91rFgEKCFZb7aLnl+G/jw5S4RzgtdRUuyVtLFRZ3Qfvnf8y1SYjSOg== X-Google-Smtp-Source: AGHT+IEP9Tt7LqNQINiFRIXyJES2b4IiG1MvMmcn9dBhPGB8fEun0Nz95LoQHlsWecCdhm6aT6kc X-Received: by 2002:a05:6a20:8f92:b0:1a1:14f2:4b70 with SMTP id k18-20020a056a208f9200b001a114f24b70mr870192pzj.22.1709173021234; Wed, 28 Feb 2024 18:17:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709173021; cv=pass; d=google.com; s=arc-20160816; b=Z4GVkVCJ93VsJLpl4FV7rYYCuPqteQIZbi14yLac7JTh+NI1IluQocGvxAC5BG79C1 rlAKv7LmdeCeDeCjwydKD1L5rum6lg2WIOwABg8EIY84fPZHgEWJNW8chwISYEm5PAQu 6ltqf1NhThtWwQc42RhhEjQfnKazQPRpAB5V+kmonOZVepglCfAbWJRkY1GeOwhNGn0L xzuyGMZSxWdLAXlrRttUlLpijlphmIBPB778O/AwxOirSht3cXWGC1RaHmtpUy+xLz2G 8dm/CQiFt3xdSEry6ZpG+IRWmAwJfFm98rZ5B9mnLzmZdfQw5yCvg4UX4Qh5pTHzjt5G j2OA== 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=fQMfBhc1n6DTIzVjiwqqIpnk4wi4d2GCnJ4A/mgp6Sc=; fh=SDJEwBjUOHB9dr3Xf35E782n6oCWBirh57Q+2DGhRIA=; b=q+x/sdflzUtSeWu30FYIgoQd+M1HyHngmHLURYOMG7NxeblsxFFHiBCOJ8HNv9h0au gAVWEIoHFcnS5170zJlB2YDxY2U+MduZREOy4lJs3bUjQlu1wOvdxdDBgMaaW0f4G7mf AoEmVZiB4yywHhYkfFVqe+cTs525vPG/PR2pnBIAZxkQQ853vSdC2NsxM9vDzANmc0OT vMy3VZsd1U8hSPbLUsUG7qvT5nFJfq4/vZuIH7AP+EJDgS1+FWwq3t5GWaPOMZkg5LXh NT+Y7xQZuGRBystywOSMx8nrRBzAK48uvIMUuTjCXKxiGA0ESqmw5sDhIfjzxLn6vWuT E8UA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QZ09pxQo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85693-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g5-20020a636b05000000b005dcd29510e5si362217pgc.349.2024.02.28.18.17.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 18:17:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QZ09pxQo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85693-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 65A8228CB9B for ; Wed, 28 Feb 2024 20:51:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 609F076F13; Wed, 28 Feb 2024 20:49:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QZ09pxQo" 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 C5DA470024; Wed, 28 Feb 2024 20:49:46 +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=1709153388; cv=none; b=A4I/YGhh7YB2UJXVAYotwg7A2QWygpwDT/3YxWzznFJxoGlJTzk1rk7VQTn6jSEBn1PQ7i3IujN8kgJMAmOrVbK+2DOpFUkZXvHxY61AN0jsIfIncCuBK2hCagQ03+GwjOxHYvfJwS5jRekYlh6wNSNnlPp9KSOjNWljKTJjaK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709153388; c=relaxed/simple; bh=8BAIf0j7CaHKQ/zZDl1HE0ybcnT2/U9McrHMACFS6nk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bc6m38LBgqBZkBhVaFOtO+WM5p2QxZ8o3FtlkQCeA2ForQLLRsS5mqXmZ150IPNqqpksrdFB/R+ifzRjCAEA//Yy1dPEbUlmF6xqymY1Xm30Tw+mcCVVNjBgaLK2K9Xn2yI8cYM2vPR4HbHSKdrMxPw65FDIbK2NzIda08I08Bk= 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=QZ09pxQo; 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=1709153387; x=1740689387; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8BAIf0j7CaHKQ/zZDl1HE0ybcnT2/U9McrHMACFS6nk=; b=QZ09pxQorS2cktz5/PqzrEEJ1ZhQzKXIsb/o28M2LCQ+Y/WAQrWPi0VI Rnv6d9HOpXGy6XYOgXfU6x6TWSfN5oVmL2F8YxXIUAyYmk8CjoMPkjzsW Fwn1wxZlojqJnEXm59296i/tLew/BkQND+BmXAjUhUQ84Y98vJiDMKV7t KEqO3hTKBM7agMu1DmK4Y9H+bai+gkmYnYO8A6rAZ11lZXv8mTFqS9Y7L qWIeOqx9ig/8Igy/UlXUQ2WnbV+GN033+kopYAGurPJQzxiccqpA/OwJz +IHR+BErf/HlrfaSP/wON9gSqHMrs9buO8WTXEFpX6SwySuDkVhDZfHdo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3428753" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3428753" 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="937034663" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="937034663" 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 6F964715; 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 8/8] dmaengine: ste_dma40: Use new helpers from overflow.h Date: Wed, 28 Feb 2024 22:41:38 +0200 Message-ID: <20240228204919.3680786-9-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 d40_hw_detect_init(). Do it so. Signed-off-by: Andy Shevchenko --- drivers/dma/ste_dma40.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 2c489299148e..bead3b8836c7 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -3141,6 +3142,7 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, int num_log_chans; int num_phy_chans; int num_memcpy_chans; + size_t sz; int i; u32 pid; u32 cid; @@ -3207,11 +3209,9 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, "hardware rev: %d with %d physical and %d logical channels\n", rev, num_phy_chans, num_log_chans); - base = devm_kzalloc(dev, - ALIGN(sizeof(struct d40_base), 4) + - (num_phy_chans + num_log_chans + num_memcpy_chans) * - sizeof(struct d40_chan), GFP_KERNEL); - + sz = array_size(num_phy_chans + num_log_chans + num_memcpy_chans, + sizeof(struct d40_chan)); + base = devm_kzalloc(dev, struct_size_with_data(base, 4, sz), GFP_KERNEL); if (!base) return -ENOMEM; @@ -3223,7 +3223,7 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, base->virtbase = virtbase; base->plat_data = plat_data; base->dev = dev; - base->phy_chans = ((void *)base) + ALIGN(sizeof(struct d40_base), 4); + base->phy_chans = struct_data_pointer(base, 4); base->log_chans = &base->phy_chans[num_phy_chans]; if (base->plat_data->num_of_phy_chans == 14) { -- 2.43.0.rc1.1.gbec44491f096