Merge ~sylvain-pineau/checkbox-support:add_bt_hci_interface into checkbox-support:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: bcaeafabb606811f98a8219ae48d8336d42553f6
Merged at revision: 04059ec405fdb1c4ebc1ae5beb5c61f280e370aa
Proposed branch: ~sylvain-pineau/checkbox-support:add_bt_hci_interface
Merge into: checkbox-support:master
Diff against target: 103 lines (+37/-15)
1 file modified
checkbox_support/parsers/udevadm.py (+37/-15)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+356251@code.launchpad.net

Description of the change

Ensure all BLUETOOTH devices get an hci interface property.

e.g:

path: /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0
bus: usb
category: BLUETOOTH
driver: btusb
product_id: 2603
vendor_id: 32903
vendor: Intel Corp.
interface: hci0
vendor_slug: Intel_Corp.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

self-approved, tested using the udevadm parser test data files.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
index 4c0590e..38b5882 100644
--- a/checkbox_support/parsers/udevadm.py
+++ b/checkbox_support/parsers/udevadm.py
@@ -534,6 +534,14 @@ class UdevadmDevice(object):
534 if self._environment["SUBSYSTEM"] == "video4linux":534 if self._environment["SUBSYSTEM"] == "video4linux":
535 return "CAPTURE"535 return "CAPTURE"
536536
537 if (
538 'RFKILL_TYPE' in self._environment and
539 'RFKILL_NAME' in self._environment
540 ):
541 if self._environment["RFKILL_TYPE"] == 'bluetooth':
542 if self._environment["RFKILL_NAME"].startswith('hci'):
543 return 'BLUETOOTH'
544
537 # Any devices that have a product name and proper vendor and product545 # Any devices that have a product name and proper vendor and product
538 # IDs, but had no other category, are lumped together in OTHER.546 # IDs, but had no other category, are lumped together in OTHER.
539 # A few devices may have no self.product but carry PRODUCT data in547 # A few devices may have no self.product but carry PRODUCT data in
@@ -645,11 +653,11 @@ class UdevadmDevice(object):
645 if "ID_MODEL_ID" in self._environment:653 if "ID_MODEL_ID" in self._environment:
646 return decode_id(self._environment["ID_MODEL_ID"])654 return decode_id(self._environment["ID_MODEL_ID"])
647 if "SUBSYSTEM" in self._environment:655 if "SUBSYSTEM" in self._environment:
648 # hidraw656 # hidraw
649 if self._environment["SUBSYSTEM"] == "hidraw" and self._stack:657 if self._environment["SUBSYSTEM"] == "hidraw" and self._stack:
650 parent = self._stack[-1]658 parent = self._stack[-1]
651 return parent.product_id659 return parent.product_id
652 # video4linux660 # video4linux
653 if self._environment["SUBSYSTEM"] == "video4linux":661 if self._environment["SUBSYSTEM"] == "video4linux":
654 if "ID_MODEL_ID" in self._environment:662 if "ID_MODEL_ID" in self._environment:
655 return decode_id(self._environment["ID_MODEL_ID"])663 return decode_id(self._environment["ID_MODEL_ID"])
@@ -699,11 +707,11 @@ class UdevadmDevice(object):
699 if "ID_VENDOR_ID" in self._environment:707 if "ID_VENDOR_ID" in self._environment:
700 return decode_id(self._environment["ID_VENDOR_ID"])708 return decode_id(self._environment["ID_VENDOR_ID"])
701 if "SUBSYSTEM" in self._environment:709 if "SUBSYSTEM" in self._environment:
702 # hidraw710 # hidraw
703 if self._environment["SUBSYSTEM"] == "hidraw" and self._stack:711 if self._environment["SUBSYSTEM"] == "hidraw" and self._stack:
704 parent = self._stack[-1]712 parent = self._stack[-1]
705 return parent.vendor_id713 return parent.vendor_id
706 # video4linux714 # video4linux
707 if self._environment["SUBSYSTEM"] == "video4linux":715 if self._environment["SUBSYSTEM"] == "video4linux":
708 if "ID_VENDOR_ID" in self._environment:716 if "ID_VENDOR_ID" in self._environment:
709 return decode_id(self._environment["ID_VENDOR_ID"])717 return decode_id(self._environment["ID_VENDOR_ID"])
@@ -975,6 +983,8 @@ class UdevadmDevice(object):
975 return self._environment["INTERFACE"]983 return self._environment["INTERFACE"]
976 else:984 else:
977 return 'UNKNOWN'985 return 'UNKNOWN'
986 if "RFKILL_NAME" in self._environment:
987 return self._environment["RFKILL_NAME"]
978 return None988 return None
979989
980 @property990 @property
@@ -1224,7 +1234,7 @@ class UdevadmParser(object):
1224 for parent in (device._stack[-1], device._stack[-2]):1234 for parent in (device._stack[-1], device._stack[-2]):
1225 if parent._raw_path in HID_devices_path_list:1235 if parent._raw_path in HID_devices_path_list:
1226 self.devices.pop(device._raw_path, None)1236 self.devices.pop(device._raw_path, None)
1227 if device.category in ("INFINIBAND", "NETWORK", "SOCKETCAN",1237 elif device.category in ("INFINIBAND", "NETWORK", "SOCKETCAN",
1228 "WIRELESS", "WWAN", "OTHER"):1238 "WIRELESS", "WWAN", "OTHER"):
1229 dev_interface = [1239 dev_interface = [
1230 d for d in self.devices.values()1240 d for d in self.devices.values()
@@ -1243,16 +1253,28 @@ class UdevadmParser(object):
1243 dev_interface.subproduct_id = device.subproduct_id1253 dev_interface.subproduct_id = device.subproduct_id
1244 dev_interface.subvendor_id = device.subvendor_id1254 dev_interface.subvendor_id = device.subvendor_id
1245 self.devices.pop(device._raw_path, None)1255 self.devices.pop(device._raw_path, None)
1246 # If dev/mapper list devices then they take precedence over the1256 elif device.category == 'BLUETOOTH':
1247 # other block devices1257 dev_interface = [
1248 if dev_mapper_devices and device.category == 'DISK':1258 d for d in self.devices.values()
1249 if device not in dev_mapper_devices:1259 if d.category == 'BLUETOOTH' and
1250 self.devices.pop(device._raw_path, None)1260 device._raw_path != d._raw_path and
1251 # Remove DISK devices participating in RAID arrays created by1261 device._raw_path + '/' in d._raw_path
1252 # mdstat1262 ]
1253 if md_devices and device.category == 'DISK':1263 if dev_interface:
1254 if device.name in md_devices:1264 dev_interface = dev_interface.pop()
1255 self.devices.pop(device._raw_path, None)1265 device.interface = dev_interface.interface
1266 self.devices.pop(dev_interface._raw_path, None)
1267 elif device.category == 'DISK':
1268 # If dev/mapper list devices then they take precedence over the
1269 # other block devices
1270 if dev_mapper_devices:
1271 if device not in dev_mapper_devices:
1272 self.devices.pop(device._raw_path, None)
1273 # Remove DISK devices participating in RAID arrays created by
1274 # mdstat
1275 if md_devices:
1276 if device.name in md_devices:
1277 self.devices.pop(device._raw_path, None)
12561278
1257 [result.addDevice(device) for device in self.devices.values()]1279 [result.addDevice(device) for device in self.devices.values()]
12581280

Subscribers

People subscribed via source and target branches