Quoting ron minnich rminnich@gmail.com:
I should have been clearer.
perror("You need to be root.\n");
No, the issue here is the iopl failed. In many cases it will be "you need to be root" but you can't be sure in all.
So you want this:
perror("Enabling IO ports via iopl(3)");
perror will take care of telling why; you need to let the user know what the program was trying to do.
Also, just FYI:
- printf("GPIOBASE = 0x%04x\n\n", gpiobadd);
- pci_free_dev(sb);
- pci_cleanup(pacc);
- map_gpio(gpiobadd);
It's clean coding style, but the pci_free_dev and pci_cleanup are not really necessary ... your program is leaving right after the map_gpio, and these operations are not doing anything that you need to. Plus, if someone wants to add some more looking around in the pci space, later, they'll have to move this free/cleanup code around. But not really a huge deal either way.
Thanks
ron
Ok, I got ya on the perror..... And if the pci_free_dev and pci_cleanup are not very important I have removed them also.
Signed-off-by: Joseph Smith joe@smittys.pointclark.net
Thanks - Joe