mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
UPSTREAM: spi: rockchip: remove master pointer from dev data
In almost all cases we already have a pointer to the
spi master structure where we have the driver data.
The only exceptions are the dma callbacks which are
easily fixed by passing them the master and using
spi_master_get_devdata to retrieve the driver data.
Change-Id: Ia821c4924ca243447c0aa6c1a61ea4ef6319ff0a
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d790c342e6)
This commit is contained in:
committed by
Tao Huang
parent
ea2f9daa4c
commit
9378f64680
@@ -166,7 +166,6 @@
|
||||
|
||||
struct rockchip_spi {
|
||||
struct device *dev;
|
||||
struct spi_master *master;
|
||||
|
||||
struct clk *spiclk;
|
||||
struct clk *apb_pclk;
|
||||
@@ -359,19 +358,21 @@ static int rockchip_spi_pio_transfer(struct rockchip_spi *rs)
|
||||
|
||||
static void rockchip_spi_dma_rxcb(void *data)
|
||||
{
|
||||
struct rockchip_spi *rs = data;
|
||||
struct spi_master *master = data;
|
||||
struct rockchip_spi *rs = spi_master_get_devdata(master);
|
||||
int state = atomic_fetch_andnot(RXDMA, &rs->state);
|
||||
|
||||
if (state & TXDMA)
|
||||
return;
|
||||
|
||||
spi_enable_chip(rs, false);
|
||||
spi_finalize_current_transfer(rs->master);
|
||||
spi_finalize_current_transfer(master);
|
||||
}
|
||||
|
||||
static void rockchip_spi_dma_txcb(void *data)
|
||||
{
|
||||
struct rockchip_spi *rs = data;
|
||||
struct spi_master *master = data;
|
||||
struct rockchip_spi *rs = spi_master_get_devdata(master);
|
||||
int state = atomic_fetch_andnot(TXDMA, &rs->state);
|
||||
|
||||
if (state & RXDMA)
|
||||
@@ -381,7 +382,7 @@ static void rockchip_spi_dma_txcb(void *data)
|
||||
wait_for_idle(rs);
|
||||
|
||||
spi_enable_chip(rs, false);
|
||||
spi_finalize_current_transfer(rs->master);
|
||||
spi_finalize_current_transfer(master);
|
||||
}
|
||||
|
||||
static u32 rockchip_spi_calc_burst_size(u32 data_len)
|
||||
@@ -424,7 +425,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
|
||||
return -EINVAL;
|
||||
|
||||
rxdesc->callback = rockchip_spi_dma_rxcb;
|
||||
rxdesc->callback_param = rs;
|
||||
rxdesc->callback_param = master;
|
||||
}
|
||||
|
||||
txdesc = NULL;
|
||||
@@ -449,7 +450,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
|
||||
}
|
||||
|
||||
txdesc->callback = rockchip_spi_dma_txcb;
|
||||
txdesc->callback_param = rs;
|
||||
txdesc->callback_param = master;
|
||||
}
|
||||
|
||||
/* rx must be started before tx due to spi instinct */
|
||||
@@ -670,7 +671,6 @@ static int rockchip_spi_probe(struct platform_device *pdev)
|
||||
|
||||
spi_enable_chip(rs, false);
|
||||
|
||||
rs->master = master;
|
||||
rs->dev = &pdev->dev;
|
||||
rs->max_freq = clk_get_rate(rs->spiclk);
|
||||
|
||||
@@ -790,9 +790,8 @@ static int rockchip_spi_suspend(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct spi_master *master = dev_get_drvdata(dev);
|
||||
struct rockchip_spi *rs = spi_master_get_devdata(master);
|
||||
|
||||
ret = spi_master_suspend(rs->master);
|
||||
ret = spi_master_suspend(master);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -817,7 +816,7 @@ static int rockchip_spi_resume(struct device *dev)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = spi_master_resume(rs->master);
|
||||
ret = spi_master_resume(master);
|
||||
if (ret < 0) {
|
||||
clk_disable_unprepare(rs->spiclk);
|
||||
clk_disable_unprepare(rs->apb_pclk);
|
||||
|
||||
Reference in New Issue
Block a user