aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parisc
diff options
context:
space:
mode:
authorKyle McMartin <kyle@parisc-linux.org>2006-02-05 22:37:53 -0500
committerKyle McMartin <kyle@duet.int.mcmartin.ca>2006-02-08 22:56:16 -0500
commitf823bcae2b9f194cfc164b8cbb87d71695dec563 (patch)
tree7a6d5e8c65069c29539e8edc7c0117176b13a532 /drivers/parisc
parent0bdd340c092b0936f78a54bdbd3927463ed4fca3 (diff)
[PARISC] Convert ccio-dma.c to use seq_file
Gut ccio-dma.c of the ugly proc append and snprintf cruft and just use seq_printf instead. Tested on a K-class. Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Diffstat (limited to 'drivers/parisc')
-rw-r--r--drivers/parisc/ccio-dma.c160
1 files changed, 74 insertions, 86 deletions
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index f46e8438e0d2..93f8a8fa8890 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -40,6 +40,8 @@
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/pci.h> 41#include <linux/pci.h>
42#include <linux/reboot.h> 42#include <linux/reboot.h>
43#include <linux/proc_fs.h>
44#include <linux/seq_file.h>
43 45
44#include <asm/byteorder.h> 46#include <asm/byteorder.h>
45#include <asm/cache.h> /* for L1_CACHE_BYTES */ 47#include <asm/cache.h> /* for L1_CACHE_BYTES */
@@ -1019,62 +1021,33 @@ static struct hppa_dma_ops ccio_ops = {
1019}; 1021};
1020 1022
1021#ifdef CONFIG_PROC_FS 1023#ifdef CONFIG_PROC_FS
1022static int proc_append(char *src, int len, char **dst, off_t *offset, int *max) 1024static int ccio_proc_info(struct seq_file *m, void *p)
1023{
1024 if (len < *offset) {
1025 *offset -= len;
1026 return 0;
1027 }
1028 if (*offset > 0) {
1029 src += *offset;
1030 len -= *offset;
1031 *offset = 0;
1032 }
1033 if (len > *max) {
1034 len = *max;
1035 }
1036 memcpy(*dst, src, len);
1037 *dst += len;
1038 *max -= len;
1039 return (*max == 0);
1040}
1041
1042static int ccio_proc_info(char *buf, char **start, off_t offset, int count,
1043 int *eof, void *data)
1044{ 1025{
1045 int max = count; 1026 int len = 0;
1046 char tmp[80]; /* width of an ANSI-standard terminal */
1047 struct ioc *ioc = ioc_list; 1027 struct ioc *ioc = ioc_list;
1048 1028
1049 while (ioc != NULL) { 1029 while (ioc != NULL) {
1050 unsigned int total_pages = ioc->res_size << 3; 1030 unsigned int total_pages = ioc->res_size << 3;
1051 unsigned long avg = 0, min, max; 1031 unsigned long avg = 0, min, max;
1052 int j, len; 1032 int j;
1053 1033
1054 len = sprintf(tmp, "%s\n", ioc->name); 1034 len += seq_printf(m, "%s\n", ioc->name);
1055 if (proc_append(tmp, len, &buf, &offset, &count))
1056 break;
1057 1035
1058 len = sprintf(tmp, "Cujo 2.0 bug : %s\n", 1036 len += seq_printf(m, "Cujo 2.0 bug : %s\n",
1059 (ioc->cujo20_bug ? "yes" : "no")); 1037 (ioc->cujo20_bug ? "yes" : "no"));
1060 if (proc_append(tmp, len, &buf, &offset, &count))
1061 break;
1062 1038
1063 len = sprintf(tmp, "IO PDIR size : %d bytes (%d entries)\n", 1039 len += seq_printf(m, "IO PDIR size : %d bytes (%d entries)\n",
1064 total_pages * 8, total_pages); 1040 total_pages * 8, total_pages);
1065 if (proc_append(tmp, len, &buf, &offset, &count)) 1041
1066 break;
1067#ifdef CCIO_MAP_STATS 1042#ifdef CCIO_MAP_STATS
1068 len = sprintf(tmp, "IO PDIR entries : %ld free %ld used (%d%%)\n", 1043 len += seq_printf(m, "IO PDIR entries : %ld free %ld used (%d%%)\n",
1069 total_pages - ioc->used_pages, ioc->used_pages, 1044 total_pages - ioc->used_pages, ioc->used_pages,
1070 (int)(ioc->used_pages * 100 / total_pages)); 1045 (int)(ioc->used_pages * 100 / total_pages));
1071 if (proc_append(tmp, len, &buf, &offset, &count))
1072 break;
1073#endif 1046#endif
1074 len = sprintf(tmp, "Resource bitmap : %d bytes (%d pages)\n", 1047
1075 ioc->res_size, total_pages); 1048 len += seq_printf(m, "Resource bitmap : %d bytes (%d pages)\n",
1076 if (proc_append(tmp, len, &buf, &offset, &count)) 1049 ioc->res_size, total_pages);
1077 break; 1050
1078#ifdef CCIO_SEARCH_TIME 1051#ifdef CCIO_SEARCH_TIME
1079 min = max = ioc->avg_search[0]; 1052 min = max = ioc->avg_search[0];
1080 for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) { 1053 for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) {
@@ -1085,70 +1058,83 @@ static int ccio_proc_info(char *buf, char **start, off_t offset, int count,
1085 min = ioc->avg_search[j]; 1058 min = ioc->avg_search[j];
1086 } 1059 }
1087 avg /= CCIO_SEARCH_SAMPLE; 1060 avg /= CCIO_SEARCH_SAMPLE;
1088 len = sprintf(tmp, " Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n", 1061 len += seq_printf(m, " Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n",
1089 min, avg, max); 1062 min, avg, max);
1090 if (proc_append(tmp, len, &buf, &offset, &count))
1091 break;
1092#endif 1063#endif
1093#ifdef CCIO_MAP_STATS 1064#ifdef CCIO_MAP_STATS
1094 len = sprintf(tmp, "pci_map_single(): %8ld calls %8ld pages (avg %d/1000)\n", 1065 len += seq_printf(m, "pci_map_single(): %8ld calls %8ld pages (avg %d/1000)\n",
1095 ioc->msingle_calls, ioc->msingle_pages, 1066 ioc->msingle_calls, ioc->msingle_pages,
1096 (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls)); 1067 (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls));
1097 if (proc_append(tmp, len, &buf, &offset, &count))
1098 break;
1099
1100 1068
1101 /* KLUGE - unmap_sg calls unmap_single for each mapped page */ 1069 /* KLUGE - unmap_sg calls unmap_single for each mapped page */
1102 min = ioc->usingle_calls - ioc->usg_calls; 1070 min = ioc->usingle_calls - ioc->usg_calls;
1103 max = ioc->usingle_pages - ioc->usg_pages; 1071 max = ioc->usingle_pages - ioc->usg_pages;
1104 len = sprintf(tmp, "pci_unmap_single: %8ld calls %8ld pages (avg %d/1000)\n", 1072 len += seq_printf(m, "pci_unmap_single: %8ld calls %8ld pages (avg %d/1000)\n",
1105 min, max, (int)((max * 1000)/min)); 1073 min, max, (int)((max * 1000)/min));
1106 if (proc_append(tmp, len, &buf, &offset, &count))
1107 break;
1108 1074
1109 len = sprintf(tmp, "pci_map_sg() : %8ld calls %8ld pages (avg %d/1000)\n", 1075 len += seq_printf(m, "pci_map_sg() : %8ld calls %8ld pages (avg %d/1000)\n",
1110 ioc->msg_calls, ioc->msg_pages, 1076 ioc->msg_calls, ioc->msg_pages,
1111 (int)((ioc->msg_pages * 1000)/ioc->msg_calls)); 1077 (int)((ioc->msg_pages * 1000)/ioc->msg_calls));
1112 if (proc_append(tmp, len, &buf, &offset, &count)) 1078
1113 break; 1079 len += seq_printf(m, "pci_unmap_sg() : %8ld calls %8ld pages (avg %d/1000)\n\n\n",
1114 len = sprintf(tmp, "pci_unmap_sg() : %8ld calls %8ld pages (avg %d/1000)\n\n\n", 1080 ioc->usg_calls, ioc->usg_pages,
1115 ioc->usg_calls, ioc->usg_pages, 1081 (int)((ioc->usg_pages * 1000)/ioc->usg_calls));
1116 (int)((ioc->usg_pages * 1000)/ioc->usg_calls));
1117 if (proc_append(tmp, len, &buf, &offset, &count))
1118 break;
1119#endif /* CCIO_MAP_STATS */ 1082#endif /* CCIO_MAP_STATS */
1083
1120 ioc = ioc->next; 1084 ioc = ioc->next;
1121 } 1085 }
1122 1086
1123 if (count == 0) { 1087 return 0;
1124 *eof = 1; 1088}
1125 } 1089
1126 return (max - count); 1090static int ccio_proc_info_open(struct inode *inode, struct file *file)
1091{
1092 return single_open(file, &ccio_proc_info, NULL);
1127} 1093}
1128 1094
1129static int ccio_resource_map(char *buf, char **start, off_t offset, int len, 1095static struct file_operations ccio_proc_info_fops = {
1130 int *eof, void *data) 1096 .owner = THIS_MODULE,
1097 .open = ccio_proc_info_open,
1098 .read = seq_read,
1099 .llseek = seq_lseek,
1100 .release = single_release,
1101};
1102
1103static int ccio_proc_bitmap_info(struct seq_file *m, void *p)
1131{ 1104{
1105 int len = 0;
1132 struct ioc *ioc = ioc_list; 1106 struct ioc *ioc = ioc_list;
1133 1107
1134 buf[0] = '\0';
1135 while (ioc != NULL) { 1108 while (ioc != NULL) {
1136 u32 *res_ptr = (u32 *)ioc->res_map; 1109 u32 *res_ptr = (u32 *)ioc->res_map;
1137 int j; 1110 int j;
1138 1111
1139 for (j = 0; j < (ioc->res_size / sizeof(u32)); j++) { 1112 for (j = 0; j < (ioc->res_size / sizeof(u32)); j++) {
1140 if ((j & 7) == 0) 1113 if ((j & 7) == 0)
1141 strcat(buf,"\n "); 1114 len += seq_puts(m, "\n ");
1142 sprintf(buf, "%s %08x", buf, *res_ptr); 1115 len += seq_printf(m, "%08x", *res_ptr);
1143 res_ptr++; 1116 res_ptr++;
1144 } 1117 }
1145 strcat(buf, "\n\n"); 1118 len += seq_puts(m, "\n\n");
1146 ioc = ioc->next; 1119 ioc = ioc->next;
1147 break; /* XXX - remove me */ 1120 break; /* XXX - remove me */
1148 } 1121 }
1149 1122
1150 return strlen(buf); 1123 return 0;
1151} 1124}
1125
1126static int ccio_proc_bitmap_open(struct inode *inode, struct file *file)
1127{
1128 return single_open(file, &ccio_proc_bitmap_info, NULL);
1129}
1130
1131static struct file_operations ccio_proc_bitmap_fops = {
1132 .owner = THIS_MODULE,
1133 .open = ccio_proc_bitmap_open,
1134 .read = seq_read,
1135 .llseek = seq_lseek,
1136 .release = single_release,
1137};
1152#endif 1138#endif
1153 1139
1154/** 1140/**
@@ -1556,6 +1542,7 @@ static int ccio_probe(struct parisc_device *dev)
1556{ 1542{
1557 int i; 1543 int i;
1558 struct ioc *ioc, **ioc_p = &ioc_list; 1544 struct ioc *ioc, **ioc_p = &ioc_list;
1545 struct proc_dir_entry *info_entry, *bitmap_entry;
1559 1546
1560 ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL); 1547 ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
1561 if (ioc == NULL) { 1548 if (ioc == NULL) {
@@ -1583,13 +1570,14 @@ static int ccio_probe(struct parisc_device *dev)
1583 BUG_ON(dev->dev.platform_data == NULL); 1570 BUG_ON(dev->dev.platform_data == NULL);
1584 HBA_DATA(dev->dev.platform_data)->iommu = ioc; 1571 HBA_DATA(dev->dev.platform_data)->iommu = ioc;
1585 1572
1586
1587 if (ioc_count == 0) { 1573 if (ioc_count == 0) {
1588 /* FIXME: Create separate entries for each ioc */ 1574 info_entry = create_proc_entry(MODULE_NAME, 0, proc_runway_root);
1589 create_proc_read_entry(MODULE_NAME, S_IRWXU, proc_runway_root, 1575 if (info_entry)
1590 ccio_proc_info, NULL); 1576 info_entry->proc_fops = &ccio_proc_info_fops;
1591 create_proc_read_entry(MODULE_NAME"-bitmap", S_IRWXU, 1577
1592 proc_runway_root, ccio_resource_map, NULL); 1578 bitmap_entry = create_proc_entry(MODULE_NAME"-bitmap", 0, proc_runway_root);
1579 if (bitmap_entry)
1580 bitmap_entry->proc_fops = &ccio_proc_bitmap_fops;
1593 } 1581 }
1594 1582
1595 ioc_count++; 1583 ioc_count++;