dri3: simplify dri3_open() implementation

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
Emil Velikov 2018-04-02 16:41:15 +01:00 committed by Adam Jackson
parent 9a159f37e0
commit a83ceec868

View File

@ -32,33 +32,21 @@
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <unistd.h> #include <unistd.h>
static inline Bool has_open(const dri3_screen_info_rec *info) {
if (info == NULL)
return FALSE;
return info->open != NULL ||
(info->version >= 1 && info->open_client != NULL);
}
int int
dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd) dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
{ {
dri3_screen_priv_ptr ds = dri3_screen_priv(screen); dri3_screen_priv_ptr ds = dri3_screen_priv(screen);
const dri3_screen_info_rec *info = ds->info; const dri3_screen_info_rec *info = ds->info;
int rc;
if (!has_open(info)) if (info == NULL)
return BadMatch; return BadMatch;
if (info->version >= 1 && info->open_client != NULL) if (info->version >= 1 && info->open_client != NULL)
rc = (*info->open_client) (client, screen, provider, fd); return (*info->open_client) (client, screen, provider, fd);
else if (info->open != NULL)
rc = (*info->open) (screen, provider, fd); return (*info->open) (screen, provider, fd);
if (rc != Success) return BadMatch;
return rc;
return Success;
} }
int int