diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-12-17 09:45:05 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-12-17 22:53:37 -0500 |
commit | 5c916a295f27dbc0df4769a53b109666506bd061 (patch) | |
tree | 886c81735c56e292afcd0355db4547f98fbc7365 /arch/powerpc | |
parent | 14b8a76b9d53346f2871bf419da2aaf219940c50 (diff) |
powerpc/iseries: Convert to proc_fops
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/iseries/mf.c | 147 |
1 files changed, 83 insertions, 64 deletions
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c index 0d9343df35bc..6617915bcb1a 100644 --- a/arch/powerpc/platforms/iseries/mf.c +++ b/arch/powerpc/platforms/iseries/mf.c | |||
@@ -855,59 +855,58 @@ static int mf_get_boot_rtc(struct rtc_time *tm) | |||
855 | } | 855 | } |
856 | 856 | ||
857 | #ifdef CONFIG_PROC_FS | 857 | #ifdef CONFIG_PROC_FS |
858 | 858 | static int mf_cmdline_proc_show(struct seq_file *m, void *v) | |
859 | static int proc_mf_dump_cmdline(char *page, char **start, off_t off, | ||
860 | int count, int *eof, void *data) | ||
861 | { | 859 | { |
862 | int len; | 860 | char *page, *p; |
863 | char *p; | ||
864 | struct vsp_cmd_data vsp_cmd; | 861 | struct vsp_cmd_data vsp_cmd; |
865 | int rc; | 862 | int rc; |
866 | dma_addr_t dma_addr; | 863 | dma_addr_t dma_addr; |
867 | 864 | ||
868 | /* The HV appears to return no more than 256 bytes of command line */ | 865 | /* The HV appears to return no more than 256 bytes of command line */ |
869 | if (off >= 256) | 866 | page = kmalloc(256, GFP_KERNEL); |
870 | return 0; | 867 | if (!page) |
871 | if ((off + count) > 256) | 868 | return -ENOMEM; |
872 | count = 256 - off; | ||
873 | 869 | ||
874 | dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE); | 870 | dma_addr = iseries_hv_map(page, 256, DMA_FROM_DEVICE); |
875 | if (dma_addr == DMA_ERROR_CODE) | 871 | if (dma_addr == DMA_ERROR_CODE) { |
872 | kfree(page); | ||
876 | return -ENOMEM; | 873 | return -ENOMEM; |
877 | memset(page, 0, off + count); | 874 | } |
875 | memset(page, 0, 256); | ||
878 | memset(&vsp_cmd, 0, sizeof(vsp_cmd)); | 876 | memset(&vsp_cmd, 0, sizeof(vsp_cmd)); |
879 | vsp_cmd.cmd = 33; | 877 | vsp_cmd.cmd = 33; |
880 | vsp_cmd.sub_data.kern.token = dma_addr; | 878 | vsp_cmd.sub_data.kern.token = dma_addr; |
881 | vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex; | 879 | vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex; |
882 | vsp_cmd.sub_data.kern.side = (u64)data; | 880 | vsp_cmd.sub_data.kern.side = (u64)m->private; |
883 | vsp_cmd.sub_data.kern.length = off + count; | 881 | vsp_cmd.sub_data.kern.length = 256; |
884 | mb(); | 882 | mb(); |
885 | rc = signal_vsp_instruction(&vsp_cmd); | 883 | rc = signal_vsp_instruction(&vsp_cmd); |
886 | iseries_hv_unmap(dma_addr, off + count, DMA_FROM_DEVICE); | 884 | iseries_hv_unmap(dma_addr, 256, DMA_FROM_DEVICE); |
887 | if (rc) | 885 | if (rc) { |
886 | kfree(page); | ||
888 | return rc; | 887 | return rc; |
889 | if (vsp_cmd.result_code != 0) | 888 | } |
889 | if (vsp_cmd.result_code != 0) { | ||
890 | kfree(page); | ||
890 | return -ENOMEM; | 891 | return -ENOMEM; |
892 | } | ||
891 | p = page; | 893 | p = page; |
892 | len = 0; | 894 | while (p - page < 256) { |
893 | while (len < (off + count)) { | 895 | if (*p == '\0' || *p == '\n') { |
894 | if ((*p == '\0') || (*p == '\n')) { | 896 | *p = '\n'; |
895 | if (*p == '\0') | ||
896 | *p = '\n'; | ||
897 | p++; | ||
898 | len++; | ||
899 | *eof = 1; | ||
900 | break; | 897 | break; |
901 | } | 898 | } |
902 | p++; | 899 | p++; |
903 | len++; | ||
904 | } | ||
905 | 900 | ||
906 | if (len < off) { | ||
907 | *eof = 1; | ||
908 | len = 0; | ||
909 | } | 901 | } |
910 | return len; | 902 | seq_write(m, page, p - page); |
903 | kfree(page); | ||
904 | return 0; | ||
905 | } | ||
906 | |||
907 | static int mf_cmdline_proc_open(struct inode *inode, struct file *file) | ||
908 | { | ||
909 | return single_open(file, mf_cmdline_proc_show, PDE(inode)->data); | ||
911 | } | 910 | } |
912 | 911 | ||
913 | #if 0 | 912 | #if 0 |
@@ -962,10 +961,8 @@ static int proc_mf_dump_vmlinux(char *page, char **start, off_t off, | |||
962 | } | 961 | } |
963 | #endif | 962 | #endif |
964 | 963 | ||
965 | static int proc_mf_dump_side(char *page, char **start, off_t off, | 964 | static int mf_side_proc_show(struct seq_file *m, void *v) |
966 | int count, int *eof, void *data) | ||
967 | { | 965 | { |
968 | int len; | ||
969 | char mf_current_side = ' '; | 966 | char mf_current_side = ' '; |
970 | struct vsp_cmd_data vsp_cmd; | 967 | struct vsp_cmd_data vsp_cmd; |
971 | 968 | ||
@@ -989,21 +986,17 @@ static int proc_mf_dump_side(char *page, char **start, off_t off, | |||
989 | } | 986 | } |
990 | } | 987 | } |
991 | 988 | ||
992 | len = sprintf(page, "%c\n", mf_current_side); | 989 | seq_printf(m, "%c\n", mf_current_side); |
990 | return 0; | ||
991 | } | ||
993 | 992 | ||
994 | if (len <= (off + count)) | 993 | static int mf_side_proc_open(struct inode *inode, struct file *file) |
995 | *eof = 1; | 994 | { |
996 | *start = page + off; | 995 | return single_open(file, mf_side_proc_show, NULL); |
997 | len -= off; | ||
998 | if (len > count) | ||
999 | len = count; | ||
1000 | if (len < 0) | ||
1001 | len = 0; | ||
1002 | return len; | ||
1003 | } | 996 | } |
1004 | 997 | ||
1005 | static int proc_mf_change_side(struct file *file, const char __user *buffer, | 998 | static ssize_t mf_side_proc_write(struct file *file, const char __user *buffer, |
1006 | unsigned long count, void *data) | 999 | size_t count, loff_t *pos) |
1007 | { | 1000 | { |
1008 | char side; | 1001 | char side; |
1009 | u64 newSide; | 1002 | u64 newSide; |
@@ -1041,6 +1034,15 @@ static int proc_mf_change_side(struct file *file, const char __user *buffer, | |||
1041 | return count; | 1034 | return count; |
1042 | } | 1035 | } |
1043 | 1036 | ||
1037 | static const struct file_operations mf_side_proc_fops = { | ||
1038 | .owner = THIS_MODULE, | ||
1039 | .open = mf_side_proc_open, | ||
1040 | .read = seq_read, | ||
1041 | .llseek = seq_lseek, | ||
1042 | .release = single_release, | ||
1043 | .write = mf_side_proc_write, | ||
1044 | }; | ||
1045 | |||
1044 | #if 0 | 1046 | #if 0 |
1045 | static void mf_getSrcHistory(char *buffer, int size) | 1047 | static void mf_getSrcHistory(char *buffer, int size) |
1046 | { | 1048 | { |
@@ -1087,8 +1089,7 @@ static void mf_getSrcHistory(char *buffer, int size) | |||
1087 | } | 1089 | } |
1088 | #endif | 1090 | #endif |
1089 | 1091 | ||
1090 | static int proc_mf_dump_src(char *page, char **start, off_t off, | 1092 | static int mf_src_proc_show(struct seq_file *m, void *v) |
1091 | int count, int *eof, void *data) | ||
1092 | { | 1093 | { |
1093 | #if 0 | 1094 | #if 0 |
1094 | int len; | 1095 | int len; |
@@ -1109,8 +1110,13 @@ static int proc_mf_dump_src(char *page, char **start, off_t off, | |||
1109 | #endif | 1110 | #endif |
1110 | } | 1111 | } |
1111 | 1112 | ||
1112 | static int proc_mf_change_src(struct file *file, const char __user *buffer, | 1113 | static int mf_src_proc_open(struct inode *inode, struct file *file) |
1113 | unsigned long count, void *data) | 1114 | { |
1115 | return single_open(file, mf_src_proc_show, NULL); | ||
1116 | } | ||
1117 | |||
1118 | static ssize_t mf_src_proc_write(struct file *file, const char __user *buffer, | ||
1119 | size_t count, loff_t *pos) | ||
1114 | { | 1120 | { |
1115 | char stkbuf[10]; | 1121 | char stkbuf[10]; |
1116 | 1122 | ||
@@ -1135,9 +1141,19 @@ static int proc_mf_change_src(struct file *file, const char __user *buffer, | |||
1135 | return count; | 1141 | return count; |
1136 | } | 1142 | } |
1137 | 1143 | ||
1138 | static int proc_mf_change_cmdline(struct file *file, const char __user *buffer, | 1144 | static const struct file_operations mf_src_proc_fops = { |
1139 | unsigned long count, void *data) | 1145 | .owner = THIS_MODULE, |
1146 | .open = mf_src_proc_open, | ||
1147 | .read = seq_read, | ||
1148 | .llseek = seq_lseek, | ||
1149 | .release = single_release, | ||
1150 | .write = mf_src_proc_write, | ||
1151 | }; | ||
1152 | |||
1153 | static ssize_t mf_cmdline_proc_write(struct file *file, const char __user *buffer, | ||
1154 | size_t count, loff_t *pos) | ||
1140 | { | 1155 | { |
1156 | void *data = PDE(file->f_path.dentry->d_inode)->data; | ||
1141 | struct vsp_cmd_data vsp_cmd; | 1157 | struct vsp_cmd_data vsp_cmd; |
1142 | dma_addr_t dma_addr; | 1158 | dma_addr_t dma_addr; |
1143 | char *page; | 1159 | char *page; |
@@ -1172,6 +1188,15 @@ out: | |||
1172 | return ret; | 1188 | return ret; |
1173 | } | 1189 | } |
1174 | 1190 | ||
1191 | static const struct file_operations mf_cmdline_proc_fops = { | ||
1192 | .owner = THIS_MODULE, | ||
1193 | .open = mf_cmdline_proc_open, | ||
1194 | .read = seq_read, | ||
1195 | .llseek = seq_lseek, | ||
1196 | .release = single_release, | ||
1197 | .write = mf_cmdline_proc_write, | ||
1198 | }; | ||
1199 | |||
1175 | static ssize_t proc_mf_change_vmlinux(struct file *file, | 1200 | static ssize_t proc_mf_change_vmlinux(struct file *file, |
1176 | const char __user *buf, | 1201 | const char __user *buf, |
1177 | size_t count, loff_t *ppos) | 1202 | size_t count, loff_t *ppos) |
@@ -1246,12 +1271,10 @@ static int __init mf_proc_init(void) | |||
1246 | if (!mf) | 1271 | if (!mf) |
1247 | return 1; | 1272 | return 1; |
1248 | 1273 | ||
1249 | ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf); | 1274 | ent = proc_create_data("cmdline", S_IRUSR|S_IWUSR, mf, |
1275 | &mf_cmdline_proc_fops, (void *)(long)i); | ||
1250 | if (!ent) | 1276 | if (!ent) |
1251 | return 1; | 1277 | return 1; |
1252 | ent->data = (void *)(long)i; | ||
1253 | ent->read_proc = proc_mf_dump_cmdline; | ||
1254 | ent->write_proc = proc_mf_change_cmdline; | ||
1255 | 1278 | ||
1256 | if (i == 3) /* no vmlinux entry for 'D' */ | 1279 | if (i == 3) /* no vmlinux entry for 'D' */ |
1257 | continue; | 1280 | continue; |
@@ -1263,19 +1286,15 @@ static int __init mf_proc_init(void) | |||
1263 | return 1; | 1286 | return 1; |
1264 | } | 1287 | } |
1265 | 1288 | ||
1266 | ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); | 1289 | ent = proc_create("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root, |
1290 | &mf_side_proc_fops); | ||
1267 | if (!ent) | 1291 | if (!ent) |
1268 | return 1; | 1292 | return 1; |
1269 | ent->data = (void *)0; | ||
1270 | ent->read_proc = proc_mf_dump_side; | ||
1271 | ent->write_proc = proc_mf_change_side; | ||
1272 | 1293 | ||
1273 | ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); | 1294 | ent = proc_create("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root, |
1295 | &mf_src_proc_fops); | ||
1274 | if (!ent) | 1296 | if (!ent) |
1275 | return 1; | 1297 | return 1; |
1276 | ent->data = (void *)0; | ||
1277 | ent->read_proc = proc_mf_dump_src; | ||
1278 | ent->write_proc = proc_mf_change_src; | ||
1279 | 1298 | ||
1280 | return 0; | 1299 | return 0; |
1281 | } | 1300 | } |