aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-07-15 13:05:16 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-07-15 13:05:16 +0000
commit6ccacc5e4f961ca89bd6cc011ef6c29ae1962efa (patch)
tree51d59fc34fa30e5ef09f2029caa877ee0c1c4baa /target/linux/generic/files/drivers
parent430322ad5503bd865116cd48121873c917251fec (diff)
downloadupstream-6ccacc5e4f961ca89bd6cc011ef6c29ae1962efa.tar.gz
upstream-6ccacc5e4f961ca89bd6cc011ef6c29ae1962efa.tar.bz2
upstream-6ccacc5e4f961ca89bd6cc011ef6c29ae1962efa.zip
generic: rtl8366: introduce rtl8366_smi_alloc
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22195 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.c20
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.h1
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366rb.c4
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366s.c4
4 files changed, 20 insertions, 9 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
index d0b3680562..ac8862ced6 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
@@ -741,13 +741,27 @@ static void rtl8366_smi_mii_cleanup(struct rtl8366_smi *smi)
mdiobus_free(smi->mii_bus);
}
+struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent)
+{
+ struct rtl8366_smi *smi;
+
+ BUG_ON(!parent);
+
+ smi = kzalloc(sizeof(*smi), GFP_KERNEL);
+ if (!smi) {
+ dev_err(parent, "no memory for private data\n");
+ return NULL;
+ }
+
+ smi->parent = parent;
+ return smi;
+}
+EXPORT_SYMBOL_GPL(rtl8366_smi_alloc);
+
int rtl8366_smi_init(struct rtl8366_smi *smi)
{
int err;
- if (!smi->parent)
- return -EINVAL;
-
if (!smi->ops)
return -EINVAL;
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
index bd16cbe55e..775f95935e 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
@@ -87,6 +87,7 @@ struct rtl8366_smi_ops {
int port, unsigned long long *val);
};
+struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent);
int rtl8366_smi_init(struct rtl8366_smi *smi);
void rtl8366_smi_cleanup(struct rtl8366_smi *smi);
int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index 2156078f86..aa0b4a0b71 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -1133,14 +1133,12 @@ static int __init rtl8366rb_probe(struct platform_device *pdev)
goto err_out;
}
- smi = kzalloc(sizeof(*smi), GFP_KERNEL);
+ smi = rtl8366_smi_alloc(&pdev->dev);
if (!smi) {
- dev_err(&pdev->dev, "no memory for private data\n");
err = -ENOMEM;
goto err_out;
}
- smi->parent = &pdev->dev;
smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck;
smi->ops = &rtl8366rb_smi_ops;
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
index 923f51a977..6f3fdd5092 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
@@ -1160,14 +1160,12 @@ static int __init rtl8366s_probe(struct platform_device *pdev)
goto err_out;
}
- smi = kzalloc(sizeof(*smi), GFP_KERNEL);
+ smi = rtl8366_smi_alloc(&pdev->dev);
if (!smi) {
- dev_err(&pdev->dev, "no memory for private data\n");
err = -ENOMEM;
goto err_out;
}
- smi->parent = &pdev->dev;
smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck;
smi->ops = &rtl8366s_smi_ops;