OSDN Git Service

dmaengine: at_hdmac: Use devm_kzalloc() and struct_size()
authorTudor Ambarus <tudor.ambarus@microchip.com>
Tue, 25 Oct 2022 09:02:56 +0000 (12:02 +0300)
committerVinod Koul <vkoul@kernel.org>
Fri, 11 Nov 2022 06:45:08 +0000 (12:15 +0530)
commit5f1d429b43b34b310a93651681d0cd8a39a86e3d
tree8954f19de9cc106e349d8b037e28a0e69a4af259
parentb50cf4bdfb9164c55d002624217d5a5ef4ab9573
dmaengine: at_hdmac: Use devm_kzalloc() and struct_size()

Use the resource-managed kzalloc to simplify error logic. Memory allocated
with this function is automatically freed on driver detach. Use
struct_size() helper to calculate the size of the atdma structure with its
trailing flexible array. While here, move the mem allocation higher in the
probe method, as failing to allocate memory indicates a serious system
issue, and everything else does not matter anyway. All these help the code
look a bit cleaner.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20221025090306.297886-1-tudor.ambarus@microchip.com
Link: https://lore.kernel.org/r/20221025090306.297886-23-tudor.ambarus@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/at_hdmac.c