From patchwork Wed Aug 28 03:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780430 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 522DC14B946; Wed, 28 Aug 2024 03:16:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724814967; cv=none; b=nqgnGe6Gqv+MvU2vhyIYpPGXSPv/5uVEEJ8nnUGfGiBRXo5ouZ5RRd4HWIk7n8uBhMCXGiJkD33zmijg3q3I+qxOzjfCIAyxq8XmarpaMIRjn01s9LbZu/FzMD6yS/h3Mn1ghVFA+lDUiO++rPsIf3s3v5g3QMOpjlcqIy2egx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724814967; c=relaxed/simple; bh=jtLZ3cvhFS5UQh7cvmbTOAtJdUhhsDBvkZN5KPxL1Qc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R4mWl/CkeE5Z127Oc3VGGnZaAYW4bXu9eYcqbircCeAF02eGFw7s4wbi8jA5ArZDYApOnt8LY254WYGcpXXTMSIS1VWyjKK+VfZKmy/JFT3RGx0CXyPAvIcvC15naH0G3vGkRGlGm03xJu6l+4fYsLaItMH3LKpOkHMeQzlRaWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WtqKb23MqzyQgl; Wed, 28 Aug 2024 11:15:15 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 4F903180AE6; Wed, 28 Aug 2024 11:16:03 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 28 Aug 2024 11:16:02 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH net-next v2 11/13] net: dsa: microchip: Use __free() to simplfy code Date: Wed, 28 Aug 2024 11:23:41 +0800 Message-ID: <20240828032343.1218749-12-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828032343.1218749-1-ruanjinjie@huawei.com> References: <20240828032343.1218749-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Avoids the need for manual cleanup of_node_put() by using __free(). Signed-off-by: Jinjie Ruan Reviewed-by: Jonathan Cameron --- v2: - Split into 2 patches. --- drivers/net/dsa/microchip/ksz_common.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 86ed563938f6..8058a0b7c161 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -4595,7 +4595,6 @@ static int ksz_parse_drive_strength(struct ksz_device *dev) int ksz_switch_register(struct ksz_device *dev) { const struct ksz_chip_data *info; - struct device_node *ports; phy_interface_t interface; unsigned int port_num; int ret; @@ -4677,7 +4676,8 @@ int ksz_switch_register(struct ksz_device *dev) ret = of_get_phy_mode(dev->dev->of_node, &interface); if (ret == 0) dev->compat_interface = interface; - ports = of_get_child_by_name(dev->dev->of_node, "ethernet-ports"); + struct device_node *ports __free(device_node) = + of_get_child_by_name(dev->dev->of_node, "ethernet-ports"); if (!ports) ports = of_get_child_by_name(dev->dev->of_node, "ports"); if (ports) { @@ -4685,16 +4685,13 @@ int ksz_switch_register(struct ksz_device *dev) if (of_property_read_u32(port, "reg", &port_num)) continue; - if (!(dev->port_mask & BIT(port_num))) { - of_node_put(ports); + if (!(dev->port_mask & BIT(port_num))) return -EINVAL; - } of_get_phy_mode(port, &dev->ports[port_num].interface); ksz_parse_rgmii_delay(dev, port_num, port); } - of_node_put(ports); } dev->synclko_125 = of_property_read_bool(dev->dev->of_node, "microchip,synclko-125");