summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-01-11 21:43:12 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-01-13 18:51:49 +0100
commit093846aaea3da28f2227f8c300ee807edd5c1ff4 (patch)
tree0d498f3c1bbd1e0e31676bd17dda2fb9c544b392 /src/lib/ecore_drm
parent5e0c1b7cc6bc85545f0a96d7fd302c5d071d9c78 (diff)
ecore_drm: check if device is already opened before open and free
check if fd is -1 before opening a device, so a device cannot be opened twice. Also check if fd is != -1 before closing it.
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_device.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c
index 5376dbd..1b7fc8b 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -237,6 +237,7 @@ cont:
237 237
238 if ((dev = calloc(1, sizeof(Ecore_Drm_Device)))) 238 if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
239 { 239 {
240 dev->drm.fd = -1;
240 dev->drm.name = eeze_udev_syspath_get_devpath(device); 241 dev->drm.name = eeze_udev_syspath_get_devpath(device);
241 dev->drm.path = eina_stringshare_add(device); 242 dev->drm.path = eina_stringshare_add(device);
242 243
@@ -314,8 +315,15 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
314 /* check for valid device */ 315 /* check for valid device */
315 if ((!dev) || (!dev->drm.name)) return EINA_FALSE; 316 if ((!dev) || (!dev->drm.name)) return EINA_FALSE;
316 317
318 /* check if device is already opened */
319 if (dev->drm.fd != -1)
320 {
321 ERR("Device is already opened");
322 return EINA_FALSE;
323 }
324
317 /* DRM device node is needed immediately to keep going. */ 325 /* DRM device node is needed immediately to keep going. */
318 dev->drm.fd = 326 dev->drm.fd =
319 _ecore_drm_launcher_device_open_no_pending(dev->drm.name, O_RDWR); 327 _ecore_drm_launcher_device_open_no_pending(dev->drm.name, O_RDWR);
320 if (dev->drm.fd < 0) return EINA_FALSE; 328 if (dev->drm.fd < 0) return EINA_FALSE;
321 329
@@ -382,12 +390,15 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
382 return EINA_TRUE; 390 return EINA_TRUE;
383} 391}
384 392
385EAPI Eina_Bool 393EAPI Eina_Bool
386ecore_drm_device_close(Ecore_Drm_Device *dev) 394ecore_drm_device_close(Ecore_Drm_Device *dev)
387{ 395{
388 /* check for valid device */ 396 /* check for valid device */
389 EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE); 397 EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
390 398
399 /* check if device is opened */
400 if (dev->drm.fd == -1) return EINA_FALSE;
401
391 /* delete udev watch */ 402 /* delete udev watch */
392 if (dev->watch) eeze_udev_watch_del(dev->watch); 403 if (dev->watch) eeze_udev_watch_del(dev->watch);
393 404