Only unbind if device is bound to a driver.

This commit is contained in:
Filip Strajnar 2024-10-26 22:41:28 +02:00
parent 6c8f248e3e
commit 29b007c2af

View file

@ -25,8 +25,12 @@ class PciDevice:
).lstrip("0x")
def unbind_driver(self):
with open(f"/sys/bus/pci/devices/{self.device_id}/driver/unbind",
"w") as device_driver:
driver_unbind_path = f"/sys/bus/pci/devices/{self.device_id}/driver/unbind"
if not exists(driver_unbind_path):
print("Device is not bound to any driver.")
return
with open(driver_unbind_path, "w") as device_driver:
device_driver.write(self.device_id)
def set_driver_override(self, reserved_for_driver: str):