Skip to content

Commit 45a536e

Browse files
Peter Ujfalusiherbertx
authored andcommitted
crypto: atmel-tdes - Retire dma_request_slave_channel_compat()
The driver no longer boots in legacy mode, only via DT. This makes the dma_request_slave_channel_compat() redundant. If ever the filter function would be executed it will return false as the dma_slave is not really initialized. Switch to use dma_request_chan() which would allow legacy boot if ever needed again by configuring dma_slave_map for the DMA driver. At the same time skip allocating memory for dma_slave as it is not used anymore. Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent db28512 commit 45a536e

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

drivers/crypto/atmel-tdes.c

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -739,31 +739,17 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)
739739
return atmel_tdes_handle_queue(ctx->dd, req);
740740
}
741741

742-
static bool atmel_tdes_filter(struct dma_chan *chan, void *slave)
743-
{
744-
struct at_dma_slave *sl = slave;
745-
746-
if (sl && sl->dma_dev == chan->device->dev) {
747-
chan->private = sl;
748-
return true;
749-
} else {
750-
return false;
751-
}
752-
}
753-
754742
static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd,
755743
struct crypto_platform_data *pdata)
756744
{
757-
dma_cap_mask_t mask;
758-
759-
dma_cap_zero(mask);
760-
dma_cap_set(DMA_SLAVE, mask);
745+
int ret;
761746

762747
/* Try to grab 2 DMA channels */
763-
dd->dma_lch_in.chan = dma_request_slave_channel_compat(mask,
764-
atmel_tdes_filter, &pdata->dma_slave->rxdata, dd->dev, "tx");
765-
if (!dd->dma_lch_in.chan)
748+
dd->dma_lch_in.chan = dma_request_chan(dd->dev, "tx");
749+
if (IS_ERR(dd->dma_lch_in.chan)) {
750+
ret = PTR_ERR(dd->dma_lch_in.chan);
766751
goto err_dma_in;
752+
}
767753

768754
dd->dma_lch_in.dma_conf.direction = DMA_MEM_TO_DEV;
769755
dd->dma_lch_in.dma_conf.dst_addr = dd->phys_base +
@@ -776,10 +762,11 @@ static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd,
776762
DMA_SLAVE_BUSWIDTH_4_BYTES;
777763
dd->dma_lch_in.dma_conf.device_fc = false;
778764

779-
dd->dma_lch_out.chan = dma_request_slave_channel_compat(mask,
780-
atmel_tdes_filter, &pdata->dma_slave->txdata, dd->dev, "rx");
781-
if (!dd->dma_lch_out.chan)
765+
dd->dma_lch_out.chan = dma_request_chan(dd->dev, "rx");
766+
if (IS_ERR(dd->dma_lch_out.chan)) {
767+
ret = PTR_ERR(dd->dma_lch_out.chan);
782768
goto err_dma_out;
769+
}
783770

784771
dd->dma_lch_out.dma_conf.direction = DMA_DEV_TO_MEM;
785772
dd->dma_lch_out.dma_conf.src_addr = dd->phys_base +
@@ -797,8 +784,9 @@ static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd,
797784
err_dma_out:
798785
dma_release_channel(dd->dma_lch_in.chan);
799786
err_dma_in:
800-
dev_warn(dd->dev, "no DMA channel available\n");
801-
return -ENODEV;
787+
if (ret != -EPROBE_DEFER)
788+
dev_warn(dd->dev, "no DMA channel available\n");
789+
return ret;
802790
}
803791

804792
static void atmel_tdes_dma_cleanup(struct atmel_tdes_dev *dd)
@@ -1229,12 +1217,6 @@ static struct crypto_platform_data *atmel_tdes_of_init(struct platform_device *p
12291217
if (!pdata)
12301218
return ERR_PTR(-ENOMEM);
12311219

1232-
pdata->dma_slave = devm_kzalloc(&pdev->dev,
1233-
sizeof(*(pdata->dma_slave)),
1234-
GFP_KERNEL);
1235-
if (!pdata->dma_slave)
1236-
return ERR_PTR(-ENOMEM);
1237-
12381220
return pdata;
12391221
}
12401222
#else /* CONFIG_OF */
@@ -1328,10 +1310,7 @@ static int atmel_tdes_probe(struct platform_device *pdev)
13281310
goto err_pdata;
13291311
}
13301312
}
1331-
if (!pdata->dma_slave) {
1332-
err = -ENXIO;
1333-
goto err_pdata;
1334-
}
1313+
13351314
err = atmel_tdes_dma_init(tdes_dd, pdata);
13361315
if (err)
13371316
goto err_tdes_dma;

0 commit comments

Comments
 (0)