X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fspi%2Fspi_s3c24xx.c;h=0885cc357a371552dc2190a6da682f98a652abdb;hb=90621ed829ac64eb25b4d1214e9a5155e5c67ff2;hp=e75103aac79054706920dabe78301c790c083e3d;hpb=adf6d34e460387ee3e8f1e1875d52bff51212c7d;p=linux-2.6 diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index e75103aac7..0885cc357a 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c @@ -125,10 +125,10 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi, /* is clk = pclk / (2 * (pre+1)), or is it * clk = (pclk * 2) / ( pre + 1) */ - div = (div / 2) - 1; + div /= 2; - if (div < 0) - div = 1; + if (div > 0) + div -= 1; if (div > 255) div = 255; @@ -169,7 +169,7 @@ static int s3c24xx_spi_setup(struct spi_device *spi) } dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", - __FUNCTION__, spi->mode, spi->bits_per_word, + __func__, spi->mode, spi->bits_per_word, spi->max_speed_hz); return 0; @@ -192,8 +192,11 @@ static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) hw->len = t->len; hw->count = 0; + init_completion(&hw->done); + /* send the first byte */ writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT); + wait_for_completion(&hw->done); return hw->count; @@ -235,6 +238,7 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev) static int __init s3c24xx_spi_probe(struct platform_device *pdev) { + struct s3c2410_spi_info *pdata; struct s3c24xx_spi *hw; struct spi_master *master; struct resource *res; @@ -251,10 +255,10 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev) memset(hw, 0, sizeof(struct s3c24xx_spi)); hw->master = spi_master_get(master); - hw->pdata = pdev->dev.platform_data; + hw->pdata = pdata = pdev->dev.platform_data; hw->dev = &pdev->dev; - if (hw->pdata == NULL) { + if (pdata == NULL) { dev_err(&pdev->dev, "No platform data supplied\n"); err = -ENOENT; goto err_no_pdata; @@ -263,6 +267,10 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, hw); init_completion(&hw->done); + /* setup the master state. */ + + master->num_chipselect = hw->pdata->num_cs; + /* setup the state for the bitbang driver */ hw->bitbang.master = hw->master; @@ -330,13 +338,13 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev) /* setup any gpio we can */ - if (!hw->pdata->set_cs) { + if (!pdata->set_cs) { hw->set_cs = s3c24xx_spi_gpiocs; - s3c2410_gpio_setpin(hw->pdata->pin_cs, 1); - s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT); + s3c2410_gpio_setpin(pdata->pin_cs, 1); + s3c2410_gpio_cfgpin(pdata->pin_cs, S3C2410_GPIO_OUTPUT); } else - hw->set_cs = hw->pdata->set_cs; + hw->set_cs = pdata->set_cs; /* register our spi controller */