diff options
author | Thomas Haller <thaller@redhat.com> | 2017-05-14 22:08:26 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-15 17:38:47 +0200 |
commit | 7e472b4eb36347684e81e1c3a2bd7348e19eb628 (patch) | |
tree | 29f0a9c2a4e75181e7f78db172da5279c46e63a9 | |
parent | eaba285375248a691aaa896fecdd991ad695c1b1 (diff) | |
download | NetworkManager-7e472b4eb36347684e81e1c3a2bd7348e19eb628.tar.gz |
device: rename and minor refactoring of check_carrier()
The name should mirror what we already have: nm_device_set_carrier().
Also, move the code closer to nm_device_set_carrier() and refactor
it a bit.
-rw-r--r-- | src/devices/nm-device.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f26d434e9b..65bcd83d74 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2306,6 +2306,16 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier) } } +static void +nm_device_set_carrier_from_platform (NMDevice *self) +{ + if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) { + nm_device_set_carrier (self, + nm_platform_link_is_connected (nm_device_get_platform (self), + nm_device_get_ip_ifindex (self))); + } +} + /*****************************************************************************/ static void @@ -2884,15 +2894,6 @@ config_changed (NMConfig *config, } static void -check_carrier (NMDevice *self) -{ - int ifindex = nm_device_get_ip_ifindex (self); - - if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) - nm_device_set_carrier (self, nm_platform_link_is_connected (nm_device_get_platform (self), ifindex)); -} - -static void realize_start_notify (NMDevice *self, const NMPlatformLink *pllink) { @@ -3023,7 +3024,7 @@ realize_start_setup (NMDevice *self, } if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { - check_carrier (self); + nm_device_set_carrier_from_platform (self); _LOGD (LOGD_PLATFORM, "carrier is %s%s", priv->carrier ? "ON" : "OFF", @@ -10287,7 +10288,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) /* Store carrier immediately. */ if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) - check_carrier (self); + nm_device_set_carrier_from_platform (self); device_is_up = nm_device_is_up (self); if (block && !device_is_up) { |