All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Hellstrom <daniel@gaisler.com>
To: sparclinux@vger.kernel.org
Subject: Re: [RFC 1/8] sparc: prom: Sanitize return value from prom_nbputchar()
Date: Tue, 04 Jan 2011 14:42:45 +0000	[thread overview]
Message-ID: <4D2331E5.7050608@gaisler.com> (raw)
In-Reply-To: <4CF9BBC6.3080809@julian.is-a-geek.org>

David Miller wrote:

>From: Julian Calaby <jcalaby@julian.is-a-geek.org>
>Date: Sat, 04 Dec 2010 14:55:50 +1100
>
>  
>
>>Signed-off-by: Julian Calaby <julian.calaby@gmail.com>
>>    
>>
>
>Applied.
>  
>

I think this patch breaks the backwards compatability... Before this 
patch one had to return -1 from prom-code in order to implement a 
non-locking nbputchar() in PROM code (see old code below). With the new 
patch however one has to return a 0 and -1 is now interpreted as send 
successful.

Should we not check for values bigger than 0 so that -1 can be return by 
old PROMs? I suggest:

-		i = (*(romvec->pv_nbputchar))(*buf);
+		if ((*(romvec->pv_nbputchar))(*buf) > 0)
+			i = 1;


Regards,
Daniel


The applied patch:

-		i = (*(romvec->pv_nbputchar))(*buf);
+		if ((*(romvec->pv_nbputchar))(*buf))
+			i = 1;


Old version of nbputchar():

/* Non blocking put character to console device, returns -1 if
 * unsuccessful.
 */
int
prom_nbputchar(char c)
{
	static char outc;
	unsigned long flags;
	int i = -1;

	spin_lock_irqsave(&prom_lock, flags);
	switch(prom_vers) {
	case PROM_V0:
		i = (*(romvec->pv_nbputchar))(c);
		break;
	case PROM_V2:
	case PROM_V3:
		outc = c;
		if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) = 1)
			i = 0;
		else
			i = -1;
		break;
	default:
		i = -1;
		break;
	};
	restore_current();
	spin_unlock_irqrestore(&prom_lock, flags);
	return i; /* Ugh, we could spin forever on unsupported proms ;( */
}

/* Blocking version of put character routine above. */
void
prom_putchar(char c)
{
	while(prom_nbputchar(c) = -1) ;
}



  parent reply	other threads:[~2011-01-04 14:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04  3:55 [RFC 1/8] sparc: prom: Sanitize return value from prom_nbputchar() Julian Calaby
2010-12-04  3:56 ` Julian Calaby
2010-12-12 22:51 ` [RFC 1/8] sparc: prom: Sanitize return value from David Miller
2011-01-04 14:42 ` Daniel Hellstrom [this message]
2011-01-04 17:50 ` David Miller
2011-01-04 19:51 ` [RFC 1/8] sparc: prom: Sanitize return value from prom_nbputchar() Julian Calaby
2011-01-05  8:58 ` Daniel Hellstrom

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=4D2331E5.7050608@gaisler.com \
    --to=daniel@gaisler.com \
    --cc=sparclinux@vger.kernel.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.