[PATCH master 20/23] treewide: use new dma_zalloc instead of opencoding
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Apr 23 23:40:55 PDT 2024
We got a number of places using dma_alloc and zeroing its contents.
Replace the ones found by a quick grep with the new dma_zalloc.
No functional change.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/net/fsl-fman.c | 4 +---
drivers/usb/gadget/function/f_fastboot.c | 3 +--
drivers/video/mipi_dbi.c | 3 +--
fs/ext4/ext4_common.h | 10 +---------
4 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 9ae4dc9abf70..5528ecccc950 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -616,9 +616,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
return -ENOMEM;
/* alloc Rx buffer from main memory */
- rx_buf_pool = dma_alloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE);
-
- memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE);
+ rx_buf_pool = dma_zalloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE);
/* save them to fm_eth */
fm_eth->rx_bd_ring = rx_bd_ring_base;
diff --git a/drivers/usb/gadget/function/f_fastboot.c b/drivers/usb/gadget/function/f_fastboot.c
index 41450268fcdb..30d257b5002a 100644
--- a/drivers/usb/gadget/function/f_fastboot.c
+++ b/drivers/usb/gadget/function/f_fastboot.c
@@ -199,12 +199,11 @@ static struct usb_request *fastboot_alloc_request(struct usb_ep *ep)
return NULL;
req->length = EP_BUFFER_SIZE;
- req->buf = dma_alloc(EP_BUFFER_SIZE);
+ req->buf = dma_zalloc(EP_BUFFER_SIZE);
if (!req->buf) {
usb_ep_free_request(ep, req);
return NULL;
}
- memset(req->buf, 0, EP_BUFFER_SIZE);
return req;
}
diff --git a/drivers/video/mipi_dbi.c b/drivers/video/mipi_dbi.c
index 2f8d6ecc72cf..9611a402d1ba 100644
--- a/drivers/video/mipi_dbi.c
+++ b/drivers/video/mipi_dbi.c
@@ -398,8 +398,7 @@ int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev, struct fb_ops *ops,
info->bits_per_pixel = 16;
info->line_length = info->xres * 2;
info->screen_size = info->line_length * info->yres;
- info->screen_base = dma_alloc(info->screen_size);
- memset(info->screen_base, 0, info->screen_size);
+ info->screen_base = dma_zalloc(info->screen_size);
info->red.length = 5;
info->red.offset = 11;
diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h
index f8ebd7626636..3286a21c0e26 100644
--- a/fs/ext4/ext4_common.h
+++ b/fs/ext4/ext4_common.h
@@ -36,15 +36,7 @@
#include "ext4fs.h"
#include "ext_common.h"
-static inline void *zalloc(size_t size)
-{
- void *p = dma_alloc(size);
-
- if (p)
- memset(p, 0, size);
-
- return p;
-}
+#define zalloc dma_zalloc
int ext4fs_read_inode(struct ext2_data *data, int ino,
struct ext2_inode *inode);
--
2.39.2
More information about the barebox
mailing list