From 9cd3f03f652fc7ee905001e09dafa40b72e1317d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 17 Dec 2020 20:48:47 +0100 Subject: [PATCH] backend/drm: add wlr_drm_backend.name Save the DRM device name in a wlr_drm_backend field, so that we can easily use it for logging purposes. --- backend/drm/backend.c | 8 ++++---- include/backend/drm/drm.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/drm/backend.c b/backend/drm/backend.c index b2da7cb3..44794b51 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -50,6 +50,8 @@ static void backend_destroy(struct wlr_backend *backend) { finish_drm_resources(drm); finish_drm_renderer(&drm->renderer); + + free(drm->name); wlr_session_close_file(drm->session, drm->dev); wl_event_source_remove(drm->drm_event); free(drm); @@ -108,9 +110,7 @@ static void drm_invalidated(struct wl_listener *listener, void *data) { struct wlr_drm_backend *drm = wl_container_of(listener, drm, drm_invalidated); - char *name = drmGetDeviceNameFromFd2(drm->fd); - wlr_log(WLR_DEBUG, "%s invalidated", name); - free(name); + wlr_log(WLR_DEBUG, "%s invalidated", drm->name); scan_drm_connectors(drm); } @@ -137,7 +137,6 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, char *name = drmGetDeviceNameFromFd2(dev->fd); drmVersion *version = drmGetVersion(dev->fd); wlr_log(WLR_INFO, "Initializing DRM backend for %s (%s)", name, version->name); - free(name); drmFreeVersion(version); struct wlr_drm_backend *drm = calloc(1, sizeof(struct wlr_drm_backend)); @@ -152,6 +151,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, drm->dev = dev; drm->fd = dev->fd; + drm->name = name; if (parent != NULL) { drm->parent = get_drm_backend_from_backend(parent); } diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index e8b1198f..ea3cdbd4 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -75,6 +75,7 @@ struct wlr_drm_backend { bool addfb2_modifiers; int fd; + char *name; struct wlr_device *dev; size_t num_crtcs;