From patchwork Fri Oct 23 11:25:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 36780 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 1336C1007D1 for ; Fri, 23 Oct 2009 22:26:18 +1100 (EST) Received: by ozlabs.org (Postfix) id 842AEB7BC2; Fri, 23 Oct 2009 22:26:12 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by ozlabs.org (Postfix) with ESMTP id 2B2B6B7BBB for ; Fri, 23 Oct 2009 22:26:12 +1100 (EST) Received: from [2001:6f8:1178:2:221:70ff:fe71:1890] (helo=pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.63) (envelope-from ) id 1N1IHX-0005rF-Cy; Fri, 23 Oct 2009 13:26:07 +0200 From: Wolfram Sang To: spi-devel-general@lists.sourceforge.net Subject: [PATCH] spi/mpc52xx: check for invalid PSC usage Date: Fri, 23 Oct 2009 13:25:57 +0200 Message-Id: <1256297157-28246-1-git-send-email-w.sang@pengutronix.de> X-Mailer: git-send-email 1.6.3.3 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890 X-SA-Exim-Mail-From: w.sang@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linuxppc-dev@ozlabs.org Cc: linuxppc-dev@ozlabs.org, David Brownell X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Add checks to allow only PSCs capable of SPI. Also turn printk to dev_err while we are here. Signed-off-by: Wolfram Sang Cc: Grant Likely Cc: David Brownell --- 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;