at master 52 lines 1.3 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only OR MIT 2/* Copyright (c) 2023 Imagination Technologies Ltd. */ 3 4#include "pvr_debugfs.h" 5 6#include "pvr_device.h" 7#include "pvr_fw_trace.h" 8#include "pvr_params.h" 9 10#include <linux/dcache.h> 11#include <linux/debugfs.h> 12#include <linux/err.h> 13#include <linux/kernel.h> 14#include <linux/types.h> 15 16#include <drm/drm_device.h> 17#include <drm/drm_file.h> 18#include <drm/drm_print.h> 19 20static const struct pvr_debugfs_entry pvr_debugfs_entries[] = { 21 {"pvr_params", pvr_params_debugfs_init}, 22 {"pvr_fw", pvr_fw_trace_debugfs_init}, 23}; 24 25void 26pvr_debugfs_init(struct drm_minor *minor) 27{ 28 struct drm_device *drm_dev = minor->dev; 29 struct pvr_device *pvr_dev = to_pvr_device(drm_dev); 30 struct dentry *root = minor->debugfs_root; 31 32 for (size_t i = 0; i < ARRAY_SIZE(pvr_debugfs_entries); ++i) { 33 const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i]; 34 struct dentry *dir; 35 36 dir = debugfs_create_dir(entry->name, root); 37 if (IS_ERR(dir)) { 38 drm_warn(drm_dev, 39 "failed to create debugfs dir '%s' (err=%d)", 40 entry->name, (int)PTR_ERR(dir)); 41 continue; 42 } 43 44 entry->init(pvr_dev, dir); 45 } 46} 47 48/* 49 * Since all entries are created under &drm_minor->debugfs_root, there's no 50 * need for a pvr_debugfs_fini() as DRM will clean up everything under its root 51 * automatically. 52 */