summaryrefslogtreecommitdiff
path: root/io-module/mts_supercap.h
blob: bbe5529b04fd9407866daf14ceb699b3851ec7ec (plain)
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
#ifndef IO_MODULE_SUPERCAP_H_
#define IO_MODULE_SUPERCAP_H_

#include <linux/workqueue.h>
#include <linux/pid.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
#include <linux/signalfd.h>
#endif

#include "mts_io.h"
#include "mts_io_module.h"

#define SUPERCAP_CHECKS_PER_SEC  10
#define SUPERCAP_CHECK_INTERVAL  (HZ / SUPERCAP_CHECKS_PER_SEC)
#define SUPERCAP_TOTAL_INTERVALS 50    /* 5s */

typedef struct supercap_info {
    char name[32];
    char label_monitor[32];

    /* PID to notify */
    pid_t pid;

    /* signal to send */
    int signal;

    /* internal fields used in worker*/
    int pwf_count;    /* count of intervals in worker */
    int pin_is_one;   /* count of number of times pin has been set to one */

} supercap_info_t, *supercap_info_pt;

extern void init_supercap_worker(void);
extern void cleanup_supercap_worker(void);

extern ssize_t mts_attr_show_supercap_monitor(struct device *dev,
			       struct device_attribute *attr,
			       char *buf);

extern ssize_t mts_attr_store_supercap_monitor(struct device *dev,
		           struct device_attribute *attr, const char *buf, size_t count);

extern struct device_attribute dev_attr_supercap_monitor;

#endif /* IO_MODULE_SUPERCAP_H_ */