Xilinx: ARM: I2C: SI570: Driver updated for more error checking
[linux-2.6-xlnx.git] / drivers / xilinx_common / xil_assert.c
blob9e38cf14ee48597bc7385012361b3fb9fff55d0b
1 /******************************************************************************
4 * (c) Copyright 2009 Xilinx, Inc. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * You should have received a copy of the GNU General Public License
11 * along with this program; if not, write to the Free Software
12 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
13 * MA 02110-1301 USA
15 * This file contains confidential and proprietary information of Xilinx, Inc.
16 * and is protected under U.S. and international copyright and other
17 * intellectual property laws.
19 * DISCLAIMER
20 * This disclaimer is not a license and does not grant any rights to the
21 * materials distributed herewith. Except as otherwise provided in a valid
22 * license issued to you by Xilinx, and to the maximum extent permitted by
23 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
24 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
25 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
26 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
27 * and (2) Xilinx shall not be liable (whether in contract or tort, including
28 * negligence, or under any other theory of liability) for any loss or damage
29 * of any kind or nature related to, arising under or in connection with these
30 * materials, including for any direct, or any indirect, special, incidental,
31 * or consequential loss or damage (including loss of data, profits, goodwill,
32 * or any type of loss or damage suffered as a result of any action brought by
33 * a third party) even if such damage or loss was reasonably foreseeable or
34 * Xilinx had been advised of the possibility of the same.
36 * CRITICAL APPLICATIONS
37 * Xilinx products are not designed or intended to be fail-safe, or for use in
38 * any application requiring fail-safe performance, such as life-support or
39 * safety devices or systems, Class III medical devices, nuclear facilities,
40 * applications related to the deployment of airbags, or any other applications
41 * that could lead to death, personal injury, or severe property or
42 * environmental damage (individually and collectively, "Critical
43 * Applications"). Customer assumes the sole risk and liability of any use of
44 * Xilinx products in Critical Applications, subject only to applicable laws
45 * and regulations governing limitations on product liability.
47 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
48 * AT ALL TIMES.
51 ******************************************************************************/
52 /*****************************************************************************/
53 /**
55 * @file xil_assert.c
57 * This file contains basic assert related functions for Xilinx software IP.
59 * <pre>
60 * MODIFICATION HISTORY:
62 * Ver Who Date Changes
63 * ----- ---- -------- -------------------------------------------------------
64 * 1.00a hbm 07/14/09 Initial release
65 * </pre>
67 ******************************************************************************/
69 /***************************** Include Files *********************************/
71 #include "xil_types.h"
72 #include "xil_assert.h"
74 /************************** Constant Definitions *****************************/
76 /**************************** Type Definitions *******************************/
78 /***************** Macros (Inline Functions) Definitions *********************/
80 /************************** Variable Definitions *****************************/
82 /**
83 * This variable allows testing to be done easier with asserts. An assert
84 * sets this variable such that a driver can evaluate this variable
85 * to determine if an assert occurred.
87 unsigned int Xil_AssertStatus;
89 /**
90 * This variable allows the assert functionality to be changed for testing
91 * such that it does not wait infinitely. Use the debugger to disable the
92 * waiting during testing of asserts.
94 int Xil_AssertWait = TRUE;
96 /* The callback function to be invoked when an assert is taken */
97 static Xil_AssertCallback Xil_AssertCallbackRoutine = NULL;
99 /************************** Function Prototypes ******************************/
101 /*****************************************************************************/
104 * Implement assert. Currently, it calls a user-defined callback function
105 * if one has been set. Then, it potentially enters an infinite loop depending
106 * on the value of the Xil_AssertWait variable.
108 * @param file is the name of the filename of the source
109 * @param line is the linenumber within File
111 * @return None.
113 * @note None.
115 ******************************************************************************/
116 void Xil_Assert(char *File, int Line)
118 /* if the callback has been set then invoke it */
119 if (Xil_AssertCallbackRoutine != 0) {
120 (*Xil_AssertCallbackRoutine)(File, Line);
123 /* if specified, wait indefinitely such that the assert will show up
124 * in testing
126 while (Xil_AssertWait) {
130 /*****************************************************************************/
133 * Set up a callback function to be invoked when an assert occurs. If there
134 * was already a callback installed, then it is replaced.
136 * @param routine is the callback to be invoked when an assert is taken
138 * @return None.
140 * @note This function has no effect if NDEBUG is set
142 ******************************************************************************/
143 void Xil_AssertSetCallback(Xil_AssertCallback Routine)
145 Xil_AssertCallbackRoutine = Routine;