While getting to know how to write device drivers I came across IS_ERR() macro. But I couldn't find how is it working. I have include the code below:
majorNumber = register_chrdev(0, DEVICE_NAME, &fops);
if (majorNumber<0)
{
printk(KERN_ALERT "Failed to register a major number\n");
return majorNumber;
}
printk(KERN_INFO "Registered correctly with major number %d\n", majorNumber);
// Register the device class
ebbcharClass = class_create(THIS_MODULE, CLASS_NAME);
if (IS_ERR(ebbcharClass))
{
unregister_chrdev(majorNumber, DEVICE_NAME);
printk(KERN_ALERT "Failed to register device class\n");
return PTR_ERR(ebbcharClass);
}
So what does the IS_ERR() macro expand to and how it gets executed.