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.
This commit is contained in:
Thomas Haller 2017-05-15 11:35:41 +02:00
parent 7e472b4eb3
commit 02bb4ce7eb

View file

@ -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) {