123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- #ifndef __WINDFARM_H__
- #define __WINDFARM_H__
- #include <linux/kref.h>
- #include <linux/list.h>
- #include <linux/module.h>
- #include <linux/notifier.h>
- #include <linux/device.h>
- #define FIX32TOPRINT(f) (((s32)(f)) >> 16),(((((s32)(f)) & 0xffff) * 1000) >> 16)
- struct wf_control;
- struct wf_control_ops {
- int (*set_value)(struct wf_control *ct, s32 val);
- int (*get_value)(struct wf_control *ct, s32 *val);
- s32 (*get_min)(struct wf_control *ct);
- s32 (*get_max)(struct wf_control *ct);
- void (*release)(struct wf_control *ct);
- struct module *owner;
- };
- struct wf_control {
- struct list_head link;
- const struct wf_control_ops *ops;
- const char *name;
- int type;
- struct kref ref;
- struct device_attribute attr;
- void *priv;
- };
- #define WF_CONTROL_TYPE_GENERIC 0
- #define WF_CONTROL_RPM_FAN 1
- #define WF_CONTROL_PWM_FAN 2
- extern int wf_register_control(struct wf_control *ct);
- extern void wf_unregister_control(struct wf_control *ct);
- extern struct wf_control * wf_find_control(const char *name);
- extern int wf_get_control(struct wf_control *ct);
- extern void wf_put_control(struct wf_control *ct);
- static inline int wf_control_set_max(struct wf_control *ct)
- {
- s32 vmax = ct->ops->get_max(ct);
- return ct->ops->set_value(ct, vmax);
- }
- static inline int wf_control_set_min(struct wf_control *ct)
- {
- s32 vmin = ct->ops->get_min(ct);
- return ct->ops->set_value(ct, vmin);
- }
- static inline int wf_control_set(struct wf_control *ct, s32 val)
- {
- return ct->ops->set_value(ct, val);
- }
- static inline int wf_control_get(struct wf_control *ct, s32 *val)
- {
- return ct->ops->get_value(ct, val);
- }
- static inline s32 wf_control_get_min(struct wf_control *ct)
- {
- return ct->ops->get_min(ct);
- }
- static inline s32 wf_control_get_max(struct wf_control *ct)
- {
- return ct->ops->get_max(ct);
- }
- struct wf_sensor;
- struct wf_sensor_ops {
- int (*get_value)(struct wf_sensor *sr, s32 *val);
- void (*release)(struct wf_sensor *sr);
- struct module *owner;
- };
- struct wf_sensor {
- struct list_head link;
- const struct wf_sensor_ops *ops;
- const char *name;
- struct kref ref;
- struct device_attribute attr;
- void *priv;
- };
- extern int wf_register_sensor(struct wf_sensor *sr);
- extern void wf_unregister_sensor(struct wf_sensor *sr);
- extern struct wf_sensor * wf_find_sensor(const char *name);
- extern int wf_get_sensor(struct wf_sensor *sr);
- extern void wf_put_sensor(struct wf_sensor *sr);
- static inline int wf_sensor_get(struct wf_sensor *sr, s32 *val)
- {
- return sr->ops->get_value(sr, val);
- }
- extern int wf_register_client(struct notifier_block *nb);
- extern int wf_unregister_client(struct notifier_block *nb);
- extern void wf_set_overtemp(void);
- extern void wf_clear_overtemp(void);
- extern int wf_is_overtemp(void);
- #define WF_EVENT_NEW_CONTROL 0
- #define WF_EVENT_NEW_SENSOR 1
- #define WF_EVENT_OVERTEMP 2
- #define WF_EVENT_NORMALTEMP 3
- #define WF_EVENT_TICK 4
- #endif
|