kernel-device: Add get_wwandev_sysfs_path
The wwan subsystem is a new bus agnostic framework exposing wwan device and its components (ports, netdev...). It can be useful to get the wwan device a device belongs to Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
This commit is contained in:

committed by
Aleksander Morgado

parent
97ab517348
commit
2f38ea0155
@@ -58,6 +58,7 @@ struct _MMKernelDeviceGenericPrivate {
|
|||||||
gchar **drivers;
|
gchar **drivers;
|
||||||
gchar **subsystems;
|
gchar **subsystems;
|
||||||
gchar *sysfs_path;
|
gchar *sysfs_path;
|
||||||
|
gchar *wwandev_sysfs_path;
|
||||||
gchar *interface_sysfs_path;
|
gchar *interface_sysfs_path;
|
||||||
guint8 interface_class;
|
guint8 interface_class;
|
||||||
guint8 interface_subclass;
|
guint8 interface_subclass;
|
||||||
@@ -460,6 +461,30 @@ preload_contents_usb (MMKernelDeviceGeneric *self)
|
|||||||
self->priv->subsystems = (gchar **) g_ptr_array_free (subsystems, FALSE);
|
self->priv->subsystems = (gchar **) g_ptr_array_free (subsystems, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
preload_contents_wwan (MMKernelDeviceGeneric *self)
|
||||||
|
{
|
||||||
|
g_autofree gchar *iter = NULL;
|
||||||
|
|
||||||
|
/* Find the first parent device subsystem */
|
||||||
|
iter = g_path_get_dirname(self->priv->sysfs_path);
|
||||||
|
while (iter && (g_strcmp0 (iter, "/") != 0)) {
|
||||||
|
g_autofree gchar *current_subsystem = NULL;
|
||||||
|
gchar *parent;
|
||||||
|
|
||||||
|
current_subsystem = read_sysfs_attribute_link_basename (iter, "subsystem");
|
||||||
|
if (current_subsystem) {
|
||||||
|
if (g_strcmp0 (current_subsystem, "wwan") == 0)
|
||||||
|
self->priv->wwandev_sysfs_path = g_strdup (iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent = g_path_get_dirname (iter);
|
||||||
|
g_clear_pointer (&iter, g_free);
|
||||||
|
iter = parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
find_device_bus_subsystem (MMKernelDeviceGeneric *self)
|
find_device_bus_subsystem (MMKernelDeviceGeneric *self)
|
||||||
{
|
{
|
||||||
@@ -518,6 +543,8 @@ preload_contents (MMKernelDeviceGeneric *self)
|
|||||||
else
|
else
|
||||||
preload_contents_other (self);
|
preload_contents_other (self);
|
||||||
|
|
||||||
|
preload_contents_wwan (self); /* wwan is bus agnostic class */
|
||||||
|
|
||||||
if (!bus_subsys)
|
if (!bus_subsys)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -580,6 +607,12 @@ kernel_device_get_sysfs_path (MMKernelDevice *self)
|
|||||||
return MM_KERNEL_DEVICE_GENERIC (self)->priv->sysfs_path;
|
return MM_KERNEL_DEVICE_GENERIC (self)->priv->sysfs_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_wwandev_sysfs_path (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
return MM_KERNEL_DEVICE_GENERIC (self)->priv->wwandev_sysfs_path;
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
kernel_device_get_interface_number (MMKernelDevice *self)
|
kernel_device_get_interface_number (MMKernelDevice *self)
|
||||||
{
|
{
|
||||||
@@ -1200,6 +1233,7 @@ mm_kernel_device_generic_class_init (MMKernelDeviceGenericClass *klass)
|
|||||||
kernel_device_class->get_name = kernel_device_get_name;
|
kernel_device_class->get_name = kernel_device_get_name;
|
||||||
kernel_device_class->get_driver = kernel_device_get_driver;
|
kernel_device_class->get_driver = kernel_device_get_driver;
|
||||||
kernel_device_class->get_sysfs_path = kernel_device_get_sysfs_path;
|
kernel_device_class->get_sysfs_path = kernel_device_get_sysfs_path;
|
||||||
|
kernel_device_class->get_wwandev_sysfs_path = kernel_device_get_wwandev_sysfs_path;
|
||||||
kernel_device_class->get_physdev_uid = kernel_device_get_physdev_uid;
|
kernel_device_class->get_physdev_uid = kernel_device_get_physdev_uid;
|
||||||
kernel_device_class->get_physdev_vid = kernel_device_get_physdev_vid;
|
kernel_device_class->get_physdev_vid = kernel_device_get_physdev_vid;
|
||||||
kernel_device_class->get_physdev_pid = kernel_device_get_physdev_pid;
|
kernel_device_class->get_physdev_pid = kernel_device_get_physdev_pid;
|
||||||
|
@@ -347,6 +347,27 @@ kernel_device_get_sysfs_path (MMKernelDevice *_self)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_wwandev_sysfs_path (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
g_autoptr(GUdevDevice) parent = NULL;
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
const gchar *subsys;
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
parent = g_udev_device_get_parent (self->priv->device);
|
||||||
|
|
||||||
|
if (!parent)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
subsys = g_udev_device_get_subsystem (parent);
|
||||||
|
|
||||||
|
if (!subsys || g_strcmp0 (subsys, "wwan"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return g_udev_device_get_sysfs_path (parent);
|
||||||
|
}
|
||||||
|
|
||||||
static const gchar *
|
static const gchar *
|
||||||
kernel_device_get_physdev_uid (MMKernelDevice *_self)
|
kernel_device_get_physdev_uid (MMKernelDevice *_self)
|
||||||
{
|
{
|
||||||
@@ -780,6 +801,7 @@ mm_kernel_device_udev_class_init (MMKernelDeviceUdevClass *klass)
|
|||||||
kernel_device_class->get_name = kernel_device_get_name;
|
kernel_device_class->get_name = kernel_device_get_name;
|
||||||
kernel_device_class->get_driver = kernel_device_get_driver;
|
kernel_device_class->get_driver = kernel_device_get_driver;
|
||||||
kernel_device_class->get_sysfs_path = kernel_device_get_sysfs_path;
|
kernel_device_class->get_sysfs_path = kernel_device_get_sysfs_path;
|
||||||
|
kernel_device_class->get_wwandev_sysfs_path = kernel_device_get_wwandev_sysfs_path;
|
||||||
kernel_device_class->get_physdev_uid = kernel_device_get_physdev_uid;
|
kernel_device_class->get_physdev_uid = kernel_device_get_physdev_uid;
|
||||||
kernel_device_class->get_physdev_vid = kernel_device_get_physdev_vid;
|
kernel_device_class->get_physdev_vid = kernel_device_get_physdev_vid;
|
||||||
kernel_device_class->get_physdev_pid = kernel_device_get_physdev_pid;
|
kernel_device_class->get_physdev_pid = kernel_device_get_physdev_pid;
|
||||||
|
@@ -73,6 +73,14 @@ mm_kernel_device_get_sysfs_path (MMKernelDevice *self)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_wwandev_sysfs_path (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_wwandev_sysfs_path ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_wwandev_sysfs_path (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
mm_kernel_device_get_physdev_uid (MMKernelDevice *self)
|
mm_kernel_device_get_physdev_uid (MMKernelDevice *self)
|
||||||
{
|
{
|
||||||
|
@@ -43,6 +43,8 @@ struct _MMKernelDeviceClass {
|
|||||||
const gchar * (* get_driver) (MMKernelDevice *self);
|
const gchar * (* get_driver) (MMKernelDevice *self);
|
||||||
const gchar * (* get_sysfs_path) (MMKernelDevice *self);
|
const gchar * (* get_sysfs_path) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar * (* get_wwandev_sysfs_path) (MMKernelDevice *self);
|
||||||
|
|
||||||
gint (* get_interface_number) (MMKernelDevice *self);
|
gint (* get_interface_number) (MMKernelDevice *self);
|
||||||
gint (* get_interface_class) (MMKernelDevice *self);
|
gint (* get_interface_class) (MMKernelDevice *self);
|
||||||
gint (* get_interface_subclass) (MMKernelDevice *self);
|
gint (* get_interface_subclass) (MMKernelDevice *self);
|
||||||
@@ -77,6 +79,8 @@ const gchar *mm_kernel_device_get_name (MMKernelDevice *self);
|
|||||||
const gchar *mm_kernel_device_get_driver (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_sysfs_path (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar *mm_kernel_device_get_wwandev_sysfs_path (MMKernelDevice *self);
|
||||||
|
|
||||||
gint mm_kernel_device_get_interface_number (MMKernelDevice *self);
|
gint mm_kernel_device_get_interface_number (MMKernelDevice *self);
|
||||||
gint mm_kernel_device_get_interface_class (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_subclass (MMKernelDevice *self);
|
||||||
|
Reference in New Issue
Block a user