linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc
@ 2020-07-31 21:55 Denis Efremov
  2020-07-31 21:58 ` Joe Perches
  2020-08-01 13:31 ` [PATCH v2] " Denis Efremov
  0 siblings, 2 replies; 12+ messages in thread
From: Denis Efremov @ 2020-07-31 21:55 UTC (permalink / raw)
  To: Martin K. Petersen, James E.J. Bottomley
  Cc: Denis Efremov, linux-scsi, linux-kernel

Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() functions
and use kvzalloc/kvfree instead.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 drivers/scsi/cxgbi/libcxgbi.c |  8 ++++----
 drivers/scsi/cxgbi/libcxgbi.h | 16 ----------------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 4bc794d2f51c..a98b870eb1f3 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -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);
 	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);
 }
 
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index 84b96af52655..321426242be4 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -537,22 +537,6 @@ struct cxgbi_task_data {
 #define iscsi_task_cxgbi_data(task) \
 	((task)->dd_data + sizeof(struct iscsi_tcp_task))
 
-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)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-09-09  2:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 21:55 [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc Denis Efremov
2020-07-31 21:58 ` Joe Perches
2020-07-31 22:10   ` Denis Efremov
2020-07-31 22:24     ` Joe Perches
2020-08-01  7:51       ` Denis Efremov
2020-08-01  7:58         ` Denis Efremov
2020-08-01  8:10         ` Joe Perches
2020-08-01 13:28           ` Denis Efremov
2020-08-01 13:31 ` [PATCH v2] " Denis Efremov
2020-08-27 15:13   ` Denis Efremov
2020-08-27 15:17     ` Martin K. Petersen
2020-09-09  2:17   ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).