aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net/phy/ar8216.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
commit3d5783d3c490b4da159dbf69812ebcb5f9f41b29 (patch)
treea9432c86caea410933545f281cf2bba534c5e3f4 /target/linux/generic/files/drivers/net/phy/ar8216.c
parent40174d507da9231e212881ea42c6a37f57e75d51 (diff)
downloadmaster-187ad058-3d5783d3c490b4da159dbf69812ebcb5f9f41b29.tar.gz
master-187ad058-3d5783d3c490b4da159dbf69812ebcb5f9f41b29.tar.bz2
master-187ad058-3d5783d3c490b4da159dbf69812ebcb5f9f41b29.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 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22476 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/ar8216.c')
-rw-r--r--target/linux/generic/files/drivers/net/phy/ar8216.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 4ae61da233..98bfc7eb31 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -52,7 +52,6 @@ struct ar8216_priv {
u8 vlan_tagged;
u16 pvid[AR8216_NUM_PORTS];
};
-static struct switch_dev athdev;
#define to_ar8216(_dev) container_of(_dev, struct ar8216_priv, dev)
@@ -631,11 +630,34 @@ ar8216_reset_switch(struct switch_dev *dev)
return ar8216_hw_apply(dev);
}
+
+static const struct switch_dev_ops ar8216_ops = {
+ .attr_global = {
+ .attr = ar8216_globals,
+ .n_attr = ARRAY_SIZE(ar8216_globals),
+ },
+ .attr_port = {
+ .attr = ar8216_port,
+ .n_attr = ARRAY_SIZE(ar8216_port),
+ },
+ .attr_vlan = {
+ .attr = ar8216_vlan,
+ .n_attr = ARRAY_SIZE(ar8216_vlan),
+ },
+ .get_port_pvid = ar8216_get_pvid,
+ .set_port_pvid = ar8216_set_pvid,
+ .get_vlan_ports = ar8216_get_ports,
+ .set_vlan_ports = ar8216_set_ports,
+ .apply_config = ar8216_hw_apply,
+ .reset_switch = ar8216_reset_switch,
+};
+
static int
ar8216_config_init(struct phy_device *pdev)
{
struct ar8216_priv *priv;
struct net_device *dev = pdev->attached_dev;
+ struct switch_dev *swdev;
int ret;
priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
@@ -667,14 +689,22 @@ ar8216_config_init(struct phy_device *pdev)
mutex_init(&priv->reg_mutex);
priv->read = ar8216_mii_read;
priv->write = ar8216_mii_write;
- memcpy(&priv->dev, &athdev, sizeof(struct switch_dev));
+
pdev->priv = priv;
+ swdev = &priv->dev;
+ swdev->cpu_port = AR8216_PORT_CPU;
+ swdev->ops = &ar8216_ops;
+
if (priv->chip == AR8316) {
- priv->dev.name = "Atheros AR8316";
- priv->dev.vlans = AR8X16_MAX_VLANS;
+ swdev->name = "Atheros AR8316";
+ swdev->vlans = AR8X16_MAX_VLANS;
/* port 5 connected to the other mac, therefore unusable */
- priv->dev.ports = (AR8216_NUM_PORTS - 1);
+ swdev->ports = (AR8216_NUM_PORTS - 1);
+ } else {
+ swdev->name = "Atheros AR8216";
+ swdev->vlans = AR8216_NUM_VLANS;
+ swdev->ports = AR8216_NUM_PORTS;
}
if ((ret = register_switch(&priv->dev, pdev->attached_dev)) < 0) {
@@ -782,32 +812,6 @@ ar8216_remove(struct phy_device *pdev)
kfree(priv);
}
-/* template */
-static struct switch_dev athdev = {
- .name = "Atheros AR8216",
- .cpu_port = AR8216_PORT_CPU,
- .ports = AR8216_NUM_PORTS,
- .vlans = AR8216_NUM_VLANS,
- .attr_global = {
- .attr = ar8216_globals,
- .n_attr = ARRAY_SIZE(ar8216_globals),
- },
- .attr_port = {
- .attr = ar8216_port,
- .n_attr = ARRAY_SIZE(ar8216_port),
- },
- .attr_vlan = {
- .attr = ar8216_vlan,
- .n_attr = ARRAY_SIZE(ar8216_vlan),
- },
- .get_port_pvid = ar8216_get_pvid,
- .set_port_pvid = ar8216_set_pvid,
- .get_vlan_ports = ar8216_get_ports,
- .set_vlan_ports = ar8216_set_ports,
- .apply_config = ar8216_hw_apply,
- .reset_switch = ar8216_reset_switch,
-};
-
static struct phy_driver ar8216_driver = {
.phy_id = 0x004d0000,
.name = "Atheros AR8216/AR8316",