broadband-modem-qmi: allow subclassing the match of control vs net ports

By default we provide the implementation for the qmi_wwan driver,
where both control and net ports share the same USB interface.
This commit is contained in:
Aleksander Morgado
2020-10-22 12:28:26 +02:00
parent b8f6fb59ed
commit b8cbc87249
2 changed files with 32 additions and 4 deletions

View File

@@ -225,19 +225,31 @@ mm_broadband_modem_qmi_get_port_qmi_for_data (MMBroadbandModemQmi *self,
NULL);
}
MMPortQmi *
mm_broadband_modem_qmi_peek_port_qmi_for_data (MMBroadbandModemQmi *self,
MMPort *data,
GError **error)
static MMPortQmi *
peek_port_qmi_for_data (MMBroadbandModemQmi *self,
MMPort *data,
GError **error)
{
GList *cdc_wdm_qmi_ports;
GList *l;
const gchar *net_port_parent_path;
MMPortQmi *found = NULL;
const gchar *net_port_driver;
g_assert (MM_IS_BROADBAND_MODEM_QMI (self));
g_assert (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET);
net_port_driver = mm_kernel_device_get_driver (mm_port_peek_kernel_device (data));
if (g_strcmp0 (net_port_driver, "qmi_wwan") != 0) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Unsupported QMI kernel driver for 'net/%s': %s",
mm_port_get_device (data),
net_port_driver);
return NULL;
}
net_port_parent_path = mm_kernel_device_get_interface_sysfs_path (mm_port_peek_kernel_device (data));
if (!net_port_parent_path) {
g_set_error (error,
@@ -274,6 +286,16 @@ mm_broadband_modem_qmi_peek_port_qmi_for_data (MMBroadbandModemQmi *self,
return found;
}
MMPortQmi *
mm_broadband_modem_qmi_peek_port_qmi_for_data (MMBroadbandModemQmi *self,
MMPort *data,
GError **error)
{
g_assert (MM_BROADBAND_MODEM_QMI_GET_CLASS (self)->peek_port_qmi_for_data);
return MM_BROADBAND_MODEM_QMI_GET_CLASS (self)->peek_port_qmi_for_data (self, data, error);
}
/*****************************************************************************/
/* Create Bearer (Modem interface) */
@@ -9724,6 +9746,8 @@ mm_broadband_modem_qmi_class_init (MMBroadbandModemQmiClass *klass)
g_type_class_add_private (object_class, sizeof (MMBroadbandModemQmiPrivate));
klass->peek_port_qmi_for_data = peek_port_qmi_for_data;
object_class->finalize = finalize;
object_class->dispose = dispose;

View File

@@ -36,6 +36,10 @@ struct _MMBroadbandModemQmi {
struct _MMBroadbandModemQmiClass{
MMBroadbandModemClass parent;
MMPortQmi * (* peek_port_qmi_for_data) (MMBroadbandModemQmi *self,
MMPort *data,
GError **error);
};
GType mm_broadband_modem_qmi_get_type (void);