core: rename nm_device_hw_* to nm_device_*

Now that we only have one set of is_up/bring_up/take_down functions
lets rename the _hw_ variants.
This commit is contained in:
Dan Williams
2013-06-13 15:13:58 -05:00
parent 4d4a99beaa
commit cf1d2f81f2
8 changed files with 57 additions and 57 deletions

View File

@@ -78,8 +78,8 @@ get_generic_capabilities (NMDevice *dev)
static gboolean static gboolean
is_available (NMDevice *dev) is_available (NMDevice *dev)
{ {
if (NM_DEVICE_GET_CLASS (dev)->hw_is_up) if (NM_DEVICE_GET_CLASS (dev)->is_up)
return NM_DEVICE_GET_CLASS (dev)->hw_is_up (dev); return NM_DEVICE_GET_CLASS (dev)->is_up (dev);
return FALSE; return FALSE;
} }
@@ -198,12 +198,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
g_assert (s_bond); g_assert (s_bond);
/* Interface must be down to set bond options */ /* Interface must be down to set bond options */
nm_device_hw_take_down (dev, TRUE); nm_device_take_down (dev, TRUE);
if (!nm_system_apply_bonding_config (nm_device_get_ip_iface (dev), s_bond)) if (!nm_system_apply_bonding_config (nm_device_get_ip_iface (dev), s_bond))
ret = NM_ACT_STAGE_RETURN_FAILURE; ret = NM_ACT_STAGE_RETURN_FAILURE;
nm_device_hw_bring_up (dev, TRUE, &no_firmware); nm_device_bring_up (dev, TRUE, &no_firmware);
} }
return ret; return ret;
} }
@@ -215,12 +215,12 @@ enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection)
const char *iface = nm_device_get_ip_iface (device); const char *iface = nm_device_get_ip_iface (device);
const char *slave_iface = nm_device_get_ip_iface (slave); const char *slave_iface = nm_device_get_ip_iface (slave);
nm_device_hw_take_down (slave, TRUE); nm_device_take_down (slave, TRUE);
success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device), success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device),
nm_device_get_ip_ifindex (slave)); nm_device_get_ip_ifindex (slave));
nm_device_hw_bring_up (slave, TRUE, &no_firmware); nm_device_bring_up (slave, TRUE, &no_firmware);
if (success) { if (success) {
nm_log_info (LOGD_BOND, "(%s): enslaved bond slave %s", iface, slave_iface); nm_log_info (LOGD_BOND, "(%s): enslaved bond slave %s", iface, slave_iface);
@@ -248,7 +248,7 @@ release_slave (NMDevice *device, NMDevice *slave)
* IFF_UP), so we must bring it back up here to ensure carrier changes and * IFF_UP), so we must bring it back up here to ensure carrier changes and
* other state is noticed by the now-released slave. * other state is noticed by the now-released slave.
*/ */
if (!nm_device_hw_bring_up (slave, TRUE, &no_firmware)) { if (!nm_device_bring_up (slave, TRUE, &no_firmware)) {
nm_log_warn (LOGD_BOND, "(%s): released bond slave could not be brought up.", nm_log_warn (LOGD_BOND, "(%s): released bond slave could not be brought up.",
nm_device_get_iface (slave)); nm_device_get_iface (slave));
} }

View File

@@ -78,8 +78,8 @@ get_generic_capabilities (NMDevice *dev)
static gboolean static gboolean
is_available (NMDevice *dev) is_available (NMDevice *dev)
{ {
if (NM_DEVICE_GET_CLASS (dev)->hw_is_up) if (NM_DEVICE_GET_CLASS (dev)->is_up)
return NM_DEVICE_GET_CLASS (dev)->hw_is_up (dev); return NM_DEVICE_GET_CLASS (dev)->is_up (dev);
return FALSE; return FALSE;
} }

View File

