swconfig: add a generic switch reset call
authorFelix Fietkau <nbd@openwrt.org>
Tue, 28 Apr 2009 19:16:17 +0000 (19:16 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 28 Apr 2009 19:16:17 +0000 (19:16 +0000)
SVN-Revision: 15470

target/linux/generic-2.6/files/drivers/net/phy/ip175c.c
target/linux/generic-2.6/files/drivers/net/phy/swconfig.c
target/linux/generic-2.6/files/include/linux/switch.h

index 673ff127639768a95479339a03a99692b5547f11..c56186192cd4713d4412eb64157e58e4e7af0af2 100644 (file)
@@ -801,7 +801,7 @@ static int ip175c_apply(struct switch_dev *dev)
        return 0;
 }
 
        return 0;
 }
 
-static int ip175c_reset(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
+static int ip175c_reset(struct switch_dev *dev)
 {
        struct ip175c_state *state = dev->priv;
        int i, err;
 {
        struct ip175c_state *state = dev->priv;
        int i, err;
@@ -1125,14 +1125,6 @@ enum Globals {
 };
 
 static const struct switch_attr ip175c_global[] = {
 };
 
 static const struct switch_attr ip175c_global[] = {
-       [IP175C_RESET] = {
-               .id = IP175C_RESET,
-               .type = SWITCH_TYPE_NOVAL,
-               .name  = "reset",
-               .get = NULL,
-               .description = "Resets the switch but does not clear vlan configuration",
-               .set = ip175c_reset,
-       },
        [IP175C_ENABLE_VLAN] = {
                .id = IP175C_ENABLE_VLAN,
                .type = SWITCH_TYPE_INT,
        [IP175C_ENABLE_VLAN] = {
                .id = IP175C_ENABLE_VLAN,
                .type = SWITCH_TYPE_INT,
@@ -1233,6 +1225,7 @@ static int ip175c_probe(struct phy_device *pdev)
        dev->get_vlan_ports = ip175c_get_ports;
        dev->set_vlan_ports = ip175c_set_ports;
        dev->apply_config = ip175c_apply;
        dev->get_vlan_ports = ip175c_get_ports;
        dev->set_vlan_ports = ip175c_set_ports;
        dev->apply_config = ip175c_apply;
+       dev->reset_switch = ip175c_reset;
 
        dev->priv = state;
        pdev->priv = state;
 
        dev->priv = state;
        pdev->priv = state;
@@ -1265,7 +1258,7 @@ static int ip175c_config_init(struct phy_device *pdev)
        if (err < 0)
                return err;
 
        if (err < 0)
                return err;
 
-       ip175c_reset(&state->dev, NULL, NULL);
+       ip175c_reset(&state->dev);
 
        state->registered = true;
        netif_carrier_on(pdev->attached_dev);
 
        state->registered = true;
        netif_carrier_on(pdev->attached_dev);
index 8bae667081123202cbf7a05dabbeac13c4f92f61..7207e4659240b2f611a34036a9342a74d5909a74 100644 (file)
@@ -133,9 +133,19 @@ swconfig_apply_config(struct switch_dev *dev, const struct switch_attr *attr, st
        return dev->apply_config(dev);
 }
 
        return dev->apply_config(dev);
 }
 
+static int
+swconfig_reset_switch(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
+{
+       /* don't complain if not supported by the switch driver */
+       if (!dev->reset_switch)
+               return 0;
+
+       return dev->reset_switch(dev);
+}
 
 enum global_defaults {
        GLOBAL_APPLY,
 
 enum global_defaults {
        GLOBAL_APPLY,
+       GLOBAL_RESET,
 };
 
 enum vlan_defaults {
 };
 
 enum vlan_defaults {
@@ -152,6 +162,12 @@ static struct switch_attr default_global[] = {
                .name = "apply",
                .description = "Activate changes in the hardware",
                .set = swconfig_apply_config,
                .name = "apply",
                .description = "Activate changes in the hardware",
                .set = swconfig_apply_config,
+       },
+       [GLOBAL_RESET] = {
+               .type = SWITCH_TYPE_NOVAL,
+               .name = "reset",
+               .description = "Reset the switch",
+               .set = swconfig_reset_switch,
        }
 };
 
        }
 };
 
@@ -190,6 +206,7 @@ static void swconfig_defaults_init(struct switch_dev *dev)
 
        /* always present, can be no-op */
        set_bit(GLOBAL_APPLY, &dev->def_global);
 
        /* always present, can be no-op */
        set_bit(GLOBAL_APPLY, &dev->def_global);
+       set_bit(GLOBAL_RESET, &dev->def_global);
 }
 
 
 }
 
 
index 75c7dcfa912cc3b52a939cc997cc442adb1d3c29..98b86e8514cb4fd981c81a9084659b6cbd9a50b8 100644 (file)
@@ -132,6 +132,7 @@ struct switch_dev {
        int (*get_port_pvid)(struct switch_dev *dev, int port, int *val);
        int (*set_port_pvid)(struct switch_dev *dev, int port, int val);
        int (*apply_config)(struct switch_dev *dev);
        int (*get_port_pvid)(struct switch_dev *dev, int port, int *val);
        int (*set_port_pvid)(struct switch_dev *dev, int port, int val);
        int (*apply_config)(struct switch_dev *dev);
+       int (*reset_switch)(struct switch_dev *dev);
 };
 
 struct switch_port {
 };
 
 struct switch_port {