From: 黄涛 Date: Wed, 1 Feb 2012 11:39:04 +0000 (+0800) Subject: rk: move last_log.c from mach-rk29 to plat-rk X-Git-Tag: firefly_0821_release~9595^2~196 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=496093fdc4bd865b8206d161d4221d5afe1e6696;p=firefly-linux-kernel-4.4.55.git rk: move last_log.c from mach-rk29 to plat-rk --- diff --git a/arch/arm/Makefile b/arch/arm/Makefile index e36ba2ebec05..824054012c90 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -208,6 +208,7 @@ plat-$(CONFIG_PLAT_IOP) := iop plat-$(CONFIG_PLAT_NOMADIK) := nomadik plat-$(CONFIG_PLAT_ORION) := orion plat-$(CONFIG_PLAT_PXA) := pxa +plat-$(CONFIG_PLAT_RK) := rk plat-$(CONFIG_PLAT_S3C24XX) := s3c24xx samsung plat-$(CONFIG_PLAT_S5P) := s5p samsung plat-$(CONFIG_PLAT_SPEAR) := spear diff --git a/arch/arm/mach-rk29/Makefile b/arch/arm/mach-rk29/Makefile index 1d5d68c4f809..65898f2e3bcd 100644 --- a/arch/arm/mach-rk29/Makefile +++ b/arch/arm/mach-rk29/Makefile @@ -4,7 +4,6 @@ obj-y += early_printk.o ifndef CONFIG_DEBUG_LL obj-y += ../kernel/debug.o endif -obj-$(CONFIG_RK29_LAST_LOG) += last_log.o obj-$(CONFIG_USB_GADGET) += usb_detect.o obj-$(CONFIG_PM) += pm.o obj-$(CONFIG_CPU_FREQ) += cpufreq.o diff --git a/arch/arm/mach-rk29/last_log.c b/arch/arm/mach-rk29/last_log.c deleted file mode 100644 index 6e6ead70372b..000000000000 --- a/arch/arm/mach-rk29/last_log.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * arch/arm/mach-rk29/last_log.c - * - * Copyright (C) 2011 ROCKCHIP, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include - -#define LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) -static char last_log_buf[LOG_BUF_LEN]; -extern void switch_log_buf(char *new_log_buf, unsigned size); - -static ssize_t last_log_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) -{ - loff_t pos = *offset; - ssize_t count; - - if (pos >= LOG_BUF_LEN) - return 0; - - count = min(len, (size_t)(LOG_BUF_LEN - pos)); - if (copy_to_user(buf, &last_log_buf[pos], count)) - return -EFAULT; - - *offset += count; - return count; -} - -static const struct file_operations last_log_file_ops = { - .owner = THIS_MODULE, - .read = last_log_read, -}; - -static int __init last_log_init(void) -{ - char *log_buf; - struct proc_dir_entry *entry; - - log_buf = (char *)__get_free_pages(GFP_KERNEL, CONFIG_LOG_BUF_SHIFT - PAGE_SHIFT); - if (!log_buf) { - printk(KERN_ERR "last_log: failed to __get_free_pages(%d)\n", CONFIG_LOG_BUF_SHIFT - PAGE_SHIFT); - return 0; - } - printk("last_log: 0x%p 0x%p\n", log_buf, last_log_buf); - - memcpy(last_log_buf, log_buf, LOG_BUF_LEN); - switch_log_buf(log_buf, LOG_BUF_LEN); - - entry = create_proc_entry("last_log", S_IFREG | S_IRUGO, NULL); - if (!entry) { - printk(KERN_ERR "last_log: failed to create proc entry\n"); - return 0; - } - - entry->proc_fops = &last_log_file_ops; - entry->size = LOG_BUF_LEN; - -#ifndef CONFIG_ANDROID_RAM_CONSOLE - proc_symlink("last_kmsg", NULL, "last_log"); -#endif - - return 0; -} - -postcore_initcall(last_log_init); - diff --git a/arch/arm/plat-rk/Makefile b/arch/arm/plat-rk/Makefile new file mode 100644 index 000000000000..fd1f267c0c89 --- /dev/null +++ b/arch/arm/plat-rk/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_RK29_LAST_LOG) += last_log.o diff --git a/arch/arm/plat-rk/last_log.c b/arch/arm/plat-rk/last_log.c new file mode 100644 index 000000000000..6e6ead70372b --- /dev/null +++ b/arch/arm/plat-rk/last_log.c @@ -0,0 +1,76 @@ +/* + * arch/arm/mach-rk29/last_log.c + * + * Copyright (C) 2011 ROCKCHIP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +#define LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) +static char last_log_buf[LOG_BUF_LEN]; +extern void switch_log_buf(char *new_log_buf, unsigned size); + +static ssize_t last_log_read(struct file *file, char __user *buf, + size_t len, loff_t *offset) +{ + loff_t pos = *offset; + ssize_t count; + + if (pos >= LOG_BUF_LEN) + return 0; + + count = min(len, (size_t)(LOG_BUF_LEN - pos)); + if (copy_to_user(buf, &last_log_buf[pos], count)) + return -EFAULT; + + *offset += count; + return count; +} + +static const struct file_operations last_log_file_ops = { + .owner = THIS_MODULE, + .read = last_log_read, +}; + +static int __init last_log_init(void) +{ + char *log_buf; + struct proc_dir_entry *entry; + + log_buf = (char *)__get_free_pages(GFP_KERNEL, CONFIG_LOG_BUF_SHIFT - PAGE_SHIFT); + if (!log_buf) { + printk(KERN_ERR "last_log: failed to __get_free_pages(%d)\n", CONFIG_LOG_BUF_SHIFT - PAGE_SHIFT); + return 0; + } + printk("last_log: 0x%p 0x%p\n", log_buf, last_log_buf); + + memcpy(last_log_buf, log_buf, LOG_BUF_LEN); + switch_log_buf(log_buf, LOG_BUF_LEN); + + entry = create_proc_entry("last_log", S_IFREG | S_IRUGO, NULL); + if (!entry) { + printk(KERN_ERR "last_log: failed to create proc entry\n"); + return 0; + } + + entry->proc_fops = &last_log_file_ops; + entry->size = LOG_BUF_LEN; + +#ifndef CONFIG_ANDROID_RAM_CONSOLE + proc_symlink("last_kmsg", NULL, "last_log"); +#endif + + return 0; +} + +postcore_initcall(last_log_init); +