diff --git a/drivers/staging/hilog/hilog.c b/drivers/staging/hilog/hilog.c index 167d4e3f359f742676b5dd713d8fbea90641f5dc..2c0f843a1867aa19dea52e5227e5fab71474024b 100644 --- a/drivers/staging/hilog/hilog.c +++ b/drivers/staging/hilog/hilog.c @@ -44,7 +44,7 @@ module_param(hilog_major, int, 0444); struct cdev g_hilog_cdev; -#define HILOG_BUFFER CONFIG_HILOG_BUFFER_SIZE +#define HILOG_BUFFER ((size_t)CONFIG_HILOG_BUFFER_SIZE) #define HILOG_DRIVER "/dev/hilog" struct hilog_entry { @@ -161,7 +161,7 @@ static ssize_t hilog_read(struct file *file, if (count < header.len + sizeof(header)) { pr_err("buffer too small,buf_len=%d, header.len=%d,%d\n", - count, header.len, header.header_size); + (int)count, header.len, header.header_size); retval = -ENOMEM; goto out; } @@ -260,7 +260,7 @@ static void hilog_head_init(struct hilog_entry *header, size_t len) header->len = len; header->pid = current->pid; - header->task_id = current->pid; + header->task_id = current->tgid; header->header_size = sizeof(struct hilog_entry); } @@ -269,7 +269,9 @@ static void hilog_cover_old_log(size_t buf_len) int retval; struct hilog_entry header; size_t total_size = buf_len + sizeof(struct hilog_entry); - int drop_log_lines = 0; + static int drop_log_lines; + static int is_last_time_full; + int is_this_time_full = 0; while (total_size + hilog_dev.size >= HILOG_BUFFER) { retval = hilog_read_ring_head_buffer((unsigned char *)&header, @@ -278,11 +280,18 @@ static void hilog_cover_old_log(size_t buf_len) break; drop_log_lines++; + is_this_time_full = 1; + is_last_time_full = 1; hilog_buffer_dec(sizeof(header) + header.len); } - if (drop_log_lines > 0) - pr_info("hilog ringbuffer full, drop %d line(s) log", - drop_log_lines); + if (is_last_time_full == 1 && is_this_time_full == 0) { + /* so we can only print one log if hilog ring buffer is full in a short time */ + if (drop_log_lines > 0) + pr_info("hilog ringbuffer full, drop %d line(s) log\n", + drop_log_lines); + is_last_time_full = 0; + drop_log_lines = 0; + } } int hilog_write_internal(const char __user *buffer, size_t buf_len)