aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-09-28 20:34:48 +0200
committerAleksander Morgado <aleksander@aleksander.es>2016-09-29 15:43:05 +0200
commitae9ede926a1747216b54e22398edde203ec9a03c (patch)
treec6d1c405982051497ed78fbbfc7cbb6a3f16e5e4 /src/mm-base-modem.c
parentc4a584416ab4af81b6cae653625c78f9158de1e6 (diff)
core: use the kernel device object in the port object and the plugin interface
The mm_base_modem_grab_port() now receives a MMKernelDevice directly from the plugin, which is then stored in the MMPort corresponding to the port. This means that we have direct access to e.g. all properties set by udev rules everywhere, and we don't need additional GUdevClient objects (e.g. like the one used in the Huawei plugin to detect NDISDUP support during runtime). For virtual ports (e.g. generated during unit tests), we have a new 'generic' kernel device object which just provides the values from the kernel device properties given during its creation.
Diffstat (limited to 'src/mm-base-modem.c')
-rw-r--r--src/mm-base-modem.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index 2dc00ce7..50717471 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <gudev/gudev.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
@@ -129,18 +128,23 @@ serial_port_timed_out_cb (MMPortSerial *port,
}
gboolean
-mm_base_modem_grab_port (MMBaseModem *self,
- const gchar *subsys,
- const gchar *name,
- const gchar *parent_path,
- MMPortType ptype,
- MMPortSerialAtFlag at_pflags,
- GError **error)
+mm_base_modem_grab_port (MMBaseModem *self,
+ MMKernelDevice *kernel_device,
+ MMPortType ptype,
+ MMPortSerialAtFlag at_pflags,
+ GError **error)
{
- MMPort *port;
- gchar *key;
+ MMPort *port;
+ gchar *key;
+ const gchar *subsys;
+ const gchar *name;
g_return_val_if_fail (MM_IS_BASE_MODEM (self), FALSE);
+ g_return_val_if_fail (MM_IS_KERNEL_DEVICE (kernel_device), FALSE);
+
+ subsys = mm_kernel_device_get_subsystem (kernel_device);
+ name = mm_kernel_device_get_name (kernel_device);
+
g_return_val_if_fail (subsys != NULL, FALSE);
g_return_val_if_fail (name != NULL, FALSE);
@@ -285,9 +289,9 @@ mm_base_modem_grab_port (MMBaseModem *self,
* Note: 'key' and 'port' now owned by the HT. */
g_hash_table_insert (self->priv->ports, key, port);
- /* Store parent path */
+ /* Store kernel device */
g_object_set (port,
- MM_PORT_PARENT_PATH, parent_path,
+ MM_PORT_KERNEL_DEVICE, kernel_device,
NULL);
return TRUE;
@@ -555,7 +559,7 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self,
const gchar *net_port_parent_path;
g_warn_if_fail (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET);
- net_port_parent_path = mm_port_get_parent_path (data);
+ net_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (data));
if (!net_port_parent_path) {
g_set_error (error,
MM_CORE_ERROR,
@@ -574,7 +578,7 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self,
const gchar *wdm_port_parent_path;
g_assert (MM_IS_PORT_QMI (l->data));
- wdm_port_parent_path = mm_port_get_parent_path (MM_PORT (l->data));
+ wdm_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (MM_PORT (l->data)));
if (wdm_port_parent_path && g_str_equal (wdm_port_parent_path, net_port_parent_path))
return MM_PORT_QMI (l->data);
}
@@ -629,7 +633,7 @@ mm_base_modem_peek_port_mbim_for_data (MMBaseModem *self,
const gchar *net_port_parent_path;
g_warn_if_fail (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET);
- net_port_parent_path = mm_port_get_parent_path (data);
+ net_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (data));
if (!net_port_parent_path) {
g_set_error (error,
MM_CORE_ERROR,
@@ -648,7 +652,7 @@ mm_base_modem_peek_port_mbim_for_data (MMBaseModem *self,
const gchar *wdm_port_parent_path;
g_assert (MM_IS_PORT_MBIM (l->data));
- wdm_port_parent_path = mm_port_get_parent_path (MM_PORT (l->data));
+ wdm_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (MM_PORT (l->data)));
if (wdm_port_parent_path && g_str_equal (wdm_port_parent_path, net_port_parent_path))
return MM_PORT_MBIM (l->data);
}