diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-09-11 12:10:23 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-09-11 12:10:23 +0200 |
commit | a047e6bc29fb9c3e62c0835e55b9c6322ec62f05 (patch) | |
tree | e00b78755e5bba6e74a1bf318606cb4794df90c2 | |
parent | a323f3adf275954727f32895eea37bfcf0aa9fb7 (diff) |
make it possible to decouple interface availability from having a main device
-rw-r--r-- | interface.c | 17 | ||||
-rw-r--r-- | interface.h | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/interface.c b/interface.c index 4b22807..8c1c006 100644 --- a/interface.c +++ b/interface.c @@ -86,7 +86,8 @@ mark_interface_down(struct interface *iface) { vlist_flush_all(&iface->proto_addr); vlist_flush_all(&iface->proto_route); - device_release(&iface->main_dev); + if (iface->main_dev.dev) + device_release(&iface->main_dev); iface->state = IFS_DOWN; } @@ -98,9 +99,11 @@ __interface_set_up(struct interface *iface) if (iface->state != IFS_DOWN) return 0; - ret = device_claim(&iface->main_dev); - if (ret) - return ret; + if (iface->main_dev.dev) { + ret = device_claim(&iface->main_dev); + if (ret) + return ret; + } iface->state = IFS_SETUP; ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false); @@ -145,6 +148,12 @@ interface_cb(struct device_user *dep, enum device_event ev) return; } + interface_set_available(iface, new_state); +} + +void +interface_set_available(struct interface *iface, bool new_state) +{ if (iface->available == new_state) return; diff --git a/interface.h b/interface.h index 020306c..72a00c9 100644 --- a/interface.h +++ b/interface.h @@ -69,6 +69,7 @@ void interface_free(struct interface *iface); void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state); +void interface_set_available(struct interface *iface, bool new_state); int interface_set_up(struct interface *iface); int interface_set_down(struct interface *iface); |