diff options
author | Thomas Haller <thaller@redhat.com> | 2017-05-15 11:35:41 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-15 17:38:47 +0200 |
commit | 02bb4ce7eb518bf955ed802511f1efde921bc919 (patch) | |
tree | 86fa9e4fc86c9a7429ead4e48340ed01ca8898d4 | |
parent | 7e472b4eb36347684e81e1c3a2bd7348e19eb628 (diff) | |
download | NetworkManager-02bb4ce7eb518bf955ed802511f1efde921bc919.tar.gz |
device: cleanup nm_device_set_carrier_from_platform()
nm_device_set_carrier_from_platform() is only called from two places.
- both check for NM_DEVICE_CAP_CARRIER_DETECT, so move that check
inside the function.
- drop the logging in realize_start_setup(). nm_device_set_carrier() already
does logging.
- always set the fake carrier in nm_device_set_carrier_from_platform().
For the fake carrer, we anyway expect it to be already TRUE in most
case, so usually this should have no effect.
Also emit a property changed signal. That is necessary to refresh the
D-Bus property.
-rw-r--r-- | src/devices/nm-device.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 65bcd83d74..1ea051c918 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2309,10 +2309,20 @@ 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))); + if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { + 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))); + } + } else { + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + /* Fake online link when carrier detection is not available. */ + if (!priv->carrier) { + priv->carrier = TRUE; + _notify (self, PROP_CARRIER); + } } } @@ -3023,16 +3033,7 @@ realize_start_setup (NMDevice *self, self); } - if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { - nm_device_set_carrier_from_platform (self); - _LOGD (LOGD_PLATFORM, - "carrier is %s%s", - priv->carrier ? "ON" : "OFF", - priv->ignore_carrier ? " (but ignored)" : ""); - } else { - /* Fake online link when carrier detection is not available. */ - priv->carrier = TRUE; - } + nm_device_set_carrier_from_platform (self); device_init_sriov_num_vfs (self); @@ -10287,8 +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)) - nm_device_set_carrier_from_platform (self); + nm_device_set_carrier_from_platform (self); device_is_up = nm_device_is_up (self); if (block && !device_is_up) { |