<html><body><div style="color:#000; background-color:#fff; font-family:bookman old style, new york, times, serif;font-size:10pt">Hi <br><br>Please find the example to user file open in kernel below. source file #linux/<span class="tab">sound/sound_firmware.c</span><br><br>struct file* filp;<br> <br>filp = filp_open(fn, 0, 0);<br>if (IS_ERR(filp))<br>{<br> printk(KERN_INFO "Unable to load '%s'.\n", fn);<br> return 0;<br>}<br><br>IS_ERR expand to below example. <br><br><div><span>#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)<br> <br>static inline long __must_check IS_ERR(__force const void *ptr)<br>{ <br> return IS_ERR_VALUE((unsigned long)ptr);<br>}<br></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: bookman old style,new york,times,serif;
background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: bookman old style,new york,times,serif; background-color: transparent; font-style: normal;">-Anand Moon<br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: bookman old style,new york,times,serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: bookman old style, new york, times, serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Thursday, November 7, 2013 11:24 AM, 乃宏周 <naive231@gmail.com> wrote:<br> </font> </div> <div class="y_msg_container"><div id="yiv7611810910"><div dir="ltr"><div><div><div><div><div>In kernel source,
`IS_ERR_VALUE` is defined:<br><br>#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)<br><br></div>It's usage can be realized literally, but definition is not.<br>
</div>Can I use this macro to determines the kernel API's result is valid?<br></div><br>Example:<br></div>if (IS_ERR_VALUE(filp_open(device)))<br>{<br></div> filp_close(device);<br><div>}<br></div></div></div><br>_______________________________________________<br>Kernelnewbies mailing list<br><a ymailto="mailto:Kernelnewbies@kernelnewbies.org" href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br><a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br><br><br></div> </div> </div> </div> </div></body></html>