0001
0002
0003
0004
0005
0006
0007 #ifndef __FIELDBUS_DEV_H
0008 #define __FIELDBUS_DEV_H
0009
0010 #include <linux/cdev.h>
0011 #include <linux/wait.h>
0012
0013 enum fieldbus_dev_type {
0014 FIELDBUS_DEV_TYPE_UNKNOWN = 0,
0015 FIELDBUS_DEV_TYPE_PROFINET,
0016 };
0017
0018 enum fieldbus_dev_offl_mode {
0019 FIELDBUS_DEV_OFFL_MODE_CLEAR = 0,
0020 FIELDBUS_DEV_OFFL_MODE_FREEZE,
0021 FIELDBUS_DEV_OFFL_MODE_SET
0022 };
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 struct fieldbus_dev {
0047 ssize_t (*read_area)(struct fieldbus_dev *fbdev, char __user *buf,
0048 size_t size, loff_t *offset);
0049 ssize_t (*write_area)(struct fieldbus_dev *fbdev,
0050 const char __user *buf, size_t size,
0051 loff_t *offset);
0052 size_t write_area_sz, read_area_sz;
0053 const char *card_name;
0054 enum fieldbus_dev_type fieldbus_type;
0055 bool (*enable_get)(struct fieldbus_dev *fbdev);
0056 int (*fieldbus_id_get)(struct fieldbus_dev *fbdev, char *buf,
0057 size_t max_size);
0058 int (*simple_enable_set)(struct fieldbus_dev *fbdev, bool enable);
0059 struct device *parent;
0060
0061
0062 int id;
0063 struct cdev cdev;
0064 struct device *dev;
0065 int dc_event;
0066 wait_queue_head_t dc_wq;
0067 bool online;
0068 };
0069
0070 #if IS_ENABLED(CONFIG_FIELDBUS_DEV)
0071
0072
0073
0074
0075
0076
0077 void fieldbus_dev_unregister(struct fieldbus_dev *fb);
0078
0079
0080
0081
0082
0083
0084 int __must_check fieldbus_dev_register(struct fieldbus_dev *fb);
0085
0086
0087
0088
0089
0090
0091
0092 void fieldbus_dev_area_updated(struct fieldbus_dev *fb);
0093
0094
0095
0096
0097
0098
0099 void fieldbus_dev_online_changed(struct fieldbus_dev *fb, bool online);
0100
0101 #else
0102
0103 static inline void fieldbus_dev_unregister(struct fieldbus_dev *fb) {}
0104 static inline int __must_check fieldbus_dev_register(struct fieldbus_dev *fb)
0105 {
0106 return -ENOTSUPP;
0107 }
0108
0109 static inline void fieldbus_dev_area_updated(struct fieldbus_dev *fb) {}
0110 static inline void fieldbus_dev_online_changed(struct fieldbus_dev *fb,
0111 bool online) {}
0112
0113 #endif
0114 #endif