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