From patchwork Sun Nov 6 10:21:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 16119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1427729wru; Sun, 6 Nov 2022 02:29:29 -0800 (PST) X-Google-Smtp-Source: AMsMyM5F8sMJLX7wMBvGlmsQa/KDFZSeOsdok3sxEUAkmZZ3/vZCCfrei6ATRZe1IZJ8HTYnjqhX X-Received: by 2002:a63:d64b:0:b0:46f:7941:a8ea with SMTP id d11-20020a63d64b000000b0046f7941a8eamr37905985pgj.331.1667730568663; Sun, 06 Nov 2022 02:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667730568; cv=none; d=google.com; s=arc-20160816; b=1BfEJtk5pIZAKrXuMr3gRNqKexaWV0AYxjBdT9LnBWayj5PA72X8BPC8ESzsLOS8QO t8LNQWbl0/U03Cc3/ftfiY0LCRR+AwyWXscvBqqMF9F7Ur/Sfw0DE8skGubVh9LH7C80 apQVFm0fAEzNHjKFpabBJuaJExA6czCSxKixClCadM4/ZMOH0bq7GNM2Hj6q+36SjRPe 1TO98WHjZUhpRpwIAPOQaM8E1Bh2UV4F5hO5triaGuBBwzfjpGVxvSVhX7Qdkh6/qb2O oRzvqWuJY1+/wBxIfft6DFbNISrUUwO9gutb0VTMiSyTpzHbuDnE7Zlr3F+GpOvl2qxU NdWw== 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:to:from:date:dkim-signature; bh=XjRMDXThxIXZVkZ8V587FdEStEQRUoB12xGT3K79WuI=; b=Bg+TRnC5pTZSbMYXv843TOTU5g5cizbsTIvJbBnFqxv1Glwc49+oUjijGI/06Q6lOB sMQQydZ93et4UNpSPf0+iyK6UCncWH3vzZJCHEuNwbErYdWfwwyjk3b+An92vtfkZ5yX wHkZsVG97K1ilTxa1/Alh3LmHS2z8QU+PUoI5x6k5Xo7thrnoj1sf6ncFZUVQZmdKdbO Dp8LvhXFP9vlC5HnCoUSJWbAJ/M/z3APQVZ6ymHRFFreKKe5vcmC2Ru72wRMMFvekkM5 KM+45zpLMBzlIRUv3S57b3idJA4eZDU3bC5hqwSCRXbEheC+IGqj8N5pA36XiO3QPvSd Ixvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=BXnanERq; 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 v7-20020a17090a898700b00205b268cd58si9727578pjn.181.2022.11.06.02.29.15; Sun, 06 Nov 2022 02:29:28 -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=BXnanERq; 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 S229841AbiKFKWT (ORCPT + 99 others); Sun, 6 Nov 2022 05:22:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbiKFKWR (ORCPT ); Sun, 6 Nov 2022 05:22:17 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 125946173 for ; Sun, 6 Nov 2022 02:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667730122; bh=ISjlC7Zy+nyFdyGUXO1A3JhMcsFjRxDUI5qhIuaQEww=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=BXnanERqeXpxhMkZZL6hWqf/Fk5eUEbmtImWn+m5Uc0A7KF7Um6w7Sf7M5NRAftzy 7zjFea4uFUItTNNSm/9W2ir0fpmkcjNfxOYmIeQ94A+40HhyZ40GzqBx5vdRIANQMg sIIJrSz1Upm30NdtKDdjHZYe29nb5EdsGmCeTauU= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 6 Nov 2022 11:22:02 +0100 (CET) X-EA-Auth: a+kvvG//INTDj2l+ci+g/2Ip90DYBs8/Wx6kRlgV1YlG+PWrT+xXkgxFT4PzrWnEJ9En91A+4LGBwibu1KVBfatWZZiw29ER Date: Sun, 6 Nov 2022 15:51:58 +0530 From: Deepak R Varma To: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: emxx_udc: use min helper macro for variable comparison 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?1748742248671230381?= X-GMAIL-MSGID: =?utf-8?q?1748742248671230381?= Simplify code by using min helper macros in place of lengthy if/else block oriented logical evaluation and value assignment. This issue is identified by coccicheck using the minmax.cocci file. Signed-off-by: Deepak R Varma --- drivers/staging/emxx_udc/emxx_udc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.34.1 diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index b6abd3770e81..b4e19174bef2 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -1004,10 +1004,7 @@ static int _nbu2ss_in_dma(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, /* MAX Packet Size */ mpkt = _nbu2ss_readl(&preg->EP_REGS[num].EP_PCKT_ADRS) & EPN_MPKT; - if ((DMA_MAX_COUNT * mpkt) < length) - i_write_length = DMA_MAX_COUNT * mpkt; - else - i_write_length = length; + i_write_length = min(DMA_MAX_COUNT * mpkt, length); /*------------------------------------------------------------*/ /* Number of transmission packets */