[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240228204919.3680786-9-andriy.shevchenko@linux.intel.com>
Date: Wed, 28 Feb 2024 22:41:38 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Vinod Koul <vkoul@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Mark Brown <broonie@...nel.org>,
Kees Cook <keescook@...omium.org>,
linux-arm-kernel@...ts.infradead.org,
dmaengine@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org,
linux-spi@...r.kernel.org,
netdev@...r.kernel.org,
linux-hardening@...r.kernel.org
Cc: Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>
Subject: [PATCH v4 8/8] dmaengine: ste_dma40: Use new helpers from overflow.h
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 <andriy.shevchenko@...ux.intel.com>
---
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 <linux/clk.h>
#include <linux/delay.h>
#include <linux/log2.h>
+#include <linux/overflow.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/err.h>
@@ -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
Powered by blists - more mailing lists