aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2008-04-17 01:46:31 -0400
committerHeiko Carstens <heiko.carstens@de.ibm.com>2008-04-17 01:47:07 -0400
commitca68305bf3c76c4a7cd1c77d5423219f39164df8 (patch)
treedc73a7d9eb53a47d16690e8106a097aa8f601866
parent9e74a6b8983c2653dd2a6f51e634efa281e95d59 (diff)
[S390] Remove code duplication from monreader / dcssblk.
Move the function that prints the segment warning messages found in the monreader driver and the dcssblk driver to the extmem base code. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
-rw-r--r--arch/s390/mm/extmem.c67
-rw-r--r--drivers/s390/block/dcssblk.c53
-rw-r--r--drivers/s390/char/monreader.c54
-rw-r--r--include/asm-s390/extmem.h11
4 files changed, 61 insertions, 124 deletions
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
index 880b0ebf894b..ed2af0a3303b 100644
--- a/arch/s390/mm/extmem.c
+++ b/arch/s390/mm/extmem.c
@@ -289,22 +289,8 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
289 289
290 rc = add_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1); 290 rc = add_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1);
291 291
292 switch (rc) { 292 if (rc)
293 case 0:
294 break;
295 case -ENOSPC:
296 PRINT_WARN("segment_load: not loading segment %s - overlaps "
297 "storage/segment\n", name);
298 goto out_free;
299 case -ERANGE:
300 PRINT_WARN("segment_load: not loading segment %s - exceeds "
301 "kernel mapping range\n", name);
302 goto out_free;
303 default:
304 PRINT_WARN("segment_load: not loading segment %s (rc: %d)\n",
305 name, rc);
306 goto out_free; 293 goto out_free;
307 }
308 294
309 seg->res = kzalloc(sizeof(struct resource), GFP_KERNEL); 295 seg->res = kzalloc(sizeof(struct resource), GFP_KERNEL);
310 if (seg->res == NULL) { 296 if (seg->res == NULL) {
@@ -582,8 +568,59 @@ out:
582 mutex_unlock(&dcss_lock); 568 mutex_unlock(&dcss_lock);
583} 569}
584 570
571/*
572 * print appropriate error message for segment_load()/segment_type()
573 * return code
574 */
575void segment_warning(int rc, char *seg_name)
576{
577 switch (rc) {
578 case -ENOENT:
579 PRINT_WARN("cannot load/query segment %s, "
580 "does not exist\n", seg_name);
581 break;
582 case -ENOSYS:
583 PRINT_WARN("cannot load/query segment %s, "
584 "not running on VM\n", seg_name);
585 break;
586 case -EIO:
587 PRINT_WARN("cannot load/query segment %s, "
588 "hardware error\n", seg_name);
589 break;
590 case -ENOTSUPP:
591 PRINT_WARN("cannot load/query segment %s, "
592 "is a multi-part segment\n", seg_name);
593 break;
594 case -ENOSPC:
595 PRINT_WARN("cannot load/query segment %s, "
596 "overlaps with storage\n", seg_name);
597 break;
598 case -EBUSY:
599 PRINT_WARN("cannot load/query segment %s, "
600 "overlaps with already loaded dcss\n", seg_name);
601 break;
602 case -EPERM:
603 PRINT_WARN("cannot load/query segment %s, "
604 "already loaded in incompatible mode\n", seg_name);
605 break;
606 case -ENOMEM:
607 PRINT_WARN("cannot load/query segment %s, "
608 "out of memory\n", seg_name);
609 break;
610 case -ERANGE:
611 PRINT_WARN("cannot load/query segment %s, "
612 "exceeds kernel mapping range\n", seg_name);
613 break;
614 default:
615 PRINT_WARN("cannot load/query segment %s, "
616 "return value %i\n", seg_name, rc);
617 break;
618 }
619}
620
585EXPORT_SYMBOL(segment_load); 621EXPORT_SYMBOL(segment_load);
586EXPORT_SYMBOL(segment_unload); 622EXPORT_SYMBOL(segment_unload);
587EXPORT_SYMBOL(segment_save); 623EXPORT_SYMBOL(segment_save);
588EXPORT_SYMBOL(segment_type); 624EXPORT_SYMBOL(segment_type);
589EXPORT_SYMBOL(segment_modify_shared); 625EXPORT_SYMBOL(segment_modify_shared);
626EXPORT_SYMBOL(segment_warning);
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index e6c94dbfdeaa..04787eab1016 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -142,57 +142,6 @@ dcssblk_get_device_by_name(char *name)
142 return NULL; 142 return NULL;
143} 143}
144 144
145/*
146 * print appropriate error message for segment_load()/segment_type()
147 * return code
148 */
149static void
150dcssblk_segment_warn(int rc, char* seg_name)
151{
152 switch (rc) {
153 case -ENOENT:
154 PRINT_WARN("cannot load/query segment %s, does not exist\n",
155 seg_name);
156 break;
157 case -ENOSYS:
158 PRINT_WARN("cannot load/query segment %s, not running on VM\n",
159 seg_name);
160 break;
161 case -EIO:
162 PRINT_WARN("cannot load/query segment %s, hardware error\n",
163 seg_name);
164 break;
165 case -ENOTSUPP:
166 PRINT_WARN("cannot load/query segment %s, is a multi-part "
167 "segment\n", seg_name);
168 break;
169 case -ENOSPC:
170 PRINT_WARN("cannot load/query segment %s, overlaps with "
171 "storage\n", seg_name);
172 break;
173 case -EBUSY:
174 PRINT_WARN("cannot load/query segment %s, overlaps with "
175 "already loaded dcss\n", seg_name);
176 break;
177 case -EPERM:
178 PRINT_WARN("cannot load/query segment %s, already loaded in "
179 "incompatible mode\n", seg_name);
180 break;
181 case -ENOMEM:
182 PRINT_WARN("cannot load/query segment %s, out of memory\n",
183 seg_name);
184 break;
185 case -ERANGE:
186 PRINT_WARN("cannot load/query segment %s, exceeds kernel "
187 "mapping range\n", seg_name);
188 break;
189 default:
190 PRINT_WARN("cannot load/query segment %s, return value %i\n",
191 seg_name, rc);
192 break;
193 }
194}
195
196static void dcssblk_unregister_callback(struct device *dev) 145static void dcssblk_unregister_callback(struct device *dev)
197{ 146{
198 device_unregister(dev); 147 device_unregister(dev);
@@ -423,7 +372,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
423 rc = segment_load(local_buf, SEGMENT_SHARED, 372 rc = segment_load(local_buf, SEGMENT_SHARED,
424 &dev_info->start, &dev_info->end); 373 &dev_info->start, &dev_info->end);
425 if (rc < 0) { 374 if (rc < 0) {
426 dcssblk_segment_warn(rc, dev_info->segment_name); 375 segment_warning(rc, dev_info->segment_name);
427 goto dealloc_gendisk; 376 goto dealloc_gendisk;
428 } 377 }
429 seg_byte_size = (dev_info->end - dev_info->start + 1); 378 seg_byte_size = (dev_info->end - dev_info->start + 1);
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 67009bfa093e..1e1f50655bbf 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -111,56 +111,6 @@ static void dcss_mkname(char *ascii_name, char *ebcdic_name)
111 ASCEBC(ebcdic_name, 8); 111 ASCEBC(ebcdic_name, 8);
112} 112}
113 113
114/*
115 * print appropriate error message for segment_load()/segment_type()
116 * return code
117 */
118static void mon_segment_warn(int rc, char* seg_name)
119{
120 switch (rc) {
121 case -ENOENT:
122 P_WARNING("cannot load/query segment %s, does not exist\n",
123 seg_name);
124 break;
125 case -ENOSYS:
126 P_WARNING("cannot load/query segment %s, not running on VM\n",
127 seg_name);
128 break;
129 case -EIO:
130 P_WARNING("cannot load/query segment %s, hardware error\n",
131 seg_name);
132 break;
133 case -ENOTSUPP:
134 P_WARNING("cannot load/query segment %s, is a multi-part "
135 "segment\n", seg_name);
136 break;
137 case -ENOSPC:
138 P_WARNING("cannot load/query segment %s, overlaps with "
139 "storage\n", seg_name);
140 break;
141 case -EBUSY:
142 P_WARNING("cannot load/query segment %s, overlaps with "
143 "already loaded dcss\n", seg_name);
144 break;
145 case -EPERM:
146 P_WARNING("cannot load/query segment %s, already loaded in "
147 "incompatible mode\n", seg_name);
148 break;
149 case -ENOMEM:
150 P_WARNING("cannot load/query segment %s, out of memory\n",
151 seg_name);
152 break;
153 case -ERANGE:
154 P_WARNING("cannot load/query segment %s, exceeds kernel "
155 "mapping range\n", seg_name);
156 break;
157 default:
158 P_WARNING("cannot load/query segment %s, return value %i\n",
159 seg_name, rc);
160 break;
161 }
162}
163
164static inline unsigned long mon_mca_start(struct mon_msg *monmsg) 114static inline unsigned long mon_mca_start(struct mon_msg *monmsg)
165{ 115{
166 return *(u32 *) &monmsg->msg.rmmsg; 116 return *(u32 *) &monmsg->msg.rmmsg;
@@ -585,7 +535,7 @@ static int __init mon_init(void)
585 535
586 rc = segment_type(mon_dcss_name); 536 rc = segment_type(mon_dcss_name);
587 if (rc < 0) { 537 if (rc < 0) {
588 mon_segment_warn(rc, mon_dcss_name); 538 segment_warning(rc, mon_dcss_name);
589 goto out_iucv; 539 goto out_iucv;
590 } 540 }
591 if (rc != SEG_TYPE_SC) { 541 if (rc != SEG_TYPE_SC) {
@@ -598,7 +548,7 @@ static int __init mon_init(void)
598 rc = segment_load(mon_dcss_name, SEGMENT_SHARED, 548 rc = segment_load(mon_dcss_name, SEGMENT_SHARED,
599 &mon_dcss_start, &mon_dcss_end); 549 &mon_dcss_start, &mon_dcss_end);
600 if (rc < 0) { 550 if (rc < 0) {
601 mon_segment_warn(rc, mon_dcss_name); 551 segment_warning(rc, mon_dcss_name);
602 rc = -EINVAL; 552 rc = -EINVAL;
603 goto out_iucv; 553 goto out_iucv;
604 } 554 }
diff --git a/include/asm-s390/extmem.h b/include/asm-s390/extmem.h
index c8802c934b74..33837d756184 100644
--- a/include/asm-s390/extmem.h
+++ b/include/asm-s390/extmem.h
@@ -22,11 +22,12 @@
22#define SEGMENT_SHARED 0 22#define SEGMENT_SHARED 0
23#define SEGMENT_EXCLUSIVE 1 23#define SEGMENT_EXCLUSIVE 1
24 24
25extern int segment_load (char *name,int segtype,unsigned long *addr,unsigned long *length); 25int segment_load (char *name, int segtype, unsigned long *addr, unsigned long *length);
26extern void segment_unload(char *name); 26void segment_unload(char *name);
27extern void segment_save(char *name); 27void segment_save(char *name);
28extern int segment_type (char* name); 28int segment_type (char* name);
29extern int segment_modify_shared (char *name, int do_nonshared); 29int segment_modify_shared (char *name, int do_nonshared);
30void segment_warning(int rc, char *seg_name);
30 31
31#endif 32#endif
32#endif 33#endif