diff options
Diffstat (limited to 'Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl')
-rw-r--r-- | Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 56723b42813e..87a7c07ab658 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | |||
@@ -6134,44 +6134,58 @@ struct _snd_pcm_runtime { | |||
6134 | </para> | 6134 | </para> |
6135 | </section> | 6135 | </section> |
6136 | 6136 | ||
6137 | <section id="useful-functions-snd-assert"> | 6137 | <section id="useful-functions-snd-bug"> |
6138 | <title><function>snd_assert()</function></title> | 6138 | <title><function>snd_BUG()</function></title> |
6139 | <para> | 6139 | <para> |
6140 | <function>snd_assert()</function> macro is similar with the | 6140 | It shows the <computeroutput>BUG?</computeroutput> message and |
6141 | normal <function>assert()</function> macro. For example, | 6141 | stack trace as well as <function>snd_BUG_ON</function> at the point. |
6142 | It's useful to show that a fatal error happens there. | ||
6143 | </para> | ||
6144 | <para> | ||
6145 | When no debug flag is set, this macro is ignored. | ||
6146 | </para> | ||
6147 | </section> | ||
6148 | |||
6149 | <section id="useful-functions-snd-bug-on"> | ||
6150 | <title><function>snd_BUG_ON()</function></title> | ||
6151 | <para> | ||
6152 | <function>snd_BUG_ON()</function> macro is similar with | ||
6153 | <function>WARN_ON()</function> macro. For example, | ||
6142 | 6154 | ||
6143 | <informalexample> | 6155 | <informalexample> |
6144 | <programlisting> | 6156 | <programlisting> |
6145 | <![CDATA[ | 6157 | <![CDATA[ |
6146 | snd_assert(pointer != NULL, return -EINVAL); | 6158 | snd_BUG_ON(!pointer); |
6147 | ]]> | 6159 | ]]> |
6148 | </programlisting> | 6160 | </programlisting> |
6149 | </informalexample> | 6161 | </informalexample> |
6150 | </para> | ||
6151 | 6162 | ||
6152 | <para> | 6163 | or it can be used as the condition, |
6153 | The first argument is the expression to evaluate, and the | 6164 | <informalexample> |
6154 | second argument is the action if it fails. When | 6165 | <programlisting> |
6155 | <constant>CONFIG_SND_DEBUG</constant>, is set, it will show an | 6166 | <![CDATA[ |
6156 | error message such as <computeroutput>BUG? (xxx)</computeroutput> | 6167 | if (snd_BUG_ON(non_zero_is_bug)) |
6157 | together with stack trace. | 6168 | return -EINVAL; |
6158 | </para> | 6169 | ]]> |
6159 | <para> | 6170 | </programlisting> |
6160 | When no debug flag is set, this macro is ignored. | 6171 | </informalexample> |
6161 | </para> | ||
6162 | </section> | ||
6163 | 6172 | ||
6164 | <section id="useful-functions-snd-bug"> | ||
6165 | <title><function>snd_BUG()</function></title> | ||
6166 | <para> | ||
6167 | It shows the <computeroutput>BUG?</computeroutput> message and | ||
6168 | stack trace as well as <function>snd_assert</function> at the point. | ||
6169 | It's useful to show that a fatal error happens there. | ||
6170 | </para> | 6173 | </para> |
6174 | |||
6171 | <para> | 6175 | <para> |
6172 | When no debug flag is set, this macro is ignored. | 6176 | The macro takes an conditional expression to evaluate. |
6177 | When <constant>CONFIG_SND_DEBUG</constant>, is set, the | ||
6178 | expression is actually evaluated. If it's non-zero, it shows | ||
6179 | the warning message such as | ||
6180 | <computeroutput>BUG? (xxx)</computeroutput> | ||
6181 | normally followed by stack trace. It returns the evaluated | ||
6182 | value. | ||
6183 | When no <constant>CONFIG_SND_DEBUG</constant> is set, this | ||
6184 | macro always returns zero. | ||
6173 | </para> | 6185 | </para> |
6186 | |||
6174 | </section> | 6187 | </section> |
6188 | |||
6175 | </chapter> | 6189 | </chapter> |
6176 | 6190 | ||
6177 | 6191 | ||