diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2016-04-29 09:02:18 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-05-03 04:08:49 -0400 |
commit | da8b29a6c1894874b681f42186c61c58c09e0b56 (patch) | |
tree | 649d2f6550ba5e713e364cdf4db68c3fcb6caa13 | |
parent | f1b77aaca85a610948f02d11288845f4cfe7d3eb (diff) |
crypto: omap-aes - 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-aes.c | 62 |
1 files changed, 16 insertions, 46 deletions
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index d420ec751c7c..ce174d3b842c 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/scatterlist.h> | 26 | #include <linux/scatterlist.h> |
27 | #include <linux/dma-mapping.h> | 27 | #include <linux/dma-mapping.h> |
28 | #include <linux/dmaengine.h> | 28 | #include <linux/dmaengine.h> |
29 | #include <linux/omap-dma.h> | ||
30 | #include <linux/pm_runtime.h> | 29 | #include <linux/pm_runtime.h> |
31 | #include <linux/of.h> | 30 | #include <linux/of.h> |
32 | #include <linux/of_device.h> | 31 | #include <linux/of_device.h> |
@@ -176,9 +175,7 @@ struct omap_aes_dev { | |||
176 | 175 | ||
177 | struct scatter_walk in_walk; | 176 | struct scatter_walk in_walk; |
178 | struct scatter_walk out_walk; | 177 | struct scatter_walk out_walk; |
179 | int dma_in; | ||
180 | struct dma_chan *dma_lch_in; | 178 | struct dma_chan *dma_lch_in; |
181 | int dma_out; | ||
182 | struct dma_chan *dma_lch_out; | 179 | struct dma_chan *dma_lch_out; |
183 | int in_sg_len; | 180 | int in_sg_len; |
184 | int out_sg_len; | 181 | int out_sg_len; |
@@ -351,30 +348,21 @@ static void omap_aes_dma_out_callback(void *data) | |||
351 | 348 | ||
352 | static int omap_aes_dma_init(struct omap_aes_dev *dd) | 349 | static int omap_aes_dma_init(struct omap_aes_dev *dd) |
353 | { | 350 | { |
354 | int err = -ENOMEM; | 351 | int err; |
355 | dma_cap_mask_t mask; | ||
356 | 352 | ||
357 | dd->dma_lch_out = NULL; | 353 | dd->dma_lch_out = NULL; |
358 | dd->dma_lch_in = NULL; | 354 | dd->dma_lch_in = NULL; |
359 | 355 | ||
360 | dma_cap_zero(mask); | 356 | dd->dma_lch_in = dma_request_chan(dd->dev, "rx"); |
361 | dma_cap_set(DMA_SLAVE, mask); | 357 | if (IS_ERR(dd->dma_lch_in)) { |
362 | |||
363 | dd->dma_lch_in = dma_request_slave_channel_compat(mask, | ||
364 | omap_dma_filter_fn, | ||
365 | &dd->dma_in, | ||
366 | dd->dev, "rx"); | ||
367 | if (!dd->dma_lch_in) { | ||
368 | dev_err(dd->dev, "Unable to request in DMA channel\n"); | 358 | dev_err(dd->dev, "Unable to request in DMA channel\n"); |
369 | goto err_dma_in; | 359 | return PTR_ERR(dd->dma_lch_in); |
370 | } | 360 | } |
371 | 361 | ||
372 | dd->dma_lch_out = dma_request_slave_channel_compat(mask, | 362 | dd->dma_lch_out = dma_request_chan(dd->dev, "tx"); |
373 | omap_dma_filter_fn, | 363 | if (IS_ERR(dd->dma_lch_out)) { |
374 | &dd->dma_out, | ||
375 | dd->dev, "tx"); | ||
376 | if (!dd->dma_lch_out) { | ||
377 | dev_err(dd->dev, "Unable to request out DMA channel\n"); | 364 | dev_err(dd->dev, "Unable to request out DMA channel\n"); |
365 | err = PTR_ERR(dd->dma_lch_out); | ||
378 | goto err_dma_out; | 366 | goto err_dma_out; |
379 | } | 367 | } |
380 | 368 | ||
@@ -382,14 +370,15 @@ static int omap_aes_dma_init(struct omap_aes_dev *dd) | |||
382 | 370 | ||
383 | err_dma_out: | 371 | err_dma_out: |
384 | dma_release_channel(dd->dma_lch_in); | 372 | dma_release_channel(dd->dma_lch_in); |
385 | err_dma_in: | 373 | |
386 | if (err) | ||
387 | pr_err("error: %d\n", err); | ||
388 | return err; | 374 | return err; |
389 | } | 375 | } |
390 | 376 | ||
391 | static void omap_aes_dma_cleanup(struct omap_aes_dev *dd) | 377 | static void omap_aes_dma_cleanup(struct omap_aes_dev *dd) |
392 | { | 378 | { |
379 | if (dd->pio_only) | ||
380 | return; | ||
381 | |||
393 | dma_release_channel(dd->dma_lch_out); | 382 | dma_release_channel(dd->dma_lch_out); |
394 | dma_release_channel(dd->dma_lch_in); | 383 | dma_release_channel(dd->dma_lch_in); |
395 | } | 384 | } |
@@ -1080,9 +1069,6 @@ static int omap_aes_get_res_of(struct omap_aes_dev *dd, | |||
1080 | goto err; | 1069 | goto err; |
1081 | } | 1070 | } |
1082 | 1071 | ||
1083 | dd->dma_out = -1; /* Dummy value that's unused */ | ||
1084 | dd->dma_in = -1; /* Dummy value that's unused */ | ||
1085 | |||
1086 | dd->pdata = match->data; | 1072 | dd->pdata = match->data; |
1087 | 1073 | ||
1088 | err: | 1074 | err: |
@@ -1116,24 +1102,6 @@ static int omap_aes_get_res_pdev(struct omap_aes_dev *dd, | |||
1116 | } | 1102 | } |
1117 | memcpy(res, r, sizeof(*res)); | 1103 | memcpy(res, r, sizeof(*res)); |
1118 | 1104 | ||
1119 | /* Get the DMA out channel */ | ||
1120 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
1121 | if (!r) { | ||
1122 | dev_err(dev, "no DMA out resource info\n"); | ||
1123 | err = -ENODEV; | ||
1124 | goto err; | ||
1125 | } | ||
1126 | dd->dma_out = r->start; | ||
1127 | |||
1128 | /* Get the DMA in channel */ | ||
1129 | r = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
1130 | if (!r) { | ||
1131 | dev_err(dev, "no DMA in resource info\n"); | ||
1132 | err = -ENODEV; | ||
1133 | goto err; | ||
1134 | } | ||
1135 | dd->dma_in = r->start; | ||
1136 | |||
1137 | /* Only OMAP2/3 can be non-DT */ | 1105 | /* Only OMAP2/3 can be non-DT */ |
1138 | dd->pdata = &omap_aes_pdata_omap2; | 1106 | dd->pdata = &omap_aes_pdata_omap2; |
1139 | 1107 | ||
@@ -1191,7 +1159,9 @@ static int omap_aes_probe(struct platform_device *pdev) | |||
1191 | tasklet_init(&dd->done_task, omap_aes_done_task, (unsigned long)dd); | 1159 | tasklet_init(&dd->done_task, omap_aes_done_task, (unsigned long)dd); |
1192 | 1160 | ||
1193 | err = omap_aes_dma_init(dd); | 1161 | err = omap_aes_dma_init(dd); |
1194 | if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) { | 1162 | if (err == -EPROBE_DEFER) { |
1163 | goto err_irq; | ||
1164 | } else if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) { | ||
1195 | dd->pio_only = 1; | 1165 | dd->pio_only = 1; |
1196 | 1166 | ||
1197 | irq = platform_get_irq(pdev, 0); | 1167 | irq = platform_get_irq(pdev, 0); |
@@ -1248,8 +1218,8 @@ err_algs: | |||
1248 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) | 1218 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) |
1249 | crypto_unregister_alg( | 1219 | crypto_unregister_alg( |
1250 | &dd->pdata->algs_info[i].algs_list[j]); | 1220 | &dd->pdata->algs_info[i].algs_list[j]); |
1251 | if (!dd->pio_only) | 1221 | |
1252 | omap_aes_dma_cleanup(dd); | 1222 | omap_aes_dma_cleanup(dd); |
1253 | err_irq: | 1223 | err_irq: |
1254 | tasklet_kill(&dd->done_task); | 1224 | tasklet_kill(&dd->done_task); |
1255 | pm_runtime_disable(dev); | 1225 | pm_runtime_disable(dev); |