On Wed, Nov 20, 2013 at 5:12 PM, Anand Moon wrote:
> Hi
>
> Please find the example to user file open in kernel below. source file
> #linux/sound/sound_firmware.c
>
> struct file* filp;
>
> filp = filp_open(fn, 0, 0);
> if (IS_ERR(filp))
> {
> printk(KERN_INFO "Unable to load '%s'.\n", fn
Hi
Please find the example to user file open in kernel below. source file
#linux/sound/sound_firmware.c
struct file* filp;
filp = filp_open(fn, 0, 0);
if (IS_ERR(filp))
{
printk(KERN_INFO "Unable to load '%s'.\n", fn);
return 0;
}
IS_ERR expand to below example.
#define
In kernel source, `IS_ERR_VALUE` is defined:
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
It's usage can be realized literally, but definition is not.
Can I use this macro to determines the kernel API's result is valid?
Example:
if (IS_ERR_VALUE(filp_open(device)))
{
fi