Kernel常见错误类型总结
1) ENOMEM
dev->base = ioremap(mem->start, resource_size(mem));
if (!dev->base) {
r = -ENOMEM;
goto err_free_mem;
}
dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
if (!dev) {
r = -ENOMEM; /* 内存分配失败 */
goto err_release_region;
}
2) ERESTARTSYS
if (down_interruptible(&gDMA.lock) < 0) {
return -ERESTARTSYS; /* */
}
3) EBUSY
ioarea = request_mem_region(mem->start, resource_size(mem),
pdev->name);
if (!ioarea) {
dev_err(&pdev->dev, "I2C region already claimed/n");
return -EBUSY; /* 内存已经被占用 */
}
4) ENODEV
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!irq) {
dev_err(&pdev->dev, "no irq resource?/n");
return -ENODEV; /* 没有该设备 */
}
5) EFAULT
if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
return -EFAULT;
6) EAGAIN
if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot))
return -EAGAIN;
7) EINVAL
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL; /* 无效 */
Author: WoodPecker <Pecker.hu@gmail.com>