derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d8a9b895bb3c3e70c4b56441c0c34b981381a8d0

commit d8a9b895bb3c3e70c4b56441c0c34b981381a8d0
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Thu Aug 3 14:56:19 2017 -0500

    ecore_drm2: Merge ecore_drm2_device_find and ecore_drm2_device_open
    
    There's never a reason to find a device and not open it, so all callers
    end up calling these two functions back to back.
---
 src/lib/ecore_drm2/Ecore_Drm2.h                    | 19 ++--------
 src/lib/ecore_drm2/ecore_drm2_device.c             | 41 ++++++++--------------
 .../ecore_evas/engines/drm/ecore_evas_drm.c        |  9 +----
 3 files changed, 19 insertions(+), 50 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 81c3ace6a8..d90ee99dc2 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -166,30 +166,17 @@ EAPI int ecore_drm2_event_handle(Ecore_Drm2_Device *dev, 
Ecore_Drm2_Context *drm
  */
 
 /**
- * Try to find a drm device on a given seat
+ * Try to open the Ecore_Drm2_Device for a given seat
  *
  * @param seat
  * @param tty
- * @param sync
  *
- * @return A newly allocated Ecore_Drm2_Device on success, NULL otherwise
+ * @return An Ecore_Drm2_Device or NULL on failure.
  *
  * @ingroup Ecore_Drm2_Device_Group
  * @since 1.18
  */
-EAPI Ecore_Drm2_Device *ecore_drm2_device_find(const char *seat, unsigned int 
tty);
-
-/**
- * Try to open a given Ecore_Drm2_Device
- *
- * @param device
- *
- * @return A valid file descriptor if open succeeds, -1 otherwise.
- *
- * @ingroup Ecore_Drm2_Device_Group
- * @since 1.18
- */
-EAPI int ecore_drm2_device_open(Ecore_Drm2_Device *device);
+EAPI Ecore_Drm2_Device *ecore_drm2_device_open(const char *seat, unsigned int 
tty);
 
 /**
  * Close an open Ecore_Drm2_Device
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c 
b/src/lib/ecore_drm2/ecore_drm2_device.c
index aa8917ce4e..42a21c0742 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -593,43 +593,29 @@ _drm2_atomic_state_free(Ecore_Drm2_Atomic_State *state)
 }
 
 EAPI Ecore_Drm2_Device *
-ecore_drm2_device_find(const char *seat, unsigned int tty)
+ecore_drm2_device_open(const char *seat, unsigned int tty)
 {
-   Ecore_Drm2_Device *dev;
+   Ecore_Drm2_Device *device;
 
-   dev = calloc(1, sizeof(Ecore_Drm2_Device));
-   if (!dev) return NULL;
+   device = calloc(1, sizeof(Ecore_Drm2_Device));
+   if (!device) return NULL;
 
-   dev->em = elput_manager_connect(seat, tty);
-   if (!dev->em)
+   device->em = elput_manager_connect(seat, tty);
+   if (!device->em)
      {
         ERR("Could not connect to input manager");
         goto man_err;
      }
 
-   dev->path = _drm2_device_find(dev->em, seat);
-   if (!dev->path)
+   device->path = _drm2_device_find(device->em, seat);
+   if (!device->path)
      {
         ERR("Could not find drm device on seat %s", seat);
         goto path_err;
      }
 
-   return dev;
-
-path_err:
-   elput_manager_disconnect(dev->em);
-man_err:
-   free(dev);
-   return NULL;
-}
-
-EAPI int
-ecore_drm2_device_open(Ecore_Drm2_Device *device)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(device, -1);
-
    device->fd = elput_manager_open(device->em, device->path, -1);
-   if (device->fd < 0) goto open_err;
+   if (device->fd < 0) goto path_err;
 
    if (!elput_input_init(device->em))
      {
@@ -681,12 +667,15 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
      ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE,
                              _cb_device_change, device);
 
-   return device->fd;
+   return device;
 
 input_err:
    elput_manager_close(device->em, device->fd);
-open_err:
-   return -1;
+path_err:
+   elput_manager_disconnect(device->em);
+man_err:
+   free(device);
+   return NULL;
 }
 
 EAPI void
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index a801445492..c8714ac1b9 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -148,15 +148,9 @@ _ecore_evas_drm_init(Ecore_Evas *ee, 
Ecore_Evas_Engine_Drm_Data *edata, const ch
 
    if (!device) device = "seat0";
 
-   edata->dev = ecore_drm2_device_find(device, 0);
+   edata->dev = ecore_drm2_device_open(device, 0);
    if (!edata->dev)
      {
-        ERR("Failed to create device");
-        goto dev_err;
-     }
-
-   if (ecore_drm2_device_open(edata->dev) < 0)
-     {
         ERR("Failed to open device");
         goto open_err;
      }
@@ -187,7 +181,6 @@ output_err:
    ecore_drm2_device_close(edata->dev);
 open_err:
    ecore_drm2_device_free(edata->dev);
-dev_err:
    ecore_drm2_shutdown();
 init_err:
    return --_drm_init_count;

-- 


Reply via email to