Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update printk.c #96

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,46 @@ static void wake_up_klogd_work_func(struct irq_work *irq_work)
if (pending & PRINTK_PENDING_WAKEUP)
wake_up_interruptible(&log_wait);
}

int type_printk(int type, const char *fmt, ...)
{
unsigned long flags;
va_list args;
char *buf;
const char *all_fmt;
int r;
ocal_irq_save(flags);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ocal_irq_save(flags); --> should be "local_irq_save(flags);"?
Is it a spelling wrong?

buf = __get_cpu_var(printk_sched_buf);
switch(type){
case 0:
/* normal type , we will print an output like the one that printk print */
va_start(args, fmt);
r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
break;
case 1:
/* error type , we we will print the fmt and adding [error] */
sprintf(all_fmt, "[Error] : %s", fmt);
va_start(args, all_fmt)
r = vsnprintf(buf, PRINTK_BUF_SIZE, all_fmt, args);
break;
case 2:
/* Action type , we we will print the fmt and adding [action] */
sprintf(all_fmt, "[Action] : %s", fmt);
va_start(args, all_fmt)
r = vsnprintf(buf, PRINTK_BUF_SIZE, all_fmt, args);
break;
default:
/* no type , printing normaly */
va_start(args, fmt);
r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
break;
}
va_end(args);
__this_cpu_or(printk_pending, PRINTK_PENDING_SCHED);
irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
local_irq_restore(flags);
return r;
}
EXPORT_SYMBOL(type_printk);
static DEFINE_PER_CPU(struct irq_work, wake_up_klogd_work) = {
.func = wake_up_klogd_work_func,
.flags = IRQ_WORK_LAZY,
Expand Down