Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2790022iob; Mon, 16 May 2022 06:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzOKo33Nfjaz9IiFul3ybBWGnCWF0njiGCP1hUWN14sPxWV4U6s8MWqQO3j9HDF/J8X9lF X-Received: by 2002:a17:906:58cf:b0:6f4:4fe8:6092 with SMTP id e15-20020a17090658cf00b006f44fe86092mr15100528ejs.160.1652707428746; Mon, 16 May 2022 06:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652707428; cv=none; d=google.com; s=arc-20160816; b=gKzVz+vErfUzjY3kMhLiRj09JdAL0Chvhuw6ilM50Haihr30Nksas3FsxOarXL/VZk wuKL1q1s4riGQUQZjcOwcY7qQNmLWuGWnOZ8Fy3jNJPayyQ194K0hXJvGS+0jrmrc3im CWggIHdFmhKYTRfeX7MGUoOdGPXOMpMYhzdtnmu9jqQrpnruh/JfVpABV4TCneszLVf+ oh/XP61FMzdYv7t2bju26WwTY62y5CQgHPWc8E2W4HpJXQSJesOvDj69ay7SjFHqCwCy oosDhRCLC3CdXwPzpFejc49bNm9dpAiyJopyNxMVvqhEQAcg2o5wW+dWKvjWievh3wnw wHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=rm9YkkwtDL0YcJNxRgQUShnYH7rP76swq1NKuXONdWs=; b=yubBizP5NWN83bOh/u+UAFFgXRARebgRR74s+95w4O2V1gNnFdTTmEivFQfeZR5tKy rg+uwnihZ0Wg7AzQOpN8Ntl8DQQCbt6Lt8mGPLIDxo+qzdJOxMey59qxFLB9AQrqg0zs siBBvtU5Uc1xaI/u9luDkK+cxVYPPK3puzCgbPnMlm4lZ1/hxma0sZ/Y/Ass+KoSkFkL eAYjHdKaGxXjClVW605Tzl20J/8I2YyCYTwMQmumGJBDWUOtRD2wD6e98TvATaVQPo6A CHKDJKvUJ8YbwFF7dsba+H2cprcF7RadxNhbMx4+zyyzprvwYRKyiLUx+rFfZ+3Dy+eN ai4g== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w21-20020a05640234d500b00418ed45e7ddsi11861395edc.38.2022.05.16.06.23.22; Mon, 16 May 2022 06:23:48 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240266AbiEPG1g (ORCPT + 99 others); Mon, 16 May 2022 02:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235673AbiEPG12 (ORCPT ); Mon, 16 May 2022 02:27:28 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE27E2611C; Sun, 15 May 2022 23:27:25 -0700 (PDT) Received: from kwepemi500015.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L1q614v33zgY7h; Mon, 16 May 2022 14:26:49 +0800 (CST) Received: from huawei.com (10.175.101.6) by kwepemi500015.china.huawei.com (7.221.188.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 14:27:22 +0800 From: Lu Wei To: , , , , , , , , Subject: [PATCH net-next] ax25: merge repeat codes in ax25_dev_device_down() Date: Mon, 16 May 2022 14:28:04 +0800 Message-ID: <20220516062804.254742-1-luwei32@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500015.china.huawei.com (7.221.188.92) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Merge repeat codes to reduce the duplication. Signed-off-by: Lu Wei --- net/ax25/ax25_dev.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c index d2a244e1c260..b80fccbac62a 100644 --- a/net/ax25/ax25_dev.c +++ b/net/ax25/ax25_dev.c @@ -115,23 +115,13 @@ void ax25_dev_device_down(struct net_device *dev) if ((s = ax25_dev_list) == ax25_dev) { ax25_dev_list = s->next; - spin_unlock_bh(&ax25_dev_lock); - ax25_dev_put(ax25_dev); - dev->ax25_ptr = NULL; - dev_put_track(dev, &ax25_dev->dev_tracker); - ax25_dev_put(ax25_dev); - return; + goto unlock_put; } while (s != NULL && s->next != NULL) { if (s->next == ax25_dev) { s->next = ax25_dev->next; - spin_unlock_bh(&ax25_dev_lock); - ax25_dev_put(ax25_dev); - dev->ax25_ptr = NULL; - dev_put_track(dev, &ax25_dev->dev_tracker); - ax25_dev_put(ax25_dev); - return; + goto unlock_put; } s = s->next; @@ -139,6 +129,14 @@ void ax25_dev_device_down(struct net_device *dev) spin_unlock_bh(&ax25_dev_lock); dev->ax25_ptr = NULL; ax25_dev_put(ax25_dev); + return; + +unlock_put: + spin_unlock_bh(&ax25_dev_lock); + ax25_dev_put(ax25_dev); + dev->ax25_ptr = NULL; + dev_put_track(dev, &ax25_dev->dev_tracker); + ax25_dev_put(ax25_dev); } int ax25_fwd_ioctl(unsigned int cmd, struct ax25_fwd_struct *fwd) -- 2.17.1