Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexey Dobriyan and committed by
Mike Frysinger
934fe05b 6362ec27

+26 -17
+26 -17
arch/blackfin/mm/sram-alloc.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/poll.h> 17 17 #include <linux/proc_fs.h> 18 + #include <linux/seq_file.h> 18 19 #include <linux/spinlock.h> 19 20 #include <linux/rtc.h> 20 21 #include <linux/slab.h> ··· 765 764 /* Need to keep line of output the same. Currently, that is 44 bytes 766 765 * (including newline). 767 766 */ 768 - static int _sram_proc_read(char *buf, int *len, int count, const char *desc, 767 + static int _sram_proc_show(struct seq_file *m, const char *desc, 769 768 struct sram_piece *pfree_head, 770 769 struct sram_piece *pused_head) 771 770 { ··· 774 773 if (!pfree_head || !pused_head) 775 774 return -1; 776 775 777 - *len += sprintf(&buf[*len], "--- SRAM %-14s Size PID State \n", desc); 776 + seq_printf(m, "--- SRAM %-14s Size PID State \n", desc); 778 777 779 778 /* search the relevant memory slot */ 780 779 pslot = pused_head->next; 781 780 782 781 while (pslot != NULL) { 783 - *len += sprintf(&buf[*len], "%p-%p %10i %5i %-10s\n", 782 + seq_printf(m, "%p-%p %10i %5i %-10s\n", 784 783 pslot->paddr, pslot->paddr + pslot->size, 785 784 pslot->size, pslot->pid, "ALLOCATED"); 786 785 ··· 790 789 pslot = pfree_head->next; 791 790 792 791 while (pslot != NULL) { 793 - *len += sprintf(&buf[*len], "%p-%p %10i %5i %-10s\n", 792 + seq_printf(m, "%p-%p %10i %5i %-10s\n", 794 793 pslot->paddr, pslot->paddr + pslot->size, 795 794 pslot->size, pslot->pid, "FREE"); 796 795 ··· 799 798 800 799 return 0; 801 800 } 802 - static int sram_proc_read(char *buf, char **start, off_t offset, int count, 803 - int *eof, void *data) 801 + static int sram_proc_show(struct seq_file *m, void *v) 804 802 { 805 - int len = 0; 806 803 unsigned int cpu; 807 804 808 805 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { 809 - if (_sram_proc_read(buf, &len, count, "Scratchpad", 806 + if (_sram_proc_show(m, "Scratchpad", 810 807 &per_cpu(free_l1_ssram_head, cpu), &per_cpu(used_l1_ssram_head, cpu))) 811 808 goto not_done; 812 809 #if L1_DATA_A_LENGTH != 0 813 - if (_sram_proc_read(buf, &len, count, "L1 Data A", 810 + if (_sram_proc_show(m, "L1 Data A", 814 811 &per_cpu(free_l1_data_A_sram_head, cpu), 815 812 &per_cpu(used_l1_data_A_sram_head, cpu))) 816 813 goto not_done; 817 814 #endif 818 815 #if L1_DATA_B_LENGTH != 0 819 - if (_sram_proc_read(buf, &len, count, "L1 Data B", 816 + if (_sram_proc_show(m, "L1 Data B", 820 817 &per_cpu(free_l1_data_B_sram_head, cpu), 821 818 &per_cpu(used_l1_data_B_sram_head, cpu))) 822 819 goto not_done; 823 820 #endif 824 821 #if L1_CODE_LENGTH != 0 825 - if (_sram_proc_read(buf, &len, count, "L1 Instruction", 822 + if (_sram_proc_show(m, "L1 Instruction", 826 823 &per_cpu(free_l1_inst_sram_head, cpu), 827 824 &per_cpu(used_l1_inst_sram_head, cpu))) 828 825 goto not_done; 829 826 #endif 830 827 } 831 828 #if L2_LENGTH != 0 832 - if (_sram_proc_read(buf, &len, count, "L2", &free_l2_sram_head, 833 - &used_l2_sram_head)) 829 + if (_sram_proc_show(m, "L2", &free_l2_sram_head, &used_l2_sram_head)) 834 830 goto not_done; 835 831 #endif 836 - *eof = 1; 837 832 not_done: 838 - return len; 833 + return 0; 839 834 } 835 + 836 + static int sram_proc_open(struct inode *inode, struct file *file) 837 + { 838 + return single_open(file, sram_proc_show, NULL); 839 + } 840 + 841 + static const struct file_operations sram_proc_ops = { 842 + .open = sram_proc_open, 843 + .read = seq_read, 844 + .llseek = seq_lseek, 845 + .release = single_release, 846 + }; 840 847 841 848 static int __init sram_proc_init(void) 842 849 { 843 850 struct proc_dir_entry *ptr; 844 - ptr = create_proc_entry("sram", S_IFREG | S_IRUGO, NULL); 851 + 852 + ptr = proc_create("sram", S_IRUGO, NULL, &sram_proc_ops); 845 853 if (!ptr) { 846 854 printk(KERN_WARNING "unable to create /proc/sram\n"); 847 855 return -1; 848 856 } 849 - ptr->read_proc = sram_proc_read; 850 857 return 0; 851 858 } 852 859 late_initcall(sram_proc_init);