lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <ea9ed7f72adb0bd83581e9f55f99fb8630e7bc48.camel@microchip.com> Date: Fri, 16 Dec 2022 08:41:09 +0000 From: <Arun.Ramadoss@...rochip.com> To: <netdev@...r.kernel.org>, <linux-riscv@...ts.infradead.org>, <yanhong.wang@...rfivetech.com>, <linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org> CC: <andrew@...n.ch>, <robh+dt@...nel.org>, <pgwipeout@...il.com>, <kernel@...il.dk>, <kuba@...nel.org>, <pabeni@...hat.com>, <edumazet@...gle.com>, <richardcochran@...il.com>, <krzysztof.kozlowski+dt@...aro.org>, <davem@...emloft.net>, <hkallweit1@...il.com> Subject: Re: [PATCH v2 6/9] net: phy: motorcomm: Add YT8531 phy support Hi Yanhong, On Fri, 2022-12-16 at 15:06 +0800, Yanhong Wang wrote: > This adds basic support for the Motorcomm YT8531 > Gigabit Ethernet PHY. > > Signed-off-by: Yanhong Wang <yanhong.wang@...rfivetech.com> > --- > drivers/net/phy/Kconfig | 3 +- > drivers/net/phy/motorcomm.c | 202 > ++++++++++++++++++++++++++++++++++++ > 2 files changed, 204 insertions(+), 1 deletion(-) > > > +static int ytphy_read_ext(struct phy_device *phydev, u32 regnum) > +{ > + int ret; > + int val; > + > + ret = __phy_write(phydev, YT8511_PAGE_SELECT, regnum); > + if (ret < 0) > + return ret; You are returning the error value as well as the read value in the function. But in the config_init, you are not checking the error value, just using the value directly. So instead of returning both the value and error, you may consider return error and for value use call by reference. > + > + val = __phy_read(phydev, YT8511_PAGE); > + > + return val; > +} > + > + > static int yt8511_config_init(struct phy_device *phydev) > { > int oldpage, ret = 0; > @@ -111,6 +191,116 @@ static int yt8511_config_init(struct phy_device > *phydev) > return phy_restore_page(phydev, oldpage, ret); > } > > +static int ytphy_config_init(struct phy_device *phydev) > +{ > + struct device_node *of_node; > + u32 val; > + u32 mask; > + u32 cfg; > + int ret; > + int i = 0; i initialized here as well as in for loop. > + > + of_node = phydev->mdio.dev.of_node; > + if (of_node) { to reduce the ident level, you may consider returning here by checking if(!of_node) return -EINVAL; > + ret = of_property_read_u32(of_node, > ytphy_rxden_grp[0].name, &cfg); > + if (!ret) { > + mask = ytphy_rxden_grp[0].mask; > + val = ytphy_read_ext(phydev, > YTPHY_EXT_CHIP_CONFIG); > + > + /* check the cfg overflow or not */ > + cfg = cfg > mask >> (ffs(mask) - 1) ? mask : > cfg; > + > + val &= ~mask; > + val |= FIELD_PREP(mask, cfg); > + ytphy_write_ext(phydev, YTPHY_EXT_CHIP_CONFIG, > val); > + } > + > + val = ytphy_read_ext(phydev, YTPHY_EXT_RGMII_CONFIG1); > + for (i = 0; i < ARRAY_SIZE(ytphy_rxtxd_grp); i++) { > + ret = of_property_read_u32(of_node, > ytphy_rxtxd_grp[i].name, &cfg); > + if (!ret) { > + mask = ytphy_rxtxd_grp[i].mask; > + > + /* check the cfg overflow or not */ > + cfg = cfg > mask >> (ffs(mask) - 1) ? > mask : cfg; > + > + val &= ~mask; > + val |= cfg << (ffs(mask) - 1); > + } > + } > + return ytphy_write_ext(phydev, YTPHY_EXT_RGMII_CONFIG1, > val); > + } > + > + phydev_err(phydev, "Get of node fail\n"); > + > + return -EINVAL; > +} > + > +static void ytphy_link_change_notify(struct phy_device *phydev) > +{ > + u32 val; > + struct ytphy_priv_t *ytphy_priv = phydev->priv; reverse christmas tree > + > + if (phydev->speed < 0) > + return; > + > + > +static int yt8531_probe(struct phy_device *phydev) > +{ > + struct ytphy_priv_t *priv; > + const struct device_node *of_node; Reverse christmas tree. > + u32 val; > + int ret; > + > + priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), > GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + of_node = phydev->mdio.dev.of_node; > + if (of_node) { > + ret = of_property_read_u32(of_node, > ytphy_txinver_grp[0].name, &val); > + if (!ret) > + priv->tx_inverted_1000 = val; > + > + ret = of_property_read_u32(of_node, > ytphy_txinver_grp[1].name, &val); > + if (!ret) > + priv->tx_inverted_100 = val; > + > + ret = of_property_read_u32(of_node, > ytphy_txinver_grp[2].name, &val); > + if (!ret) > + priv->tx_inverted_10 = val; > + } > + phydev->priv = priv; > + > + return 0; > +} > + >
Powered by blists - more mailing lists