Skip to content

Commit 2afccbd

Browse files
fancerbroonie
authored andcommitted
spi: dw: Discard static DW DMA slave structures
Having them declared is redundant since each struct dw_dma_chan has the same structure embedded and the structure from the passed dma_chan private pointer will be copied there as a result of the next calls chain: dma_request_channel() -> find_candidate() -> dma_chan_get() -> device_alloc_chan_resources() = dwc_alloc_chan_resources() -> dw_dma_filter(). So just remove the static dw_dma_chan structures and use a locally declared data instance with dst_id/src_id set to the same values as the static copies used to have. Co-developed-by: Georgy Vlasov <[email protected]> Signed-off-by: Georgy Vlasov <[email protected]> Co-developed-by: Ramil Zaripov <[email protected]> Signed-off-by: Ramil Zaripov <[email protected]> Signed-off-by: Serge Semin <[email protected]> Cc: Alexey Malahov <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 43dba9f commit 2afccbd

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

drivers/spi/spi-dw-mid.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#define RX_BUSY 0
2121
#define TX_BUSY 1
2222

23-
static struct dw_dma_slave mid_dma_tx = { .dst_id = 1 };
24-
static struct dw_dma_slave mid_dma_rx = { .src_id = 0 };
25-
2623
static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)
2724
{
2825
struct dw_dma_slave *s = param;
@@ -36,9 +33,11 @@ static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)
3633

3734
static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
3835
{
36+
struct dw_dma_slave slave = {
37+
.src_id = 0,
38+
.dst_id = 0
39+
};
3940
struct pci_dev *dma_dev;
40-
struct dw_dma_slave *tx = dws->dma_tx;
41-
struct dw_dma_slave *rx = dws->dma_rx;
4241
dma_cap_mask_t mask;
4342

4443
/*
@@ -53,14 +52,14 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
5352
dma_cap_set(DMA_SLAVE, mask);
5453

5554
/* 1. Init rx channel */
56-
rx->dma_dev = &dma_dev->dev;
57-
dws->rxchan = dma_request_channel(mask, mid_spi_dma_chan_filter, rx);
55+
slave.dma_dev = &dma_dev->dev;
56+
dws->rxchan = dma_request_channel(mask, mid_spi_dma_chan_filter, &slave);
5857
if (!dws->rxchan)
5958
goto err_exit;
6059

6160
/* 2. Init tx channel */
62-
tx->dma_dev = &dma_dev->dev;
63-
dws->txchan = dma_request_channel(mask, mid_spi_dma_chan_filter, tx);
61+
slave.dst_id = 1;
62+
dws->txchan = dma_request_channel(mask, mid_spi_dma_chan_filter, &slave);
6463
if (!dws->txchan)
6564
goto free_rxchan;
6665

@@ -317,8 +316,6 @@ static const struct dw_spi_dma_ops mfld_dma_ops = {
317316

318317
static void dw_spi_mid_setup_dma_mfld(struct dw_spi *dws)
319318
{
320-
dws->dma_tx = &mid_dma_tx;
321-
dws->dma_rx = &mid_dma_rx;
322319
dws->dma_ops = &mfld_dma_ops;
323320
}
324321

drivers/spi/spi-dw.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ struct dw_spi {
146146
unsigned long dma_chan_busy;
147147
dma_addr_t dma_addr; /* phy address of the Data register */
148148
const struct dw_spi_dma_ops *dma_ops;
149-
void *dma_tx;
150-
void *dma_rx;
151149

152150
/* Bus interface info */
153151
void *priv;

0 commit comments

Comments
 (0)