aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Cox <jkc@redhat.com>2014-03-19 14:06:19 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-19 16:55:40 -0400
commit9f8d0e8bac8c74706b698dedd8ce307395091508 (patch)
treea1f682ab2f165e094ab065fc840ade3bb067ad38
parent316d363d680131eb8aef89d1a3b5744f71a504f6 (diff)
Staging: unisys: Cleanup macros to get rid of goto statements
Remove the following macros: TRY CHKFD CHKDD CHKFDX CHKDDX ADDPROCLINE TRY_WPOSTCODE_1 TRY_WPOSTCODE_2 FAIL_WPOSTCODE_2 FAIL_WPOSTCODE_3 Part of a series to get rid of goto statements embedded in macros. I'm breaking this up into a series of smaller patches for easier review. The later patches in the series will actually remove the goto statements. 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.h83
-rw-r--r--drivers/staging/unisys/visorchipset/visorchipset_main.c27
2 files changed, 18 insertions, 92 deletions
diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h
index c4262ab2cac3..413a3673772d 100644
--- a/drivers/staging/unisys/include/timskmod.h
+++ b/drivers/staging/unisys/include/timskmod.h
@@ -155,44 +155,10 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */
155 POSTCODE_LINUX_2(EVENT_PC, DIAG_SEVERITY_ERR); \ 155 POSTCODE_LINUX_2(EVENT_PC, DIAG_SEVERITY_ERR); \
156 RETINT(status); \ 156 RETINT(status); \
157 } while (0) 157 } while (0)
158#define FAIL_WPOSTCODE_2(msg, status, EVENT_PC, pcval32bit) do { \
159 ERRDRV("'%s'" \
160 ": error (status=%d)\n", \
161 msg, status); \
162 POSTCODE_LINUX_3(EVENT_PC, pcval32bit, DIAG_SEVERITY_ERR); \
163 RETINT(status); \
164 } while (0)
165#define FAIL_WPOSTCODE_3(msg, status, EVENT_PC, pcval16bit1, pcval16bit2) \
166 do { \
167 ERRDRV("'%s'" \
168 ": error (status=%d)\n", \
169 msg, status); \
170 POSTCODE_LINUX_4(EVENT_PC, pcval16bit1, pcval16bit2, \
171 DIAG_SEVERITY_ERR); \
172 RETINT(status); \
173 } while (0)
174/** Try to evaulate the provided expression, and do a RETINT(x) iff 158/** Try to evaulate the provided expression, and do a RETINT(x) iff
175 * the expression evaluates to < 0. 159 * the expression evaluates to < 0.
176 * @param x the expression to try 160 * @param x the expression to try
177 */ 161 */
178#define TRY(x) do { int status = (x); \
179 if (status < 0) \
180 FAIL(__stringify(x), status); \
181 } while (0)
182
183#define TRY_WPOSTCODE_1(x, EVENT_PC) do { \
184 int status = (x); \
185 if (status < 0) \
186 FAIL_WPOSTCODE_1(__stringify(x), status, EVENT_PC); \
187 } while (0)
188
189#define TRY_WPOSTCODE_2(x, EVENT_PC, pcval32bit) do { \
190 int status = (x); \
191 if (status < 0) \
192 FAIL_WPOSTCODE_2(__stringify(x), status, EVENT_PC, \
193 pcval32bit); \
194 } while (0)
195
196#define ASSERT(cond) \ 162#define ASSERT(cond) \
197 do { if (!(cond)) \ 163 do { if (!(cond)) \
198 HUHDRV("ASSERT failed - %s", \ 164 HUHDRV("ASSERT failed - %s", \
@@ -237,19 +203,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */
237 203
238/* @} */ 204/* @} */
239 205
240/** Used to add a single line to the /proc filesystem buffer */
241#define ADDPROCLINE(buf, bufsize, line, linelen, totallen) \
242 { \
243 if ((totallen) + (linelen) >= bufsize) \
244 RETINT(totallen); \
245 if (linelen > 0) { \
246 strcat(buf, line); \
247 totallen += linelen; \
248 } \
249 }
250
251
252
253/** Verifies the consistency of your PRIVATEDEVICEDATA structure using 206/** Verifies the consistency of your PRIVATEDEVICEDATA structure using
254 * conventional "signature" fields: 207 * conventional "signature" fields:
255 * <p> 208 * <p>
@@ -272,42 +225,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */
272 ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \ 225 ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \
273 ((fd)->sig2 == fd)) 226 ((fd)->sig2 == fd))
274 227
275/** Verifies the consistency of a PRIVATEDEVICEDATA structure and reacts
276 * if necessary
277 */
278#define CHKDDX(dd, x) ( \
279 if (!DDLOOKSVALID((dd))) { \
280 PRINTKDRV("bad device structure"); \
281 RETINT(x); \
282 })
283
284/** Verifies the consistency of a PRIVATEDEVICEDATA structure and reacts
285 * if necessary
286 */
287#define CHKDD(dd) ( \
288 if (!DDLOOKSVALID(dd)) { \
289 PRINTKDRV("bad device structure"); \
290 RETVOID; \
291 })
292
293/** Verifies the consistency of a PRIVATEFILEDATA structure and reacts
294 * if necessary
295 */
296#define CHKFDX(fd, x) ( \
297 if (!FDLOOKSVALID(fd)) { \
298 PRINTKDRV("bad file structure"); \
299 RETINT(x); \
300 })
301
302/** Verifies the consistency of a PRIVATEFILEDATA structure and reacts
303 * if necessary
304 */
305#define CHKFD(fd) ( \
306 if (!FDLOOKSVALID(fd)) { \
307 PRINTKDRV("bad file structure"); \
308 RETVOID; \
309 })
310
311/** Locks dd->lockDev if you havn't already locked it */ 228/** Locks dd->lockDev if you havn't already locked it */
312#define LOCKDEV(dd) \ 229#define LOCKDEV(dd) \
313 { \ 230 { \
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index e58b136d65e6..b0f97db2645e 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -2684,14 +2684,21 @@ visorchipset_init(void)
2684 memset(&LiveDump_info, 0, sizeof(LiveDump_info)); 2684 memset(&LiveDump_info, 0, sizeof(LiveDump_info));
2685 atomic_set(&LiveDump_info.buffers_in_use, 0); 2685 atomic_set(&LiveDump_info.buffers_in_use, 0);
2686 2686
2687 if (visorchipset_testvnic) 2687 if (visorchipset_testvnic) {
2688 FAIL_WPOSTCODE_2("testvnic option no longer supported", x, 2688 ERRDRV("testvnic option no longer supported: (status = %d)\n",
2689 CHIPSET_INIT_FAILURE_PC, x); 2689 x);
2690 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
2691 rc = x;
2692 goto Away;
2693 }
2690 2694
2691 controlvm_init(); 2695 controlvm_init();
2692 MajorDev = MKDEV(visorchipset_major, 0); 2696 MajorDev = MKDEV(visorchipset_major, 0);
2693 TRY_WPOSTCODE_1(visorchipset_file_init(MajorDev, &ControlVm_channel), 2697 rc = visorchipset_file_init(MajorDev, &ControlVm_channel);
2694 CHIPSET_INIT_FAILURE_PC); 2698 if (rc < 0)
2699 FAIL_WPOSTCODE_1("visorchipset_file_init(MajorDev, &ControlVm_channel)",
2700 rc, CHIPSET_INIT_FAILURE_PC);
2701
2695 proc_Init(); 2702 proc_Init();
2696 memset(PartitionPropertyNames, 0, sizeof(PartitionPropertyNames)); 2703 memset(PartitionPropertyNames, 0, sizeof(PartitionPropertyNames));
2697 memset(ControlVmPropertyNames, 0, sizeof(ControlVmPropertyNames)); 2704 memset(ControlVmPropertyNames, 0, sizeof(ControlVmPropertyNames));
@@ -2760,10 +2767,12 @@ visorchipset_init(void)
2760 -ENOMEM, CREATE_WORKQUEUE_FAILED_PC); 2767 -ENOMEM, CREATE_WORKQUEUE_FAILED_PC);
2761 Most_recent_message_jiffies = jiffies; 2768 Most_recent_message_jiffies = jiffies;
2762 Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; 2769 Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
2763 TRY_WPOSTCODE_1(queue_delayed_work 2770 rc = queue_delayed_work(Periodic_controlvm_workqueue,
2764 (Periodic_controlvm_workqueue, 2771 &Periodic_controlvm_work, Poll_jiffies);
2765 &Periodic_controlvm_work, Poll_jiffies), 2772 if (rc < 0)
2766 QUEUE_DELAYED_WORK_PC); 2773 FAIL_WPOSTCODE_1("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies);",
2774 rc, QUEUE_DELAYED_WORK_PC);
2775
2767 } 2776 }
2768 2777
2769 Visorchipset_platform_device.dev.devt = MajorDev; 2778 Visorchipset_platform_device.dev.devt = MajorDev;