diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2016-04-29 09:02:56 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-05-03 04:09:14 -0400 |
commit | 2f6f0680c78e2bc35f576ea956b284aa45cef0d1 (patch) | |
tree | 8249d68b55f50584d8f57336e582958e81143c4a | |
parent | da8b29a6c1894874b681f42186c61c58c09e0b56 (diff) |
crypto: omap-des - Use dma_request_chan() for requesting DMA channel
With the new dma_request_chan() the client driver does not need to look for
the DMA resource and it does not need to pass filter_fn anymore.
By switching to the new API the driver can now support deferred probing
against DMA.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: David S. Miller <davem@davemloft.net>
CC: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/omap-des.c | 68 |
1 files changed, 17 insertions, 51 deletions
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index b9a465fc2300..3eedb03111ba 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/scatterlist.h> | 29 | #include <linux/scatterlist.h> |
30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
31 | #include <linux/dmaengine.h> | 31 | #include <linux/dmaengine.h> |
32 | #include <linux/omap-dma.h> | ||
33 | #include <linux/pm_runtime.h> | 32 | #include <linux/pm_runtime.h> |
34 | #include <linux/of.h> | 33 | #include <linux/of.h> |
35 | #include <linux/of_device.h> | 34 | #include <linux/of_device.h> |
@@ -155,9 +154,7 @@ struct omap_des_dev { | |||
155 | 154 | ||
156 | struct scatter_walk in_walk; | 155 | struct scatter_walk in_walk; |
157 | struct scatter_walk out_walk; | 156 | struct scatter_walk out_walk; |
158 | int dma_in; | ||
159 | struct dma_chan *dma_lch_in; | 157 | struct dma_chan *dma_lch_in; |
160 | int dma_out; | ||
161 | struct dma_chan *dma_lch_out; | 158 | struct dma_chan *dma_lch_out; |
162 | int in_sg_len; | 159 | int in_sg_len; |
163 | int out_sg_len; | 160 | int out_sg_len; |
@@ -337,30 +334,21 @@ static void omap_des_dma_out_callback(void *data) | |||
337 | 334 | ||
338 | static int omap_des_dma_init(struct omap_des_dev *dd) | 335 | static int omap_des_dma_init(struct omap_des_dev *dd) |
339 | { | 336 | { |
340 | int err = -ENOMEM; | 337 | int err; |
341 | dma_cap_mask_t mask; | ||
342 | 338 | ||
343 | dd->dma_lch_out = NULL; | 339 | dd->dma_lch_out = NULL; |
344 | dd->dma_lch_in = NULL; | 340 | dd->dma_lch_in = NULL; |
345 | 341 | ||
346 | dma_cap_zero(mask); | 342 | dd->dma_lch_in = dma_request_chan(dd->dev, "rx"); |
347 | dma_cap_set(DMA_SLAVE, mask); | 343 | if (IS_ERR(dd->dma_lch_in)) { |
348 | |||
349 | dd->dma_lch_in = dma_request_slave_channel_compat(mask, | ||
350 | omap_dma_filter_fn, | ||
351 | &dd->dma_in, | ||
352 | dd->dev, "rx"); | ||
353 | if (!dd->dma_lch_in) { | ||
354 | dev_err(dd->dev, "Unable to request in DMA channel\n"); | 344 | dev_err(dd->dev, "Unable to request in DMA channel\n"); |
355 | goto err_dma_in; | 345 | return PTR_ERR(dd->dma_lch_in); |
356 | } | 346 | } |
357 | 347 | ||
358 | dd->dma_lch_out = dma_request_slave_channel_compat(mask, | 348 | dd->dma_lch_out = dma_request_chan(dd->dev, "tx"); |
359 | omap_dma_filter_fn, | 349 | if (IS_ERR(dd->dma_lch_out)) { |
360 | &dd->dma_out, | ||
361 | dd->dev, "tx"); | ||
362 | if (!dd->dma_lch_out) { | ||
363 | dev_err(dd->dev, "Unable to request out DMA channel\n"); | 350 | dev_err(dd->dev, "Unable to request out DMA channel\n"); |
351 | err = PTR_ERR(dd->dma_lch_out); | ||
364 | goto err_dma_out; | 352 | goto err_dma_out; |
365 | } | 353 | } |
366 | 354 | ||
@@ -368,14 +356,15 @@ static int omap_des_dma_init(struct omap_des_dev *dd) | |||
368 | 356 | ||
369 | err_dma_out: | 357 | err_dma_out: |
370 | dma_release_channel(dd->dma_lch_in); | 358 | dma_release_channel(dd->dma_lch_in); |
371 | err_dma_in: | 359 | |
372 | if (err) | ||
373 | pr_err("error: %d\n", err); | ||
374 | return err; | 360 | return err; |
375 | } | 361 | } |
376 | 362 | ||
377 | static void omap_des_dma_cleanup(struct omap_des_dev *dd) | 363 | static void omap_des_dma_cleanup(struct omap_des_dev *dd) |
378 | { | 364 | { |
365 | if (dd->pio_only) | ||
366 | return; | ||
367 | |||
379 | dma_release_channel(dd->dma_lch_out); | 368 | dma_release_channel(dd->dma_lch_out); |
380 | dma_release_channel(dd->dma_lch_in); | 369 | dma_release_channel(dd->dma_lch_in); |
381 | } | 370 | } |
@@ -980,8 +969,6 @@ static int omap_des_get_of(struct omap_des_dev *dd, | |||
980 | return -EINVAL; | 969 | return -EINVAL; |
981 | } | 970 | } |
982 | 971 | ||
983 | dd->dma_out = -1; /* Dummy value that's unused */ | ||
984 | dd->dma_in = -1; /* Dummy value that's unused */ | ||
985 | dd->pdata = match->data; | 972 | dd->pdata = match->data; |
986 | 973 | ||
987 | return 0; | 974 | return 0; |
@@ -997,33 +984,10 @@ static int omap_des_get_of(struct omap_des_dev *dd, | |||
997 | static int omap_des_get_pdev(struct omap_des_dev *dd, | 984 | static int omap_des_get_pdev(struct omap_des_dev *dd, |
998 | struct platform_device *pdev) | 985 | struct platform_device *pdev) |
999 | { | 986 | { |
1000 | struct device *dev = &pdev->dev; | ||
1001 | struct resource *r; | ||
1002 | int err = 0; | ||
1003 | |||
1004 | /* Get the DMA out channel */ | ||
1005 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
1006 | if (!r) { | ||
1007 | dev_err(dev, "no DMA out resource info\n"); | ||
1008 | err = -ENODEV; | ||
1009 | goto err; | ||
1010 | } | ||
1011 | dd->dma_out = r->start; | ||
1012 | |||
1013 | /* Get the DMA in channel */ | ||
1014 | r = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
1015 | if (!r) { | ||
1016 | dev_err(dev, "no DMA in resource info\n"); | ||
1017 | err = -ENODEV; | ||
1018 | goto err; | ||
1019 | } | ||
1020 | dd->dma_in = r->start; | ||
1021 | |||
1022 | /* non-DT devices get pdata from pdev */ | 987 | /* non-DT devices get pdata from pdev */ |
1023 | dd->pdata = pdev->dev.platform_data; | 988 | dd->pdata = pdev->dev.platform_data; |
1024 | 989 | ||
1025 | err: | 990 | return 0; |
1026 | return err; | ||
1027 | } | 991 | } |
1028 | 992 | ||
1029 | static int omap_des_probe(struct platform_device *pdev) | 993 | static int omap_des_probe(struct platform_device *pdev) |
@@ -1083,7 +1047,9 @@ static int omap_des_probe(struct platform_device *pdev) | |||
1083 | tasklet_init(&dd->done_task, omap_des_done_task, (unsigned long)dd); | 1047 | tasklet_init(&dd->done_task, omap_des_done_task, (unsigned long)dd); |
1084 | 1048 | ||
1085 | err = omap_des_dma_init(dd); | 1049 | err = omap_des_dma_init(dd); |
1086 | if (err && DES_REG_IRQ_STATUS(dd) && DES_REG_IRQ_ENABLE(dd)) { | 1050 | if (err == -EPROBE_DEFER) { |
1051 | goto err_irq; | ||
1052 | } else if (err && DES_REG_IRQ_STATUS(dd) && DES_REG_IRQ_ENABLE(dd)) { | ||
1087 | dd->pio_only = 1; | 1053 | dd->pio_only = 1; |
1088 | 1054 | ||
1089 | irq = platform_get_irq(pdev, 0); | 1055 | irq = platform_get_irq(pdev, 0); |
@@ -1141,8 +1107,8 @@ err_algs: | |||
1141 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) | 1107 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) |
1142 | crypto_unregister_alg( | 1108 | crypto_unregister_alg( |
1143 | &dd->pdata->algs_info[i].algs_list[j]); | 1109 | &dd->pdata->algs_info[i].algs_list[j]); |
1144 | if (!dd->pio_only) | 1110 | |
1145 | omap_des_dma_cleanup(dd); | 1111 | omap_des_dma_cleanup(dd); |
1146 | err_irq: | 1112 | err_irq: |
1147 | tasklet_kill(&dd->done_task); | 1113 | tasklet_kill(&dd->done_task); |
1148 | err_get: | 1114 | err_get: |