kerneldevice: allow getting interface class/subclass/protocol
This commit is contained in:
@@ -2200,7 +2200,7 @@ peek_port_at_for_data (MMBroadbandModemHuawei *self,
|
||||
MMPortSerialAt *found = NULL;
|
||||
|
||||
g_warn_if_fail (mm_port_get_subsys (port) == MM_PORT_SUBSYS_NET);
|
||||
net_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (port));
|
||||
net_port_parent_path = mm_kernel_device_get_interface_sysfs_path (mm_port_peek_kernel_device (port));
|
||||
if (!net_port_parent_path) {
|
||||
mm_warn ("(%s) no parent path for net port", mm_port_get_device (port));
|
||||
return NULL;
|
||||
@@ -2215,7 +2215,7 @@ peek_port_at_for_data (MMBroadbandModemHuawei *self,
|
||||
const gchar *wdm_port_parent_path;
|
||||
|
||||
g_assert (MM_IS_PORT_SERIAL_AT (l->data));
|
||||
wdm_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (MM_PORT (l->data)));
|
||||
wdm_port_parent_path = mm_kernel_device_get_interface_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))
|
||||
found = MM_PORT_SERIAL_AT (l->data);
|
||||
}
|
||||
|
||||
@@ -442,8 +442,32 @@ kernel_device_get_sysfs_path (MMKernelDevice *self)
|
||||
return MM_KERNEL_DEVICE_GENERIC (self)->priv->sysfs_path;
|
||||
}
|
||||
|
||||
static gint
|
||||
kernel_device_get_interface_class (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_GENERIC (self), -1);
|
||||
|
||||
return (gint) MM_KERNEL_DEVICE_GENERIC (self)->priv->interface_class;
|
||||
}
|
||||
|
||||
static gint
|
||||
kernel_device_get_interface_subclass (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_GENERIC (self), -1);
|
||||
|
||||
return (gint) MM_KERNEL_DEVICE_GENERIC (self)->priv->interface_subclass;
|
||||
}
|
||||
|
||||
static gint
|
||||
kernel_device_get_interface_protocol (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_GENERIC (self), -1);
|
||||
|
||||
return (gint) MM_KERNEL_DEVICE_GENERIC (self)->priv->interface_protocol;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
kernel_device_get_parent_sysfs_path (MMKernelDevice *self)
|
||||
kernel_device_get_interface_sysfs_path (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_GENERIC (self), NULL);
|
||||
|
||||
@@ -1057,7 +1081,10 @@ mm_kernel_device_generic_class_init (MMKernelDeviceGenericClass *klass)
|
||||
kernel_device_class->get_physdev_sysfs_path = kernel_device_get_physdev_sysfs_path;
|
||||
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;
|
||||
kernel_device_class->get_physdev_manufacturer = kernel_device_get_physdev_manufacturer;
|
||||
kernel_device_class->get_parent_sysfs_path = kernel_device_get_parent_sysfs_path;
|
||||
kernel_device_class->get_interface_class = kernel_device_get_interface_class;
|
||||
kernel_device_class->get_interface_subclass = kernel_device_get_interface_subclass;
|
||||
kernel_device_class->get_interface_protocol = kernel_device_get_interface_protocol;
|
||||
kernel_device_class->get_interface_sysfs_path = kernel_device_get_interface_sysfs_path;
|
||||
kernel_device_class->cmp = kernel_device_cmp;
|
||||
kernel_device_class->has_property = kernel_device_has_property;
|
||||
kernel_device_class->get_property = kernel_device_get_property;
|
||||
|
||||
@@ -242,6 +242,17 @@ ensure_physdev (MMKernelDeviceUdev *self)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
ensure_parent (MMKernelDeviceUdev *self)
|
||||
{
|
||||
if (self->priv->parent)
|
||||
return;
|
||||
if (self->priv->device)
|
||||
self->priv->parent = g_udev_device_get_parent (self->priv->device);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const gchar *
|
||||
kernel_device_get_subsystem (MMKernelDevice *_self)
|
||||
{
|
||||
@@ -428,17 +439,51 @@ kernel_device_get_physdev_manufacturer (MMKernelDevice *_self)
|
||||
return g_udev_device_get_sysfs_attr (self->priv->physdev, "manufacturer");
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
kernel_device_get_parent_sysfs_path (MMKernelDevice *_self)
|
||||
static gint
|
||||
kernel_device_get_interface_class (MMKernelDevice *_self)
|
||||
{
|
||||
MMKernelDeviceUdev *self;
|
||||
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), 0);
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), -1);
|
||||
|
||||
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||
ensure_parent (self);
|
||||
return (self->priv->parent ? g_udev_device_get_sysfs_attr_as_int (self->priv->parent, "bInterfaceClass") : -1);
|
||||
}
|
||||
|
||||
if (!self->priv->parent && self->priv->device)
|
||||
self->priv->parent = g_udev_device_get_parent (self->priv->device);
|
||||
static gint
|
||||
kernel_device_get_interface_subclass (MMKernelDevice *_self)
|
||||
{
|
||||
MMKernelDeviceUdev *self;
|
||||
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), -1);
|
||||
|
||||
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||
ensure_parent (self);
|
||||
return (self->priv->parent ? g_udev_device_get_sysfs_attr_as_int (self->priv->parent, "bInterfaceSubClass") : -1);
|
||||
}
|
||||
|
||||
static gint
|
||||
kernel_device_get_interface_protocol (MMKernelDevice *_self)
|
||||
{
|
||||
MMKernelDeviceUdev *self;
|
||||
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), -1);
|
||||
|
||||
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||
ensure_parent (self);
|
||||
return (self->priv->parent ? g_udev_device_get_sysfs_attr_as_int (self->priv->parent, "bInterfaceProtocol") : -1);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
kernel_device_get_interface_sysfs_path (MMKernelDevice *_self)
|
||||
{
|
||||
MMKernelDeviceUdev *self;
|
||||
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), NULL);
|
||||
|
||||
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||
ensure_parent (self);
|
||||
return (self->priv->parent ? g_udev_device_get_sysfs_path (self->priv->parent) : NULL);
|
||||
}
|
||||
|
||||
@@ -837,7 +882,10 @@ mm_kernel_device_udev_class_init (MMKernelDeviceUdevClass *klass)
|
||||
kernel_device_class->get_physdev_sysfs_path = kernel_device_get_physdev_sysfs_path;
|
||||
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;
|
||||
kernel_device_class->get_physdev_manufacturer = kernel_device_get_physdev_manufacturer;
|
||||
kernel_device_class->get_parent_sysfs_path = kernel_device_get_parent_sysfs_path;
|
||||
kernel_device_class->get_interface_class = kernel_device_get_interface_class;
|
||||
kernel_device_class->get_interface_subclass = kernel_device_get_interface_subclass;
|
||||
kernel_device_class->get_interface_protocol = kernel_device_get_interface_protocol;
|
||||
kernel_device_class->get_interface_sysfs_path = kernel_device_get_interface_sysfs_path;
|
||||
kernel_device_class->cmp = kernel_device_cmp;
|
||||
kernel_device_class->has_property = kernel_device_has_property;
|
||||
kernel_device_class->get_property = kernel_device_get_property;
|
||||
|
||||
@@ -123,13 +123,43 @@ mm_kernel_device_get_physdev_manufacturer (MMKernelDevice *self)
|
||||
NULL);
|
||||
}
|
||||
|
||||
gint
|
||||
mm_kernel_device_get_interface_class (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), -1);
|
||||
|
||||
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_class ?
|
||||
MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_class (self) :
|
||||
-1);
|
||||
}
|
||||
|
||||
gint
|
||||
mm_kernel_device_get_interface_subclass (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), -1);
|
||||
|
||||
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_subclass ?
|
||||
MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_subclass (self) :
|
||||
-1);
|
||||
}
|
||||
|
||||
gint
|
||||
mm_kernel_device_get_interface_protocol (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), -1);
|
||||
|
||||
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_protocol ?
|
||||
MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_protocol (self) :
|
||||
-1);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
mm_kernel_device_get_parent_sysfs_path (MMKernelDevice *self)
|
||||
mm_kernel_device_get_interface_sysfs_path (MMKernelDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||
|
||||
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_parent_sysfs_path ?
|
||||
MM_KERNEL_DEVICE_GET_CLASS (self)->get_parent_sysfs_path (self) :
|
||||
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_sysfs_path ?
|
||||
MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_sysfs_path (self) :
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,25 +37,20 @@ struct _MMKernelDeviceClass {
|
||||
GObjectClass parent;
|
||||
|
||||
const gchar * (* get_subsystem) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_name) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_driver) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_sysfs_path) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_parent_sysfs_path) (MMKernelDevice *self);
|
||||
gint (* get_interface_class) (MMKernelDevice *self);
|
||||
gint (* get_interface_subclass) (MMKernelDevice *self);
|
||||
gint (* get_interface_protocol) (MMKernelDevice *self);
|
||||
const gchar * (* get_interface_sysfs_path) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_physdev_uid) (MMKernelDevice *self);
|
||||
|
||||
guint16 (* get_physdev_vid) (MMKernelDevice *self);
|
||||
|
||||
guint16 (* get_physdev_pid) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_physdev_sysfs_path) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_physdev_subsystem) (MMKernelDevice *self);
|
||||
|
||||
const gchar * (* get_physdev_manufacturer) (MMKernelDevice *self);
|
||||
|
||||
gboolean (* cmp) (MMKernelDevice *a, MMKernelDevice *b);
|
||||
@@ -80,7 +75,10 @@ const gchar *mm_kernel_device_get_name (MMKernelDevice *self);
|
||||
const gchar *mm_kernel_device_get_driver (MMKernelDevice *self);
|
||||
const gchar *mm_kernel_device_get_sysfs_path (MMKernelDevice *self);
|
||||
|
||||
const gchar *mm_kernel_device_get_parent_sysfs_path (MMKernelDevice *self);
|
||||
gint mm_kernel_device_get_interface_class (MMKernelDevice *self);
|
||||
gint mm_kernel_device_get_interface_subclass (MMKernelDevice *self);
|
||||
gint mm_kernel_device_get_interface_protocol (MMKernelDevice *self);
|
||||
const gchar *mm_kernel_device_get_interface_sysfs_path (MMKernelDevice *self);
|
||||
|
||||
const gchar *mm_kernel_device_get_physdev_uid (MMKernelDevice *self);
|
||||
guint16 mm_kernel_device_get_physdev_vid (MMKernelDevice *self);
|
||||
|
||||
+4
-4
@@ -566,7 +566,7 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self,
|
||||
MMPortQmi *found = NULL;
|
||||
|
||||
g_warn_if_fail (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET);
|
||||
net_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (data));
|
||||
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,
|
||||
MM_CORE_ERROR,
|
||||
@@ -585,7 +585,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_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (MM_PORT (l->data)));
|
||||
wdm_port_parent_path = mm_kernel_device_get_interface_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))
|
||||
found = MM_PORT_QMI (l->data);
|
||||
}
|
||||
@@ -645,7 +645,7 @@ mm_base_modem_peek_port_mbim_for_data (MMBaseModem *self,
|
||||
MMPortMbim *found = NULL;
|
||||
|
||||
g_warn_if_fail (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET);
|
||||
net_port_parent_path = mm_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (data));
|
||||
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,
|
||||
MM_CORE_ERROR,
|
||||
@@ -665,7 +665,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_kernel_device_get_parent_sysfs_path (mm_port_peek_kernel_device (MM_PORT (l->data)));
|
||||
wdm_port_parent_path = mm_kernel_device_get_interface_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))
|
||||
found = MM_PORT_MBIM (l->data);
|
||||
}
|
||||
|
||||
@@ -1711,14 +1711,6 @@ mm_port_probe_get_port_subsys (MMPortProbe *self)
|
||||
return mm_kernel_device_get_subsystem (self->priv->port);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
mm_port_probe_get_parent_path (MMPortProbe *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||
|
||||
return mm_kernel_device_get_parent_sysfs_path (self->priv->port);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMPortProbe *
|
||||
|
||||
@@ -87,7 +87,6 @@ MMKernelDevice *mm_port_probe_peek_port (MMPortProbe *self);
|
||||
MMKernelDevice *mm_port_probe_get_port (MMPortProbe *self);
|
||||
const gchar *mm_port_probe_get_port_name (MMPortProbe *self);
|
||||
const gchar *mm_port_probe_get_port_subsys (MMPortProbe *self);
|
||||
const gchar *mm_port_probe_get_parent_path (MMPortProbe *self);
|
||||
|
||||
/* Probing result setters */
|
||||
void mm_port_probe_set_result_at (MMPortProbe *self,
|
||||
|
||||
Reference in New Issue
Block a user