diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2011-05-26 19:25:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-26 20:12:37 -0400 |
commit | 074127367a503de0168e2ca5d0b36a6f761f026a (patch) | |
tree | 7f6b82c412c12ac977e06c922a3a43c8192d50c3 /drivers/char/ipmi/ipmi_msghandler.c | |
parent | 997c136f518c5debd63847e78e2a8694f56dcf90 (diff) |
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>
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 138 |
1 files changed, 81 insertions, 57 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 38223e93aa98..58c0e6387cf7 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <asm/system.h> | 36 | #include <asm/system.h> |
37 | #include <linux/poll.h> | 37 | #include <linux/poll.h> |
38 | #include <linux/sched.h> | 38 | #include <linux/sched.h> |
39 | #include <linux/seq_file.h> | ||
39 | #include <linux/spinlock.h> | 40 | #include <linux/spinlock.h> |
40 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
41 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
@@ -1896,102 +1897,128 @@ int ipmi_request_supply_msgs(ipmi_user_t user, | |||
1896 | EXPORT_SYMBOL(ipmi_request_supply_msgs); | 1897 | EXPORT_SYMBOL(ipmi_request_supply_msgs); |
1897 | 1898 | ||
1898 | #ifdef CONFIG_PROC_FS | 1899 | #ifdef CONFIG_PROC_FS |
1899 | static int ipmb_file_read_proc(char *page, char **start, off_t off, | 1900 | static int smi_ipmb_proc_show(struct seq_file *m, void *v) |
1900 | int count, int *eof, void *data) | ||
1901 | { | 1901 | { |
1902 | char *out = (char *) page; | 1902 | ipmi_smi_t intf = m->private; |
1903 | ipmi_smi_t intf = data; | ||
1904 | int i; | 1903 | int i; |
1905 | int rv = 0; | ||
1906 | 1904 | ||
1907 | for (i = 0; i < IPMI_MAX_CHANNELS; i++) | 1905 | seq_printf(m, "%x", intf->channels[0].address); |
1908 | rv += sprintf(out+rv, "%x ", intf->channels[i].address); | 1906 | for (i = 1; i < IPMI_MAX_CHANNELS; i++) |
1909 | out[rv-1] = '\n'; /* Replace the final space with a newline */ | 1907 | seq_printf(m, " %x", intf->channels[i].address); |
1910 | out[rv] = '\0'; | 1908 | return seq_putc(m, '\n'); |
1911 | rv++; | ||
1912 | return rv; | ||
1913 | } | 1909 | } |
1914 | 1910 | ||
1915 | static int version_file_read_proc(char *page, char **start, off_t off, | 1911 | static int smi_ipmb_proc_open(struct inode *inode, struct file *file) |
1916 | int count, int *eof, void *data) | ||
1917 | { | 1912 | { |
1918 | char *out = (char *) page; | 1913 | return single_open(file, smi_ipmb_proc_show, PDE(inode)->data); |
1919 | ipmi_smi_t intf = data; | 1914 | } |
1920 | 1915 | ||
1921 | return sprintf(out, "%u.%u\n", | 1916 | static const struct file_operations smi_ipmb_proc_ops = { |
1917 | .open = smi_ipmb_proc_open, | ||
1918 | .read = seq_read, | ||
1919 | .llseek = seq_lseek, | ||
1920 | .release = single_release, | ||
1921 | }; | ||
1922 | |||
1923 | static int smi_version_proc_show(struct seq_file *m, void *v) | ||
1924 | { | ||
1925 | ipmi_smi_t intf = m->private; | ||
1926 | |||
1927 | return seq_printf(m, "%u.%u\n", | ||
1922 | ipmi_version_major(&intf->bmc->id), | 1928 | ipmi_version_major(&intf->bmc->id), |
1923 | ipmi_version_minor(&intf->bmc->id)); | 1929 | ipmi_version_minor(&intf->bmc->id)); |
1924 | } | 1930 | } |
1925 | 1931 | ||
1926 | static int stat_file_read_proc(char *page, char **start, off_t off, | 1932 | static int smi_version_proc_open(struct inode *inode, struct file *file) |
1927 | int count, int *eof, void *data) | ||
1928 | { | 1933 | { |
1929 | char *out = (char *) page; | 1934 | return single_open(file, smi_version_proc_show, PDE(inode)->data); |
1930 | ipmi_smi_t intf = data; | 1935 | } |
1936 | |||
1937 | static const struct file_operations smi_version_proc_ops = { | ||
1938 | .open = smi_version_proc_open, | ||
1939 | .read = seq_read, | ||
1940 | .llseek = seq_lseek, | ||
1941 | .release = single_release, | ||
1942 | }; | ||
1931 | 1943 | ||
1932 | out += sprintf(out, "sent_invalid_commands: %u\n", | 1944 | static int smi_stats_proc_show(struct seq_file *m, void *v) |
1945 | { | ||
1946 | ipmi_smi_t intf = m->private; | ||
1947 | |||
1948 | seq_printf(m, "sent_invalid_commands: %u\n", | ||
1933 | ipmi_get_stat(intf, sent_invalid_commands)); | 1949 | ipmi_get_stat(intf, sent_invalid_commands)); |
1934 | out += sprintf(out, "sent_local_commands: %u\n", | 1950 | seq_printf(m, "sent_local_commands: %u\n", |
1935 | ipmi_get_stat(intf, sent_local_commands)); | 1951 | ipmi_get_stat(intf, sent_local_commands)); |
1936 | out += sprintf(out, "handled_local_responses: %u\n", | 1952 | seq_printf(m, "handled_local_responses: %u\n", |
1937 | ipmi_get_stat(intf, handled_local_responses)); | 1953 | ipmi_get_stat(intf, handled_local_responses)); |
1938 | out += sprintf(out, "unhandled_local_responses: %u\n", | 1954 | seq_printf(m, "unhandled_local_responses: %u\n", |
1939 | ipmi_get_stat(intf, unhandled_local_responses)); | 1955 | ipmi_get_stat(intf, unhandled_local_responses)); |
1940 | out += sprintf(out, "sent_ipmb_commands: %u\n", | 1956 | seq_printf(m, "sent_ipmb_commands: %u\n", |
1941 | ipmi_get_stat(intf, sent_ipmb_commands)); | 1957 | ipmi_get_stat(intf, sent_ipmb_commands)); |
1942 | out += sprintf(out, "sent_ipmb_command_errs: %u\n", | 1958 | seq_printf(m, "sent_ipmb_command_errs: %u\n", |
1943 | ipmi_get_stat(intf, sent_ipmb_command_errs)); | 1959 | ipmi_get_stat(intf, sent_ipmb_command_errs)); |
1944 | out += sprintf(out, "retransmitted_ipmb_commands: %u\n", | 1960 | seq_printf(m, "retransmitted_ipmb_commands: %u\n", |
1945 | ipmi_get_stat(intf, retransmitted_ipmb_commands)); | 1961 | ipmi_get_stat(intf, retransmitted_ipmb_commands)); |
1946 | out += sprintf(out, "timed_out_ipmb_commands: %u\n", | 1962 | seq_printf(m, "timed_out_ipmb_commands: %u\n", |
1947 | ipmi_get_stat(intf, timed_out_ipmb_commands)); | 1963 | ipmi_get_stat(intf, timed_out_ipmb_commands)); |
1948 | out += sprintf(out, "timed_out_ipmb_broadcasts: %u\n", | 1964 | seq_printf(m, "timed_out_ipmb_broadcasts: %u\n", |
1949 | ipmi_get_stat(intf, timed_out_ipmb_broadcasts)); | 1965 | ipmi_get_stat(intf, timed_out_ipmb_broadcasts)); |
1950 | out += sprintf(out, "sent_ipmb_responses: %u\n", | 1966 | seq_printf(m, "sent_ipmb_responses: %u\n", |
1951 | ipmi_get_stat(intf, sent_ipmb_responses)); | 1967 | ipmi_get_stat(intf, sent_ipmb_responses)); |
1952 | out += sprintf(out, "handled_ipmb_responses: %u\n", | 1968 | seq_printf(m, "handled_ipmb_responses: %u\n", |
1953 | ipmi_get_stat(intf, handled_ipmb_responses)); | 1969 | ipmi_get_stat(intf, handled_ipmb_responses)); |
1954 | out += sprintf(out, "invalid_ipmb_responses: %u\n", | 1970 | seq_printf(m, "invalid_ipmb_responses: %u\n", |
1955 | ipmi_get_stat(intf, invalid_ipmb_responses)); | 1971 | ipmi_get_stat(intf, invalid_ipmb_responses)); |
1956 | out += sprintf(out, "unhandled_ipmb_responses: %u\n", | 1972 | seq_printf(m, "unhandled_ipmb_responses: %u\n", |
1957 | ipmi_get_stat(intf, unhandled_ipmb_responses)); | 1973 | ipmi_get_stat(intf, unhandled_ipmb_responses)); |
1958 | out += sprintf(out, "sent_lan_commands: %u\n", | 1974 | seq_printf(m, "sent_lan_commands: %u\n", |
1959 | ipmi_get_stat(intf, sent_lan_commands)); | 1975 | ipmi_get_stat(intf, sent_lan_commands)); |
1960 | out += sprintf(out, "sent_lan_command_errs: %u\n", | 1976 | seq_printf(m, "sent_lan_command_errs: %u\n", |
1961 | ipmi_get_stat(intf, sent_lan_command_errs)); | 1977 | ipmi_get_stat(intf, sent_lan_command_errs)); |
1962 | out += sprintf(out, "retransmitted_lan_commands: %u\n", | 1978 | seq_printf(m, "retransmitted_lan_commands: %u\n", |
1963 | ipmi_get_stat(intf, retransmitted_lan_commands)); | 1979 | ipmi_get_stat(intf, retransmitted_lan_commands)); |
1964 | out += sprintf(out, "timed_out_lan_commands: %u\n", | 1980 | seq_printf(m, "timed_out_lan_commands: %u\n", |
1965 | ipmi_get_stat(intf, timed_out_lan_commands)); | 1981 | ipmi_get_stat(intf, timed_out_lan_commands)); |
1966 | out += sprintf(out, "sent_lan_responses: %u\n", | 1982 | seq_printf(m, "sent_lan_responses: %u\n", |
1967 | ipmi_get_stat(intf, sent_lan_responses)); | 1983 | ipmi_get_stat(intf, sent_lan_responses)); |
1968 | out += sprintf(out, "handled_lan_responses: %u\n", | 1984 | seq_printf(m, "handled_lan_responses: %u\n", |
1969 | ipmi_get_stat(intf, handled_lan_responses)); | 1985 | ipmi_get_stat(intf, handled_lan_responses)); |
1970 | out += sprintf(out, "invalid_lan_responses: %u\n", | 1986 | seq_printf(m, "invalid_lan_responses: %u\n", |
1971 | ipmi_get_stat(intf, invalid_lan_responses)); | 1987 | ipmi_get_stat(intf, invalid_lan_responses)); |
1972 | out += sprintf(out, "unhandled_lan_responses: %u\n", | 1988 | seq_printf(m, "unhandled_lan_responses: %u\n", |
1973 | ipmi_get_stat(intf, unhandled_lan_responses)); | 1989 | ipmi_get_stat(intf, unhandled_lan_responses)); |
1974 | out += sprintf(out, "handled_commands: %u\n", | 1990 | seq_printf(m, "handled_commands: %u\n", |
1975 | ipmi_get_stat(intf, handled_commands)); | 1991 | ipmi_get_stat(intf, handled_commands)); |
1976 | out += sprintf(out, "invalid_commands: %u\n", | 1992 | seq_printf(m, "invalid_commands: %u\n", |
1977 | ipmi_get_stat(intf, invalid_commands)); | 1993 | ipmi_get_stat(intf, invalid_commands)); |
1978 | out += sprintf(out, "unhandled_commands: %u\n", | 1994 | seq_printf(m, "unhandled_commands: %u\n", |
1979 | ipmi_get_stat(intf, unhandled_commands)); | 1995 | ipmi_get_stat(intf, unhandled_commands)); |
1980 | out += sprintf(out, "invalid_events: %u\n", | 1996 | seq_printf(m, "invalid_events: %u\n", |
1981 | ipmi_get_stat(intf, invalid_events)); | 1997 | ipmi_get_stat(intf, invalid_events)); |
1982 | out += sprintf(out, "events: %u\n", | 1998 | seq_printf(m, "events: %u\n", |
1983 | ipmi_get_stat(intf, events)); | 1999 | ipmi_get_stat(intf, events)); |
1984 | out += sprintf(out, "failed rexmit LAN msgs: %u\n", | 2000 | seq_printf(m, "failed rexmit LAN msgs: %u\n", |
1985 | ipmi_get_stat(intf, dropped_rexmit_lan_commands)); | 2001 | ipmi_get_stat(intf, dropped_rexmit_lan_commands)); |
1986 | out += sprintf(out, "failed rexmit IPMB msgs: %u\n", | 2002 | seq_printf(m, "failed rexmit IPMB msgs: %u\n", |
1987 | ipmi_get_stat(intf, dropped_rexmit_ipmb_commands)); | 2003 | ipmi_get_stat(intf, dropped_rexmit_ipmb_commands)); |
2004 | return 0; | ||
2005 | } | ||
1988 | 2006 | ||
1989 | return (out - ((char *) page)); | 2007 | static int smi_stats_proc_open(struct inode *inode, struct file *file) |
2008 | { | ||
2009 | return single_open(file, smi_stats_proc_show, PDE(inode)->data); | ||
1990 | } | 2010 | } |
2011 | |||
2012 | static const struct file_operations smi_stats_proc_ops = { | ||
2013 | .open = smi_stats_proc_open, | ||
2014 | .read = seq_read, | ||
2015 | .llseek = seq_lseek, | ||
2016 | .release = single_release, | ||
2017 | }; | ||
1991 | #endif /* CONFIG_PROC_FS */ | 2018 | #endif /* CONFIG_PROC_FS */ |
1992 | 2019 | ||
1993 | int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, | 2020 | int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, |
1994 | read_proc_t *read_proc, | 2021 | const struct file_operations *proc_ops, |
1995 | void *data) | 2022 | void *data) |
1996 | { | 2023 | { |
1997 | int rv = 0; | 2024 | int rv = 0; |
@@ -2010,15 +2037,12 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, | |||
2010 | } | 2037 | } |
2011 | strcpy(entry->name, name); | 2038 | strcpy(entry->name, name); |
2012 | 2039 | ||
2013 | file = create_proc_entry(name, 0, smi->proc_dir); | 2040 | file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data); |
2014 | if (!file) { | 2041 | if (!file) { |
2015 | kfree(entry->name); | 2042 | kfree(entry->name); |
2016 | kfree(entry); | 2043 | kfree(entry); |
2017 | rv = -ENOMEM; | 2044 | rv = -ENOMEM; |
2018 | } else { | 2045 | } else { |
2019 | file->data = data; | ||
2020 | file->read_proc = read_proc; | ||
2021 | |||
2022 | mutex_lock(&smi->proc_entry_lock); | 2046 | mutex_lock(&smi->proc_entry_lock); |
2023 | /* Stick it on the list. */ | 2047 | /* Stick it on the list. */ |
2024 | entry->next = smi->proc_entries; | 2048 | entry->next = smi->proc_entries; |
@@ -2043,17 +2067,17 @@ static int add_proc_entries(ipmi_smi_t smi, int num) | |||
2043 | 2067 | ||
2044 | if (rv == 0) | 2068 | if (rv == 0) |
2045 | rv = ipmi_smi_add_proc_entry(smi, "stats", | 2069 | rv = ipmi_smi_add_proc_entry(smi, "stats", |
2046 | stat_file_read_proc, | 2070 | &smi_stats_proc_ops, |
2047 | smi); | 2071 | smi); |
2048 | 2072 | ||
2049 | if (rv == 0) | 2073 | if (rv == 0) |
2050 | rv = ipmi_smi_add_proc_entry(smi, "ipmb", | 2074 | rv = ipmi_smi_add_proc_entry(smi, "ipmb", |
2051 | ipmb_file_read_proc, | 2075 | &smi_ipmb_proc_ops, |
2052 | smi); | 2076 | smi); |
2053 | 2077 | ||
2054 | if (rv == 0) | 2078 | if (rv == 0) |
2055 | rv = ipmi_smi_add_proc_entry(smi, "version", | 2079 | rv = ipmi_smi_add_proc_entry(smi, "version", |
2056 | version_file_read_proc, | 2080 | &smi_version_proc_ops, |
2057 | smi); | 2081 | smi); |
2058 | #endif /* CONFIG_PROC_FS */ | 2082 | #endif /* CONFIG_PROC_FS */ |
2059 | 2083 | ||