diff options
author | Ken Cox <jkc@redhat.com> | 2014-03-19 14:06:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-19 16:56:31 -0400 |
commit | 5e54c97dab0298cf5479bc1f2d3f42ef5605ce6e (patch) | |
tree | 2cad1122b5e503999c85dfb3ac98c5958658201d | |
parent | 097f4c19e838b5e8a5674b1ab9def7e20bc88e7a (diff) |
Staging: unisys: Remove FAIL macro
The FAIL macro ultimately includes a goto statement which is not allowed
in the kernel.
Signed-off-by: Ken Cox <jkc@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/unisys/include/timskmod.h | 12 | ||||
-rw-r--r-- | drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 97 | ||||
-rw-r--r-- | drivers/staging/unisys/visorchipset/file.c | 7 | ||||
-rw-r--r-- | drivers/staging/unisys/visorutil/procobjecttree.c | 52 |
4 files changed, 103 insertions, 65 deletions
diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index 1101ecd85fc6..3f8e6a2fd8c7 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h | |||
@@ -126,18 +126,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ | |||
126 | * @param x the value to return | 126 | * @param x the value to return |
127 | */ | 127 | */ |
128 | #define RETINT(x) do { rc = (x); RETTRACE(x); goto Away; } while (0) | 128 | #define RETINT(x) do { rc = (x); RETTRACE(x); goto Away; } while (0) |
129 | /** Given a typedef/struct/union and a member field name, | ||
130 | * return the number of bytes occupied by that field. | ||
131 | * @param TYPE the typedef name, or "struct xx" or "union xx" | ||
132 | * @param MEMBER the name of the member field whose size is to be determined | ||
133 | * @return the size of the field in bytes | ||
134 | */ | ||
135 | #define FAIL(msg, status) do { \ | ||
136 | ERRDRV("'%s'" \ | ||
137 | ": error (status=%d)\n", \ | ||
138 | msg, status); \ | ||
139 | RETINT(status); \ | ||
140 | } while (0) | ||
141 | /** Try to evaulate the provided expression, and do a RETINT(x) iff | 129 | /** Try to evaulate the provided expression, and do a RETINT(x) iff |
142 | * the expression evaluates to < 0. | 130 | * the expression evaluates to < 0. |
143 | * @param x the expression to try | 131 | * @param x the expression to try |
diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 99889fd2ea1e..8a200af3f0c8 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c | |||
@@ -57,8 +57,11 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, | |||
57 | void *rc = NULL; | 57 | void *rc = NULL; |
58 | 58 | ||
59 | p = kmalloc(sizeof(VISORCHANNEL), GFP_KERNEL|__GFP_NORETRY); | 59 | p = kmalloc(sizeof(VISORCHANNEL), GFP_KERNEL|__GFP_NORETRY); |
60 | if (p == NULL) | 60 | if (p == NULL) { |
61 | FAIL("allocation failed", 0); | 61 | ERRDRV("allocation failed: (status=0)\n"); |
62 | rc = NULL; | ||
63 | goto Away; | ||
64 | } | ||
62 | p->memregion = NULL; | 65 | p->memregion = NULL; |
63 | p->needs_lock = needs_lock; | 66 | p->needs_lock = needs_lock; |
64 | spin_lock_init(&p->insert_lock); | 67 | spin_lock_init(&p->insert_lock); |
@@ -73,19 +76,28 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, | |||
73 | visor_memregion_create_overlapped(parent->memregion, | 76 | visor_memregion_create_overlapped(parent->memregion, |
74 | off, | 77 | off, |
75 | sizeof(CHANNEL_HEADER)); | 78 | sizeof(CHANNEL_HEADER)); |
76 | if (p->memregion == NULL) | 79 | if (p->memregion == NULL) { |
77 | FAIL("visor_memregion_create failed", 0); | 80 | ERRDRV("visor_memregion_create failed failed: (status=0)\n"); |
81 | rc = NULL; | ||
82 | goto Away; | ||
83 | } | ||
78 | if (visor_memregion_read(p->memregion, 0, &p->chan_hdr, | 84 | if (visor_memregion_read(p->memregion, 0, &p->chan_hdr, |
79 | sizeof(CHANNEL_HEADER)) < 0) | 85 | sizeof(CHANNEL_HEADER)) < 0) { |
80 | FAIL("visor_memregion_read failed", 0); | 86 | ERRDRV("visor_memregion_read failed: (status=0)\n"); |
87 | rc = NULL; | ||
88 | goto Away; | ||
89 | } | ||
81 | if (channelBytes == 0) | 90 | if (channelBytes == 0) |
82 | /* we had better be a CLIENT of this channel */ | 91 | /* we had better be a CLIENT of this channel */ |
83 | channelBytes = (ulong) p->chan_hdr.Size; | 92 | channelBytes = (ulong) p->chan_hdr.Size; |
84 | if (STRUCTSEQUAL(guid, Guid0)) | 93 | if (STRUCTSEQUAL(guid, Guid0)) |
85 | /* we had better be a CLIENT of this channel */ | 94 | /* we had better be a CLIENT of this channel */ |
86 | guid = p->chan_hdr.Type; | 95 | guid = p->chan_hdr.Type; |
87 | if (visor_memregion_resize(p->memregion, channelBytes) < 0) | 96 | if (visor_memregion_resize(p->memregion, channelBytes) < 0) { |
88 | FAIL("visor_memregion_resize failed", 0); | 97 | ERRDRV("visor_memregion_resize failed: (status=0)\n"); |
98 | rc = NULL; | ||
99 | goto Away; | ||
100 | } | ||
89 | p->size = channelBytes; | 101 | p->size = channelBytes; |
90 | p->guid = guid; | 102 | p->guid = guid; |
91 | 103 | ||
@@ -300,8 +312,10 @@ sig_read_header(VISORCHANNEL *channel, U32 queue, | |||
300 | { | 312 | { |
301 | BOOL rc = FALSE; | 313 | BOOL rc = FALSE; |
302 | 314 | ||
303 | if (channel->chan_hdr.oChannelSpace < sizeof(CHANNEL_HEADER)) | 315 | if (channel->chan_hdr.oChannelSpace < sizeof(CHANNEL_HEADER)) { |
304 | FAIL("oChannelSpace too small", FALSE); | 316 | ERRDRV("oChannelSpace too small: (status=%d)\n", rc); |
317 | goto Away; | ||
318 | } | ||
305 | 319 | ||
306 | /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ | 320 | /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ |
307 | 321 | ||
@@ -310,7 +324,8 @@ sig_read_header(VISORCHANNEL *channel, U32 queue, | |||
310 | sig_hdr, sizeof(SIGNAL_QUEUE_HEADER)) < 0) { | 324 | sig_hdr, sizeof(SIGNAL_QUEUE_HEADER)) < 0) { |
311 | ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d", | 325 | ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d", |
312 | queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)); | 326 | queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)); |
313 | FAIL("visor_memregion_read of signal queue failed", FALSE); | 327 | ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", rc); |
328 | goto Away; | ||
314 | } | 329 | } |
315 | rc = TRUE; | 330 | rc = TRUE; |
316 | Away: | 331 | Away: |
@@ -327,14 +342,16 @@ sig_do_data(VISORCHANNEL *channel, U32 queue, | |||
327 | if (is_write) { | 342 | if (is_write) { |
328 | if (visor_memregion_write(channel->memregion, | 343 | if (visor_memregion_write(channel->memregion, |
329 | signal_data_offset, | 344 | signal_data_offset, |
330 | data, sig_hdr->SignalSize) < 0) | 345 | data, sig_hdr->SignalSize) < 0) { |
331 | FAIL("visor_memregion_write of signal data failed", | 346 | ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", rc); |
332 | FALSE); | 347 | goto Away; |
348 | } | ||
333 | } else { | 349 | } else { |
334 | if (visor_memregion_read(channel->memregion, signal_data_offset, | 350 | if (visor_memregion_read(channel->memregion, signal_data_offset, |
335 | data, sig_hdr->SignalSize) < 0) | 351 | data, sig_hdr->SignalSize) < 0) { |
336 | FAIL("visor_memregion_read of signal data failed", | 352 | ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", rc); |
337 | FALSE); | 353 | goto Away; |
354 | } | ||
338 | } | 355 | } |
339 | rc = TRUE; | 356 | rc = TRUE; |
340 | Away: | 357 | Away: |
@@ -395,19 +412,25 @@ visorchannel_signalremove(VISORCHANNEL *channel, U32 queue, void *msg) | |||
395 | goto Away; | 412 | goto Away; |
396 | } | 413 | } |
397 | sig_hdr.Tail = (sig_hdr.Tail + 1) % sig_hdr.MaxSignalSlots; | 414 | sig_hdr.Tail = (sig_hdr.Tail + 1) % sig_hdr.MaxSignalSlots; |
398 | if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.Tail, msg)) | 415 | if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.Tail, msg)) { |
399 | FAIL("sig_read_data failed", FALSE); | 416 | ERRDRV("sig_read_data failed: (status=%d)\n", rc); |
417 | goto Away; | ||
418 | } | ||
400 | sig_hdr.NumSignalsReceived++; | 419 | sig_hdr.NumSignalsReceived++; |
401 | 420 | ||
402 | /* For each data field in SIGNAL_QUEUE_HEADER that was modified, | 421 | /* For each data field in SIGNAL_QUEUE_HEADER that was modified, |
403 | * update host memory. | 422 | * update host memory. |
404 | */ | 423 | */ |
405 | MEMORYBARRIER; | 424 | MEMORYBARRIER; |
406 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail)) | 425 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail)) { |
407 | FAIL("visor_memregion_write of Tail failed", FALSE); | 426 | ERRDRV("visor_memregion_write of Tail failed: (status=%d)\n", |
408 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsReceived)) | 427 | rc); |
409 | FAIL("visor_memregion_write of NumSignalsReceived failed", | 428 | goto Away; |
410 | FALSE); | 429 | } |
430 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsReceived)) { | ||
431 | ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", rc); | ||
432 | goto Away; | ||
433 | } | ||
411 | rc = TRUE; | 434 | rc = TRUE; |
412 | Away: | 435 | Away: |
413 | if (channel->needs_lock) | 436 | if (channel->needs_lock) |
@@ -434,25 +457,33 @@ visorchannel_signalinsert(VISORCHANNEL *channel, U32 queue, void *msg) | |||
434 | sig_hdr.Head = ((sig_hdr.Head + 1) % sig_hdr.MaxSignalSlots); | 457 | sig_hdr.Head = ((sig_hdr.Head + 1) % sig_hdr.MaxSignalSlots); |
435 | if (sig_hdr.Head == sig_hdr.Tail) { | 458 | if (sig_hdr.Head == sig_hdr.Tail) { |
436 | sig_hdr.NumOverflows++; | 459 | sig_hdr.NumOverflows++; |
437 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumOverflows)) | 460 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumOverflows)) { |
438 | FAIL("visor_memregion_write of NumOverflows failed", | 461 | ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", rc); |
439 | FALSE); | 462 | goto Away; |
463 | } | ||
440 | rc = FALSE; | 464 | rc = FALSE; |
441 | goto Away; | 465 | goto Away; |
442 | } | 466 | } |
443 | 467 | ||
444 | if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.Head, msg)) | 468 | if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.Head, msg)) { |
445 | FAIL("sig_write_data failed", FALSE); | 469 | ERRDRV("sig_write_data failed: (status=%d)\n", rc); |
470 | goto Away; | ||
471 | } | ||
446 | sig_hdr.NumSignalsSent++; | 472 | sig_hdr.NumSignalsSent++; |
447 | 473 | ||
448 | /* For each data field in SIGNAL_QUEUE_HEADER that was modified, | 474 | /* For each data field in SIGNAL_QUEUE_HEADER that was modified, |
449 | * update host memory. | 475 | * update host memory. |
450 | */ | 476 | */ |
451 | MEMORYBARRIER; | 477 | MEMORYBARRIER; |
452 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head)) | 478 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head)) { |
453 | FAIL("visor_memregion_write of Head failed", FALSE); | 479 | ERRDRV("visor_memregion_write of Head failed: (status=%d)\n", |
454 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsSent)) | 480 | rc); |
455 | FAIL("visor_memregion_write of NumSignalsSent failed", FALSE); | 481 | goto Away; |
482 | } | ||
483 | if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsSent)) { | ||
484 | ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", rc); | ||
485 | goto Away; | ||
486 | } | ||
456 | rc = TRUE; | 487 | rc = TRUE; |
457 | Away: | 488 | Away: |
458 | if (channel->needs_lock) | 489 | if (channel->needs_lock) |
diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 7e8bc9824457..839a943a52c8 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c | |||
@@ -84,8 +84,11 @@ visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel) | |||
84 | Registered = TRUE; | 84 | Registered = TRUE; |
85 | INFODRV("Static major number %d registered\n", MAJOR(MajorDev)); | 85 | INFODRV("Static major number %d registered\n", MAJOR(MajorDev)); |
86 | } | 86 | } |
87 | if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0) | 87 | if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0) { |
88 | FAIL("failed to create char device", -1); | 88 | ERRDRV("failed to create char device: (status=-1)\n"); |
89 | rc = -1; | ||
90 | goto Away; | ||
91 | } | ||
89 | INFODRV("Registered char device for %s (major=%d)", | 92 | INFODRV("Registered char device for %s (major=%d)", |
90 | MYDRVNAME, MAJOR(MajorDev)); | 93 | MYDRVNAME, MAJOR(MajorDev)); |
91 | RETINT(0); | 94 | RETINT(0); |
diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c index 6a082b952066..67a19e1c7b02 100644 --- a/drivers/staging/unisys/visorutil/procobjecttree.c +++ b/drivers/staging/unisys/visorutil/procobjecttree.c | |||
@@ -136,13 +136,19 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot, | |||
136 | MYPROCTYPE *rc = NULL, *type = NULL; | 136 | MYPROCTYPE *rc = NULL, *type = NULL; |
137 | struct proc_dir_entry *parent = NULL; | 137 | struct proc_dir_entry *parent = NULL; |
138 | 138 | ||
139 | if (procDirRoot == NULL) | 139 | if (procDirRoot == NULL) { |
140 | FAIL("procDirRoot cannot be NULL!", 0); | 140 | ERRDRV("procDirRoot cannot be NULL!\n"); |
141 | if (name == NULL || name[0] == NULL) | 141 | goto Away; |
142 | FAIL("name must contain at least 1 node name!", 0); | 142 | } |
143 | if (name == NULL || name[0] == NULL) { | ||
144 | ERRDRV("name must contain at least 1 node name!\n"); | ||
145 | goto Away; | ||
146 | } | ||
143 | type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY); | 147 | type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY); |
144 | if (type == NULL) | 148 | if (type == NULL) { |
145 | FAIL("out of memory", 0); | 149 | ERRDRV("out of memory\n"); |
150 | goto Away; | ||
151 | } | ||
146 | type->name = name; | 152 | type->name = name; |
147 | type->propertyNames = propertyNames; | 153 | type->propertyNames = propertyNames; |
148 | type->nProperties = 0; | 154 | type->nProperties = 0; |
@@ -157,8 +163,10 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot, | |||
157 | type->procDirs = kzalloc((type->nNames + 1) * | 163 | type->procDirs = kzalloc((type->nNames + 1) * |
158 | sizeof(struct proc_dir_entry *), | 164 | sizeof(struct proc_dir_entry *), |
159 | GFP_KERNEL | __GFP_NORETRY); | 165 | GFP_KERNEL | __GFP_NORETRY); |
160 | if (type->procDirs == NULL) | 166 | if (type->procDirs == NULL) { |
161 | FAIL("out of memory", 0); | 167 | ERRDRV("out of memory\n"); |
168 | goto Away; | ||
169 | } | ||
162 | parent = procDirRoot; | 170 | parent = procDirRoot; |
163 | for (i = 0; i < type->nNames; i++) { | 171 | for (i = 0; i < type->nNames; i++) { |
164 | type->procDirs[i] = createProcDir(type->name[i], parent); | 172 | type->procDirs[i] = createProcDir(type->name[i], parent); |
@@ -215,11 +223,15 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, | |||
215 | MYPROCOBJECT *obj = NULL, *rc = NULL; | 223 | MYPROCOBJECT *obj = NULL, *rc = NULL; |
216 | int i = 0; | 224 | int i = 0; |
217 | 225 | ||
218 | if (type == NULL) | 226 | if (type == NULL) { |
219 | FAIL("type cannot be NULL", 0); | 227 | ERRDRV("type cannot be NULL\n"); |
228 | goto Away; | ||
229 | } | ||
220 | obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY); | 230 | obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY); |
221 | if (obj == NULL) | 231 | if (obj == NULL) { |
222 | FAIL("out of memory", 0); | 232 | ERRDRV("out of memory\n"); |
233 | goto Away; | ||
234 | } | ||
223 | obj->type = type; | 235 | obj->type = type; |
224 | obj->context = context; | 236 | obj->context = context; |
225 | if (name == NULL) { | 237 | if (name == NULL) { |
@@ -230,25 +242,29 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, | |||
230 | obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY); | 242 | obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY); |
231 | if (obj->name == NULL) { | 243 | if (obj->name == NULL) { |
232 | obj->namesize = 0; | 244 | obj->namesize = 0; |
233 | FAIL("out of memory", 0); | 245 | ERRDRV("out of memory\n"); |
246 | goto Away; | ||
234 | } | 247 | } |
235 | strcpy(obj->name, name); | 248 | strcpy(obj->name, name); |
236 | obj->procDir = createProcDir(obj->name, type->procDir); | 249 | obj->procDir = createProcDir(obj->name, type->procDir); |
237 | if (obj->procDir == NULL) { | 250 | if (obj->procDir == NULL) { |
238 | rc = NULL; | ||
239 | goto Away; | 251 | goto Away; |
240 | } | 252 | } |
241 | } | 253 | } |
242 | obj->procDirPropertyContexts = | 254 | obj->procDirPropertyContexts = |
243 | kzalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT), | 255 | kzalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT), |
244 | GFP_KERNEL | __GFP_NORETRY); | 256 | GFP_KERNEL | __GFP_NORETRY); |
245 | if (obj->procDirPropertyContexts == NULL) | 257 | if (obj->procDirPropertyContexts == NULL) { |
246 | FAIL("out of memory", 0); | 258 | ERRDRV("out of memory\n"); |
259 | goto Away; | ||
260 | } | ||
247 | obj->procDirProperties = | 261 | obj->procDirProperties = |
248 | kzalloc((type->nProperties + 1) * sizeof(struct proc_dir_entry *), | 262 | kzalloc((type->nProperties + 1) * sizeof(struct proc_dir_entry *), |
249 | GFP_KERNEL | __GFP_NORETRY); | 263 | GFP_KERNEL | __GFP_NORETRY); |
250 | if (obj->procDirProperties == NULL) | 264 | if (obj->procDirProperties == NULL) { |
251 | FAIL("out of memory", 0); | 265 | ERRDRV("out of memory\n"); |
266 | goto Away; | ||
267 | } | ||
252 | for (i = 0; i < type->nProperties; i++) { | 268 | for (i = 0; i < type->nProperties; i++) { |
253 | obj->procDirPropertyContexts[i].procObject = obj; | 269 | obj->procDirPropertyContexts[i].procObject = obj; |
254 | obj->procDirPropertyContexts[i].propertyIndex = i; | 270 | obj->procDirPropertyContexts[i].propertyIndex = i; |