-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathasp_mycdev.h
57 lines (44 loc) · 1.41 KB
/
asp_mycdev.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* @Author: Izhar Shaikh <izhar>
* @Date: 2017-03-20T19:24:05-04:00
* @Email: izharits@gmail.com
* @Filename: asp_mycdev.h
* @Last modified by: izhar
* @Last modified time: 2017-03-22T01:27:58-04:00
* @License: MIT
*/
#ifndef __ASP_MYCDEV__
#define __ASP_MYCDEV__
#include <linux/mutex.h>
#include <linux/device.h>
/* Defaul size of each device - keep it multiple of PAGE_SIZE */
#define DEFAULT_RAMDISK_SIZE 2*PAGE_SIZE
/* Dynamic Major by default */
#define DEFAULT_MAJOR 0
#define DEFAULT_MINOR 0
/* Max number of devices by default */
/* mycdev0 to mycdev3 */
#define DEFAULT_NUM_DEVICES 3
/* Module name */
#define MODULE_NAME "asp_mycdev"
#define MODULE_CLASS_NAME "asp_mycdev_class"
#define MODULE_NODE_NAME "mycdev"
#define MAX_NODE_NAME_SIZE 10
/* Device struct */
struct asp_mycdev
{
int devID; /* device ID */
char *ramdisk; /* device */
size_t ramdiskSize; /* device size */
struct mutex lock; /* mutex for this device */
struct cdev cdev; /* char device struct */
struct device *device; /* device node in sysfs */
bool devReset; /* flag to indicate that the device is reset */
};
/* IOCTLs */
#define ASP_MYCDEV_MAGIC 0x37
/* clear the ramdisk and sets the file position at the beginning */
#define ASP_CLEAR_BUF _IO(ASP_MYCDEV_MAGIC, 0)
/* Maximum number of IOCTL defs implemented in this driver */
#define ASP_IOCTL_MAXNR 0
#endif /* __ASP_MYCDEV__ */