summaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net/phy/rtl8306.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-08-04 00:43:40 +0000
committerFelix Fietkau <nbd@openwrt.org>2010-08-04 00:43:40 +0000
commitbd6324190fb4784a51ae70ecd0b1e0c606213702 (patch)
treefb07f597da35c8b342abb43998198b47d8f3f34d /target/linux/generic/files/drivers/net/phy/rtl8306.c
parent86b209211e125479e547b18163b01dc99cfc400d (diff)
downloadmaster-31e0f0ae-bd6324190fb4784a51ae70ecd0b1e0c606213702.tar.gz
master-31e0f0ae-bd6324190fb4784a51ae70ecd0b1e0c606213702.tar.bz2
master-31e0f0ae-bd6324190fb4784a51ae70ecd0b1e0c606213702.zip
swconfig: cleanup of kernel drivers and interface - add some comments to a few data structures - add a switch_dev_ops data structure for attributes and callback to replace the stupid template memcpy - get rid of the switch_dev.priv pointer - using container_of() is better
SVN-Revision: 22476
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/rtl8306.c')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8306.c128
1 files changed, 60 insertions, 68 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8306.c b/target/linux/generic/files/drivers/net/phy/rtl8306.c
index 901b5b2f83..87c661a77a 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8306.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8306.c
@@ -250,11 +250,6 @@ static const struct rtl_reg rtl_regs[] = {
};
-/* IFXMIPS compat stuff - remove after PHY layer migration */
-static struct switch_dev rtldev;
-/* END IFXMIPS compat stuff */
-
-
static inline void
rtl_set_page(struct rtl_priv *priv, unsigned int page)
{
@@ -706,64 +701,6 @@ rtl_set_ports(struct switch_dev *dev, struct switch_val *val)
return 0;
}
-static int
-rtl8306_config_init(struct phy_device *pdev)
-{
- struct net_device *netdev = pdev->attached_dev;
- struct rtl_priv *priv = pdev->priv;
- struct switch_dev *dev = &priv->dev;
- struct switch_val val;
- unsigned int chipid, chipver, chiptype;
- int err;
-
- /* Only init the switch for the primary PHY */
- if (pdev->addr != 0)
- return 0;
-
- val.value.i = 1;
- memcpy(&priv->dev, &rtldev, sizeof(struct switch_dev));
- priv->do_cpu = 0;
- priv->page = -1;
- priv->bus = pdev->bus;
-
- dev->priv = priv;
-
- chipid = rtl_get(dev, RTL_REG_CHIPID);
- chipver = rtl_get(dev, RTL_REG_CHIPVER);
- chiptype = rtl_get(dev, RTL_REG_CHIPTYPE);
- switch(chiptype) {
- case 0:
- case 2:
- strncpy(priv->hwname, RTL_NAME_S, sizeof(priv->hwname));
- priv->type = RTL_TYPE_S;
- break;
- case 1:
- strncpy(priv->hwname, RTL_NAME_SD, sizeof(priv->hwname));
- priv->type = RTL_TYPE_SD;
- break;
- case 3:
- strncpy(priv->hwname, RTL_NAME_SDM, sizeof(priv->hwname));
- priv->type = RTL_TYPE_SDM;
- break;
- default:
- strncpy(priv->hwname, RTL_NAME_UNKNOWN, sizeof(priv->hwname));
- break;
- }
-
- dev->name = priv->hwname;
- rtl_hw_init(dev);
-
- printk(KERN_INFO "Registering %s switch with Chip ID: 0x%04x, version: 0x%04x\n", priv->hwname, chipid, chipver);
-
- err = register_switch(dev, netdev);
- if (err < 0) {
- kfree(priv);
- return err;
- }
-
- return 0;
-}
-
static struct switch_attr rtl_globals[] = {
{
.type = SWITCH_TYPE_INT,
@@ -897,11 +834,7 @@ static struct switch_attr rtl_vlan[] = {
},
};
-/* template */
-static struct switch_dev rtldev = {
- .cpu_port = RTL8306_PORT_CPU,
- .ports = RTL8306_NUM_PORTS,
- .vlans = RTL8306_NUM_VLANS,
+static const struct switch_dev_ops rtl8306_ops = {
.attr_global = {
.attr = rtl_globals,
.n_attr = ARRAY_SIZE(rtl_globals),
@@ -920,6 +853,65 @@ static struct switch_dev rtldev = {
.apply_config = rtl_hw_apply,
};
+static int
+rtl8306_config_init(struct phy_device *pdev)
+{
+ struct net_device *netdev = pdev->attached_dev;
+ struct rtl_priv *priv = pdev->priv;
+ struct switch_dev *dev = &priv->dev;
+ struct switch_val val;
+ unsigned int chipid, chipver, chiptype;
+ int err;
+
+ /* Only init the switch for the primary PHY */
+ if (pdev->addr != 0)
+ return 0;
+
+ val.value.i = 1;
+ priv->dev.cpu_port = RTL8306_PORT_CPU;
+ priv->dev.ports = RTL8306_NUM_PORTS;
+ priv->dev.vlans = RTL8306_NUM_VLANS;
+ priv->dev.ops = &rtl8306_ops;
+ priv->do_cpu = 0;
+ priv->page = -1;
+ priv->bus = pdev->bus;
+
+ chipid = rtl_get(dev, RTL_REG_CHIPID);
+ chipver = rtl_get(dev, RTL_REG_CHIPVER);
+ chiptype = rtl_get(dev, RTL_REG_CHIPTYPE);
+ switch(chiptype) {
+ case 0:
+ case 2:
+ strncpy(priv->hwname, RTL_NAME_S, sizeof(priv->hwname));
+ priv->type = RTL_TYPE_S;
+ break;
+ case 1:
+ strncpy(priv->hwname, RTL_NAME_SD, sizeof(priv->hwname));
+ priv->type = RTL_TYPE_SD;
+ break;
+ case 3:
+ strncpy(priv->hwname, RTL_NAME_SDM, sizeof(priv->hwname));
+ priv->type = RTL_TYPE_SDM;
+ break;
+ default:
+ strncpy(priv->hwname, RTL_NAME_UNKNOWN, sizeof(priv->hwname));
+ break;
+ }
+
+ dev->name = priv->hwname;
+ rtl_hw_init(dev);
+
+ printk(KERN_INFO "Registering %s switch with Chip ID: 0x%04x, version: 0x%04x\n", priv->hwname, chipid, chipver);
+
+ err = register_switch(dev, netdev);
+ if (err < 0) {
+ kfree(priv);
+ return err;
+ }
+
+ return 0;
+}
+
static int
rtl8306_fixup(struct phy_device *pdev)