Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1266672iob; Thu, 12 May 2022 15:18:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX9kMj5bBRHsv48qO7MFPj/TdZHyVoswo2nOV+poXOxUxtkPvlSXl/ge8mqhZqeli3cxcQ X-Received: by 2002:a17:902:ea09:b0:15e:b761:3ca2 with SMTP id s9-20020a170902ea0900b0015eb7613ca2mr1732589plg.121.1652393893505; Thu, 12 May 2022 15:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652393893; cv=none; d=google.com; s=arc-20160816; b=loPFVlpBkm3/JhJWY9dJFZgEid1oksJfcd7cbkW+QflLlpZ2tURUu3E306NtnO58X8 fQd6uwiAcIT08gU3VOyWeFtHbtS1OuqEGDn54EPMkvv2keBq6YmUnpQmh0l7289NY2rD SHpTvCRrIIhC/p3aP7RuHpgJBa/eSeYS0mPgMtaHnMVY+mh7i44dW7nlWH4ink6dxiTc Ntp8ZisS4W0qqhjzdTDCKjpXOzQyyxhSCbSR/hvjSiI7XqjqK6x1xiFKFicw5PbxDdF4 USarK2BwzSmQMPAr06505nzu1yq2WtqwH+ge6ujwhE1ZnmZ6z+mBVQXucFXRPSKjWvbq HFZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vDBRjfcj53x2BcE3SDzlmC5H1io+PIw8A0T82r+QDLI=; b=XKyLqKfodFO0DqLZ7rNCsLncyKeEXu/SUePWBwnMhn0hPH/Q0pWgA25xAjGFNpSh1G 6Hismg2fzxWD6QrxPwoBUdFzRlDsIg6RxMNa1DFJ0ueQI4IXIkVyb++HYg/nLNR7zMxk nyuRY2oXxbuyi0qcAw4nqizwgg9qQJ9Qeo+s/PG6MYSVRIsmuuyDD/XqPJnD9VSGxn9r MIt7kakETNJRHSjzf4uAWc77mOY5T4J9xKyxJUKykgu6dtf6jEOlp4I2cYJ5XvowAgAL KBawguCNyuinKgRlYwItPQ+AmjSBDDyNVi7tWauDW5rP3OjwBQ1STSuU3ffV68fe7317 WxRQ== ARC-Authentication-Results: i=1; mx.google.com; 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=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a63b14c000000b003995aee3634si840872pgp.175.2022.05.12.15.17.19; Thu, 12 May 2022 15:18:13 -0700 (PDT) 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; 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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350137AbiELGJ0 (ORCPT + 99 others); Thu, 12 May 2022 02:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350110AbiELGJU (ORCPT ); Thu, 12 May 2022 02:09:20 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2EDC104C83; Wed, 11 May 2022 23:09:16 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VCzTSH7_1652335746; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0VCzTSH7_1652335746) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 May 2022 14:09:14 +0800 From: Jiapeng Chong To: wellslutw@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, p.zabel@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH v2] net: ethernet: Use swap() instead of open coding it Date: Thu, 12 May 2022 14:09:05 +0800 Message-Id: <20220512060905.33744-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 Clean the following coccicheck warning: ./drivers/net/ethernet/sunplus/spl2sw_driver.c:217:27-28: WARNING opportunity for swap(). ./drivers/net/ethernet/sunplus/spl2sw_driver.c:222:27-28: WARNING opportunity for swap(). Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong --- Changes in v2: -Delete useless comments. drivers/net/ethernet/sunplus/spl2sw_driver.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c index 8320fa833d3e..1cb7076f946d 100644 --- a/drivers/net/ethernet/sunplus/spl2sw_driver.c +++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c @@ -204,28 +204,16 @@ static const struct net_device_ops netdev_ops = { static void spl2sw_check_mac_vendor_id_and_convert(u8 *mac_addr) { - u8 tmp; - /* Byte order of MAC address of some samples are reversed. * Check vendor id and convert byte order if it is wrong. * OUI of Sunplus: fc:4b:bc */ if (mac_addr[5] == 0xfc && mac_addr[4] == 0x4b && mac_addr[3] == 0xbc && (mac_addr[0] != 0xfc || mac_addr[1] != 0x4b || mac_addr[2] != 0xbc)) { - /* Swap mac_addr[0] and mac_addr[5] */ - tmp = mac_addr[0]; - mac_addr[0] = mac_addr[5]; - mac_addr[5] = tmp; - - /* Swap mac_addr[1] and mac_addr[4] */ - tmp = mac_addr[1]; - mac_addr[1] = mac_addr[4]; - mac_addr[4] = tmp; - - /* Swap mac_addr[2] and mac_addr[3] */ - tmp = mac_addr[2]; - mac_addr[2] = mac_addr[3]; - mac_addr[3] = tmp; + + swap(mac_addr[0], mac_addr[5]); + swap(mac_addr[1], mac_addr[4]); + swap(mac_addr[2], mac_addr[3]); } } -- 2.20.1.7.g153144c