From nobody Tue Feb 10 19:16:10 2026 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 98BB62C08D5 for ; Tue, 27 Jan 2026 02:09:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769479757; cv=none; b=GGJvx+IeFm+ehk1EkpbOOHwT5dUNY2/dY/PcGGnWi7RaXodZVmggNPxiaKp3niH9DnpLhk+Es1MsJ/9EnGixnCyry9CD4mDieY9Br9xOJig/i6sgiexB+eqKv1CujzyXd/hURxJMWQDyE/RZYnvg3+7XAoAoqO73qEJ3g4sKLAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769479757; c=relaxed/simple; bh=MBs1LMoPjEjYdhkq4Ew/Rs+s+0tFbyUFwqgDEo7mlcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WQYy9omUHWXEEx+2hUUhvzHkl8PKNRTqFVuXCc4WhGEYqrsqCyYUbjTZ72BrAFWAKwVb4nQj/bjiW9b63XcE7bcKnsX7bVu35D54mdiD/nzwcVKDaW0VTXJ3rQ84C8+Ej+O453gyz1wqwq8bqi22pqFxyQu+UvJRWqk+7jTkUkk= 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=mOYJxOhF; arc=none smtp.client-ip=209.85.210.182 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="mOYJxOhF" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-81f4c0e2b42so2592478b3a.1 for ; Mon, 26 Jan 2026 18:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769479756; x=1770084556; 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=AB/9v+5HeIAl6n8QhVl8YEDoGPmeGe9LLib+gDQtwSk=; b=mOYJxOhFQukMIfQCtHXRUZzvjtCVg3mTjLxOVwu07sdwNhKeTQZiCfI4qVCYeSQt7P FRduQLHceAshXZRuxy/MmgJGI2zkiwjUBm1uGU2U6Pdcsee8y3sn2KuRcdRD5DbgizvE 3gs1wPRfxHAmfbYHaa3ScoMV5DNDQX0L1+6oSfiiZo8jsCISvlOhMts5TRsHu/3yZtCB oLClP3tconKyB7tf7RZxcnafwdMa8KPJ6TKOuWzqj4cYmzgGg8GOQk4rqEDdxIQbapmg meD1zQ+/dmZQO8XMHx/M27KRIte5xDsspDfiCkS8b8CbloL9hB44piL0nDLCvBKdh2w8 YibQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769479756; x=1770084556; 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=AB/9v+5HeIAl6n8QhVl8YEDoGPmeGe9LLib+gDQtwSk=; b=Dt925fWZBama3qQ/wVeeAoLPliWJClPZMdhO0gxL8iBzgqphcJ9PcPT6jcNgof5xP3 4CEd5RmTkSIJ48vb68M3S9ae7Rb0HJ7iG7LjpKzSrQaLO+AEbfziGQlBjJ/5qJdU7HSI SOKcXQGktVGDBGMpmkeJfSKi6NpoE6fCpMNRt+W1gXyF4Le2smzmjVTLVTwcVaK8DeRp 0HYc0LJdcueyGNAB05KSAtp9Niwm6jLv8y38BiDBbm6Zw6h/8tOTZnHIdqr9Y/VrDK8j CzEDpCT4hx39X+rQlj8+vYNPGQO6Cjap5LqOyE9IgKZH3AAAM1mnOnbeTL8I3U1o1503 6+gA== X-Forwarded-Encrypted: i=1; AJvYcCWggMHbWFezIwUB11kgoP5DAMSKiX5TExpG9KvK1HzHwYXUsXfBw2Byim6IHBDaYRT/lE19SW3Py/hpEl4=@vger.kernel.org X-Gm-Message-State: AOJu0YxoNFRNCAasdHWP1kp0YoyMfX9D57ZdNdOX2iGDFbMYaiUtovJm wuvgkywjBRtjVOGwkWfi4P0HR8QFHEWvP8+kK9or0TBAmCkcv8Ucg4Bg X-Gm-Gg: AZuq6aKbfp3QhCgNBhLuIOiQQs8l+OIf/pcasfT3GZ2A8dBcrImc6vGkCvGv/ZYD+Gw iJbGtvgdzyfvOzLtxHbu7QGuD1Ao2zM6oBhRB1rzqZkrnyG4usDiqA9cMgGOGlmbDespk1Z8ZDp tASf1jd2PmLe+4vtp0EfFhFFwOBh4Y7Ui3tZFS3RwP+HIRBsGOuvaO9jhIgEppC89BmGPwS09zp RmYgZ06ZPt8CojgBOOvccfre4l8eIn5VopkYGtMebNqNL7kUGEaZTIB4wPdwMfg8UbKlo4aL0gJ dJl6cr/Lr/STgGNdY7ttakAkPonEtA4lFFZIah5JJwRt2Rq0EvthZjCMVyXDlFSikMtZQxz+RWJ gGtbkccUdgnFDWVjuz9F1ZZUO/8zjG1Nknk8jf92+Y2ZL2l/1z/mk5ouIWCjHnO6p/3Iz0qz4Gc aGnE6atJFxNWmlQgaCFftBwasMU+eHmSLbFWP+yXF9BQ0fekzTak45GA== X-Received: by 2002:a17:90a:d448:b0:341:134:a962 with SMTP id 98e67ed59e1d1-353fed88d1bmr221870a91.28.1769479755915; Mon, 26 Jan 2026 18:09:15 -0800 (PST) Received: from d.home.mmyangfl.tk ([2001:19f0:8001:1644:5400:5ff:fe3e:12b1]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-353f613fc36sm693540a91.10.2026.01.26.18.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 18:09:15 -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 v4 3/4] net: dsa: yt921x: Refactor yt921x_chip_setup() Date: Tue, 27 Jan 2026 10:08:00 +0800 Message-ID: <20260127020847.1482724-4-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260127020847.1482724-1-mmyangfl@gmail.com> References: <20260127020847.1482724-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 880e3b5966f8..9ac0e4e236c6 100644 --- a/drivers/net/dsa/yt921x.c +++ b/drivers/net/dsa/yt921x.c @@ -2903,7 +2903,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; @@ -2921,16 +2921,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); @@ -2983,6 +2973,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