[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240228204919.3680786-7-andriy.shevchenko@linux.intel.com>
Date: Wed, 28 Feb 2024 22:41:36 +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 6/8] spi: Use new helpers from overflow.h in __spi_alloc_controller()
We have two new helpers struct_size_with_data() and struct_data_pointer()
that we can utilize in __spi_alloc_controller(). Do it so.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/spi/spi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ba4d3fde2054..de7a23da58c6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3089,12 +3089,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
unsigned int size, bool slave)
{
struct spi_controller *ctlr;
- size_t ctlr_size = ALIGN(sizeof(*ctlr), dma_get_cache_alignment());
+ int align = dma_get_cache_alignment();
if (!dev)
return NULL;
- ctlr = kzalloc(size + ctlr_size, GFP_KERNEL);
+ ctlr = kzalloc(struct_size_with_data(ctlr, align, size), GFP_KERNEL);
if (!ctlr)
return NULL;
@@ -3114,7 +3114,7 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
ctlr->dev.class = &spi_master_class;
ctlr->dev.parent = dev;
pm_suspend_ignore_children(&ctlr->dev, true);
- spi_controller_set_devdata(ctlr, (void *)ctlr + ctlr_size);
+ spi_controller_set_devdata(ctlr, struct_data_pointer(ctlr, align));
return ctlr;
}
--
2.43.0.rc1.1.gbec44491f096
Powered by blists - more mailing lists