diff options
author | Dan Williams <dcbw@redhat.com> | 2014-10-06 17:17:54 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-05-19 09:25:16 -0500 |
commit | 2a7a19e767419093f216b5dbf639d2cf4bc751dd (patch) | |
tree | 04cfec82abeedabf1c766dd3a6bd2004ebf3df3d /src/devices/nm-device-vlan.c | |
parent | 5cf226463a726b9ba9d2e4e950e65c3e71077d02 (diff) | |
download | NetworkManager-2a7a19e767419093f216b5dbf639d2cf4bc751dd.tar.gz |
core: rearrange some VLAN code and clean up dispose()
Move parent-related stuff before its callers and clean up dispose
so that we no longer need priv->disposed.
Diffstat (limited to 'src/devices/nm-device-vlan.c')
-rw-r--r-- | src/devices/nm-device-vlan.c | 77 |
1 files changed, 33 insertions, 44 deletions
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 24dd36b1e5..94827e4c17 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -52,12 +52,10 @@ G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) #define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate)) typedef struct { - gboolean disposed; gboolean invalid; NMDevice *parent; guint parent_state_id; - int vlan_id; } NMDeviceVlanPrivate; @@ -73,38 +71,6 @@ enum { /******************************************************************/ -static NMDeviceCapabilities -get_generic_capabilities (NMDevice *dev) -{ - /* We assume VLAN interfaces always support carrier detect */ - return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE; -} - -static gboolean -bring_up (NMDevice *dev, gboolean *no_firmware) -{ - gboolean success = FALSE; - guint i = 20; - - while (i-- > 0 && !success) { - success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware); - g_usleep (50); - } - - return success; -} - -/******************************************************************/ - -static gboolean -is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) -{ - if (!NM_DEVICE_VLAN_GET_PRIVATE (device)->parent) - return FALSE; - - return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags); -} - static void parent_state_changed (NMDevice *parent, NMDeviceState new_state, @@ -163,6 +129,38 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent, gboolean constr g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_PARENT); } +static NMDeviceCapabilities +get_generic_capabilities (NMDevice *dev) +{ + /* We assume VLAN interfaces always support carrier detect */ + return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE; +} + +static gboolean +bring_up (NMDevice *dev, gboolean *no_firmware) +{ + gboolean success = FALSE; + guint i = 20; + + while (i-- > 0 && !success) { + success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware); + g_usleep (50); + } + + return success; +} + +/******************************************************************/ + +static gboolean +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) +{ + if (!NM_DEVICE_VLAN_GET_PRIVATE (device)->parent) + return FALSE; + + return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags); +} + static gboolean component_added (NMDevice *device, GObject *component) { @@ -553,16 +551,7 @@ set_property (GObject *object, guint prop_id, static void dispose (GObject *object) { - NMDeviceVlan *self = NM_DEVICE_VLAN (object); - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object); - return; - } - priv->disposed = TRUE; - - nm_device_vlan_set_parent (self, NULL, FALSE); + nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), NULL, FALSE); G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object); } |