projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3bd580e
)
device: make device_set_disabled inline, add device_set_deferred
author
Felix Fietkau
<nbd@openwrt.org>
Thu, 7 Jun 2012 13:58:32 +0000
(15:58 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Thu, 7 Jun 2012 13:58:32 +0000
(15:58 +0200)
device.c
patch
|
blob
|
history
device.h
patch
|
blob
|
history
diff --git
a/device.c
b/device.c
index
9dcd29a
..
7958fed
100644
(file)
--- a/
device.c
+++ b/
device.c
@@
-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);
}
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);
}
__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)
}
void device_add_user(struct device_user *dep, struct device *dev)
diff --git
a/device.h
b/device.h
index
d41042b
..
c76c472
100644
(file)
--- a/
device.h
+++ b/
device.h
@@
-115,6
+115,7
@@
struct device {
int active;
bool external;
bool disabled;
int active;
bool external;
bool disabled;
+ bool deferred;
bool current_config;
bool default_config;
bool current_config;
bool default_config;
@@
-164,7
+165,7
@@
void device_add_user(struct device_user *dep, struct device *iface);
void device_remove_user(struct device_user *dep);
void device_set_present(struct device *dev, bool state);
void device_remove_user(struct device_user *dep);
void device_set_present(struct device *dev, bool state);
-void device_
set_disabled(struct device *dev, bool value
);
+void device_
refresh_present(struct device *dev
);
int device_claim(struct device_user *dep);
void device_release(struct device_user *dep);
int device_check_state(struct device *dev);
int device_claim(struct device_user *dep);
void device_release(struct device_user *dep);
int device_check_state(struct device *dev);
@@
-176,4
+177,18
@@
void device_free_unused(struct device *dev);
struct device *get_vlan_device_chain(const char *ifname, bool create);
void alias_notify_device(const char *name, struct device *dev);
struct device *get_vlan_device_chain(const char *ifname, bool create);
void alias_notify_device(const char *name, struct device *dev);
+static inline void
+device_set_deferred(struct device *dev, bool value)
+{
+ dev->deferred = value;
+ device_refresh_present(dev);
+}
+
+static inline void
+device_set_disabled(struct device *dev, bool value)
+{
+ dev->disabled = value;
+ device_refresh_present(dev);
+}
+
#endif
#endif