^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright IBM Corp. 2004 All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Tape class device support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Stefan Bader <shbader@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Based on simple class device code by Greg K-H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef __TAPE_CLASS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define __TAPE_CLASS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/major.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/cdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/kdev_t.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define TAPECLASS_NAME_LEN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct tape_class_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct cdev *char_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct device *class_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) char device_name[TAPECLASS_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) char mode_name[TAPECLASS_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * Register a tape device and return a pointer to the tape class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * created by the call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * The pointer to the struct device of the physical (base) device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * The intended major/minor number. The major number may be 0 to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * get a dynamic major number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * fops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * The pointer to the drivers file operations for the tape device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * device_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * Pointer to the logical device name (will also be used as kobject name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * of the cdev). This can also be called the name of the tape class
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * mode_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * Points to the name of the tape mode. This creates a link with that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * name from the physical device to the logical device (class).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct tape_class_device *register_tape_dev(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct device * device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) dev_t dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) const struct file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) char * device_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) char * node_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void unregister_tape_dev(struct device *device, struct tape_class_device *tcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #endif /* __TAPE_CLASS_H__ */