Re: [PATCH net-next v1] net:dsa:yt922x: Add support for Motorcomm YT922x
David Yang <[email protected]>
| Newsgroups | org.kernel.vger.netdev,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAAXyoMO3iZb5=xB-L5YU_PBjBFL83aJsjWipymsJGNfNwm0Sow@mail.gmail.com> |
On Mon, Aug 17, 2026 at 6:40 PM Kyle Switch <[email protected]> wrote: > >> +static int yt922x_cpu_tag_mode_set(struct yt921x_priv *priv) > >> +{ > >> + struct device *dev = to_device(priv); > >> + u16 eth_p_tag; > >> + u32 val; > >> + u32 val1; > >> + int res; > >> + > >> + /* cpu tag mode set */ > >> + res = yt921x_reg_read(priv, YT922X_CPU_TAG_RX_CTRL, &val); > >> + if (res) > >> + return res; > >> + res = yt921x_reg_read(priv, YT922X_CPU_TAG_TX_CTRL, &val1); > >> + if (res) > >> + return res; > >> + val &= ~YT922X_CPU_TAG_RX_MODE; > >> + val1 &= ~YT922X_CPU_TAG_TX_MODE; > >> + val1 &= ~YT922X_CPU_TAG_TX_TYPE; > >> + res = yt921x_reg_write(priv, YT922X_CPU_TAG_RX_CTRL, val); > >> + if (res) > >> + return res; > >> + res = yt921x_reg_write(priv, YT922X_CPU_TAG_TX_CTRL, val1); > >> + if (res) > >> + return res; > >> + > >> + /* tpid check */ > >> + res = yt921x_reg_read(priv, YT921X_CPU_TAG_TPID, &val); > >> + if (res) > >> + return res; > >> + eth_p_tag = FIELD_GET(YT921X_CPU_TAG_TPID_TPID_M, val); > >> + if (eth_p_tag != ETH_P_YT921X) { > >> + dev_err(dev, "Tag type 0x%x != 0x%x\n", eth_p_tag, > >> + ETH_P_YT921X); > >> + return -EINVAL; > >> + } > >> + > >> + return 0; > >> +} > > This looks similar to yt921x_chip_reset(), so you'd better merge it > > into yt922x_chip_reset() above. > > Ans:Given that this interface is responsible for mode selection related > to CPU tags, the cpu tag > > TPID check has been consolidated here as well. TPID does not depend on the tag mode, so this is a one-time validation right after resetting in yt921x_chip_reset(). Also the naming is confusing: why `mode_set` clears the `RX/TX_MODE`. It would be self-explanatory to rename it to `set_8b` and `RX/TX_TAG_4B`, and/or mention the existence of 4b mode in the comment for tag_yt922x as well.