@@ -325,7 +325,7 @@ _set_hw_addr (NMDeviceEthernet *self, const guint8 *addr, const char *detail)
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
/* Can't change MAC address while device is up */ /* Can't change MAC address while device is up */
nm_device_hw_take_down (dev, FALSE); nm_device_take_down (dev, FALSE);
success = nm_platform_link_set_address (nm_device_get_ip_ifindex (dev), addr, ETH_ALEN); success = nm_platform_link_set_address (nm_device_get_ip_ifindex (dev), addr, ETH_ALEN);
if (success) { if (success) {
@@ -344,7 +344,7 @@ _set_hw_addr (NMDeviceEthernet *self, const guint8 *addr, const char *detail)
nm_log_warn (LOGD_DEVICE | LOGD_ETHER, "(%s): failed to %s MAC address to %s", nm_log_warn (LOGD_DEVICE | LOGD_ETHER, "(%s): failed to %s MAC address to %s",
iface, detail, mac_str); iface, detail, mac_str);
} }
nm_device_hw_bring_up (dev, FALSE, NULL); nm_device_bring_up (dev, FALSE, NULL);
g_free (mac_str); g_free (mac_str);
return success; return success;

View File

@@ -48,9 +48,9 @@ gboolean nm_device_activate_stage3_ip4_start (NMDevice *self);
gboolean nm_device_activate_stage3_ip6_start (NMDevice *self); gboolean nm_device_activate_stage3_ip6_start (NMDevice *self);
gboolean nm_device_hw_bring_up (NMDevice *self, gboolean wait, gboolean *no_firmware); gboolean nm_device_bring_up (NMDevice *self, gboolean wait, gboolean *no_firmware);
void nm_device_hw_take_down (NMDevice *self, gboolean block); void nm_device_take_down (NMDevice *self, gboolean block);
gboolean nm_device_update_hw_address (NMDevice *self); gboolean nm_device_update_hw_address (NMDevice *self);

View File

