forked from Minki/linux
Merge remote-tracking branch 'spi/topic/devm' into spi-qspi
Conflicts: drivers/spi/spi-ti-qspi.c
This commit is contained in:
commit
dabefd56c6
@ -302,3 +302,6 @@ PHY
|
||||
|
||||
SLAVE DMA ENGINE
|
||||
devm_acpi_dma_controller_register()
|
||||
|
||||
SPI
|
||||
devm_spi_register_master()
|
||||
|
@ -358,7 +358,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
|
||||
bcm2835_wr(bs, BCM2835_SPI_CS,
|
||||
BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
|
||||
|
||||
err = spi_register_master(master);
|
||||
err = devm_spi_register_master(&pdev->dev, master);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "could not register SPI master: %d\n", err);
|
||||
goto out_free_irq;
|
||||
@ -381,14 +381,12 @@ static int bcm2835_spi_remove(struct platform_device *pdev)
|
||||
struct bcm2835_spi *bs = spi_master_get_devdata(master);
|
||||
|
||||
free_irq(bs->irq, master);
|
||||
spi_unregister_master(master);
|
||||
|
||||
/* Clear FIFOs, and disable the HW block */
|
||||
bcm2835_wr(bs, BCM2835_SPI_CS,
|
||||
BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
|
||||
|
||||
clk_disable_unprepare(bs->clk);
|
||||
spi_master_put(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
|
||||
bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
|
||||
|
||||
/* register and we are done */
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(dev, master);
|
||||
if (ret) {
|
||||
dev_err(dev, "spi register failed\n");
|
||||
goto out_clk_disable;
|
||||
@ -438,8 +438,6 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)
|
||||
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
|
||||
struct bcm63xx_spi *bs = spi_master_get_devdata(master);
|
||||
|
||||
spi_unregister_master(master);
|
||||
|
||||
/* reset spi block */
|
||||
bcm_spi_writeb(bs, 0, SPI_INT_MASK);
|
||||
|
||||
@ -447,8 +445,6 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)
|
||||
clk_disable_unprepare(bs->clk);
|
||||
clk_put(bs->clk);
|
||||
|
||||
spi_master_put(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -867,7 +867,7 @@ static int bfin_spi_probe(struct platform_device *pdev)
|
||||
tasklet_init(&drv_data->pump_transfers,
|
||||
bfin_spi_pump_transfers, (unsigned long)drv_data);
|
||||
/* register with the SPI framework */
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(dev, master);
|
||||
if (ret) {
|
||||
dev_err(dev, "can not register spi master\n");
|
||||
goto err_free_peripheral;
|
||||
@ -898,7 +898,6 @@ static int bfin_spi_remove(struct platform_device *pdev)
|
||||
free_dma(drv_data->rx_dma);
|
||||
free_dma(drv_data->tx_dma);
|
||||
|
||||
spi_unregister_master(drv_data->master);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
|
||||
goto clk_out;
|
||||
}
|
||||
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (!ret) {
|
||||
dev_info(&pdev->dev,
|
||||
"SPI bus driver initialized. Master clock %u Hz\n",
|
||||
@ -247,7 +247,6 @@ err_out:
|
||||
gpio_free(hw->chipselect[i]);
|
||||
|
||||
spi_master_put(master);
|
||||
kfree(master);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -262,9 +261,6 @@ static int spi_clps711x_remove(struct platform_device *pdev)
|
||||
if (gpio_is_valid(hw->chipselect[i]))
|
||||
gpio_free(hw->chipselect[i]);
|
||||
|
||||
spi_unregister_master(master);
|
||||
kfree(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -942,7 +942,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
|
||||
/* make sure that the hardware is disabled */
|
||||
ep93xx_spi_write_u8(espi, SSPCR1, 0);
|
||||
|
||||
error = spi_register_master(master);
|
||||
error = devm_spi_register_master(&pdev->dev, master);
|
||||
if (error) {
|
||||
dev_err(&pdev->dev, "failed to register SPI master\n");
|
||||
goto fail_free_dma;
|
||||
@ -968,7 +968,6 @@ static int ep93xx_spi_remove(struct platform_device *pdev)
|
||||
|
||||
ep93xx_spi_release_dma(espi);
|
||||
|
||||
spi_unregister_master(master);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -534,7 +534,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
|
||||
if (ret < 0)
|
||||
goto free_clock;
|
||||
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(dev, master);
|
||||
if (ret < 0)
|
||||
goto free_clock;
|
||||
|
||||
@ -557,12 +557,10 @@ static int mpc512x_psc_spi_do_remove(struct device *dev)
|
||||
struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
|
||||
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
|
||||
|
||||
spi_unregister_master(master);
|
||||
clk_disable_unprepare(mps->clk_mclk);
|
||||
free_irq(mps->irq, mps);
|
||||
if (mps->psc)
|
||||
iounmap(mps->psc);
|
||||
spi_master_put(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, master);
|
||||
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Cannot register SPI master, %d\n", ret);
|
||||
goto out_disable_clk;
|
||||
@ -598,10 +598,8 @@ static int mxs_spi_remove(struct platform_device *pdev)
|
||||
spi = spi_master_get_devdata(master);
|
||||
ssp = &spi->ssp;
|
||||
|
||||
spi_unregister_master(master);
|
||||
clk_disable_unprepare(ssp->clk);
|
||||
dma_release_channel(ssp->dmach);
|
||||
spi_master_put(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ static int octeon_spi_probe(struct platform_device *pdev)
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
err = spi_register_master(master);
|
||||
err = devm_spi_register_master(&pdev->dev, master);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "register master failed: %d\n", err);
|
||||
goto fail;
|
||||
@ -292,8 +292,6 @@ static int octeon_spi_remove(struct platform_device *pdev)
|
||||
struct octeon_spi *p = spi_master_get_devdata(master);
|
||||
u64 register_base = p->register_base;
|
||||
|
||||
spi_unregister_master(master);
|
||||
|
||||
/* Clear the CSENA* and put everything in a known state. */
|
||||
cvmx_write_csr(register_base + OCTEON_SPI_CFG, 0);
|
||||
|
||||
|
@ -457,7 +457,7 @@ static int omap1_spi100k_probe(struct platform_device *pdev)
|
||||
goto err;
|
||||
}
|
||||
|
||||
status = spi_register_master(master);
|
||||
status = devm_spi_register_master(&pdev->dev, master);
|
||||
if (status < 0)
|
||||
goto err;
|
||||
|
||||
@ -485,8 +485,6 @@ static int omap1_spi100k_remove(struct platform_device *pdev)
|
||||
|
||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
|
||||
spi_unregister_master(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1407,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
|
||||
if (status < 0)
|
||||
goto disable_pm;
|
||||
|
||||
status = spi_register_master(master);
|
||||
status = devm_spi_register_master(&pdev->dev, master);
|
||||
if (status < 0)
|
||||
goto disable_pm;
|
||||
|
||||
@ -1435,7 +1435,6 @@ static int omap2_mcspi_remove(struct platform_device *pdev)
|
||||
pm_runtime_put_sync(mcspi->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
spi_unregister_master(master);
|
||||
kfree(dma_channels);
|
||||
|
||||
return 0;
|
||||
|
@ -457,7 +457,7 @@ static int orion_spi_probe(struct platform_device *pdev)
|
||||
goto out_rel_clk;
|
||||
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
status = spi_register_master(master);
|
||||
status = devm_spi_register_master(&pdev->dev, master);
|
||||
if (status < 0)
|
||||
goto out_rel_clk;
|
||||
|
||||
@ -483,8 +483,6 @@ static int orion_spi_remove(struct platform_device *pdev)
|
||||
clk_disable_unprepare(spi->clk);
|
||||
clk_put(spi->clk);
|
||||
|
||||
spi_unregister_master(master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1619,7 +1619,6 @@ static int verify_controller_parameters(struct pl022 *pl022,
|
||||
dev_err(&pl022->adev->dev,
|
||||
"RX FIFO Trigger Level is configured incorrectly\n");
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
switch (chip_info->tx_lev_trig) {
|
||||
case SSP_TX_1_OR_MORE_EMPTY_LOC:
|
||||
@ -1645,7 +1644,6 @@ static int verify_controller_parameters(struct pl022 *pl022,
|
||||
dev_err(&pl022->adev->dev,
|
||||
"TX FIFO Trigger Level is configured incorrectly\n");
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) {
|
||||
if ((chip_info->ctrl_len < SSP_BITS_4)
|
||||
@ -2227,7 +2225,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
|
||||
|
||||
/* Register with the SPI framework */
|
||||
amba_set_drvdata(adev, pl022);
|
||||
status = spi_register_master(master);
|
||||
status = devm_spi_register_master(&adev->dev, master);
|
||||
if (status != 0) {
|
||||
dev_err(&adev->dev,
|
||||
"probe - problem registering spi master\n");
|
||||
@ -2287,8 +2285,6 @@ pl022_remove(struct amba_device *adev)
|
||||
clk_unprepare(pl022->clk);
|
||||
amba_release_regions(adev);
|
||||
tasklet_disable(&pl022->pump_transfers);
|
||||
spi_unregister_master(pl022->master);
|
||||
amba_set_drvdata(adev, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1196,7 +1196,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
|
||||
|
||||
/* Register with the SPI framework */
|
||||
platform_set_drvdata(pdev, drv_data);
|
||||
status = spi_register_master(master);
|
||||
status = devm_spi_register_master(&pdev->dev, master);
|
||||
if (status != 0) {
|
||||
dev_err(&pdev->dev, "problem registering spi master\n");
|
||||
goto out_error_clock_enabled;
|
||||
@ -1248,9 +1248,6 @@ static int pxa2xx_spi_remove(struct platform_device *pdev)
|
||||
/* Release SSP */
|
||||
pxa_ssp_free(ssp);
|
||||
|
||||
/* Disconnect from the SPI framework */
|
||||
spi_unregister_master(drv_data->master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ static int hspi_probe(struct platform_device *pdev)
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA;
|
||||
master->auto_runtime_pm = true;
|
||||
master->transfer_one_message = hspi_transfer_one_message;
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "spi_register_master error.\n");
|
||||
goto error1;
|
||||
@ -328,7 +328,6 @@ static int hspi_remove(struct platform_device *pdev)
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
clk_put(hspi->clk);
|
||||
spi_unregister_master(hspi->master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1115,7 +1115,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
|
||||
pm_runtime_put(&pdev->dev);
|
||||
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "can not register to master err %d\n", ret);
|
||||
goto exit_pm_disable;
|
||||
@ -1142,7 +1142,6 @@ static int tegra_spi_remove(struct platform_device *pdev)
|
||||
struct tegra_spi_data *tspi = spi_master_get_devdata(master);
|
||||
|
||||
free_irq(tspi->irq, tspi);
|
||||
spi_unregister_master(master);
|
||||
|
||||
if (tspi->tx_dma_chan)
|
||||
tegra_spi_deinit_dma_param(tspi, false);
|
||||
|
@ -529,7 +529,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
|
||||
pm_runtime_put(&pdev->dev);
|
||||
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "can not register to master err %d\n", ret);
|
||||
goto exit_pm_disable;
|
||||
@ -553,7 +553,6 @@ static int tegra_sflash_remove(struct platform_device *pdev)
|
||||
struct tegra_sflash_data *tsd = spi_master_get_devdata(master);
|
||||
|
||||
free_irq(tsd->irq, tsd);
|
||||
spi_unregister_master(master);
|
||||
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
if (!pm_runtime_status_suspended(&pdev->dev))
|
||||
|
@ -1164,7 +1164,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
|
||||
pm_runtime_put(&pdev->dev);
|
||||
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "can not register to master err %d\n", ret);
|
||||
goto exit_pm_disable;
|
||||
@ -1191,7 +1191,6 @@ static int tegra_slink_remove(struct platform_device *pdev)
|
||||
struct tegra_slink_data *tspi = spi_master_get_devdata(master);
|
||||
|
||||
free_irq(tspi->irq, tspi);
|
||||
spi_unregister_master(master);
|
||||
|
||||
if (tspi->tx_dma_chan)
|
||||
tegra_slink_deinit_dma_param(tspi, false);
|
||||
|
@ -504,7 +504,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
|
||||
if (!of_property_read_u32(np, "spi-max-frequency", &max_freq))
|
||||
qspi->spi_max_frequency = max_freq;
|
||||
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&pdev->dev, master);
|
||||
if (ret)
|
||||
goto free_master;
|
||||
|
||||
@ -520,7 +520,6 @@ static int ti_qspi_remove(struct platform_device *pdev)
|
||||
struct ti_qspi *qspi = platform_get_drvdata(pdev);
|
||||
|
||||
ti_qspi_write(qspi, QSPI_WC_INT_DISABLE, QSPI_INTR_ENABLE_CLEAR_REG);
|
||||
spi_unregister_master(qspi->master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -531,7 +530,7 @@ static const struct dev_pm_ops ti_qspi_pm_ops = {
|
||||
|
||||
static struct platform_driver ti_qspi_driver = {
|
||||
.probe = ti_qspi_probe,
|
||||
.remove = ti_qspi_remove,
|
||||
.remove = ti_qspi_remove,
|
||||
.driver = {
|
||||
.name = "ti,dra7xxx-qspi",
|
||||
.owner = THIS_MODULE,
|
||||
|
@ -406,7 +406,7 @@ static int txx9spi_probe(struct platform_device *dev)
|
||||
master->num_chipselect = (u16)UINT_MAX; /* any GPIO numbers */
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
|
||||
|
||||
ret = spi_register_master(master);
|
||||
ret = devm_spi_register_master(&dev->dev, master);
|
||||
if (ret)
|
||||
goto exit;
|
||||
return 0;
|
||||
@ -428,11 +428,9 @@ static int txx9spi_remove(struct platform_device *dev)
|
||||
struct spi_master *master = spi_master_get(platform_get_drvdata(dev));
|
||||
struct txx9spi *c = spi_master_get_devdata(master);
|
||||
|
||||
spi_unregister_master(master);
|
||||
destroy_workqueue(c->workqueue);
|
||||
clk_disable(c->clk);
|
||||
clk_put(c->clk);
|
||||
spi_master_put(master);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1245,6 +1245,41 @@ done:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spi_register_master);
|
||||
|
||||
static void devm_spi_unregister(struct device *dev, void *res)
|
||||
{
|
||||
spi_unregister_master(*(struct spi_master **)res);
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_spi_register_master - register managed SPI master controller
|
||||
* @dev: device managing SPI master
|
||||
* @master: initialized master, originally from spi_alloc_master()
|
||||
* Context: can sleep
|
||||
*
|
||||
* Register a SPI device as with spi_register_master() which will
|
||||
* automatically be unregister
|
||||
*/
|
||||
int devm_spi_register_master(struct device *dev, struct spi_master *master)
|
||||
{
|
||||
struct spi_master **ptr;
|
||||
int ret;
|
||||
|
||||
ptr = devres_alloc(devm_spi_unregister, sizeof(*ptr), GFP_KERNEL);
|
||||
if (!ptr)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = spi_register_master(master);
|
||||
if (ret != 0) {
|
||||
*ptr = master;
|
||||
devres_add(dev, ptr);
|
||||
} else {
|
||||
devres_free(ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_spi_register_master);
|
||||
|
||||
static int __unregister(struct device *dev, void *null)
|
||||
{
|
||||
spi_unregister_device(to_spi_device(dev));
|
||||
|
@ -434,6 +434,8 @@ extern struct spi_master *
|
||||
spi_alloc_master(struct device *host, unsigned size);
|
||||
|
||||
extern int spi_register_master(struct spi_master *master);
|
||||
extern int devm_spi_register_master(struct device *dev,
|
||||
struct spi_master *master);
|
||||
extern void spi_unregister_master(struct spi_master *master);
|
||||
|
||||
extern struct spi_master *spi_busnum_to_master(u16 busnum);
|
||||
|
Loading…
Reference in New Issue
Block a user