From nobody Mon Feb 9 13:01:03 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDED116DC28 for ; Wed, 28 Jan 2026 21:52:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769637145; cv=none; b=opu6uKqwEg2LsPIm+53Tprgt39siiO6Xf7wnbUzo8vuA3bZCMpHiR057iqyNgqTJPGAr1JyGieaXFnrIRxiXjzTEFem970pi9FLsg+PmCv8E39gsa8iAWOpmv5lF8FS6cm271aP6EvLoK4EkDOu/jsdaoxpK+U1VhEn/Jlq4lGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769637145; c=relaxed/simple; bh=oaKYUxuLnfKa0XbLlzcnsjYgUmDbWBbOM8jS1Hbn1Rk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vAEYTkAg15x6qna8yfNENWisCZuCvrDxgW4a5Nw5tL+pC3Le5aJ3yyF3KUYTLvkXbCGIhHX8myBr7021HG7sS1dOffWwftSRpBKmysq2CKBpFC7MSrC+QO6R8lDXVpkXAMLV99gfXRvys8EMVe32wlvXBwECn6d/pXdDZ9CXJDI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MVkFyuH/; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MVkFyuH/" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2a09a3bd9c5so1640125ad.3 for ; Wed, 28 Jan 2026 13:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769637143; x=1770241943; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bMTrzu5hSLCA2plrTyP1x2jCu/VUChRHqXUHm8mbcHo=; b=MVkFyuH/zOaievfsNA32xi60ptuqBiptsSY2FXnaoNTLWJeNJU8vWwSpl+in/Qx05a id51BYW9ehSUM3E+6Ml9iuPuAMzxLmsEfHvPCf5zDeb2m7KDlAbe0D6ee7TCVajU9MRr S5bjG/mRRige4pN5hQd9nEd9dWaqnNuoquSewfjt7td4dLttQz3+LeJTw+LfRx2028Zx XTgCMvk187DNQXlOxsmSfbLRymNlA0Oji6H/MVFMbjkAm3VOMmvSa4t0+BoVPEJ1ln5C gtvdBSu+OhxLD8vnDx7WZ1vQRGKZe3UjdSYRjqm2nx6bE2liQ2eDWc04tf44LFHwLbmf fwWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769637143; x=1770241943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bMTrzu5hSLCA2plrTyP1x2jCu/VUChRHqXUHm8mbcHo=; b=O1zVdaF6PqNzLSYrmCQjZxzhEsxEORxA9QwOJ1Rdor/TLLJOd4Jsza+A3DZ1u93HXT HzLi2+tjPRATd5MRxnuaaq94MxapWK+IwSgSG/Flqf/k9tjYK62PdoAWJmQGtk5FvvDI vjv5bAADCnGny8LIt+95nDYYHceFz3vgdePhBhINAe5DKrIaAVUpXPk+8hVp83fr7P5b PtLy0RVM2fpIMUnGjDLgG8QEIAslrtvoyJAkYVUrISVd1ykhWZH3EvY7AZIpvsmjJhLg pGKKULBAFwb1CANBRsfketM+j+vLWaGcUdMYuoWlLnGqB3d/WV1w8FNgRfIO//G/yIS6 rnSQ== X-Forwarded-Encrypted: i=1; AJvYcCX4q2qNFrUfnTmNuj3ZWqhuLfgqcPU76PHr6gOX6L3HGj/uPwT7LgxJznPLYnGni6BvG6vmbMVgdp4Fa9A=@vger.kernel.org X-Gm-Message-State: AOJu0YxxpCIA83kRiow42pGRHNZUrLVnYs5igO11ljR4QEgXtydqzvH2 PkXbIKij4kh//WIZbKEtefXZ/DHMlAjC9YAcyxid4+SoPk6D7+3PNI1x X-Gm-Gg: AZuq6aLSYTWX10pIDGp2uSm4MhT39srjxfU/iRPztcp5nBb1qtX5jES2NRfA72yf5BQ LuOul0aZstGa2E7E4zEOEecOgQiRefxoEih3HRfIvW4k2QXVwf4+bDNR17j4pU73sa9RCvdA8KC f7judySlaVq/IAOURLwMvGFMPUOfwDhhzNQVwwcCXftG5K0+3fvUXyvC1ASh+LvbBE88OCk6ESZ Q54KrTS/OT52PUpZsaVHfP4J4wWLCzED4qUlaaO9AAKhUbO2GP+rsAvtGgry+kew+ph/nqCTcd5 en7A9oHFopVelnDAD7w05Aqb6wfxY4L8uuKJdyxSx5/tvPOBuqdLWtW5/DiIjiiUljTcRM1NUUU gJLLqVRJo43bBNQpJQ1omBj9mr4HGcre1dL2AXXlv53gg6UcUijJ3Yq/1+GEElFiof4So/gbqD0 m1pjuJ4kDHL88u7aJyCp3t5w6AKMTkhfeynPU= X-Received: by 2002:a17:902:d511:b0:2a0:8358:88f8 with SMTP id d9443c01a7336-2a870d721cdmr63618915ad.22.1769637143057; Wed, 28 Jan 2026 13:52:23 -0800 (PST) Received: from d.home.mmyangfl.tk ([2a09:bac1:7680:d30::4:384]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a88b6e4317sm31576155ad.85.2026.01.28.13.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jan 2026 13:52:22 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v5 3/4] net: dsa: yt921x: Refactor yt921x_chip_setup() Date: Thu, 29 Jan 2026 05:51:55 +0800 Message-ID: <20260128215202.2244266-4-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128215202.2244266-1-mmyangfl@gmail.com> References: <20260128215202.2244266-1-mmyangfl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" yt921x_chip_setup() is already pretty long, and is going to become longer. Split it into parts. Signed-off-by: David Yang --- drivers/net/dsa/yt921x.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c index ef9048b904ab..31ed21acb5df 100644 --- a/drivers/net/dsa/yt921x.c +++ b/drivers/net/dsa/yt921x.c @@ -2902,7 +2902,7 @@ static int yt921x_chip_reset(struct yt921x_priv *priv) return 0; } =20 -static int yt921x_chip_setup(struct yt921x_priv *priv) +static int yt921x_chip_setup_dsa(struct yt921x_priv *priv) { struct dsa_switch *ds =3D &priv->ds; unsigned long cpu_ports_mask; @@ -2920,16 +2920,6 @@ static int yt921x_chip_setup(struct yt921x_priv *pri= v) if (res) return res; =20 - /* Enable and clear MIB */ - res =3D yt921x_reg_set_bits(priv, YT921X_FUNC, YT921X_FUNC_MIB); - if (res) - return res; - - ctrl =3D YT921X_MIB_CTRL_CLEAN | YT921X_MIB_CTRL_ALL_PORT; - res =3D yt921x_reg_write(priv, YT921X_MIB_CTRL, ctrl); - if (res) - return res; - /* Setup software switch */ ctrl =3D YT921X_CPU_COPY_TO_EXT_CPU; res =3D yt921x_reg_write(priv, YT921X_CPU_COPY, ctrl); @@ -2982,6 +2972,29 @@ static int yt921x_chip_setup(struct yt921x_priv *pri= v) if (res) return res; =20 + return 0; +} + +static int yt921x_chip_setup(struct yt921x_priv *priv) +{ + u32 ctrl; + int res; + + ctrl =3D YT921X_FUNC_MIB; + res =3D yt921x_reg_set_bits(priv, YT921X_FUNC, ctrl); + if (res) + return res; + + res =3D yt921x_chip_setup_dsa(priv); + if (res) + return res; + + /* Clear MIB */ + ctrl =3D YT921X_MIB_CTRL_CLEAN | YT921X_MIB_CTRL_ALL_PORT; + res =3D yt921x_reg_write(priv, YT921X_MIB_CTRL, ctrl); + if (res) + return res; + /* Miscellaneous */ res =3D yt921x_reg_set_bits(priv, YT921X_SENSOR, YT921X_SENSOR_TEMP); if (res) --=20 2.51.0