@@ -83,13 +83,13 @@ get_generic_capabilities (NMDevice *dev)
} }
static gboolean static gboolean
hw_bring_up (NMDevice *dev, gboolean *no_firmware) bring_up (NMDevice *dev, gboolean *no_firmware)
{ {
gboolean success = FALSE; gboolean success = FALSE;
guint i = 20; guint i = 20;
while (i-- > 0 && !success) { while (i-- > 0 && !success) {
success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->hw_bring_up (dev, no_firmware); success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware);
g_usleep (50); g_usleep (50);
} }
@@ -431,7 +431,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
object_class->dispose = dispose; object_class->dispose = dispose;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->hw_bring_up = hw_bring_up; parent_class->bring_up = bring_up;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
parent_class->complete_connection = complete_connection; parent_class->complete_connection = complete_connection;

View File

@@ -794,12 +794,12 @@ periodic_update (gpointer user_data)
} }
static gboolean static gboolean
hw_bring_up (NMDevice *device, gboolean *no_firmware) bring_up (NMDevice *device, gboolean *no_firmware)
{ {
if (!NM_DEVICE_WIFI_GET_PRIVATE (device)->enabled) if (!NM_DEVICE_WIFI_GET_PRIVATE (device)->enabled)
return FALSE; return FALSE;
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->hw_bring_up (device, no_firmware); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->bring_up (device, no_firmware);
} }
static gboolean static gboolean
@@ -826,7 +826,7 @@ _set_hw_addr (NMDeviceWifi *self, const guint8 *addr, const char *detail)
} }
/* Can't change MAC address while device is up */ /* Can't change MAC address while device is up */
nm_device_hw_take_down (dev, FALSE); nm_device_take_down (dev, FALSE);
success = nm_platform_link_set_address (nm_device_get_ip_ifindex (dev), addr, ETH_ALEN); success = nm_platform_link_set_address (nm_device_get_ip_ifindex (dev), addr, ETH_ALEN);
if (success) { if (success) {
@@ -838,7 +838,7 @@ _set_hw_addr (NMDeviceWifi *self, const guint8 *addr, const char *detail)
nm_log_warn (LOGD_DEVICE | LOGD_ETHER, "(%s): failed to %s MAC address to %s", nm_log_warn (LOGD_DEVICE | LOGD_ETHER, "(%s): failed to %s MAC address to %s",
iface, detail, mac_str); iface, detail, mac_str);
} }
hw_bring_up (dev, NULL); bring_up (dev, NULL);
g_free (mac_str); g_free (mac_str);
return success; return success;
@@ -920,9 +920,9 @@ deactivate (NMDevice *dev)
* (usually older ones) don't scan well in adhoc mode. * (usually older ones) don't scan well in adhoc mode.
*/ */
if (wifi_utils_get_mode (priv->wifi_data) != NM_802_11_MODE_INFRA) { if (wifi_utils_get_mode (priv->wifi_data) != NM_802_11_MODE_INFRA) {
nm_device_hw_take_down (NM_DEVICE (self), TRUE); nm_device_take_down (NM_DEVICE (self), TRUE);
wifi_utils_set_mode (priv->wifi_data, NM_802_11_MODE_INFRA); wifi_utils_set_mode (priv->wifi_data, NM_802_11_MODE_INFRA);
nm_device_hw_bring_up (NM_DEVICE (self), TRUE, NULL); nm_device_bring_up (NM_DEVICE (self), TRUE, NULL);
} }
if (priv->mode != NM_802_11_MODE_INFRA) { if (priv->mode != NM_802_11_MODE_INFRA) {
@@ -3455,7 +3455,7 @@ set_enabled (NMDevice *device, gboolean enabled)
if (state != NM_DEVICE_STATE_UNAVAILABLE) if (state != NM_DEVICE_STATE_UNAVAILABLE)
nm_log_warn (LOGD_CORE, "not in expected unavailable state!"); nm_log_warn (LOGD_CORE, "not in expected unavailable state!");
if (!nm_device_hw_bring_up (NM_DEVICE (self), TRUE, &no_firmware)) { if (!nm_device_bring_up (NM_DEVICE (self), TRUE, &no_firmware)) {
nm_log_dbg (LOGD_WIFI, "(%s): enable blocked by failure to bring device up", nm_log_dbg (LOGD_WIFI, "(%s): enable blocked by failure to bring device up",
nm_device_get_iface (NM_DEVICE (device))); nm_device_get_iface (NM_DEVICE (device)));
@@ -3479,7 +3479,7 @@ set_enabled (NMDevice *device, gboolean enabled)
nm_device_state_changed (NM_DEVICE (self), nm_device_state_changed (NM_DEVICE (self),
NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_UNAVAILABLE,
NM_DEVICE_STATE_REASON_NONE); NM_DEVICE_STATE_REASON_NONE);
nm_device_hw_take_down (NM_DEVICE (self), TRUE); nm_device_take_down (NM_DEVICE (self), TRUE);
} }
} }
@@ -3614,7 +3614,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->dispose = dispose; object_class->dispose = dispose;
parent_class->hw_bring_up = hw_bring_up; parent_class->bring_up = bring_up;
parent_class->update_permanent_hw_address = update_permanent_hw_address; parent_class->update_permanent_hw_address = update_permanent_hw_address;
parent_class->update_initial_hw_address = update_initial_hw_address; parent_class->update_initial_hw_address = update_initial_hw_address;
parent_class->can_auto_connect = can_auto_connect; parent_class->can_auto_connect = can_auto_connect;

View File

