0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __WINDFARM_H__
0010 #define __WINDFARM_H__
0011
0012 #include <linux/kref.h>
0013 #include <linux/list.h>
0014 #include <linux/module.h>
0015 #include <linux/notifier.h>
0016 #include <linux/device.h>
0017
0018
0019 #define FIX32TOPRINT(f) (((s32)(f)) >> 16),(((((s32)(f)) & 0xffff) * 1000) >> 16)
0020
0021
0022
0023
0024
0025 struct wf_control;
0026
0027 struct wf_control_ops {
0028 int (*set_value)(struct wf_control *ct, s32 val);
0029 int (*get_value)(struct wf_control *ct, s32 *val);
0030 s32 (*get_min)(struct wf_control *ct);
0031 s32 (*get_max)(struct wf_control *ct);
0032 void (*release)(struct wf_control *ct);
0033 struct module *owner;
0034 };
0035
0036 struct wf_control {
0037 struct list_head link;
0038 const struct wf_control_ops *ops;
0039 const char *name;
0040 int type;
0041 struct kref ref;
0042 struct device_attribute attr;
0043 void *priv;
0044 };
0045
0046 #define WF_CONTROL_TYPE_GENERIC 0
0047 #define WF_CONTROL_RPM_FAN 1
0048 #define WF_CONTROL_PWM_FAN 2
0049
0050
0051
0052
0053
0054
0055
0056 extern int wf_register_control(struct wf_control *ct);
0057 extern void wf_unregister_control(struct wf_control *ct);
0058 extern int wf_get_control(struct wf_control *ct);
0059 extern void wf_put_control(struct wf_control *ct);
0060
0061 static inline int wf_control_set_max(struct wf_control *ct)
0062 {
0063 s32 vmax = ct->ops->get_max(ct);
0064 return ct->ops->set_value(ct, vmax);
0065 }
0066
0067 static inline int wf_control_set_min(struct wf_control *ct)
0068 {
0069 s32 vmin = ct->ops->get_min(ct);
0070 return ct->ops->set_value(ct, vmin);
0071 }
0072
0073 static inline int wf_control_set(struct wf_control *ct, s32 val)
0074 {
0075 return ct->ops->set_value(ct, val);
0076 }
0077
0078 static inline int wf_control_get(struct wf_control *ct, s32 *val)
0079 {
0080 return ct->ops->get_value(ct, val);
0081 }
0082
0083 static inline s32 wf_control_get_min(struct wf_control *ct)
0084 {
0085 return ct->ops->get_min(ct);
0086 }
0087
0088 static inline s32 wf_control_get_max(struct wf_control *ct)
0089 {
0090 return ct->ops->get_max(ct);
0091 }
0092
0093
0094
0095
0096
0097 struct wf_sensor;
0098
0099 struct wf_sensor_ops {
0100 int (*get_value)(struct wf_sensor *sr, s32 *val);
0101 void (*release)(struct wf_sensor *sr);
0102 struct module *owner;
0103 };
0104
0105 struct wf_sensor {
0106 struct list_head link;
0107 const struct wf_sensor_ops *ops;
0108 const char *name;
0109 struct kref ref;
0110 struct device_attribute attr;
0111 void *priv;
0112 };
0113
0114
0115 extern int wf_register_sensor(struct wf_sensor *sr);
0116 extern void wf_unregister_sensor(struct wf_sensor *sr);
0117 extern int wf_get_sensor(struct wf_sensor *sr);
0118 extern void wf_put_sensor(struct wf_sensor *sr);
0119
0120 static inline int wf_sensor_get(struct wf_sensor *sr, s32 *val)
0121 {
0122 return sr->ops->get_value(sr, val);
0123 }
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 extern int wf_register_client(struct notifier_block *nb);
0138 extern int wf_unregister_client(struct notifier_block *nb);
0139
0140
0141 extern void wf_set_overtemp(void);
0142 extern void wf_clear_overtemp(void);
0143
0144 #define WF_EVENT_NEW_CONTROL 0
0145 #define WF_EVENT_NEW_SENSOR 1
0146 #define WF_EVENT_OVERTEMP 2
0147 #define WF_EVENT_NORMALTEMP 3
0148 #define WF_EVENT_TICK 4
0149
0150
0151
0152
0153
0154
0155
0156 #endif