aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2009-11-01 22:53:11 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-11-04 18:42:47 -0500
commitf856cf01787354fb3c8cde0a80de606f368b21ed (patch)
treea69346d1f7f075f84d2c4efa682b8eeb202e2e0d /drivers/spi
parent3c9059d79f5eea6b8b75ddac97693127c3c41db4 (diff)
spi/mpc52xx-psc-spi: check for valid PSC
This driver calls mpc52xx_set_psc_clkdiv() but doesn't check its return value to see if the PSC is actually valid for SPI use. Add the check and a hint for the user. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index a14e9fdc0065..2193d908cad6 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -314,11 +314,13 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps)
314 struct mpc52xx_psc __iomem *psc = mps->psc; 314 struct mpc52xx_psc __iomem *psc = mps->psc;
315 struct mpc52xx_psc_fifo __iomem *fifo = mps->fifo; 315 struct mpc52xx_psc_fifo __iomem *fifo = mps->fifo;
316 u32 mclken_div; 316 u32 mclken_div;
317 int ret = 0; 317 int ret;
318 318
319 /* default sysclk is 512MHz */ 319 /* default sysclk is 512MHz */
320 mclken_div = (mps->sysclk ? mps->sysclk : 512000000) / MCLK; 320 mclken_div = (mps->sysclk ? mps->sysclk : 512000000) / MCLK;
321 mpc52xx_set_psc_clkdiv(psc_id, mclken_div); 321 ret = mpc52xx_set_psc_clkdiv(psc_id, mclken_div);
322 if (ret)
323 return ret;
322 324
323 /* Reset the PSC into a known state */ 325 /* Reset the PSC into a known state */
324 out_8(&psc->command, MPC52xx_PSC_RST_RX); 326 out_8(&psc->command, MPC52xx_PSC_RST_RX);
@@ -342,7 +344,7 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps)
342 344
343 mps->bits_per_word = 8; 345 mps->bits_per_word = 8;
344 346
345 return ret; 347 return 0;
346} 348}
347 349
348static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) 350static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id)
@@ -411,8 +413,10 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
411 goto free_master; 413 goto free_master;
412 414
413 ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); 415 ret = mpc52xx_psc_spi_port_config(master->bus_num, mps);
414 if (ret < 0) 416 if (ret < 0) {
417 dev_err(dev, "can't configure PSC! Is it capable of SPI?\n");
415 goto free_irq; 418 goto free_irq;
419 }
416 420
417 spin_lock_init(&mps->lock); 421 spin_lock_init(&mps->lock);
418 init_completion(&mps->done); 422 init_completion(&mps->done);