summaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-10 18:42:04 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-10 18:42:04 +0000
commita38fe2356910a1803ad60f365494005a6992613b (patch)
treeb6e9a60547f510fbaaf801aa221413a883d84b2f /target/linux/generic/files/drivers/net
parent737f4a1c05c0bb6c9865eb9953f5b2460588a1d9 (diff)
generic: ar8216: add ar8xxx_create{,mii} helpers
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35543 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net')
-rw-r--r--target/linux/generic/files/drivers/net/phy/ar8216.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 4c83a6f62..f7fbf4e49 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -1742,9 +1742,6 @@ ar8xxx_mib_init(struct ar8216_priv *priv)
if (!priv->mib_stats)
return -ENOMEM;
- mutex_init(&priv->mib_lock);
- INIT_DELAYED_WORK(&priv->mib_work, ar8xxx_mib_work_func);
-
return 0;
}
@@ -1768,6 +1765,37 @@ ar8xxx_mib_cleanup(struct ar8216_priv *priv)
kfree(priv->mib_stats);
}
+static struct ar8216_priv *
+ar8xxx_create(void)
+{
+ struct ar8216_priv *priv;
+
+ priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
+ if (priv == NULL)
+ return NULL;
+
+ mutex_init(&priv->reg_mutex);
+ mutex_init(&priv->mib_lock);
+ INIT_DELAYED_WORK(&priv->mib_work, ar8xxx_mib_work_func);
+
+ return priv;
+}
+
+static struct ar8216_priv *
+ar8xxx_create_mii(struct mii_bus *bus)
+{
+ struct ar8216_priv *priv;
+
+ priv = ar8xxx_create();
+ if (priv) {
+ priv->mii_bus = bus;
+ priv->read = ar8216_mii_read;
+ priv->write = ar8216_mii_write;
+ }
+
+ return priv;
+}
+
static int
ar8216_config_init(struct phy_device *pdev)
{
@@ -1777,14 +1805,10 @@ ar8216_config_init(struct phy_device *pdev)
int ret;
if (!priv) {
- priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
+ priv = ar8xxx_create_mii(pdev->bus);
if (priv == NULL)
return -ENOMEM;
- priv->mii_bus = pdev->bus;
- priv->read = ar8216_mii_read;
- priv->write = ar8216_mii_write;
-
ret = ar8216_id_chip(priv);
if (ret)
goto err_free_priv;
@@ -1829,8 +1853,6 @@ ar8216_config_init(struct phy_device *pdev)
return 0;
}
- mutex_init(&priv->reg_mutex);
-
pdev->priv = priv;
swdev = &priv->dev;
@@ -2006,13 +2028,10 @@ ar8216_probe(struct phy_device *pdev)
if (!ar8xxx_is_possible(pdev->bus))
return -ENODEV;
- priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
+ priv = ar8xxx_create_mii(pdev->bus);
if (priv == NULL)
return -ENOMEM;
- priv->mii_bus = pdev->bus;
- priv->read = ar8216_mii_read;
- priv->write = ar8216_mii_write;
priv->phy = pdev;
ret = ar8216_id_chip(priv);