From patchwork Sat Jan 28 09:06:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 49826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1260791wrn; Sat, 28 Jan 2023 01:19:33 -0800 (PST) X-Google-Smtp-Source: AK7set9SLJi2Q/4bhnBgj9DRPX8JRZn5odVVWBsN4lALGWRzg1hb6GvgFiHqaNS1CLNjBqmgybu+ X-Received: by 2002:a17:902:e54c:b0:196:2143:5eff with SMTP id n12-20020a170902e54c00b0019621435effmr16844782plf.24.1674897573541; Sat, 28 Jan 2023 01:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674897573; cv=none; d=google.com; s=arc-20160816; b=AtIcti0Zw4UMAscOAqxVWl8C26sqK1nLA+wEc5+KMgjV8X5OIV+61oyqZXg7APd8uc 2DE/s8f816aJSIxAfZZ9MrKjzOUtJY5LbBeNUYXRWDIeLi3pyNmVFBte6FVhJfEGobsY o4Fec5lGOsm2Hg0JSvYCx4iDeBScpOh1UBLzLx4Sd/j0PHpNVAYGL312VmmHVGQ+98JS /0HltyQKqUBWyHysEt8LN5S9jdJRHDx5zGf81N+6KweMhISoJ2p9KRFWjb3f2b5n+DVL 99WX1wgzkwGNGLb2FSfeXHCqPVhdi0iVc0DAiTcNlOmUL/3lLgqWXsm0QWcL4UMi+Hwz S77A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=9TOj8bxjcxEZTNxb59yjXCd/25tFbPb8G/oBLuoGSmY=; b=zUML9h8G/njs+1G676RM0FhFqShwXellq9yW6bTI892iJ80FBYIgtFdi8IErT7k+kA RkXwJSLxB0apOCt33yKoUOMOdkJv3edVj3rGNRk/GDV1FpnGbdXsl8XmHgFcYgoJyz2N xeetLYoUl+3hk4fbcq+DWT0boJB3No9Qn82E/J0Xzq0YDKdrxl2H9zTEs+l6pAGJWC+7 NwRpjwSQpnq1hEi5ogd/dB/1AtnvKyAHWx6OgNi+HZnOu/R6h/MU6/WrtT+Pxrb47qB0 487ICRI2hQR9lODXlzVcG1hQ3/TVqUKRTFkhmgrxOEA7BGTOIVywddofr1ihSenNGHR1 BVUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=FgY8dCfm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020a170902a38e00b001966eaf7379si219394pla.29.2023.01.28.01.19.18; Sat, 28 Jan 2023 01:19:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=FgY8dCfm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231234AbjA1JHI (ORCPT + 99 others); Sat, 28 Jan 2023 04:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjA1JHH (ORCPT ); Sat, 28 Jan 2023 04:07:07 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 993BF3A5BF; Sat, 28 Jan 2023 01:07:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1674896816; bh=R22iGH266oHN3h6bLIRI3IU02Lca0t2HNgSH9AFK7xY=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=FgY8dCfmlku124IWKVZMOXPGlAfK5Gg2fanHRW1d0Zyw9S45K948vxgwdgsoGrubT 9FDJ5u0uLXNgRZta+ZNQpt/ZgWjcjeNvPSTWT7el8zEvjyn4l8Gj4ZZpK43LgVBqHg yalrUzxZh7FDM3rjZCNuCOUhuA6KMBAcYzxbOwlw= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sat, 28 Jan 2023 10:06:56 +0100 (CET) X-EA-Auth: SRWUIv6AJgtVE3RQZ67P7FCAUdgrw6wjpl4y1/hi8InCGVwzvJxW8XIpkgCCOobOVDEFmyiIvbqlnftv0WTXBY7q16AYgkjN Date: Sat, 28 Jan 2023 14:36:52 +0530 From: Deepak R Varma To: Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] scsi: qla2xxx: Use min/max helpers for comparison and assignment Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756257397913163069?= X-GMAIL-MSGID: =?utf-8?q?1756257397913163069?= Simplify code by using min and max helper macro for logical evaluation and value assignment. Proposed change is identified using minmax.cocci semantic patch script. Signed-off-by: Deepak R Varma --- drivers/scsi/qla2xxx/qla_dbg.c | 4 ++-- drivers/scsi/qla2xxx/qla_init.c | 8 ++------ drivers/scsi/qla2xxx/qla_sup.c | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index d7e8454304ce..02440c595753 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -686,9 +686,9 @@ qla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, __be32 **last_chain) mq->type = htonl(DUMP_CHAIN_MQ); mq->chain_size = htonl(sizeof(struct qla2xxx_mq_chain)); - que_cnt = ha->max_req_queues > ha->max_rsp_queues ? - ha->max_req_queues : ha->max_rsp_queues; + que_cnt = max(ha->max_req_queues, ha->max_rsp_queues); mq->count = htonl(que_cnt); + for (cnt = 0; cnt < que_cnt; cnt++) { reg = ISP_QUE_REG(ha, cnt); que_idx = cnt * 4; diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 8d9ecabb1aac..1250f575fb1e 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3734,12 +3734,8 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) if (!IS_FWI2_CAPABLE(ha)) req->num_outstanding_cmds = DEFAULT_OUTSTANDING_COMMANDS; - else { - if (ha->cur_fw_xcb_count <= ha->cur_fw_iocb_count) - req->num_outstanding_cmds = ha->cur_fw_xcb_count; - else - req->num_outstanding_cmds = ha->cur_fw_iocb_count; - } + else + req->num_outstanding_cmds = min(ha->cur_fw_xcb_count, ha->cur_fw_iocb_count); req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, sizeof(srb_t *), diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index c092a6b1ced4..e26f9835c124 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -3625,7 +3625,7 @@ qla24xx_read_fcp_prio_cfg(scsi_qla_host_t *vha) max_len = FCP_PRIO_CFG_SIZE - FCP_PRIO_CFG_HDR_SIZE; ha->isp_ops->read_optrom(vha, &ha->fcp_prio_cfg->entry[0], - fcp_prio_addr << 2, (len < max_len ? len : max_len)); + fcp_prio_addr << 2, min(len, max_len)); /* revalidate the entire FCP priority config data, including entries */ if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 1))