Patchwork take in count O_NONBLOCK flag for rtas log

login
register
mail settings
Submitter Vitaly Mayatskikh
Date Sept. 26, 2008, 8:21 a.m.
Message ID <m3iqsjjp1s.wl%vmayatsk@redhat.com>
Download mbox | patch
Permalink /patch/1630/
State Accepted
Commit 76c31f239ea221a6c84bd26141262a43bfe8b7f4
Headers show

Comments

Vitaly Mayatskikh - Sept. 26, 2008, 8:21 a.m.
At Thu, 25 Sep 2008 22:13:05 +0100, David Howells wrote:

> > +		if (!logging_enabled) {
> > +			spin_unlock_irqrestore(&rtasd_log_lock, s);
> > +			error = -ENODATA;
> > +			goto out;
> > +		} else
> > +			nvram_clear_error_log();
> 
> The 'else' here is unnecessary.  It's preceded inside the curlies by a goto.

Right...

Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>


--
wbr, Vitaly

Patch

diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index c9ffd8c..4f76e3b 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -295,19 +295,29 @@  static ssize_t rtas_log_read(struct file * file, char __user * buf,
 	if (!tmp)
 		return -ENOMEM;
 
-
 	spin_lock_irqsave(&rtasd_log_lock, s);
 	/* if it's 0, then we know we got the last one (the one in NVRAM) */
-	if (rtas_log_size == 0 && logging_enabled)
-		nvram_clear_error_log();
-	spin_unlock_irqrestore(&rtasd_log_lock, s);
+	while (rtas_log_size == 0) {
+		if (file->f_flags & O_NONBLOCK) {
+			spin_unlock_irqrestore(&rtasd_log_lock, s);
+			error = -EAGAIN;
+			goto out;
+		}
 
+		if (!logging_enabled) {
+			spin_unlock_irqrestore(&rtasd_log_lock, s);
+			error = -ENODATA;
+			goto out;
+		}
+		nvram_clear_error_log();
 
-	error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
-	if (error)
-		goto out;
+		spin_unlock_irqrestore(&rtasd_log_lock, s);
+		error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
+		if (error)
+			goto out;
+		spin_lock_irqsave(&rtasd_log_lock, s);
+	}
 
-	spin_lock_irqsave(&rtasd_log_lock, s);
 	offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK);
 	memcpy(tmp, &rtas_log_buf[offset], count);