1
2
3
4
5
6
7#ifndef __FIELDBUS_DEV_H
8#define __FIELDBUS_DEV_H
9
10#include <linux/cdev.h>
11#include <linux/wait.h>
12
13enum fieldbus_dev_type {
14 FIELDBUS_DEV_TYPE_UNKNOWN = 0,
15 FIELDBUS_DEV_TYPE_PROFINET,
16};
17
18enum fieldbus_dev_offl_mode {
19 FIELDBUS_DEV_OFFL_MODE_CLEAR = 0,
20 FIELDBUS_DEV_OFFL_MODE_FREEZE,
21 FIELDBUS_DEV_OFFL_MODE_SET
22};
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46struct fieldbus_dev {
47 ssize_t (*read_area)(struct fieldbus_dev *fbdev, char __user *buf,
48 size_t size, loff_t *offset);
49 ssize_t (*write_area)(struct fieldbus_dev *fbdev,
50 const char __user *buf, size_t size,
51 loff_t *offset);
52 size_t write_area_sz, read_area_sz;
53 const char *card_name;
54 enum fieldbus_dev_type fieldbus_type;
55 bool (*enable_get)(struct fieldbus_dev *fbdev);
56 int (*fieldbus_id_get)(struct fieldbus_dev *fbdev, char *buf,
57 size_t max_size);
58 int (*simple_enable_set)(struct fieldbus_dev *fbdev, bool enable);
59 struct device *parent;
60
61
62 int id;
63 struct cdev cdev;
64 struct device *dev;
65 int dc_event;
66 wait_queue_head_t dc_wq;
67 bool online;
68};
69
70#if IS_ENABLED(CONFIG_FIELDBUS_DEV)
71
72
73
74
75
76
77void fieldbus_dev_unregister(struct fieldbus_dev *fb);
78
79
80
81
82
83
84int __must_check fieldbus_dev_register(struct fieldbus_dev *fb);
85
86
87
88
89
90
91
92void fieldbus_dev_area_updated(struct fieldbus_dev *fb);
93
94
95
96
97
98
99void fieldbus_dev_online_changed(struct fieldbus_dev *fb, bool online);
100
101#else
102
103static inline void fieldbus_dev_unregister(struct fieldbus_dev *fb) {}
104static inline int __must_check fieldbus_dev_register(struct fieldbus_dev *fb)
105{
106 return -ENOTSUPP;
107}
108
109static inline void fieldbus_dev_area_updated(struct fieldbus_dev *fb) {}
110static inline void fieldbus_dev_online_changed(struct fieldbus_dev *fb,
111 bool online) {}
112
113#endif
114#endif
115