@@ -564,18 +564,18 @@ constructed (GObject *object)
} }
static gboolean static gboolean
nm_device_hw_is_up (NMDevice *self) nm_device_is_up (NMDevice *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
if (NM_DEVICE_GET_CLASS (self)->hw_is_up) if (NM_DEVICE_GET_CLASS (self)->is_up)
return NM_DEVICE_GET_CLASS (self)->hw_is_up (self); return NM_DEVICE_GET_CLASS (self)->is_up (self);
return TRUE; return TRUE;
} }
static gboolean static gboolean
hw_is_up (NMDevice *device) is_up (NMDevice *device)
{ {
int ifindex = nm_device_get_ip_ifindex (device); int ifindex = nm_device_get_ip_ifindex (device);
@@ -1797,7 +1797,7 @@ nm_device_activate_stage2_device_config (gpointer user_data)
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface); nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
if (!nm_device_hw_bring_up (self, FALSE, &no_firmware)) { if (!nm_device_bring_up (self, FALSE, &no_firmware)) {
if (no_firmware) if (no_firmware)
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING);
else else
@@ -4427,29 +4427,29 @@ nm_device_get_ip6_config (NMDevice *self)
} }
gboolean gboolean
nm_device_hw_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
{ {
gboolean success; gboolean success;
guint32 tries = 0; guint32 tries = 0;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
if (nm_device_hw_is_up (self)) if (nm_device_is_up (self))
goto out; goto out;
nm_log_info (LOGD_HW, "(%s): bringing up device.", nm_device_get_iface (self)); nm_log_info (LOGD_HW, "(%s): bringing up device.", nm_device_get_iface (self));
if (NM_DEVICE_GET_CLASS (self)->hw_bring_up) { if (NM_DEVICE_GET_CLASS (self)->bring_up) {
success = NM_DEVICE_GET_CLASS (self)->hw_bring_up (self, no_firmware); success = NM_DEVICE_GET_CLASS (self)->bring_up (self, no_firmware);
if (!success) if (!success)
return FALSE; return FALSE;
} }
/* Wait for the device to come up if requested */ /* Wait for the device to come up if requested */
while (block && !nm_device_hw_is_up (self) && (tries++ < 50)) while (block && !nm_device_is_up (self) && (tries++ < 50))
g_usleep (200); g_usleep (200);
if (!nm_device_hw_is_up (self)) { if (!nm_device_is_up (self)) {
nm_log_warn (LOGD_HW, "(%s): device not up after timeout!", nm_device_get_iface (self)); nm_log_warn (LOGD_HW, "(%s): device not up after timeout!", nm_device_get_iface (self));
return FALSE; return FALSE;
} }
@@ -4463,7 +4463,7 @@ out:
} }
static gboolean static gboolean
hw_bring_up (NMDevice *device, gboolean *no_firmware) bring_up (NMDevice *device, gboolean *no_firmware)
{ {
int ifindex = nm_device_get_ip_ifindex (device); int ifindex = nm_device_get_ip_ifindex (device);
gboolean result; gboolean result;
@@ -4483,27 +4483,27 @@ hw_bring_up (NMDevice *device, gboolean *no_firmware)
} }
void void
nm_device_hw_take_down (NMDevice *self, gboolean block) nm_device_take_down (NMDevice *self, gboolean block)
{ {
guint32 tries = 0; guint32 tries = 0;
g_return_if_fail (NM_IS_DEVICE (self)); g_return_if_fail (NM_IS_DEVICE (self));
if (!nm_device_hw_is_up (self)) if (!nm_device_is_up (self))
return; return;
nm_log_info (LOGD_HW, "(%s): taking down device.", nm_device_get_iface (self)); nm_log_info (LOGD_HW, "(%s): taking down device.", nm_device_get_iface (self));
if (NM_DEVICE_GET_CLASS (self)->hw_take_down) if (NM_DEVICE_GET_CLASS (self)->take_down)
NM_DEVICE_GET_CLASS (self)->hw_take_down (self); NM_DEVICE_GET_CLASS (self)->take_down (self);
/* Wait for the device to come up if requested */ /* Wait for the device to come up if requested */
while (block && nm_device_hw_is_up (self) && (tries++ < 50)) while (block && nm_device_is_up (self) && (tries++ < 50))
g_usleep (200); g_usleep (200);
} }
static void static void
hw_take_down (NMDevice *device) take_down (NMDevice *device)
{ {
int ifindex = nm_device_get_ip_ifindex (device); int ifindex = nm_device_get_ip_ifindex (device);
@@ -4516,7 +4516,7 @@ dispose (GObject *object)
{ {
NMDevice *self = NM_DEVICE (object); NMDevice *self = NM_DEVICE (object);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
gboolean take_down = TRUE; gboolean deconfigure = TRUE;
NMPlatform *platform; NMPlatform *platform;
if (priv->disposed || !priv->initialized) if (priv->disposed || !priv->initialized)
@@ -4545,7 +4545,7 @@ dispose (GObject *object)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
take_down = FALSE; deconfigure = FALSE;
} }
} }
@@ -4554,22 +4554,22 @@ dispose (GObject *object)
nm_device_queued_ip_config_change_clear (self); nm_device_queued_ip_config_change_clear (self);
/* Clean up and stop DHCP */ /* Clean up and stop DHCP */
dhcp4_cleanup (self, take_down, FALSE); dhcp4_cleanup (self, deconfigure, FALSE);
dhcp6_cleanup (self, take_down, FALSE); dhcp6_cleanup (self, deconfigure, FALSE);
addrconf6_cleanup (self); addrconf6_cleanup (self);
dnsmasq_cleanup (self); dnsmasq_cleanup (self);
g_warn_if_fail (priv->slaves == NULL); g_warn_if_fail (priv->slaves == NULL);
/* Take the device itself down and clear its IPv4 configuration */ /* Take the device itself down and clear its IPv4 configuration */
if (nm_device_get_managed (self) && take_down) { if (nm_device_get_managed (self) && deconfigure) {
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
if (nm_device_get_act_request (self)) if (nm_device_get_act_request (self))
nm_device_deactivate (self, NM_DEVICE_STATE_REASON_REMOVED); nm_device_deactivate (self, NM_DEVICE_STATE_REASON_REMOVED);
nm_device_set_ip4_config (self, NULL, FALSE, &ignored); nm_device_set_ip4_config (self, NULL, FALSE, &ignored);
nm_device_hw_take_down (self, FALSE); nm_device_take_down (self, FALSE);
} }
/* reset the saved RA value */ /* reset the saved RA value */
@@ -4923,9 +4923,9 @@ nm_device_class_init (NMDeviceClass *klass)
klass->can_auto_connect = can_auto_connect; klass->can_auto_connect = can_auto_connect;
klass->check_connection_compatible = check_connection_compatible; klass->check_connection_compatible = check_connection_compatible;
klass->check_connection_available = check_connection_available; klass->check_connection_available = check_connection_available;
klass->hw_is_up = hw_is_up; klass->is_up = is_up;
klass->hw_bring_up = hw_bring_up; klass->bring_up = bring_up;
klass->hw_take_down = hw_take_down; klass->take_down = take_down;
klass->carrier_changed = carrier_changed; klass->carrier_changed = carrier_changed;
klass->can_interrupt_activation = can_interrupt_activation; klass->can_interrupt_activation = can_interrupt_activation;
klass->get_hw_address_length = get_hw_address_length; klass->get_hw_address_length = get_hw_address_length;
@@ -5437,12 +5437,12 @@ nm_device_state_changed (NMDevice *device,
/* Clean up if the device is now unmanaged but was activated */ /* Clean up if the device is now unmanaged but was activated */
if (nm_device_get_act_request (device)) if (nm_device_get_act_request (device))
nm_device_deactivate (device, reason); nm_device_deactivate (device, reason);
nm_device_hw_take_down (device, TRUE); nm_device_take_down (device, TRUE);
} }
break; break;
case NM_DEVICE_STATE_UNAVAILABLE: case NM_DEVICE_STATE_UNAVAILABLE:
if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) { if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) {
if (!nm_device_hw_bring_up (device, TRUE, &no_firmware) && no_firmware) if (!nm_device_bring_up (device, TRUE, &no_firmware) && no_firmware)
nm_log_warn (LOGD_HW, "(%s): firmware may be missing.", nm_device_get_iface (device)); nm_log_warn (LOGD_HW, "(%s): firmware may be missing.", nm_device_get_iface (device));
nm_device_set_firmware_missing (device, no_firmware ? TRUE : FALSE); nm_device_set_firmware_missing (device, no_firmware ? TRUE : FALSE);
} }

View File

@@ -102,9 +102,9 @@ typedef struct {
NMDeviceStateReason reason); NMDeviceStateReason reason);
/* Hardware state (IFF_UP) */ /* Hardware state (IFF_UP) */
gboolean (*hw_is_up) (NMDevice *self); gboolean (*is_up) (NMDevice *self);
gboolean (*hw_bring_up) (NMDevice *self, gboolean *no_firmware); gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware);
void (*hw_take_down) (NMDevice *self); void (*take_down) (NMDevice *self);
/* Carrier state (IFF_LOWER_UP) */ /* Carrier state (IFF_LOWER_UP) */
void (*carrier_changed) (NMDevice *, gboolean carrier); void (*carrier_changed) (NMDevice *, gboolean carrier);