diff --git a/vcgencmd/vcgencmd.c b/vcgencmd/vcgencmd.c index 666b5ff..a89627c 100644 --- a/vcgencmd/vcgencmd.c +++ b/vcgencmd/vcgencmd.c @@ -37,7 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include /* ioctl */ -#define DEVICE_FILE_NAME "/dev/vcio" +#define countof(x) (sizeof x/sizeof *x) + #define MAJOR_NUM 100 #define IOCTL_MBOX_PROPERTY _IOWR(MAJOR_NUM, 0, char *) @@ -61,15 +62,19 @@ static int mbox_property(int file_desc, void *buf) static int mbox_open() { int file_desc; - + const char *devices[] = {"/dev/vcio_gencmd", "/dev/vcio"}; + int i; // open a char device file used for communicating with kernel mbox driver - file_desc = open(DEVICE_FILE_NAME, 0); - if (file_desc < 0) { - printf("Can't open device file: %s\n", DEVICE_FILE_NAME); - printf("Try creating a device file with: sudo mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM); - exit(-1); + // first try the more restrictive interface but fall back to full if unavailable + for (i=0; i= 0) + return file_desc; } - return file_desc; + printf("Can't open device file: %s\n", devices[0]); + printf("Try creating a device file with: sudo mknod %s c %d 0\n", devices[0], MAJOR_NUM); + exit(-1); } static void mbox_close(int file_desc) {