Commit 8af1a9af authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski

net: phy: smsc: use device-managed clock API

Simplify the code by using the device-managed clock API.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/b222be68-ba7e-999d-0a07-eca0ecedf74e@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 6edd302a
......@@ -46,7 +46,6 @@ static struct smsc_hw_stat smsc_hw_stats[] = {
struct smsc_phy_priv {
u16 intmask;
bool energy_enable;
struct clk *refclk;
};
static int smsc_phy_ack_interrupt(struct phy_device *phydev)
......@@ -285,20 +284,12 @@ static void smsc_get_stats(struct phy_device *phydev,
data[i] = smsc_get_stat(phydev, i);
}
static void smsc_phy_remove(struct phy_device *phydev)
{
struct smsc_phy_priv *priv = phydev->priv;
clk_disable_unprepare(priv->refclk);
clk_put(priv->refclk);
}
static int smsc_phy_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct device_node *of_node = dev->of_node;
struct smsc_phy_priv *priv;
int ret;
struct clk *refclk;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
......@@ -312,22 +303,12 @@ static int smsc_phy_probe(struct phy_device *phydev)
phydev->priv = priv;
/* Make clk optional to keep DTB backward compatibility. */
priv->refclk = clk_get_optional(dev, NULL);
if (IS_ERR(priv->refclk))
return dev_err_probe(dev, PTR_ERR(priv->refclk),
refclk = devm_clk_get_optional_enabled(dev, NULL);
if (IS_ERR(refclk))
return dev_err_probe(dev, PTR_ERR(refclk),
"Failed to request clock\n");
ret = clk_prepare_enable(priv->refclk);
if (ret)
return ret;
ret = clk_set_rate(priv->refclk, 50 * 1000 * 1000);
if (ret) {
clk_disable_unprepare(priv->refclk);
return ret;
}
return 0;
return clk_set_rate(refclk, 50 * 1000 * 1000);
}
static struct phy_driver smsc_phy_driver[] = {
......@@ -429,7 +410,6 @@ static struct phy_driver smsc_phy_driver[] = {
/* PHY_BASIC_FEATURES */
.probe = smsc_phy_probe,
.remove = smsc_phy_remove,
/* basic functions */
.read_status = lan87xx_read_status,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment