diff options
-rw-r--r-- | src/intel_device.c | 21 | ||||
-rw-r--r-- | src/intel_driver.h | 1 | ||||
-rw-r--r-- | src/intel_module.c | 19 |
3 files changed, 38 insertions, 3 deletions
diff --git a/src/intel_device.c b/src/intel_device.c index 54c14436..04ad7b6a 100644 --- a/src/intel_device.c +++ b/src/intel_device.c @@ -643,6 +643,27 @@ err_path: return -1; } +void intel_close_device(int entity_num) +{ + struct intel_device *dev; + + if (intel_device_key == -1) + return; + + dev = xf86GetEntityPrivate(entity_num, intel_device_key)->ptr; + xf86GetEntityPrivate(entity_num, intel_device_key)->ptr = NULL; + if (!dev) + return; + + if (dev->master_count == 0) /* Don't close server-fds */ + close(dev->fd); + + if (dev->render_node != dev->master_node) + free(dev->render_node); + free(dev->master_node); + free(dev); +} + int __intel_peek_fd(ScrnInfoPtr scrn) { struct intel_device *dev; diff --git a/src/intel_driver.h b/src/intel_driver.h index fc9beaf0..bece88a0 100644 --- a/src/intel_driver.h +++ b/src/intel_driver.h @@ -124,6 +124,7 @@ int intel_entity_get_devid(int index); int intel_open_device(int entity_num, const struct pci_device *pci, struct xf86_platform_device *dev); +void intel_close_device(int entity_num); int __intel_peek_fd(ScrnInfoPtr scrn); struct intel_device *intel_get_device(ScrnInfoPtr scrn, int *fd); int intel_has_render_node(struct intel_device *dev); diff --git a/src/intel_module.c b/src/intel_module.c index 60835b98..e443c9e9 100644 --- a/src/intel_module.c +++ b/src/intel_module.c @@ -631,6 +631,8 @@ static Bool intel_pci_probe(DriverPtr driver, struct pci_device *pci, intptr_t match_data) { + Bool ret; + if (intel_open_device(entity_num, pci, NULL) == -1) { #if UMS switch (pci->device_id) { @@ -648,7 +650,11 @@ static Bool intel_pci_probe(DriverPtr driver, #endif } - return intel_scrn_create(driver, entity_num, match_data, 0); + ret = intel_scrn_create(driver, entity_num, match_data, 0); + if (!ret) + intel_close_device(entity_num); + + return ret; } #ifdef XSERVER_PLATFORM_BUS @@ -671,9 +677,16 @@ intel_platform_probe(DriverPtr driver, /* if we get any flags we don't understand fail to probe for now */ if (flags) - return FALSE; + goto err; - return intel_scrn_create(driver, entity_num, match_data, scrn_flags); + if (!intel_scrn_create(driver, entity_num, match_data, scrn_flags)) + goto err; + + return TRUE; + +err: + intel_close_device(entity_num); + return FALSE; } #endif |