Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: s3c64xx: straightforward cleanup

Merge series from Tudor Ambarus <tudor.ambarus@linaro.org>:

Various simple cleanups for the s3c64xx driver. Tested with gs101-spi.

+41 -40
+41 -40
drivers/spi/spi-s3c64xx.c
··· 3 3 // Copyright (c) 2009 Samsung Electronics Co., Ltd. 4 4 // Jaswinder Singh <jassi.brar@samsung.com> 5 5 6 - #include <linux/init.h> 7 - #include <linux/module.h> 8 - #include <linux/interrupt.h> 9 - #include <linux/delay.h> 6 + #include <linux/bits.h> 10 7 #include <linux/clk.h> 8 + #include <linux/delay.h> 11 9 #include <linux/dma-mapping.h> 12 10 #include <linux/dmaengine.h> 11 + #include <linux/init.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/io.h> 14 + #include <linux/module.h> 15 + #include <linux/of.h> 16 + #include <linux/platform_data/spi-s3c64xx.h> 13 17 #include <linux/platform_device.h> 14 18 #include <linux/pm_runtime.h> 15 19 #include <linux/spi/spi.h> 16 - #include <linux/of.h> 17 - 18 - #include <linux/platform_data/spi-s3c64xx.h> 20 + #include <linux/types.h> 19 21 20 22 #define MAX_SPI_PORTS 16 21 23 #define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1) ··· 116 114 #define S3C64XX_SPI_MAX_TRAILCNT 0x3ff 117 115 #define S3C64XX_SPI_TRAILCNT_OFF 19 118 116 119 - #define S3C64XX_SPI_TRAILCNT S3C64XX_SPI_MAX_TRAILCNT 120 - 121 117 #define S3C64XX_SPI_POLLING_SIZE 32 122 118 123 119 #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) ··· 180 180 * @cur_speed: Current clock speed 181 181 * @rx_dma: Local receive DMA data (e.g. chan and direction) 182 182 * @tx_dma: Local transmit DMA data (e.g. chan and direction) 183 - * @port_conf: Local SPI port configuartion data 183 + * @port_conf: Local SPI port configuration data 184 184 * @port_id: Port identification number 185 185 */ 186 186 struct s3c64xx_spi_driver_data { ··· 279 279 spin_unlock_irqrestore(&sdd->lock, flags); 280 280 } 281 281 282 - static int prepare_dma(struct s3c64xx_spi_dma_data *dma, 283 - struct sg_table *sgt) 282 + static int s3c64xx_prepare_dma(struct s3c64xx_spi_dma_data *dma, 283 + struct sg_table *sgt) 284 284 { 285 285 struct s3c64xx_spi_driver_data *sdd; 286 286 struct dma_slave_config config; ··· 292 292 if (dma->direction == DMA_DEV_TO_MEM) { 293 293 sdd = container_of((void *)dma, 294 294 struct s3c64xx_spi_driver_data, rx_dma); 295 - config.direction = dma->direction; 296 295 config.src_addr = sdd->sfr_start + S3C64XX_SPI_RX_DATA; 297 296 config.src_addr_width = sdd->cur_bpw / 8; 298 297 config.src_maxburst = 1; 299 - dmaengine_slave_config(dma->ch, &config); 300 298 } else { 301 299 sdd = container_of((void *)dma, 302 300 struct s3c64xx_spi_driver_data, tx_dma); 303 - config.direction = dma->direction; 304 301 config.dst_addr = sdd->sfr_start + S3C64XX_SPI_TX_DATA; 305 302 config.dst_addr_width = sdd->cur_bpw / 8; 306 303 config.dst_maxburst = 1; 307 - dmaengine_slave_config(dma->ch, &config); 308 304 } 305 + config.direction = dma->direction; 306 + ret = dmaengine_slave_config(dma->ch, &config); 307 + if (ret) 308 + return ret; 309 309 310 310 desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents, 311 311 dma->direction, DMA_PREP_INTERRUPT); ··· 322 322 ret = dma_submit_error(dma->cookie); 323 323 if (ret) { 324 324 dev_err(&sdd->pdev->dev, "DMA submission failed"); 325 - return -EIO; 325 + return ret; 326 326 } 327 327 328 328 dma_async_issue_pending(dma->ch); ··· 408 408 { 409 409 struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host); 410 410 411 - if (sdd->rx_dma.ch && sdd->tx_dma.ch) { 411 + if (sdd->rx_dma.ch && sdd->tx_dma.ch) 412 412 return xfer->len > FIFO_DEPTH(sdd); 413 - } else { 414 - return false; 415 - } 416 413 414 + return false; 417 415 } 418 416 419 417 static void s3c64xx_iowrite8_32_rep(volatile void __iomem *addr, ··· 495 497 chcfg |= S3C64XX_SPI_CH_TXCH_ON; 496 498 if (dma_mode) { 497 499 modecfg |= S3C64XX_SPI_MODE_TXDMA_ON; 498 - ret = prepare_dma(&sdd->tx_dma, &xfer->tx_sg); 500 + ret = s3c64xx_prepare_dma(&sdd->tx_dma, &xfer->tx_sg); 499 501 } else { 500 502 s3c64xx_iowrite_rep(sdd, xfer); 501 503 } ··· 514 516 writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff) 515 517 | S3C64XX_SPI_PACKET_CNT_EN, 516 518 regs + S3C64XX_SPI_PACKET_CNT); 517 - ret = prepare_dma(&sdd->rx_dma, &xfer->rx_sg); 519 + ret = s3c64xx_prepare_dma(&sdd->rx_dma, &xfer->rx_sg); 518 520 } 519 521 } 520 522 ··· 564 566 565 567 /* 566 568 * If the previous xfer was completed within timeout, then 567 - * proceed further else return -EIO. 569 + * proceed further else return -ETIMEDOUT. 568 570 * DmaTx returns after simply writing data in the FIFO, 569 571 * w/o waiting for real transmission on the bus to finish. 570 572 * DmaRx returns only after Dma read data from FIFO which ··· 585 587 586 588 /* If timed out while checking rx/tx status return error */ 587 589 if (!val) 588 - return -EIO; 590 + return -ETIMEDOUT; 589 591 590 592 return 0; 591 593 } ··· 615 617 if (use_irq) { 616 618 val = msecs_to_jiffies(ms); 617 619 if (!wait_for_completion_timeout(&sdd->xfer_completion, val)) 618 - return -EIO; 620 + return -ETIMEDOUT; 619 621 } 620 622 621 623 val = msecs_to_loops(ms); ··· 1129 1131 1130 1132 val = readl(regs + S3C64XX_SPI_MODE_CFG); 1131 1133 val &= ~S3C64XX_SPI_MODE_4BURST; 1132 - val &= ~(S3C64XX_SPI_MAX_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF); 1133 - val |= (S3C64XX_SPI_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF); 1134 + val |= (S3C64XX_SPI_MAX_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF); 1134 1135 writel(val, regs + S3C64XX_SPI_MODE_CFG); 1135 1136 1136 1137 s3c64xx_flush_fifo(sdd); ··· 1146 1149 return ERR_PTR(-ENOMEM); 1147 1150 1148 1151 if (of_property_read_u32(dev->of_node, "samsung,spi-src-clk", &temp)) { 1149 - dev_warn(dev, "spi bus clock parent not specified, using clock at index 0 as parent\n"); 1152 + dev_dbg(dev, "spi bus clock parent not specified, using clock at index 0 as parent\n"); 1150 1153 sci->src_clk_nr = 0; 1151 1154 } else { 1152 1155 sci->src_clk_nr = temp; 1153 1156 } 1154 1157 1155 1158 if (of_property_read_u32(dev->of_node, "num-cs", &temp)) { 1156 - dev_warn(dev, "number of chip select lines not specified, assuming 1 chip select line\n"); 1159 + dev_dbg(dev, "number of chip select lines not specified, assuming 1 chip select line\n"); 1157 1160 sci->num_cs = 1; 1158 1161 } else { 1159 1162 sci->num_cs = temp; ··· 1223 1226 "Failed to get alias id\n"); 1224 1227 sdd->port_id = ret; 1225 1228 } else { 1229 + if (pdev->id < 0) 1230 + return dev_err_probe(&pdev->dev, -EINVAL, 1231 + "Negative platform ID is not allowed\n"); 1226 1232 sdd->port_id = pdev->id; 1227 1233 } 1228 1234 ··· 1357 1357 { 1358 1358 struct spi_controller *host = dev_get_drvdata(dev); 1359 1359 struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host); 1360 + int ret; 1360 1361 1361 - int ret = spi_controller_suspend(host); 1362 + ret = spi_controller_suspend(host); 1362 1363 if (ret) 1363 1364 return ret; 1364 1365 ··· 1564 1563 .data = &gs101_spi_port_config, 1565 1564 }, 1566 1565 { .compatible = "samsung,s3c2443-spi", 1567 - .data = (void *)&s3c2443_spi_port_config, 1566 + .data = &s3c2443_spi_port_config, 1568 1567 }, 1569 1568 { .compatible = "samsung,s3c6410-spi", 1570 - .data = (void *)&s3c6410_spi_port_config, 1569 + .data = &s3c6410_spi_port_config, 1571 1570 }, 1572 1571 { .compatible = "samsung,s5pv210-spi", 1573 - .data = (void *)&s5pv210_spi_port_config, 1572 + .data = &s5pv210_spi_port_config, 1574 1573 }, 1575 1574 { .compatible = "samsung,exynos4210-spi", 1576 - .data = (void *)&exynos4_spi_port_config, 1575 + .data = &exynos4_spi_port_config, 1577 1576 }, 1578 1577 { .compatible = "samsung,exynos7-spi", 1579 - .data = (void *)&exynos7_spi_port_config, 1578 + .data = &exynos7_spi_port_config, 1580 1579 }, 1581 1580 { .compatible = "samsung,exynos5433-spi", 1582 - .data = (void *)&exynos5433_spi_port_config, 1581 + .data = &exynos5433_spi_port_config, 1583 1582 }, 1584 1583 { .compatible = "samsung,exynos850-spi", 1585 - .data = (void *)&exynos850_spi_port_config, 1584 + .data = &exynos850_spi_port_config, 1586 1585 }, 1587 1586 { .compatible = "samsung,exynosautov9-spi", 1588 - .data = (void *)&exynosautov9_spi_port_config, 1587 + .data = &exynosautov9_spi_port_config, 1589 1588 }, 1590 1589 { .compatible = "tesla,fsd-spi", 1591 - .data = (void *)&fsd_spi_port_config, 1590 + .data = &fsd_spi_port_config, 1592 1591 }, 1593 1592 { }, 1594 1593 };