Hi Antara,
<snip>
@@ -1612,16 +1631,8 @@ static void add_device(const char *syspath, const char
*devname,
if (devpath == NULL)
return;
- devnode = udev_device_get_devnode(device);
- if (devnode == NULL) {
- devnode = udev_device_get_property_value(device, "INTERFACE");
- if (devnode == NULL)
- return;
- }
-
- usb_interface = udev_device_get_parent_with_subsystem_devtype(device,
- "usb", "usb_interface");
- if (usb_interface == NULL)
+ subsystem = udev_device_get_subsystem(device);
+ if (subsystem == NULL)
return;
Lets just make the modem type into an argument to this function, since
check_pci_device and check_usb_device already know this.
modem = g_hash_table_lookup(modem_list, syspath);
@@ -1630,7 +1641,12 @@ static void add_device(const char *syspath, const char
*devname,
if (modem == NULL)
return;
- modem->type = MODEM_TYPE_USB;
+ if ((g_str_equal(subsystem, "usb") == TRUE) ||
+ (g_str_equal(subsystem, "usbmisc") == TRUE))
+ modem->type = MODEM_TYPE_USB;
+ else if (g_str_equal(subsystem, "pci") == TRUE)
+ modem->type = MODEM_TYPE_PCIE;
+
modem->syspath = g_strdup(syspath);
modem->devname = g_strdup(devname);
modem->driver = g_strdup(driver);
@@ -1642,30 +1658,60 @@ static void add_device(const char *syspath, const char
*devname,
g_hash_table_replace(modem_list, modem->syspath, modem);
}
- interface = udev_device_get_property_value(usb_interface, "INTERFACE");
- number = udev_device_get_property_value(device, "ID_USB_INTERFACE_NUM");
+ label = udev_device_get_property_value(device, "OFONO_LABEL");
- /* If environment variable is not set, get value from attributes (or parent's ones) */
- if (number == NULL) {
- number = udev_device_get_sysattr_value(device,
+ if (modem->type == MODEM_TYPE_USB) {
+ devnode = udev_device_get_devnode(device);
+ if (devnode == NULL) {
+ devnode = udev_device_get_property_value(device,
+ "INTERFACE");
+ if (devnode == NULL)
+ return;
+ }
+
+ usb_interface = udev_device_get_parent_with_subsystem_devtype(
+ device, "usb",
+ "usb_interface");
+ if (usb_interface == NULL)
+ return;
+
+ interface = udev_device_get_property_value(usb_interface,
+ "INTERFACE");
+ number = udev_device_get_property_value(device,
+ "ID_USB_INTERFACE_NUM");
+
+ if (number == NULL)
+ number = udev_device_get_sysattr_value(device,
"bInterfaceNumber");
- if (number == NULL) {
- parent = udev_device_get_parent(device);
- number = udev_device_get_sysattr_value(parent,
+ if (!label)
+ label = udev_device_get_property_value(usb_interface,
+ "OFONO_LABEL");
+ } else {
+ devnode = NULL;
+ interface = udev_device_get_property_value(device,
+ "INTERFACE");
+ number = udev_device_get_sysattr_value(device,
"bInterfaceNumber");
- }
- }
- label = udev_device_get_property_value(device, "OFONO_LABEL");
- if (!label)
- label = udev_device_get_property_value(usb_interface,
+ if (!label)
+ label = udev_device_get_property_value(device,
"OFONO_LABEL");
+ }
You can drop OFONO_LABEL handling for pci devices completely. I don't
even remember why that was used but it definitely should not be needed
unless you're trying to be backward compatible with some legacy things,
which you're not.
- subsystem = udev_device_get_subsystem(device);
+ /*
+ *If environment variable is not set, get value from attributes
+ *(or parent's ones)
+ */
+ if (number == NULL) {
+ parent = udev_device_get_parent(device);
+ number = udev_device_get_sysattr_value(parent,
+ "bInterfaceNumber");
+ }
if (modem->sysattr != NULL)
- sysattr = udev_device_get_sysattr_value(device, modem->sysattr);
+ sysattr = udev_device_get_sysattr_value(device,
+ modem->sysattr);
else
sysattr = NULL;
<snip>
Regards,
-Denis
_______________________________________________
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono