mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
iio: core: Calculate alloc_size only once in iio_device_alloc()
No need to rewrite the value, instead use 'else' branch. This will also help further refactoring the code later on. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://lore.kernel.org/r/20240304140650.977784-3-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
f0245ab389
commit
5c4e411566
@ -1643,11 +1643,10 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
|
||||
struct iio_dev *indio_dev;
|
||||
size_t alloc_size;
|
||||
|
||||
alloc_size = sizeof(struct iio_dev_opaque);
|
||||
if (sizeof_priv) {
|
||||
alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN);
|
||||
alloc_size += sizeof_priv;
|
||||
}
|
||||
if (sizeof_priv)
|
||||
alloc_size = ALIGN(sizeof(*iio_dev_opaque), IIO_DMA_MINALIGN) + sizeof_priv;
|
||||
else
|
||||
alloc_size = sizeof(*iio_dev_opaque);
|
||||
|
||||
iio_dev_opaque = kzalloc(alloc_size, GFP_KERNEL);
|
||||
if (!iio_dev_opaque)
|
||||
|
Loading…
Reference in New Issue
Block a user