From patchwork Sat Jan 28 17:02:42 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: 49874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1432458wrn; Sat, 28 Jan 2023 09:23:47 -0800 (PST) X-Google-Smtp-Source: AK7set8GO1wBzV/YHlscCYPN8NHYx3QH7Yxm3gr/1rKXWdT3GLlklq/r+OIpxJ34NNQEf08SuDO1 X-Received: by 2002:a05:6a20:7fa6:b0:b9:7a34:a78d with SMTP id d38-20020a056a207fa600b000b97a34a78dmr4051468pzj.9.1674926627202; Sat, 28 Jan 2023 09:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674926627; cv=none; d=google.com; s=arc-20160816; b=kXrPv2iUwpormAYRSzgeRow/ZUer7DUlvs7dxZXIn2lzlFuFoJpor/iDramrV1GrVA lOHLaPhmEKg/62t6pH6Duk9Rbrj7mC4miX9ioQZv02eql0VwcykHGBkOxAOgDkhT5fuG g/F0jEOHGnyI3NxZ47Uet44dagixNwbXza/0zGIiEI3NJ6HOsMMEElafMnhCKabJUIah DObD0ja0BHh6DneZoTeifAHZe7pDNwEmn9N2ZsD3UNCyE4/uhACTvwU//oUlqQieHEeD xb6+T81EUQ1kLboUelbqie0lPKDomDSBU1zWwkWXMrjt6C3mdOpzKmRX0SvMpmxMtS7N DarQ== 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=QqN4o0GlRbp2sSuAKgfKdGrQEGYrhSe3RgdIvcYEZgQ=; b=K29+3h0pY9rbrcs1B/pjKOxkwM3eqbHT5Sa6rc0KoIHR2ojRXz3tanABMe5ccHwaQT G1cbMUzzrF114o40S3i4cNCdw0gM0yVhHBuWdqMhHzg8Uf+l6uSMyvwlMFBGHzWoNT3Y YQfPw+ufpgLp8YgAL3LTwxp7w2SnK97bSOVxMgBqzfAxuvD5rOxu1rfIjldy6sfG/E43 o7xsoM/S43hxJ90U8rFmFBbMv0HmR8h1ni8mvQgouD49Jb+81XrQMDz35vtG9kPyhw6a 94LzK7BYauC8BZsOvIzVe7lEXy6YKcScYmzJq2IwsuLh3FIZIqkEtgn3YHY3WOtrYQ4D YCFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=Ui0AegwQ; 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 b25-20020a639319000000b0043c5d3dc0d4si8118058pge.332.2023.01.28.09.23.34; Sat, 28 Jan 2023 09:23:47 -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=Ui0AegwQ; 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 S232115AbjA1RDB (ORCPT + 99 others); Sat, 28 Jan 2023 12:03:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjA1RDA (ORCPT ); Sat, 28 Jan 2023 12:03:00 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E659620059; Sat, 28 Jan 2023 09:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1674925368; bh=+8TKLKDrMXk1aX3sjR/kJoEvZAQFsAvwmSjZFAccLgg=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=Ui0AegwQcfT2+K0Cac1J2ZgbYyt5qkOTti+bkZ27XAokWCFdtDKV2rR0qAYxJSFIC +FZU+uhv6OtyOKpVLcXokGF/xFp9dVsHA5+cNGX/d1/QUOrvmNXroP8Gv0NAduZxqE u+5nlocKw7Y6csYdUSzNmk+JZ/X/ky0uwDHtiFIM= 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 18:02:48 +0100 (CET) X-EA-Auth: h5MYg+Yeo7m+WjFzLuSX2OLGCOmYFsxT1QAjTicMi8hGeJhhYIs9w1BsP5iTpo4oQkyrL8I3lMmx3VJBPCwN73XoBV07RqTv Date: Sat, 28 Jan 2023 22:32:42 +0530 From: Deepak R Varma To: Anil Gurumurthy , Sudarsana Kalluru , "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: bfa: Use min 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?1756287862962274218?= X-GMAIL-MSGID: =?utf-8?q?1756287862962274218?= Simplify code by using min helper macros for logical evaluation and value assignment. Use the _t variant when the variable types are not same. The change also facilitates code realignment for improved readability. Proposed change is identified using minmax.cocci Coccinelle script. Signed-off-by: Deepak R Varma --- drivers/scsi/bfa/bfa_fcbuild.c | 3 +-- drivers/scsi/bfa/bfa_fcs_rport.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/bfa/bfa_fcbuild.c b/drivers/scsi/bfa/bfa_fcbuild.c index df18d9d2af53..a58a73e596c0 100644 --- a/drivers/scsi/bfa/bfa_fcbuild.c +++ b/drivers/scsi/bfa/bfa_fcbuild.c @@ -1092,8 +1092,7 @@ fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, memset(rftid, 0, sizeof(struct fcgs_rftid_req_s)); rftid->dap = s_id; - memcpy((void *)rftid->fc4_type, (void *)fc4_bitmap, - (bitmap_size < 32 ? bitmap_size : 32)); + memcpy((void *)rftid->fc4_type, (void *)fc4_bitmap, min_t(u32, bitmap_size, 32)); return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s); } diff --git a/drivers/scsi/bfa/bfa_fcs_rport.c b/drivers/scsi/bfa/bfa_fcs_rport.c index c21aa37b8adb..d501314be8d8 100644 --- a/drivers/scsi/bfa/bfa_fcs_rport.c +++ b/drivers/scsi/bfa/bfa_fcs_rport.c @@ -2539,10 +2539,7 @@ bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, struct fc_logi_s *plogi) * - MAX receive frame size */ rport->cisc = plogi->csp.cisc; - if (be16_to_cpu(plogi->class3.rxsz) < be16_to_cpu(plogi->csp.rxsz)) - rport->maxfrsize = be16_to_cpu(plogi->class3.rxsz); - else - rport->maxfrsize = be16_to_cpu(plogi->csp.rxsz); + rport->maxfrsize = min(be16_to_cpu(plogi->class3.rxsz), be16_to_cpu(plogi->csp.rxsz)); bfa_trc(port->fcs, be16_to_cpu(plogi->csp.bbcred)); bfa_trc(port->fcs, port->fabric->bb_credit);