#include <linux/auxiliary_bus.h>
#include <linux/debugfs.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <sound/sof/header.h>
#include "sof-client.h"
#define SOF_IPC_CLIENT_SUSPEND_DELAY_MS …
struct sof_msg_inject_priv { … };
static int sof_msg_inject_dfs_open(struct inode *inode, struct file *file)
{ … }
static ssize_t sof_kernel_msg_inject_dfs_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
struct sof_client_dev *cdev = file->private_data;
struct sof_msg_inject_priv *priv = cdev->data;
struct sof_ipc_cmd_hdr *hdr = priv->kernel_buffer;
struct device *dev = &cdev->auxdev.dev;
ssize_t size;
int ret;
if (*ppos)
return 0;
size = simple_write_to_buffer(priv->kernel_buffer, priv->max_msg_size,
ppos, buffer, count);
if (size < 0)
return size;
if (size != count)
return -EFAULT;
ret = pm_runtime_resume_and_get(dev);
if (ret < 0 && ret != -EACCES) {
dev_err_ratelimited(dev, "debugfs write failed to resume %d\n", ret);
return ret;
}
sof_client_ipc_rx_message(cdev, hdr, priv->kernel_buffer);
pm_runtime_mark_last_busy(dev);
ret = pm_runtime_put_autosuspend(dev);
if (ret < 0)
dev_err_ratelimited(dev, "debugfs write failed to idle %d\n", ret);
return count;
};
static int sof_msg_inject_dfs_release(struct inode *inode, struct file *file)
{ … }
static const struct file_operations sof_kernel_msg_inject_fops = …;
static int sof_msg_inject_probe(struct auxiliary_device *auxdev,
const struct auxiliary_device_id *id)
{ … }
static void sof_msg_inject_remove(struct auxiliary_device *auxdev)
{ … }
static const struct auxiliary_device_id sof_msg_inject_client_id_table[] = …;
MODULE_DEVICE_TABLE(auxiliary, sof_msg_inject_client_id_table);
static struct auxiliary_driver sof_msg_inject_client_drv = …;
module_auxiliary_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_IMPORT_NS(…);