aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2011-05-14 12:51:54 -0400
committerMike Frysinger <vapier@gentoo.org>2011-05-25 08:24:13 -0400
commit934fe05bf0c743896b478fe3558a282911cfe621 (patch)
tree640a17d73c1cbb487f54e73e9b17f75ee9a001ff /arch/blackfin
parent6362ec272c0375c0377164532e24bf9defdb8c79 (diff)
Blackfin: convert /proc/sram to seq_file
->read_proc interface is going away, switch to seq_file. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/mm/sram-alloc.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/arch/blackfin/mm/sram-alloc.c b/arch/blackfin/mm/sram-alloc.c
index dfd304a4a3ea..29d98faa1efd 100644
--- a/arch/blackfin/mm/sram-alloc.c
+++ b/arch/blackfin/mm/sram-alloc.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/poll.h> 16#include <linux/poll.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/seq_file.h>
18#include <linux/spinlock.h> 19#include <linux/spinlock.h>
19#include <linux/rtc.h> 20#include <linux/rtc.h>
20#include <linux/slab.h> 21#include <linux/slab.h>
@@ -764,7 +765,7 @@ EXPORT_SYMBOL(sram_alloc_with_lsl);
764/* Need to keep line of output the same. Currently, that is 44 bytes 765/* Need to keep line of output the same. Currently, that is 44 bytes
765 * (including newline). 766 * (including newline).
766 */ 767 */
767static int _sram_proc_read(char *buf, int *len, int count, const char *desc, 768static int _sram_proc_show(struct seq_file *m, const char *desc,
768 struct sram_piece *pfree_head, 769 struct sram_piece *pfree_head,
769 struct sram_piece *pused_head) 770 struct sram_piece *pused_head)
770{ 771{
@@ -773,13 +774,13 @@ static int _sram_proc_read(char *buf, int *len, int count, const char *desc,
773 if (!pfree_head || !pused_head) 774 if (!pfree_head || !pused_head)
774 return -1; 775 return -1;
775 776
776 *len += sprintf(&buf[*len], "--- SRAM %-14s Size PID State \n", desc); 777 seq_printf(m, "--- SRAM %-14s Size PID State \n", desc);
777 778
778 /* search the relevant memory slot */ 779 /* search the relevant memory slot */
779 pslot = pused_head->next; 780 pslot = pused_head->next;
780 781
781 while (pslot != NULL) { 782 while (pslot != NULL) {
782 *len += sprintf(&buf[*len], "%p-%p %10i %5i %-10s\n", 783 seq_printf(m, "%p-%p %10i %5i %-10s\n",
783 pslot->paddr, pslot->paddr + pslot->size, 784 pslot->paddr, pslot->paddr + pslot->size,
784 pslot->size, pslot->pid, "ALLOCATED"); 785 pslot->size, pslot->pid, "ALLOCATED");
785 786
@@ -789,7 +790,7 @@ static int _sram_proc_read(char *buf, int *len, int count, const char *desc,
789 pslot = pfree_head->next; 790 pslot = pfree_head->next;
790 791
791 while (pslot != NULL) { 792 while (pslot != NULL) {
792 *len += sprintf(&buf[*len], "%p-%p %10i %5i %-10s\n", 793 seq_printf(m, "%p-%p %10i %5i %-10s\n",
793 pslot->paddr, pslot->paddr + pslot->size, 794 pslot->paddr, pslot->paddr + pslot->size,
794 pslot->size, pslot->pid, "FREE"); 795 pslot->size, pslot->pid, "FREE");
795 796
@@ -798,54 +799,62 @@ static int _sram_proc_read(char *buf, int *len, int count, const char *desc,
798 799
799 return 0; 800 return 0;
800} 801}
801static int sram_proc_read(char *buf, char **start, off_t offset, int count, 802static int sram_proc_show(struct seq_file *m, void *v)
802 int *eof, void *data)
803{ 803{
804 int len = 0;
805 unsigned int cpu; 804 unsigned int cpu;
806 805
807 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { 806 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) {
808 if (_sram_proc_read(buf, &len, count, "Scratchpad", 807 if (_sram_proc_show(m, "Scratchpad",
809 &per_cpu(free_l1_ssram_head, cpu), &per_cpu(used_l1_ssram_head, cpu))) 808 &per_cpu(free_l1_ssram_head, cpu), &per_cpu(used_l1_ssram_head, cpu)))
810 goto not_done; 809 goto not_done;
811#if L1_DATA_A_LENGTH != 0 810#if L1_DATA_A_LENGTH != 0
812 if (_sram_proc_read(buf, &len, count, "L1 Data A", 811 if (_sram_proc_show(m, "L1 Data A",
813 &per_cpu(free_l1_data_A_sram_head, cpu), 812 &per_cpu(free_l1_data_A_sram_head, cpu),
814 &per_cpu(used_l1_data_A_sram_head, cpu))) 813 &per_cpu(used_l1_data_A_sram_head, cpu)))
815 goto not_done; 814 goto not_done;
816#endif 815#endif
817#if L1_DATA_B_LENGTH != 0 816#if L1_DATA_B_LENGTH != 0
818 if (_sram_proc_read(buf, &len, count, "L1 Data B", 817 if (_sram_proc_show(m, "L1 Data B",
819 &per_cpu(free_l1_data_B_sram_head, cpu), 818 &per_cpu(free_l1_data_B_sram_head, cpu),
820 &per_cpu(used_l1_data_B_sram_head, cpu))) 819 &per_cpu(used_l1_data_B_sram_head, cpu)))
821 goto not_done; 820 goto not_done;
822#endif 821#endif
823#if L1_CODE_LENGTH != 0 822#if L1_CODE_LENGTH != 0
824 if (_sram_proc_read(buf, &len, count, "L1 Instruction", 823 if (_sram_proc_show(m, "L1 Instruction",
825 &per_cpu(free_l1_inst_sram_head, cpu), 824 &per_cpu(free_l1_inst_sram_head, cpu),
826 &per_cpu(used_l1_inst_sram_head, cpu))) 825 &per_cpu(used_l1_inst_sram_head, cpu)))
827 goto not_done; 826 goto not_done;
828#endif 827#endif
829 } 828 }
830#if L2_LENGTH != 0 829#if L2_LENGTH != 0
831 if (_sram_proc_read(buf, &len, count, "L2", &free_l2_sram_head, 830 if (_sram_proc_show(m, "L2", &free_l2_sram_head, &used_l2_sram_head))
832 &used_l2_sram_head))
833 goto not_done; 831 goto not_done;
834#endif 832#endif
835 *eof = 1;
836 not_done: 833 not_done:
837 return len; 834 return 0;
835}
836
837static int sram_proc_open(struct inode *inode, struct file *file)
838{
839 return single_open(file, sram_proc_show, NULL);
838} 840}
839 841
842static const struct file_operations sram_proc_ops = {
843 .open = sram_proc_open,
844 .read = seq_read,
845 .llseek = seq_lseek,
846 .release = single_release,
847};
848
840static int __init sram_proc_init(void) 849static int __init sram_proc_init(void)
841{ 850{
842 struct proc_dir_entry *ptr; 851 struct proc_dir_entry *ptr;
843 ptr = create_proc_entry("sram", S_IFREG | S_IRUGO, NULL); 852
853 ptr = proc_create("sram", S_IRUGO, NULL, &sram_proc_ops);
844 if (!ptr) { 854 if (!ptr) {
845 printk(KERN_WARNING "unable to create /proc/sram\n"); 855 printk(KERN_WARNING "unable to create /proc/sram\n");
846 return -1; 856 return -1;
847 } 857 }
848 ptr->read_proc = sram_proc_read;
849 return 0; 858 return 0;
850} 859}
851late_initcall(sram_proc_init); 860late_initcall(sram_proc_init);