linux/samples/kfifo/inttype-example.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Sample kfifo int type implementation
 *
 * Copyright (C) 2010 Stefani Seibold <[email protected]>
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/mutex.h>
#include <linux/kfifo.h>

/*
 * This module shows how to create a int type fifo.
 */

/* fifo size in elements (ints) */
#define FIFO_SIZE

/* name of the proc entry */
#define PROC_FIFO

/* lock for procfs read access */
static DEFINE_MUTEX(read_access);

/* lock for procfs write access */
static DEFINE_MUTEX(write_access);

/*
 * define DYNAMIC in this example for a dynamically allocated fifo.
 *
 * Otherwise the fifo storage will be a part of the fifo structure.
 */
#if 0
#define DYNAMIC
#endif

#ifdef DYNAMIC
static DECLARE_KFIFO_PTR(test, int);
#else
static DEFINE_KFIFO(test, } ;
#endif

static const int expected_result[FIFO_SIZE] =;

static int __init testfunc(void)
{}

static ssize_t fifo_write(struct file *file, const char __user *buf,
						size_t count, loff_t *ppos)
{}

static ssize_t fifo_read(struct file *file, char __user *buf,
						size_t count, loff_t *ppos)
{}

static const struct proc_ops fifo_proc_ops =;

static int __init example_init(void)
{}

static void __exit example_exit(void)
{}

module_init(example_init);
module_exit(example_exit);
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();