All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andrei Gherzan" <andrei@gherzan.ro>
To: yocto@yoctoproject.org
Cc: Andrei Gherzan <andrei@gherzan.ro>
Subject: [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0
Date: Thu, 13 Feb 2020 10:30:00 +0000	[thread overview]
Message-ID: <20200213103000.1594-1-andrei@gherzan.ro> (raw)

When starting psplash as early as possible in the boot process, the fb
device node might not be ready. This patch adds a loop on reading the
fb0 device with a timeout of 5 seconds.

Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
---
 psplash-fb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/psplash-fb.c b/psplash-fb.c
index 6603572..6700a3b 100644
--- a/psplash-fb.c
+++ b/psplash-fb.c
@@ -137,6 +137,7 @@ psplash_fb_new (int angle, int fbdev_id)
   struct fb_fix_screeninfo fb_fix;
   int                      off;
   char                     fbdev[9] = "/dev/fb0";
+  int retries = 0;
 
   PSplashFB *fb = NULL;
 
@@ -156,7 +157,9 @@ psplash_fb_new (int angle, int fbdev_id)
 
   fb->fd = -1;
 
-  if ((fb->fd = open (fbdev, O_RDWR)) < 0)
+  while ((fb->fd = open(fbdev, O_RDWR)) < 0 && retries++ <= 100)
+	  usleep(50000);
+  if (fb->fd < 0)
     {
       fprintf(stderr,
               "Error opening %s\n",
-- 
2.17.1


             reply	other threads:[~2020-02-13 10:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 10:30 Andrei Gherzan [this message]
2020-02-14  7:32 ` [yocto] [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0 Khem Raj
2020-02-20 17:58   ` Andrei Gherzan
2020-02-20 18:03     ` Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200213103000.1594-1-andrei@gherzan.ro \
    --to=andrei@gherzan.ro \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.