brintos

brintos / linux-shallow public Read only

0
0
Text · 1.1 KiB · f0a13c1 Raw
49 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2/* Copyright(c) 2023 Intel Corporation */3#include <linux/debugfs.h>4#include <linux/fs.h>5#include <linux/kernel.h>6 7#include "adf_accel_devices.h"8#include "adf_pm_dbgfs.h"9 10static ssize_t pm_status_read(struct file *f, char __user *buf, size_t count,11			      loff_t *pos)12{13	struct adf_accel_dev *accel_dev = file_inode(f)->i_private;14	struct adf_pm pm = accel_dev->power_management;15 16	if (pm.print_pm_status)17		return pm.print_pm_status(accel_dev, buf, count, pos);18 19	return count;20}21 22static const struct file_operations pm_status_fops = {23	.owner = THIS_MODULE,24	.read = pm_status_read,25};26 27void adf_pm_dbgfs_add(struct adf_accel_dev *accel_dev)28{29	struct adf_pm *pm = &accel_dev->power_management;30 31	if (!pm->present || !pm->print_pm_status)32		return;33 34	pm->debugfs_pm_status = debugfs_create_file("pm_status", 0400,35						    accel_dev->debugfs_dir,36						    accel_dev, &pm_status_fops);37}38 39void adf_pm_dbgfs_rm(struct adf_accel_dev *accel_dev)40{41	struct adf_pm *pm = &accel_dev->power_management;42 43	if (!pm->present)44		return;45 46	debugfs_remove(pm->debugfs_pm_status);47	pm->debugfs_pm_status = NULL;48}49