lkml.org 
[lkml]   [2023]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration
> +/**
> + * genphy_c45_plca_set_cfg - set PLCA configuration using standard registers
> + * @phydev: target phy_device struct
> + * @plca_cfg: structure containing the PLCA configuration. Fields set to -1 are
> + * not to be changed.
> + *
> + * Description: if the PHY complies to the Open Alliance TC14 10BASE-T1S PLCA
> + * Management Registers specifications, this function can be used to modify
> + * the PLCA configuration using the standard registers in MMD 31.
> + */
> +int genphy_c45_plca_set_cfg(struct phy_device *phydev,
> + const struct phy_plca_cfg *plca_cfg)
> +{
> + int ret;
> + u16 val;
> +
> + // PLCA IDVER is read-only
> + if (plca_cfg->version >= 0)
> + return -EINVAL;
> +
> + // first of all, disable PLCA if required
> + if (plca_cfg->enabled == 0) {
> + ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
> + MDIO_OATC14_PLCA_CTRL0,
> + MDIO_OATC14_PLCA_EN);
> +
> + if (ret < 0)
> + return ret;
> + }
> +
> + if (plca_cfg->node_cnt >= 0 || plca_cfg->node_id >= 0) {
> + if (plca_cfg->node_cnt < 0 || plca_cfg->node_id < 0) {

I think it would be good to add some comments since this code is not
immediately obvious to me. I had to think about it for a while.

> + if (plca_cfg->burst_cnt >= 0 || plca_cfg->burst_tmr >= 0) {
> + if (plca_cfg->burst_cnt < 0 || plca_cfg->burst_tmr < 0) {
> + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2,
> + MDIO_OATC14_PLCA_BURST);
> +

This follows the same patterns, so maybe comments here as well?

With that, you can add my Reviewed-by.

Andrew

\
 
 \ /
  Last update: 2023-03-26 23:31    [W:0.497 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site