[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240228204919.3680786-6-andriy.shevchenko@linux.intel.com>
Date: Wed, 28 Feb 2024 22:41:35 +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>,
Nuno Sa <nuno.sa@...log.com>
Subject: [PATCH v4 5/8] iio: core: Use new helpers from overflow.h in iio_device_alloc()
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 <andriy.shevchenko@...ux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@...log.com>
---
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
Powered by blists - more mailing lists