diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-06-07 15:58:32 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2012-06-07 15:58:32 +0200 |
commit | 1850d0350d3af11514744961d827a8b9facdaf00 (patch) | |
tree | 8a07b6adbf30921d23bd56a154ddea7029941154 /device.c | |
parent | 3bd580e340d2075194cb353da32e10393b006c55 (diff) | |
download | netifd-1850d0350d3af11514744961d827a8b9facdaf00.tar.gz |
device: make device_set_disabled inline, add device_set_deferred
Diffstat (limited to 'device.c')
-rw-r--r-- | device.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -452,26 +452,25 @@ static void __device_set_present(struct device *dev, bool state) device_broadcast_event(dev, state ? DEV_EVENT_ADD : DEV_EVENT_REMOVE); } -void device_set_present(struct device *dev, bool state) +void +device_refresh_present(struct device *dev) { - if (dev->sys_present == state) - return; + bool state = dev->sys_present; - dev->sys_present = state; - D(DEVICE, "%s '%s' %s present\n", dev->type->name, dev->ifname, state ? "is now" : "is no longer" ); - - if (state && dev->disabled) - return; + if (dev->disabled || dev->deferred) + state = false; __device_set_present(dev, state); } -void -device_set_disabled(struct device *dev, bool value) +void device_set_present(struct device *dev, bool state) { - dev->disabled = value; - if (dev->sys_present) - __device_set_present(dev, !value); + if (dev->sys_present == state) + return; + + D(DEVICE, "%s '%s' %s present\n", dev->type->name, dev->ifname, state ? "is now" : "is no longer" ); + dev->sys_present = state; + device_refresh_present(dev); } void device_add_user(struct device_user *dep, struct device *dev) |