minuitwrp: retry opening fb0 if it failed

On some devices TWRP tries to access the framebuffer before all
device nodes have been created. Retry opening instead of crashing later.

Change-Id: I189a8fe80a8906b46fb6cece53c0bf83c00c0e09
diff --git a/minuitwrp/graphics_fbdev.cpp b/minuitwrp/graphics_fbdev.cpp
index afc4151..066be8d 100644
--- a/minuitwrp/graphics_fbdev.cpp
+++ b/minuitwrp/graphics_fbdev.cpp
@@ -108,21 +108,31 @@
 }
 
 static GRSurface* fbdev_init(minui_backend* backend) {
-    int fd = open("/dev/graphics/fb0", O_RDWR);
-    if (fd == -1) {
-        perror("cannot open fb0");
-        return NULL;
+    int retry = 20;
+    int fd = -1;
+    while (fd == -1) {
+        fd = open("/dev/graphics/fb0", O_RDWR);
+        if (fd == -1) {
+            if (--retry) {
+                // wait for init to create the device node
+                perror("cannot open fb0 (retrying)");
+                usleep(100000);
+            } else {
+                perror("cannot open fb0 (giving up)");
+                return NULL;
+            }
+        }
     }
 
     fb_fix_screeninfo fi;
     if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) {
-        perror("failed to get fb0 info");
+        perror("failed to get fb0 info (FBIOGET_FSCREENINFO)");
         close(fd);
         return NULL;
     }
 
     if (ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) {
-        perror("failed to get fb0 info");
+        perror("failed to get fb0 info (FBIOGET_VSCREENINFO)");
         close(fd);
         return NULL;
     }