18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright IBM Corp. 2004   All Rights Reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Tape class device support
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author: Stefan Bader <shbader@de.ibm.com>
88c2ecf20Sopenharmony_ci * Based on simple class device code by Greg K-H
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci#ifndef __TAPE_CLASS_H__
118c2ecf20Sopenharmony_ci#define __TAPE_CLASS_H__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/init.h>
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/fs.h>
168c2ecf20Sopenharmony_ci#include <linux/major.h>
178c2ecf20Sopenharmony_ci#include <linux/cdev.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <linux/device.h>
208c2ecf20Sopenharmony_ci#include <linux/kdev_t.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define TAPECLASS_NAME_LEN	32
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct tape_class_device {
258c2ecf20Sopenharmony_ci	struct cdev		*char_device;
268c2ecf20Sopenharmony_ci	struct device		*class_device;
278c2ecf20Sopenharmony_ci	char			device_name[TAPECLASS_NAME_LEN];
288c2ecf20Sopenharmony_ci	char			mode_name[TAPECLASS_NAME_LEN];
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/*
328c2ecf20Sopenharmony_ci * Register a tape device and return a pointer to the tape class device
338c2ecf20Sopenharmony_ci * created by the call.
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * device
368c2ecf20Sopenharmony_ci *	The pointer to the struct device of the physical (base) device.
378c2ecf20Sopenharmony_ci * dev
388c2ecf20Sopenharmony_ci *	The intended major/minor number. The major number may be 0 to
398c2ecf20Sopenharmony_ci *	get a dynamic major number.
408c2ecf20Sopenharmony_ci * fops
418c2ecf20Sopenharmony_ci *	The pointer to the drivers file operations for the tape device.
428c2ecf20Sopenharmony_ci * device_name
438c2ecf20Sopenharmony_ci *	Pointer to the logical device name (will also be used as kobject name
448c2ecf20Sopenharmony_ci *	of the cdev). This can also be called the name of the tape class
458c2ecf20Sopenharmony_ci *	device.
468c2ecf20Sopenharmony_ci * mode_name
478c2ecf20Sopenharmony_ci *	Points to the name of the tape mode. This creates a link with that
488c2ecf20Sopenharmony_ci *	name from the physical device to the logical device (class).
498c2ecf20Sopenharmony_ci */
508c2ecf20Sopenharmony_cistruct tape_class_device *register_tape_dev(
518c2ecf20Sopenharmony_ci	struct device *		device,
528c2ecf20Sopenharmony_ci	dev_t			dev,
538c2ecf20Sopenharmony_ci	const struct file_operations *fops,
548c2ecf20Sopenharmony_ci	char *			device_name,
558c2ecf20Sopenharmony_ci	char *			node_name
568c2ecf20Sopenharmony_ci);
578c2ecf20Sopenharmony_civoid unregister_tape_dev(struct device *device, struct tape_class_device *tcd);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#endif /* __TAPE_CLASS_H__ */
60