Skip to content

Commit

Permalink
Added ability to set conversion time properties of INA231
Browse files Browse the repository at this point in the history
  • Loading branch information
alxhoff committed Apr 9, 2020
1 parent b967ab6 commit 680fde1
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 30 deletions.
58 changes: 33 additions & 25 deletions drivers/cpufreq/sys_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,40 @@ static struct file_operations syslog_EGL_fops = {
#endif
};

bool dev_loaded = false;
static struct miscdevice misc_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = EGL_SYSLOGGER_NAME,
.fops = &syslog_EGL_fops,
.mode = 0666,
};

static int IOctlInit(void)
{
int ret;

if(dev_loaded == false){
ret = misc_register(&misc_dev);
if (ret)
printk("Unable to register EGL IOctl misc dev\n");
dev_loaded = true;
printk("Misc dev registered\n");
}

return 0;
}

static void IOctlExit(void)
{
if(dev_loaded){
misc_deregister(&misc_dev);
dev_loaded = false;
}

printk("EGL IOctl| deinit done\n");

}

static int param_set_enabled(const char *val, const struct kernel_param *kp)
{
bool old = enabled;
Expand All @@ -158,32 +185,16 @@ static int param_set_enabled(const char *val, const struct kernel_param *kp)

if (enabled) {
printk("Enabling sys_logger.\n");
IOctlInit();
hrtimer_start(&timer, ktime_set(0, interval * 1000000UL),
HRTIMER_MODE_REL_PINNED);
} else
} else{
IOctlExit();
printk("Disabling sys_logger.\n");
}
return ret;
}

static int IOctlInit(void)
{
int ret;

ret = misc_register(&misc_dev);
if (ret)
printk("Unable to register EGL IOctl misc dev\n");
printk("Misc dev registered\n");

printk("EGL IOctl| init done\n");

return 0;
}

static void IOctlExit(void)
{
misc_deregister(&misc_dev);
}

static void __log_cpu_info(void)
{
u64 system, user, idle;
Expand Down Expand Up @@ -484,8 +495,6 @@ static long syslog_EGL_ioctl(struct file *f, unsigned int cmd,
{
static struct EGLLogFrame lf;

printk("In EGL IOctl");

switch (cmd) {
case IOCTL_EGL_LOG_FRAME:
if (copy_from_user(&lf, (struct EGLLogFrame *)arg,
Expand Down Expand Up @@ -539,13 +548,13 @@ static int __init init(void)
hrtimer_start(&timer, ktime_set(0, interval * 1000000UL),
HRTIMER_MODE_REL_PINNED);

IOctlInit();

printk(KERN_NOTICE "Syslogger loaded onto cpu %u with interval of %u ms\n", cpu, interval);
return 0;
}

static void __exit cleanup(void)
{
IOctlExit();
hrtimer_cancel(&timer);
kthread_stop(logging_thread);

Expand All @@ -564,7 +573,6 @@ static void __exit cleanup(void)
printk("Average runtime: %lld ns\n", sum_time);
printk("Max runtime: %lld ns\n", max_time);

IOctlExit();
}

module_init(init);
Expand Down
4 changes: 2 additions & 2 deletions drivers/hardkernel/ina231-i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// extern function define
//[*]--------------------------------------------------------------------------------------------------[*]
extern void ina231_i2c_enable (struct ina231_sensor *sensor);
extern int ina231_i2c_read (struct i2c_client *client, unsigned char *cmd, unsigned int cmd_len, unsigned char *data, unsigned int len);
extern int ina231_i2c_write (struct i2c_client *client, unsigned char *cmd, unsigned int cmd_len, unsigned char *data, unsigned int len);
extern int ina231_i2c_read (struct i2c_client *client, unsigned char cmd);
extern int ina231_i2c_write (struct i2c_client *client, unsigned char cmd, unsigned short data);

//[*]--------------------------------------------------------------------------------------------------[*]
#endif /* _INA231_I2C_H_ */
Expand Down
Loading

0 comments on commit 680fde1

Please sign in to comment.