1 路径:
drivers/staging/android/logger.c
drivers/staging/android/logger.h
2 创建的设备节点(在drivers/staging/android/logger.h定义):
dev/log_events /* system/hardware events */
dev/log_radio /* radio-related messages */
dev/log_main /* everything else */
dev/log_system /* system/framework messages */
3 查看 static int __init logger_init(void)函数:
593 static int __init logger_init(void)
594 {
595 int ret;
596
597 ret = init_log(&log_main);
598 if (unlikely(ret))
599 goto out;
600
601 ret = init_log(&log_events);
602 if (unlikely(ret))
603 goto out;
604
605 ret = init_log(&log_radio);
606 if (unlikely(ret))
607 goto out;
608
609 ret = init_log(&log_system);
610 if (unlikely(ret))
611 goto out;
612
613 out:
614 return ret;
615 }
其中参数“log_main” 是有 DEFINE_LOGGER_DEVICE(log_main, LOGGER_LOG_MAIN, 64*1024)定义的。
同时可参考如下宏声明:
535 /*
536 * Defines a log structure with name 'NAME' and a size of 'SIZE' bytes, which
537 * must be a power of two, greater than LOGGER_ENTRY_MAX_LEN, and less than
538 * LONG_MAX minus LOGGER_ENTRY_MAX_LEN.
539 */
540 #define DEFINE_LOGGER_DEVICE(VAR, NAME, SIZE) \
541 static unsigned char _buf_ ## VAR[SIZE]; \
542 static struct logger_log VAR = { \
543 .buffer = _buf_ ## VAR, \
544 .misc = { \
545 .minor = MISC_DYNAMIC_MINOR, \
546 .name = NAME, \
547 .fops = &logger_fops, \
548 .parent = NULL, \
549 }, \
550 .wq = __WAIT_QUEUE_HEAD_INITIALIZER(VAR .wq), \
551 .readers = LIST_HEAD_INIT(VAR .readers), \
552 .mutex = __MUTEX_INITIALIZER(VAR .mutex), \
553 .w_off = 0, \
554 .head = 0, \
555 .size = SIZE, \
556 };
注意:misc注册的fop结构体。