scsi: libcxgbi: Use kvzalloc instead of opencoded kzalloc/vzalloc
authorDenis Efremov <efremov@linux.com>
Sat, 1 Aug 2020 13:31:23 +0000 (16:31 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 21 Aug 2020 03:34:47 +0000 (23:34 -0400)
Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() functions and use
kvzalloc/kvfree instead. __GFP_NOWARN added to kvzalloc() call because we
already print a warning in case of allocation fail.

Link: https://lore.kernel.org/r/20200801133123.61834-1-efremov@linux.com
Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/cxgbi/libcxgbi.c
drivers/scsi/cxgbi/libcxgbi.h

index 71aebaf..13781d8 100644 (file)
@@ -77,9 +77,9 @@ int cxgbi_device_portmap_create(struct cxgbi_device *cdev, unsigned int base,
 {
        struct cxgbi_ports_map *pmap = &cdev->pmap;
 
-       pmap->port_csk = cxgbi_alloc_big_mem(max_conn *
-                                            sizeof(struct cxgbi_sock *),
-                                            GFP_KERNEL);
+       pmap->port_csk = kvzalloc(array_size(max_conn,
+                                            sizeof(struct cxgbi_sock *)),
+                                 GFP_KERNEL | __GFP_NOWARN);
        if (!pmap->port_csk) {
                pr_warn("cdev 0x%p, portmap OOM %u.\n", cdev, max_conn);
                return -ENOMEM;
@@ -124,7 +124,7 @@ static inline void cxgbi_device_destroy(struct cxgbi_device *cdev)
        if (cdev->cdev2ppm)
                cxgbi_ppm_release(cdev->cdev2ppm(cdev));
        if (cdev->pmap.max_connect)
-               cxgbi_free_big_mem(cdev->pmap.port_csk);
+               kvfree(cdev->pmap.port_csk);
        kfree(cdev);
 }
 
index fc7255f..3687b5c 100644 (file)
@@ -575,22 +575,6 @@ struct cxgbi_iso_info {
        u32 buffer_offset;
 };
 
-static inline void *cxgbi_alloc_big_mem(unsigned int size,
-                                       gfp_t gfp)
-{
-       void *p = kzalloc(size, gfp | __GFP_NOWARN);
-
-       if (!p)
-               p = vzalloc(size);
-
-       return p;
-}
-
-static inline void cxgbi_free_big_mem(void *addr)
-{
-       kvfree(addr);
-}
-
 static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
 {
        if (chba->cdev->flags & CXGBI_FLAG_IPV4_SET)