ret = simple_read_from_buffer(userbuf, count, ppos, touser, MBOX_HEXDUMP_MAX_LEN);
#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/mailbox_client.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/uaccess.h>
#include <linux/sched/signal.h>
#define MBOX_MAX_SIG_LEN 8
#define MBOX_MAX_MSG_LEN 128
#define MBOX_BYTES_PER_LINE 16
#define MBOX_HEXDUMP_LINE_LEN ((MBOX_BYTES_PER_LINE * 4) + 2)
#define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \
(MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE))
static bool mbox_data_ready;
struct mbox_test_device {
struct mbox_chan *tx_channel;
struct mbox_chan *rx_channel;
struct fasync_struct *async_queue;
struct dentry *root_debugfs_dir;
static ssize_t mbox_test_signal_write(struct file *filp,
const char __user *userbuf,
size_t count, loff_t *ppos)
struct mbox_test_device *tdev = filp->private_data;
dev_err(tdev->dev, "Channel cannot do Tx\n");
if (count > MBOX_MAX_SIG_LEN) {
"Signal length %zd greater than max allowed %d\n",
count, MBOX_MAX_SIG_LEN);
tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
if (copy_from_user(tdev->signal, userbuf, count)) {
static const struct file_operations mbox_test_signal_ops = {
.write = mbox_test_signal_write,
.llseek = generic_file_llseek,
static int mbox_test_message_fasync(int fd, struct file *filp, int on)
struct mbox_test_device *tdev = filp->private_data;