linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: spi-devel-general@lists.sourceforge.net
Cc: linuxppc-dev@ozlabs.org,
	David Brownell <dbrownell@users.sourceforge.net>
Subject: [PATCH] spi/mpc52xx: check for invalid PSC usage
Date: Fri, 23 Oct 2009 13:25:57 +0200	[thread overview]
Message-ID: <1256297157-28246-1-git-send-email-w.sang@pengutronix.de> (raw)

Add checks to allow only PSCs capable of SPI.
Also turn printk to dev_err while we are here.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: David Brownell <dbrownell@users.sourceforge.net>
---

Grant, if the patch is OK, maybe it can also go via your tree?

 drivers/spi/mpc52xx_psc_spi.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 1b74d5c..1d11a6d 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -467,19 +467,18 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op,
 
 	regaddr_p = of_get_address(op->node, 0, &size64, NULL);
 	if (!regaddr_p) {
-		printk(KERN_ERR "Invalid PSC address\n");
+		dev_err(&op->dev, "Invalid PSC address\n");
 		return -EINVAL;
 	}
 	regaddr64 = of_translate_address(op->node, regaddr_p);
 
-	/* get PSC id (1..6, used by port_config) */
+	/* get PSC id (only 1,2,3,6 can do SPI) */
 	if (op->dev.platform_data == NULL) {
 		const u32 *psc_nump;
 
 		psc_nump = of_get_property(op->node, "cell-index", NULL);
-		if (!psc_nump || *psc_nump > 5) {
-			printk(KERN_ERR "mpc52xx_psc_spi: Device node %s has invalid "
-					"cell-index property\n", op->node->full_name);
+		if (!psc_nump || (*psc_nump > 2 && *psc_nump != 5)) {
+			dev_err(&op->dev, "PSC can't do SPI\n");
 			return -EINVAL;
 		}
 		id = *psc_nump + 1;
-- 
1.6.3.3

             reply	other threads:[~2009-10-23 11:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-23 11:25 Wolfram Sang [this message]
2009-11-01  1:22 ` [PATCH] spi/mpc52xx: check for invalid PSC usage Grant Likely
2009-11-02 13:53   ` Wolfram Sang
2009-11-02 18:03     ` Grant Likely

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=1256297157-28246-1-git-send-email-w.sang@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).