From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Vinod Koul <vkoul@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Mark Brown <broonie@kernel.org>,
Kees Cook <keescook@chromium.org>,
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 <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: [PATCH v4 8/8] dmaengine: ste_dma40: Use new helpers from overflow.h
Date: Wed, 28 Feb 2024 22:41:38 +0200 [thread overview]
Message-ID: <20240228204919.3680786-9-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240228204919.3680786-1-andriy.shevchenko@linux.intel.com>
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@linux.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
next prev parent reply other threads:[~2024-02-28 20:49 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 20:41 [PATCH v4 0/8] iio: core: New macros and making use of them Andy Shevchenko
2024-02-28 20:41 ` [PATCH v4 1/8] overflow: Use POD in check_shl_overflow() Andy Shevchenko
2024-02-28 21:33 ` Kees Cook
2024-02-29 10:59 ` Andy Shevchenko
2024-02-29 18:30 ` (subset) " Kees Cook
2024-02-28 20:41 ` [PATCH v4 2/8] overflow: Add struct_size_with_data() and struct_data_pointer() helpers Andy Shevchenko
2024-02-28 21:37 ` Kees Cook
2024-02-28 21:51 ` Andy Shevchenko
2024-02-28 20:41 ` [PATCH v4 3/8] iio: core: NULLify private pointer when there is no private data Andy Shevchenko
2024-02-28 21:06 ` David Lechner
2024-02-28 21:36 ` Andy Shevchenko
2024-03-03 12:46 ` Jonathan Cameron
2024-02-28 20:41 ` [PATCH v4 4/8] iio: core: Calculate alloc_size only once in iio_device_alloc() Andy Shevchenko
2024-02-28 20:57 ` David Lechner
2024-02-28 21:09 ` Andy Shevchenko
2024-02-28 20:41 ` [PATCH v4 5/8] iio: core: Use new helpers from overflow.h " Andy Shevchenko
2024-02-29 15:29 ` Nuno Sá
2024-03-03 13:09 ` Jonathan Cameron
2024-02-28 20:41 ` [PATCH v4 6/8] spi: Use new helpers from overflow.h in __spi_alloc_controller() Andy Shevchenko
2024-02-28 21:00 ` Mark Brown
2024-02-28 20:41 ` [PATCH v4 7/8] net-device: Use new helpers from overflow.h in netdevice APIs Andy Shevchenko
2024-02-28 21:46 ` Kees Cook
2024-02-28 21:53 ` Andy Shevchenko
2024-02-28 22:41 ` Jakub Kicinski
2024-02-29 0:01 ` Kees Cook
2024-02-29 0:49 ` Gustavo A. R. Silva
2024-02-29 0:57 ` Jakub Kicinski
2024-02-29 1:03 ` Gustavo A. R. Silva
2024-02-29 1:15 ` Jakub Kicinski
2024-02-29 1:36 ` Gustavo A. R. Silva
2024-02-29 0:56 ` Jakub Kicinski
2024-02-29 19:08 ` Kees Cook
2024-02-29 19:37 ` Jakub Kicinski
2024-02-29 21:31 ` Kees Cook
2024-02-29 10:54 ` Andy Shevchenko
2024-02-28 20:41 ` Andy Shevchenko [this message]
2024-02-29 14:14 ` [PATCH v4 8/8] dmaengine: ste_dma40: Use new helpers from overflow.h Linus Walleij
2024-02-29 14:53 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240228204919.3680786-9-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=dmaengine@vger.kernel.org \
--cc=edumazet@google.com \
--cc=gustavoars@kernel.org \
--cc=jic23@kernel.org \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).