Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp799741pxa; Sat, 1 Aug 2020 06:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAItnebgKd/+/lMP2b7usR0FJvvsK0TH5px8tIaFRbt8T2bf2NBTon5BjtuJe5U8QOuCAU X-Received: by 2002:a17:907:7291:: with SMTP id dt17mr8539674ejc.73.1596288819504; Sat, 01 Aug 2020 06:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596288819; cv=none; d=google.com; s=arc-20160816; b=hiCVVMau8/hyS5ok6q7/jve2+KlsFyxxqNDB/ba+jyXZGydoYmKYvI14FVhzItdC5J 66Mf+asVvKa90PKjp5cu8fk5kW4XUiMiAlkdvqV8Ttbw5e7MRtzslIXx0GUUDIRXXvXe d90lWWZVIcdmo/reMxE1FeTyK1qVLXFtnglvmE+quZhS/0JH0GbjozYIotFJ+Uxh4lcM 2MR8L4xi77B7EDGoBn92aOjs4Wj6vSKlUuatUZiuWtTVi0fQbUYp05zLNcNMLWThHA97 0NkFBvMQKTIflqkJCQxQplrj73rVlH3Iwleb0avg04pVEBV1epxHkAdpOPO9Y1hKJlYd XKGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pzBNlNP+HjEb61+l8s6iD5NGvZcBwVXRY/7DujsTy2A=; b=y5GEplZ1COVNUg11HbIvgzfDwbZIad1R6KCSQD81mF13mTqq9gwt4lDfKxx77F3NUf ugy16QZlTtTPOFp7rHLKmKNVPptg9mfChWdxvjVHJAYtTyTioRmW3w+ZkpltCWu+zyxq mEu9TKGaNry8O0AMeZkvYPlnzKU7OkrcaWTWrPavRBps53NYlO6GQy46SfUQ1TMdG1l5 4n7jY3L5kHJHiA89kNLV9uEKw4qGen7enKh0rPhOHWHT5CnLz/e9KWiBXS/1744/JqBS yiNYmfPd6J2S3PNGKOGf8G/cLjwX0Yczra3J8XFqP9u8rFAmxD4W1Rslr3imXip9WOtY UfNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yj16si4832940ejb.357.2020.08.01.06.33.17; Sat, 01 Aug 2020 06:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728885AbgHANb4 (ORCPT + 99 others); Sat, 1 Aug 2020 09:31:56 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41907 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgHANbz (ORCPT ); Sat, 1 Aug 2020 09:31:55 -0400 Received: by mail-lj1-f196.google.com with SMTP id s16so19919695ljc.8; Sat, 01 Aug 2020 06:31:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pzBNlNP+HjEb61+l8s6iD5NGvZcBwVXRY/7DujsTy2A=; b=YLeKLhtK4nvRhu8pNjGMcWYERRRJ9kA+WK9Ed5vNEuIOZ+lNAeHez5dqOZOFn1w8qY tDneV9m7yqM0M1orPmLfRjzUA1j5e+K/GJrNrv4aUxQ92zilQ1CSWZm7UXvCYpEQw8nw nZ4k6pVHEGU8wUhxwITER1ROyLww3G8wO9S1kcKXynO7901XDBMEcgSgQDfDnmNDl/K8 w7Evz3IjCGLt5ZW58fyOGLNcQqnRkZL0da19Cn+O+i8oJP78VWwS4cYOAtyQcdSNwn5K Md77N5hm8ePTmeP5N0Aj3ONVN3/R2SSamvmAl9hvtlsnWbSeBb5l0olQAjUBBBX9kaVx 4dAA== X-Gm-Message-State: AOAM5306zFV1yyVLSQFIAWhHnY+xc4ckstSkW2wyThSvC4QIO0lXpSTo j2D2I7i8GIDvR3bc/KIbdkX2IU8s2bU= X-Received: by 2002:a05:651c:201b:: with SMTP id s27mr4058351ljo.468.1596288712717; Sat, 01 Aug 2020 06:31:52 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.googlemail.com with ESMTPSA id n82sm2704136lfa.40.2020.08.01.06.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 06:31:52 -0700 (PDT) From: Denis Efremov To: "Martin K. Petersen" , "James E.J. Bottomley" Cc: Denis Efremov , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Joe Perches Subject: [PATCH v2] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc Date: Sat, 1 Aug 2020 16:31:23 +0300 Message-Id: <20200801133123.61834-1-efremov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731215524.14295-1-efremov@linux.com> References: <20200731215524.14295-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Denis Efremov --- 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..51f4d34da73f 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 | __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); } 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