base-modem: port to use object logging
Also link all grabbed ports as owned by the modem.
This commit is contained in:
+48
-37
@@ -31,12 +31,15 @@
|
||||
#include "mm-context.h"
|
||||
#include "mm-base-modem.h"
|
||||
|
||||
#include "mm-log.h"
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-port-enums-types.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (MMBaseModem, mm_base_modem, MM_GDBUS_TYPE_OBJECT_SKELETON);
|
||||
static void log_object_iface_init (MMLogObjectInterface *iface);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MMBaseModem, mm_base_modem, MM_GDBUS_TYPE_OBJECT_SKELETON,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_LOG_OBJECT, log_object_iface_init))
|
||||
|
||||
/* If we get 10 consecutive timeouts in a serial port, we consider the modem
|
||||
* invalid and we request re-probing. */
|
||||
@@ -134,22 +137,17 @@ serial_port_timed_out_cb (MMPortSerial *port,
|
||||
{
|
||||
/* If reached the maximum number of timeouts, invalidate modem */
|
||||
if (n_consecutive_timeouts >= self->priv->max_timeouts) {
|
||||
mm_err ("(%s/%s) %s port timed out %u consecutive times, marking modem '%s' as invalid",
|
||||
mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))),
|
||||
mm_port_get_device (MM_PORT (port)),
|
||||
mm_port_type_get_string (mm_port_get_port_type (MM_PORT (port))),
|
||||
n_consecutive_timeouts,
|
||||
g_dbus_object_get_object_path (G_DBUS_OBJECT (self)));
|
||||
mm_obj_err (self, "port %s timed out %u consecutive times, marking modem as invalid",
|
||||
mm_port_get_device (MM_PORT (port)),
|
||||
n_consecutive_timeouts);
|
||||
g_cancellable_cancel (self->priv->cancellable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (n_consecutive_timeouts > 1)
|
||||
mm_warn ("(%s/%s) %s port timed out %u consecutive times",
|
||||
mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))),
|
||||
mm_port_get_device (MM_PORT (port)),
|
||||
mm_port_type_get_string (mm_port_get_port_type (MM_PORT (port))),
|
||||
n_consecutive_timeouts);
|
||||
mm_obj_warn (self, "port %s timed out %u consecutive times",
|
||||
mm_port_get_device (MM_PORT (port)),
|
||||
n_consecutive_timeouts);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -228,13 +226,13 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
||||
/* Prefer plugin-provided flags to the generic ones */
|
||||
if (at_pflags == MM_PORT_SERIAL_AT_FLAG_NONE) {
|
||||
if (mm_kernel_device_get_property_as_boolean (kernel_device, ID_MM_PORT_TYPE_AT_PRIMARY)) {
|
||||
mm_dbg ("AT port '%s/%s' flagged as primary", subsys, name);
|
||||
mm_obj_dbg (self, "AT port '%s/%s' flagged as primary", subsys, name);
|
||||
at_pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||
} else if (mm_kernel_device_get_property_as_boolean (kernel_device, ID_MM_PORT_TYPE_AT_SECONDARY)) {
|
||||
mm_dbg ("AT port '%s/%s' flagged as secondary", subsys, name);
|
||||
mm_obj_dbg (self, "AT port '%s/%s' flagged as secondary", subsys, name);
|
||||
at_pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
||||
} else if (mm_kernel_device_get_property_as_boolean (kernel_device, ID_MM_PORT_TYPE_AT_PPP)) {
|
||||
mm_dbg ("AT port '%s/%s' flagged as PPP", subsys, name);
|
||||
mm_obj_dbg (self, "AT port '%s/%s' flagged as PPP", subsys, name);
|
||||
at_pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
|
||||
}
|
||||
}
|
||||
@@ -276,8 +274,8 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
||||
|
||||
flow_control = mm_flow_control_from_string (flow_control_tag, &inner_error);
|
||||
if (flow_control == MM_FLOW_CONTROL_UNKNOWN) {
|
||||
mm_warn ("(%s/%s) unsupported flow control settings in port: %s",
|
||||
subsys, name, inner_error->message);
|
||||
mm_obj_warn (self, "unsupported flow control settings in port %s: %s",
|
||||
name, inner_error->message);
|
||||
g_error_free (inner_error);
|
||||
} else {
|
||||
g_object_set (port,
|
||||
@@ -346,10 +344,7 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
||||
/* We already filter out before all non-tty, non-net, non-cdc-wdm ports */
|
||||
g_assert_not_reached ();
|
||||
|
||||
mm_dbg ("(%s) type '%s' claimed by %s",
|
||||
name,
|
||||
mm_port_type_get_string (ptype),
|
||||
mm_base_modem_get_device (self));
|
||||
mm_obj_dbg (self, "grabbed port '%s/%s'", name, mm_port_type_get_string (ptype));
|
||||
|
||||
/* Add it to the tracking HT.
|
||||
* Note: 'key' and 'port' now owned by the HT. */
|
||||
@@ -360,6 +355,9 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
||||
MM_PORT_KERNEL_DEVICE, kernel_device,
|
||||
NULL);
|
||||
|
||||
/* Set owner ID */
|
||||
mm_log_object_set_owner_id (MM_LOG_OBJECT (port), mm_log_object_get_id (MM_LOG_OBJECT (self)));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1022,7 +1020,7 @@ initialize_ready (MMBaseModem *self,
|
||||
GError *error = NULL;
|
||||
|
||||
if (mm_base_modem_initialize_finish (self, res, &error)) {
|
||||
mm_dbg ("modem properly initialized");
|
||||
mm_obj_dbg (self, "modem initialized");
|
||||
mm_base_modem_set_valid (self, TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -1032,8 +1030,7 @@ initialize_ready (MMBaseModem *self,
|
||||
/* Even with initialization errors, we do set the state to valid, so
|
||||
* that the modem gets exported and the failure notified to the user.
|
||||
*/
|
||||
mm_dbg ("Couldn't finish initialization in the current state: '%s'",
|
||||
error->message);
|
||||
mm_obj_dbg (self, "couldn't finish initialization in the current state: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
mm_base_modem_set_valid (self, TRUE);
|
||||
return;
|
||||
@@ -1041,7 +1038,7 @@ initialize_ready (MMBaseModem *self,
|
||||
|
||||
/* Really fatal, we cannot even export the failed modem (e.g. error before
|
||||
* even trying to enable the Modem interface */
|
||||
mm_warn ("couldn't initialize the modem: '%s'", error->message);
|
||||
mm_obj_warn (self, "couldn't initialize: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
@@ -1049,11 +1046,10 @@ static inline void
|
||||
log_port (MMBaseModem *self, MMPort *port, const char *desc)
|
||||
{
|
||||
if (port) {
|
||||
mm_dbg ("(%s) %s/%s %s",
|
||||
self->priv->device,
|
||||
mm_port_subsys_get_string (mm_port_get_subsys (port)),
|
||||
mm_port_get_device (port),
|
||||
desc);
|
||||
mm_obj_dbg (self, "%s/%s %s",
|
||||
mm_port_subsys_get_string (mm_port_get_subsys (port)),
|
||||
mm_port_get_device (port),
|
||||
desc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1474,9 +1470,9 @@ static void
|
||||
cleanup_modem_port (MMBaseModem *self,
|
||||
MMPort *port)
|
||||
{
|
||||
mm_dbg ("cleaning up port '%s/%s'...",
|
||||
mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))),
|
||||
mm_port_get_device (MM_PORT (port)));
|
||||
mm_obj_dbg (self, "cleaning up port '%s/%s'...",
|
||||
mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))),
|
||||
mm_port_get_device (MM_PORT (port)));
|
||||
|
||||
/* Cleanup for serial ports */
|
||||
if (MM_IS_PORT_SERIAL (port)) {
|
||||
@@ -1522,6 +1518,17 @@ teardown_ports_table (MMBaseModem *self)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gchar *
|
||||
log_object_build_id (MMLogObject *_self)
|
||||
{
|
||||
MMBaseModem *self;
|
||||
|
||||
self = MM_BASE_MODEM (_self);
|
||||
return g_strdup_printf ("modem%u", self->priv->dbus_id);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_base_modem_init (MMBaseModem *self)
|
||||
{
|
||||
@@ -1652,9 +1659,7 @@ finalize (GObject *object)
|
||||
g_assert (!self->priv->enable_tasks);
|
||||
g_assert (!self->priv->disable_tasks);
|
||||
|
||||
mm_dbg ("Modem (%s) '%s' completely disposed",
|
||||
self->priv->plugin,
|
||||
self->priv->device);
|
||||
mm_obj_dbg (self, "completely disposed");
|
||||
|
||||
g_free (self->priv->device);
|
||||
g_strfreev (self->priv->drivers);
|
||||
@@ -1703,6 +1708,12 @@ dispose (GObject *object)
|
||||
G_OBJECT_CLASS (mm_base_modem_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
log_object_iface_init (MMLogObjectInterface *iface)
|
||||
{
|
||||
iface->build_id = log_object_build_id;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_base_modem_class_init (MMBaseModemClass *klass)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user