LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   I/O error in code example from "Essential Linux Device Drivers" (https://www.linuxquestions.org/questions/linux-kernel-70/i-o-error-in-code-example-from-essential-linux-device-drivers-4175470197/)

moo-cow 07-19-2013 07:53 AM

I/O error in code example from "Essential Linux Device Drivers"
 
Hi,

I'm trying to run a code example from the book "Essential Linux Device Drivers". It's a driver module that's supposed to access the CMOS memory banks (port 0x70). Inserting the module fails with -EIO, which is caused by the following section of the code:

Code:

/* Request I/O region */
sprintf(cmos_devp[i]->name, "cmos%d", i);
if (!(request_region(addrports[i], 2, cmos_devp[i]->name))) {
    printk("cmos: I/O port 0x%x is not free.\n", addrports[i]);
    return -EIO;
}

My guess is that this fails because the memory region has been reserved already by the RTC driver (?). How can I fix the code? I'm using kernel version 3.2.46, the book code was written for a 2.6 kernel. I had to make some minor changes to get the code compiled.

Many thanks!

bsat 07-20-2013 02:43 AM

if you do not need the RTC driver then remove it. The port should become free. Else you will have to change the memory region.

moo-cow 07-26-2013 07:20 AM

Thanks, that did the trick! I removed the RTC driver from the kernel config and did a recompile. The kernel has a legacy RTC driver that can be compiled as a module. I used that driver as a replacement for the new driver, which cannot be modularized.


All times are GMT -5. The time now is 07:07 PM.