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

ipmi: convert to seq_file interface

The ->read_proc interface is going away, convert to seq_file.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc:Corey Minyard <minyard@acm.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
07412736 997c136f

+173 -117
+111 -87
drivers/char/ipmi/ipmi_msghandler.c
··· 36 36 #include <asm/system.h> 37 37 #include <linux/poll.h> 38 38 #include <linux/sched.h> 39 + #include <linux/seq_file.h> 39 40 #include <linux/spinlock.h> 40 41 #include <linux/mutex.h> 41 42 #include <linux/slab.h> ··· 1897 1896 EXPORT_SYMBOL(ipmi_request_supply_msgs); 1898 1897 1899 1898 #ifdef CONFIG_PROC_FS 1900 - static int ipmb_file_read_proc(char *page, char **start, off_t off, 1901 - int count, int *eof, void *data) 1899 + static int smi_ipmb_proc_show(struct seq_file *m, void *v) 1902 1900 { 1903 - char *out = (char *) page; 1904 - ipmi_smi_t intf = data; 1901 + ipmi_smi_t intf = m->private; 1905 1902 int i; 1906 - int rv = 0; 1907 1903 1908 - for (i = 0; i < IPMI_MAX_CHANNELS; i++) 1909 - rv += sprintf(out+rv, "%x ", intf->channels[i].address); 1910 - out[rv-1] = '\n'; /* Replace the final space with a newline */ 1911 - out[rv] = '\0'; 1912 - rv++; 1913 - return rv; 1904 + seq_printf(m, "%x", intf->channels[0].address); 1905 + for (i = 1; i < IPMI_MAX_CHANNELS; i++) 1906 + seq_printf(m, " %x", intf->channels[i].address); 1907 + return seq_putc(m, '\n'); 1914 1908 } 1915 1909 1916 - static int version_file_read_proc(char *page, char **start, off_t off, 1917 - int count, int *eof, void *data) 1910 + static int smi_ipmb_proc_open(struct inode *inode, struct file *file) 1918 1911 { 1919 - char *out = (char *) page; 1920 - ipmi_smi_t intf = data; 1912 + return single_open(file, smi_ipmb_proc_show, PDE(inode)->data); 1913 + } 1921 1914 1922 - return sprintf(out, "%u.%u\n", 1915 + static const struct file_operations smi_ipmb_proc_ops = { 1916 + .open = smi_ipmb_proc_open, 1917 + .read = seq_read, 1918 + .llseek = seq_lseek, 1919 + .release = single_release, 1920 + }; 1921 + 1922 + static int smi_version_proc_show(struct seq_file *m, void *v) 1923 + { 1924 + ipmi_smi_t intf = m->private; 1925 + 1926 + return seq_printf(m, "%u.%u\n", 1923 1927 ipmi_version_major(&intf->bmc->id), 1924 1928 ipmi_version_minor(&intf->bmc->id)); 1925 1929 } 1926 1930 1927 - static int stat_file_read_proc(char *page, char **start, off_t off, 1928 - int count, int *eof, void *data) 1931 + static int smi_version_proc_open(struct inode *inode, struct file *file) 1929 1932 { 1930 - char *out = (char *) page; 1931 - ipmi_smi_t intf = data; 1932 - 1933 - out += sprintf(out, "sent_invalid_commands: %u\n", 1934 - ipmi_get_stat(intf, sent_invalid_commands)); 1935 - out += sprintf(out, "sent_local_commands: %u\n", 1936 - ipmi_get_stat(intf, sent_local_commands)); 1937 - out += sprintf(out, "handled_local_responses: %u\n", 1938 - ipmi_get_stat(intf, handled_local_responses)); 1939 - out += sprintf(out, "unhandled_local_responses: %u\n", 1940 - ipmi_get_stat(intf, unhandled_local_responses)); 1941 - out += sprintf(out, "sent_ipmb_commands: %u\n", 1942 - ipmi_get_stat(intf, sent_ipmb_commands)); 1943 - out += sprintf(out, "sent_ipmb_command_errs: %u\n", 1944 - ipmi_get_stat(intf, sent_ipmb_command_errs)); 1945 - out += sprintf(out, "retransmitted_ipmb_commands: %u\n", 1946 - ipmi_get_stat(intf, retransmitted_ipmb_commands)); 1947 - out += sprintf(out, "timed_out_ipmb_commands: %u\n", 1948 - ipmi_get_stat(intf, timed_out_ipmb_commands)); 1949 - out += sprintf(out, "timed_out_ipmb_broadcasts: %u\n", 1950 - ipmi_get_stat(intf, timed_out_ipmb_broadcasts)); 1951 - out += sprintf(out, "sent_ipmb_responses: %u\n", 1952 - ipmi_get_stat(intf, sent_ipmb_responses)); 1953 - out += sprintf(out, "handled_ipmb_responses: %u\n", 1954 - ipmi_get_stat(intf, handled_ipmb_responses)); 1955 - out += sprintf(out, "invalid_ipmb_responses: %u\n", 1956 - ipmi_get_stat(intf, invalid_ipmb_responses)); 1957 - out += sprintf(out, "unhandled_ipmb_responses: %u\n", 1958 - ipmi_get_stat(intf, unhandled_ipmb_responses)); 1959 - out += sprintf(out, "sent_lan_commands: %u\n", 1960 - ipmi_get_stat(intf, sent_lan_commands)); 1961 - out += sprintf(out, "sent_lan_command_errs: %u\n", 1962 - ipmi_get_stat(intf, sent_lan_command_errs)); 1963 - out += sprintf(out, "retransmitted_lan_commands: %u\n", 1964 - ipmi_get_stat(intf, retransmitted_lan_commands)); 1965 - out += sprintf(out, "timed_out_lan_commands: %u\n", 1966 - ipmi_get_stat(intf, timed_out_lan_commands)); 1967 - out += sprintf(out, "sent_lan_responses: %u\n", 1968 - ipmi_get_stat(intf, sent_lan_responses)); 1969 - out += sprintf(out, "handled_lan_responses: %u\n", 1970 - ipmi_get_stat(intf, handled_lan_responses)); 1971 - out += sprintf(out, "invalid_lan_responses: %u\n", 1972 - ipmi_get_stat(intf, invalid_lan_responses)); 1973 - out += sprintf(out, "unhandled_lan_responses: %u\n", 1974 - ipmi_get_stat(intf, unhandled_lan_responses)); 1975 - out += sprintf(out, "handled_commands: %u\n", 1976 - ipmi_get_stat(intf, handled_commands)); 1977 - out += sprintf(out, "invalid_commands: %u\n", 1978 - ipmi_get_stat(intf, invalid_commands)); 1979 - out += sprintf(out, "unhandled_commands: %u\n", 1980 - ipmi_get_stat(intf, unhandled_commands)); 1981 - out += sprintf(out, "invalid_events: %u\n", 1982 - ipmi_get_stat(intf, invalid_events)); 1983 - out += sprintf(out, "events: %u\n", 1984 - ipmi_get_stat(intf, events)); 1985 - out += sprintf(out, "failed rexmit LAN msgs: %u\n", 1986 - ipmi_get_stat(intf, dropped_rexmit_lan_commands)); 1987 - out += sprintf(out, "failed rexmit IPMB msgs: %u\n", 1988 - ipmi_get_stat(intf, dropped_rexmit_ipmb_commands)); 1989 - 1990 - return (out - ((char *) page)); 1933 + return single_open(file, smi_version_proc_show, PDE(inode)->data); 1991 1934 } 1935 + 1936 + static const struct file_operations smi_version_proc_ops = { 1937 + .open = smi_version_proc_open, 1938 + .read = seq_read, 1939 + .llseek = seq_lseek, 1940 + .release = single_release, 1941 + }; 1942 + 1943 + static int smi_stats_proc_show(struct seq_file *m, void *v) 1944 + { 1945 + ipmi_smi_t intf = m->private; 1946 + 1947 + seq_printf(m, "sent_invalid_commands: %u\n", 1948 + ipmi_get_stat(intf, sent_invalid_commands)); 1949 + seq_printf(m, "sent_local_commands: %u\n", 1950 + ipmi_get_stat(intf, sent_local_commands)); 1951 + seq_printf(m, "handled_local_responses: %u\n", 1952 + ipmi_get_stat(intf, handled_local_responses)); 1953 + seq_printf(m, "unhandled_local_responses: %u\n", 1954 + ipmi_get_stat(intf, unhandled_local_responses)); 1955 + seq_printf(m, "sent_ipmb_commands: %u\n", 1956 + ipmi_get_stat(intf, sent_ipmb_commands)); 1957 + seq_printf(m, "sent_ipmb_command_errs: %u\n", 1958 + ipmi_get_stat(intf, sent_ipmb_command_errs)); 1959 + seq_printf(m, "retransmitted_ipmb_commands: %u\n", 1960 + ipmi_get_stat(intf, retransmitted_ipmb_commands)); 1961 + seq_printf(m, "timed_out_ipmb_commands: %u\n", 1962 + ipmi_get_stat(intf, timed_out_ipmb_commands)); 1963 + seq_printf(m, "timed_out_ipmb_broadcasts: %u\n", 1964 + ipmi_get_stat(intf, timed_out_ipmb_broadcasts)); 1965 + seq_printf(m, "sent_ipmb_responses: %u\n", 1966 + ipmi_get_stat(intf, sent_ipmb_responses)); 1967 + seq_printf(m, "handled_ipmb_responses: %u\n", 1968 + ipmi_get_stat(intf, handled_ipmb_responses)); 1969 + seq_printf(m, "invalid_ipmb_responses: %u\n", 1970 + ipmi_get_stat(intf, invalid_ipmb_responses)); 1971 + seq_printf(m, "unhandled_ipmb_responses: %u\n", 1972 + ipmi_get_stat(intf, unhandled_ipmb_responses)); 1973 + seq_printf(m, "sent_lan_commands: %u\n", 1974 + ipmi_get_stat(intf, sent_lan_commands)); 1975 + seq_printf(m, "sent_lan_command_errs: %u\n", 1976 + ipmi_get_stat(intf, sent_lan_command_errs)); 1977 + seq_printf(m, "retransmitted_lan_commands: %u\n", 1978 + ipmi_get_stat(intf, retransmitted_lan_commands)); 1979 + seq_printf(m, "timed_out_lan_commands: %u\n", 1980 + ipmi_get_stat(intf, timed_out_lan_commands)); 1981 + seq_printf(m, "sent_lan_responses: %u\n", 1982 + ipmi_get_stat(intf, sent_lan_responses)); 1983 + seq_printf(m, "handled_lan_responses: %u\n", 1984 + ipmi_get_stat(intf, handled_lan_responses)); 1985 + seq_printf(m, "invalid_lan_responses: %u\n", 1986 + ipmi_get_stat(intf, invalid_lan_responses)); 1987 + seq_printf(m, "unhandled_lan_responses: %u\n", 1988 + ipmi_get_stat(intf, unhandled_lan_responses)); 1989 + seq_printf(m, "handled_commands: %u\n", 1990 + ipmi_get_stat(intf, handled_commands)); 1991 + seq_printf(m, "invalid_commands: %u\n", 1992 + ipmi_get_stat(intf, invalid_commands)); 1993 + seq_printf(m, "unhandled_commands: %u\n", 1994 + ipmi_get_stat(intf, unhandled_commands)); 1995 + seq_printf(m, "invalid_events: %u\n", 1996 + ipmi_get_stat(intf, invalid_events)); 1997 + seq_printf(m, "events: %u\n", 1998 + ipmi_get_stat(intf, events)); 1999 + seq_printf(m, "failed rexmit LAN msgs: %u\n", 2000 + ipmi_get_stat(intf, dropped_rexmit_lan_commands)); 2001 + seq_printf(m, "failed rexmit IPMB msgs: %u\n", 2002 + ipmi_get_stat(intf, dropped_rexmit_ipmb_commands)); 2003 + return 0; 2004 + } 2005 + 2006 + static int smi_stats_proc_open(struct inode *inode, struct file *file) 2007 + { 2008 + return single_open(file, smi_stats_proc_show, PDE(inode)->data); 2009 + } 2010 + 2011 + static const struct file_operations smi_stats_proc_ops = { 2012 + .open = smi_stats_proc_open, 2013 + .read = seq_read, 2014 + .llseek = seq_lseek, 2015 + .release = single_release, 2016 + }; 1992 2017 #endif /* CONFIG_PROC_FS */ 1993 2018 1994 2019 int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 1995 - read_proc_t *read_proc, 2020 + const struct file_operations *proc_ops, 1996 2021 void *data) 1997 2022 { 1998 2023 int rv = 0; ··· 2037 2010 } 2038 2011 strcpy(entry->name, name); 2039 2012 2040 - file = create_proc_entry(name, 0, smi->proc_dir); 2013 + file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data); 2041 2014 if (!file) { 2042 2015 kfree(entry->name); 2043 2016 kfree(entry); 2044 2017 rv = -ENOMEM; 2045 2018 } else { 2046 - file->data = data; 2047 - file->read_proc = read_proc; 2048 - 2049 2019 mutex_lock(&smi->proc_entry_lock); 2050 2020 /* Stick it on the list. */ 2051 2021 entry->next = smi->proc_entries; ··· 2067 2043 2068 2044 if (rv == 0) 2069 2045 rv = ipmi_smi_add_proc_entry(smi, "stats", 2070 - stat_file_read_proc, 2046 + &smi_stats_proc_ops, 2071 2047 smi); 2072 2048 2073 2049 if (rv == 0) 2074 2050 rv = ipmi_smi_add_proc_entry(smi, "ipmb", 2075 - ipmb_file_read_proc, 2051 + &smi_ipmb_proc_ops, 2076 2052 smi); 2077 2053 2078 2054 if (rv == 0) 2079 2055 rv = ipmi_smi_add_proc_entry(smi, "version", 2080 - version_file_read_proc, 2056 + &smi_version_proc_ops, 2081 2057 smi); 2082 2058 #endif /* CONFIG_PROC_FS */ 2083 2059
+61 -29
drivers/char/ipmi/ipmi_si_intf.c
··· 43 43 #include <linux/moduleparam.h> 44 44 #include <asm/system.h> 45 45 #include <linux/sched.h> 46 + #include <linux/seq_file.h> 46 47 #include <linux/timer.h> 47 48 #include <linux/errno.h> 48 49 #include <linux/spinlock.h> ··· 2806 2805 return rv; 2807 2806 } 2808 2807 2809 - static int type_file_read_proc(char *page, char **start, off_t off, 2810 - int count, int *eof, void *data) 2808 + static int smi_type_proc_show(struct seq_file *m, void *v) 2811 2809 { 2812 - struct smi_info *smi = data; 2810 + struct smi_info *smi = m->private; 2813 2811 2814 - return sprintf(page, "%s\n", si_to_str[smi->si_type]); 2812 + return seq_printf(m, "%s\n", si_to_str[smi->si_type]); 2815 2813 } 2816 2814 2817 - static int stat_file_read_proc(char *page, char **start, off_t off, 2818 - int count, int *eof, void *data) 2815 + static int smi_type_proc_open(struct inode *inode, struct file *file) 2819 2816 { 2820 - char *out = (char *) page; 2821 - struct smi_info *smi = data; 2817 + return single_open(file, smi_type_proc_show, PDE(inode)->data); 2818 + } 2822 2819 2823 - out += sprintf(out, "interrupts_enabled: %d\n", 2820 + static const struct file_operations smi_type_proc_ops = { 2821 + .open = smi_type_proc_open, 2822 + .read = seq_read, 2823 + .llseek = seq_lseek, 2824 + .release = single_release, 2825 + }; 2826 + 2827 + static int smi_si_stats_proc_show(struct seq_file *m, void *v) 2828 + { 2829 + struct smi_info *smi = m->private; 2830 + 2831 + seq_printf(m, "interrupts_enabled: %d\n", 2824 2832 smi->irq && !smi->interrupt_disabled); 2825 - out += sprintf(out, "short_timeouts: %u\n", 2833 + seq_printf(m, "short_timeouts: %u\n", 2826 2834 smi_get_stat(smi, short_timeouts)); 2827 - out += sprintf(out, "long_timeouts: %u\n", 2835 + seq_printf(m, "long_timeouts: %u\n", 2828 2836 smi_get_stat(smi, long_timeouts)); 2829 - out += sprintf(out, "idles: %u\n", 2837 + seq_printf(m, "idles: %u\n", 2830 2838 smi_get_stat(smi, idles)); 2831 - out += sprintf(out, "interrupts: %u\n", 2839 + seq_printf(m, "interrupts: %u\n", 2832 2840 smi_get_stat(smi, interrupts)); 2833 - out += sprintf(out, "attentions: %u\n", 2841 + seq_printf(m, "attentions: %u\n", 2834 2842 smi_get_stat(smi, attentions)); 2835 - out += sprintf(out, "flag_fetches: %u\n", 2843 + seq_printf(m, "flag_fetches: %u\n", 2836 2844 smi_get_stat(smi, flag_fetches)); 2837 - out += sprintf(out, "hosed_count: %u\n", 2845 + seq_printf(m, "hosed_count: %u\n", 2838 2846 smi_get_stat(smi, hosed_count)); 2839 - out += sprintf(out, "complete_transactions: %u\n", 2847 + seq_printf(m, "complete_transactions: %u\n", 2840 2848 smi_get_stat(smi, complete_transactions)); 2841 - out += sprintf(out, "events: %u\n", 2849 + seq_printf(m, "events: %u\n", 2842 2850 smi_get_stat(smi, events)); 2843 - out += sprintf(out, "watchdog_pretimeouts: %u\n", 2851 + seq_printf(m, "watchdog_pretimeouts: %u\n", 2844 2852 smi_get_stat(smi, watchdog_pretimeouts)); 2845 - out += sprintf(out, "incoming_messages: %u\n", 2853 + seq_printf(m, "incoming_messages: %u\n", 2846 2854 smi_get_stat(smi, incoming_messages)); 2847 - 2848 - return out - page; 2855 + return 0; 2849 2856 } 2850 2857 2851 - static int param_read_proc(char *page, char **start, off_t off, 2852 - int count, int *eof, void *data) 2858 + static int smi_si_stats_proc_open(struct inode *inode, struct file *file) 2853 2859 { 2854 - struct smi_info *smi = data; 2860 + return single_open(file, smi_si_stats_proc_show, PDE(inode)->data); 2861 + } 2855 2862 2856 - return sprintf(page, 2863 + static const struct file_operations smi_si_stats_proc_ops = { 2864 + .open = smi_si_stats_proc_open, 2865 + .read = seq_read, 2866 + .llseek = seq_lseek, 2867 + .release = single_release, 2868 + }; 2869 + 2870 + static int smi_params_proc_show(struct seq_file *m, void *v) 2871 + { 2872 + struct smi_info *smi = m->private; 2873 + 2874 + return seq_printf(m, 2857 2875 "%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n", 2858 2876 si_to_str[smi->si_type], 2859 2877 addr_space_to_str[smi->io.addr_type], ··· 2883 2863 smi->irq, 2884 2864 smi->slave_addr); 2885 2865 } 2866 + 2867 + static int smi_params_proc_open(struct inode *inode, struct file *file) 2868 + { 2869 + return single_open(file, smi_params_proc_show, PDE(inode)->data); 2870 + } 2871 + 2872 + static const struct file_operations smi_params_proc_ops = { 2873 + .open = smi_params_proc_open, 2874 + .read = seq_read, 2875 + .llseek = seq_lseek, 2876 + .release = single_release, 2877 + }; 2886 2878 2887 2879 /* 2888 2880 * oem_data_avail_to_receive_msg_avail ··· 3289 3257 } 3290 3258 3291 3259 rv = ipmi_smi_add_proc_entry(new_smi->intf, "type", 3292 - type_file_read_proc, 3260 + &smi_type_proc_ops, 3293 3261 new_smi); 3294 3262 if (rv) { 3295 3263 dev_err(new_smi->dev, "Unable to create proc entry: %d\n", rv); ··· 3297 3265 } 3298 3266 3299 3267 rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats", 3300 - stat_file_read_proc, 3268 + &smi_si_stats_proc_ops, 3301 3269 new_smi); 3302 3270 if (rv) { 3303 3271 dev_err(new_smi->dev, "Unable to create proc entry: %d\n", rv); ··· 3305 3273 } 3306 3274 3307 3275 rv = ipmi_smi_add_proc_entry(new_smi->intf, "params", 3308 - param_read_proc, 3276 + &smi_params_proc_ops, 3309 3277 new_smi); 3310 3278 if (rv) { 3311 3279 dev_err(new_smi->dev, "Unable to create proc entry: %d\n", rv);
+1 -1
include/linux/ipmi_smi.h
··· 236 236 directory for this interface. Note that the entry will 237 237 automatically be dstroyed when the interface is destroyed. */ 238 238 int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 239 - read_proc_t *read_proc, 239 + const struct file_operations *proc_ops, 240 240 void *data); 241 241 242 242 #endif /* __LINUX_IPMI_SMI_H */