aboutsummaryrefslogtreecommitdiff
path: root/src/kerneldevice/mm-kernel-device-generic.c
diff options
context:
space:
mode:
authorDan Williams <dan@bigw.org>2025-02-21 14:01:51 +0000
committerDan Williams <dan@bigw.org>2025-02-21 14:01:51 +0000
commit6e981b61b3ceeb54d8f3e20548c9968e281c85b8 (patch)
treebce3530522d0356fd3884440d6ed7a15de9709b0 /src/kerneldevice/mm-kernel-device-generic.c
parent286598388b129ec632998e5d72d58d847bd2892a (diff)
parent092439369ba06b488c70514b4e144fc5c83a917c (diff)
Merge request !1287 from 'sushrut-branch'
kernel-device, generic: add subsystem device ID support https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1287
Diffstat (limited to 'src/kerneldevice/mm-kernel-device-generic.c')
-rw-r--r--src/kerneldevice/mm-kernel-device-generic.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/kerneldevice/mm-kernel-device-generic.c b/src/kerneldevice/mm-kernel-device-generic.c
index 81ef962a..1ff63575 100644
--- a/src/kerneldevice/mm-kernel-device-generic.c
+++ b/src/kerneldevice/mm-kernel-device-generic.c
@@ -69,6 +69,7 @@ struct _MMKernelDeviceGenericPrivate {
guint16 physdev_vid;
guint16 physdev_pid;
guint16 physdev_subsystem_vid;
+ guint16 physdev_subsystem_pid;
guint16 physdev_revision;
gchar *physdev_manufacturer;
gchar *physdev_product;
@@ -402,6 +403,7 @@ preload_contents_pci (MMKernelDeviceGeneric *self)
self->priv->physdev_vid = read_sysfs_attribute_as_hex (self->priv->physdev_sysfs_path, "vendor");
self->priv->physdev_pid = read_sysfs_attribute_as_hex (self->priv->physdev_sysfs_path, "device");
self->priv->physdev_subsystem_vid = read_sysfs_attribute_as_hex (self->priv->physdev_sysfs_path, "subsystem_vendor");
+ self->priv->physdev_subsystem_pid = read_sysfs_attribute_as_hex (self->priv->physdev_sysfs_path, "subsystem_device");
self->priv->physdev_revision = read_sysfs_attribute_as_hex (self->priv->physdev_sysfs_path, "revision");
/* stop traversing as soon as the physical device is found */
break;
@@ -585,6 +587,8 @@ preload_contents (MMKernelDeviceGeneric *self)
mm_obj_dbg (self, " product: %04x", self->priv->physdev_pid);
if (self->priv->physdev_subsystem_vid)
mm_obj_dbg (self, " subsystem vendor: %04x", self->priv->physdev_subsystem_vid);
+ if (self->priv->physdev_subsystem_pid)
+ mm_obj_dbg (self, " subsystem device: %04x", self->priv->physdev_subsystem_pid);
if (self->priv->physdev_revision)
mm_obj_dbg (self, " revision: %04x", self->priv->physdev_revision);
if (self->priv->physdev_manufacturer)
@@ -705,6 +709,12 @@ kernel_device_get_physdev_subsystem_vid (MMKernelDevice *self)
}
static guint16
+kernel_device_get_physdev_subsystem_pid (MMKernelDevice *self)
+{
+ return MM_KERNEL_DEVICE_GENERIC (self)->priv->physdev_subsystem_pid;
+}
+
+static guint16
kernel_device_get_physdev_revision (MMKernelDevice *self)
{
return MM_KERNEL_DEVICE_GENERIC (self)->priv->physdev_revision;
@@ -827,6 +837,9 @@ check_condition (MMKernelDeviceGeneric *self,
else if (g_str_equal (attribute, "subsystem_vendor"))
result = ((mm_get_uint_from_hex_str (match->value, &val)) &&
((mm_kernel_device_get_physdev_subsystem_vid (MM_KERNEL_DEVICE (self)) == val) == condition_equal));
+ else if (g_str_equal (attribute, "subsystem_device"))
+ result = ((mm_get_uint_from_hex_str (match->value, &val)) &&
+ ((mm_kernel_device_get_physdev_subsystem_pid (MM_KERNEL_DEVICE (self)) == val) == condition_equal));
/* manufacturer in the physdev */
else if (g_str_equal (attribute, "manufacturer"))
result = ((self->priv->physdev_manufacturer && g_str_equal (self->priv->physdev_manufacturer, match->value)) == condition_equal);
@@ -1214,6 +1227,7 @@ mm_kernel_device_generic_class_init (MMKernelDeviceGenericClass *klass)
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_subsystem_vid = kernel_device_get_physdev_subsystem_vid;
+ kernel_device_class->get_physdev_subsystem_pid = kernel_device_get_physdev_subsystem_pid;
kernel_device_class->get_physdev_revision = kernel_device_get_physdev_revision;
kernel_device_class->get_physdev_sysfs_path = kernel_device_get_physdev_sysfs_path;
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;