usb: xhci: avoid type conversion of void * 48/268148/2
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 29 Sep 2020 20:03:01 +0000 (22:03 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 16 Dec 2021 16:15:09 +0000 (17:15 +0100)
void * can be assigned to any pointer variable. Avoid unnecessary
conversions.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[backport of mainline commit 3fade88686e71c9acee4cbeb3ae9706bbc845608]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I66ed937f1331ff1ea4c1df6b594a997efc26db01

drivers/usb/host/xhci-mem.c

index 8058bf191826d5cc0fa524bd8b908aaf62fb60eb..6139a023d0be0f7dd6c12a1c20678c0c93cff6d2 100644 (file)
@@ -275,10 +275,10 @@ static struct xhci_segment *xhci_segment_alloc(void)
 {
        struct xhci_segment *seg;
 
-       seg = (struct xhci_segment *)malloc(sizeof(struct xhci_segment));
+       seg = malloc(sizeof(struct xhci_segment));
        BUG_ON(!seg);
 
-       seg->trbs = (union xhci_trb *)xhci_malloc(SEGMENT_SIZE);
+       seg->trbs = xhci_malloc(SEGMENT_SIZE);
 
        seg->next = NULL;
 
@@ -305,7 +305,7 @@ struct xhci_ring *xhci_ring_alloc(unsigned int num_segs, bool link_trbs)
        struct xhci_ring *ring;
        struct xhci_segment *prev;
 
-       ring = (struct xhci_ring *)malloc(sizeof(struct xhci_ring));
+       ring = malloc(sizeof(struct xhci_ring));
        BUG_ON(!ring);
 
        if (num_segs == 0)
@@ -421,8 +421,7 @@ static struct xhci_container_ctx
 {
        struct xhci_container_ctx *ctx;
 
-       ctx = (struct xhci_container_ctx *)
-               malloc(sizeof(struct xhci_container_ctx));
+       ctx = malloc(sizeof(struct xhci_container_ctx));
        BUG_ON(!ctx);
 
        BUG_ON((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT));
@@ -432,7 +431,7 @@ static struct xhci_container_ctx
        if (type == XHCI_CTX_TYPE_INPUT)
                ctx->size += CTX_SIZE(readl(&ctrl->hccr->cr_hccparams));
 
-       ctx->bytes = (u8 *)xhci_malloc(ctx->size);
+       ctx->bytes = xhci_malloc(ctx->size);
 
        return ctx;
 }
@@ -454,8 +453,7 @@ int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id)
                return -EEXIST;
        }
 
-       ctrl->devs[slot_id] = (struct xhci_virt_device *)
-                                       malloc(sizeof(struct xhci_virt_device));
+       ctrl->devs[slot_id] = malloc(sizeof(struct xhci_virt_device));
 
        if (!ctrl->devs[slot_id]) {
                puts("Failed to allocate virtual device\n");
@@ -514,8 +512,7 @@ int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr,
        struct xhci_segment *seg;
 
        /* DCBAA initialization */
-       ctrl->dcbaa = (struct xhci_device_context_array *)
-                       xhci_malloc(sizeof(struct xhci_device_context_array));
+       ctrl->dcbaa = xhci_malloc(sizeof(struct xhci_device_context_array));
        if (ctrl->dcbaa == NULL) {
                puts("unable to allocate DCBA\n");
                return -ENOMEM;
@@ -551,8 +548,8 @@ int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr,
 
        /* Event ring does not maintain link TRB */
        ctrl->event_ring = xhci_ring_alloc(ERST_NUM_SEGS, false);
-       ctrl->erst.entries = (struct xhci_erst_entry *)
-               xhci_malloc(sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS);
+       ctrl->erst.entries = xhci_malloc(sizeof(struct xhci_erst_entry) *
+                                        ERST_NUM_SEGS);
 
        ctrl->erst.num_entries = ERST_NUM_SEGS;