Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypt: bfin_crc - Remove useless SSYNC instruction and cache flush to DMA coherent memory

1) SSYNC instruction is blackfin specific and takes no effect in this driver.
2) DMA descriptor and SG middle buffer are in DMA coherent memory. No need
to flush.
3) Turn kzalloc, ioremap and request_irq into managed device APIs respectively.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Sonic Zhang and committed by
Herbert Xu
4ea5d999 3d6f1d12

+11 -34
+11 -34
drivers/crypto/bfin_crc.c
··· 139 139 /* setup CRC interrupts */ 140 140 crc->regs->status = CMPERRI | DCNTEXPI; 141 141 crc->regs->intrenset = CMPERRI | DCNTEXPI; 142 - SSYNC(); 143 142 144 143 return 0; 145 144 } ··· 284 285 if (i == 0) 285 286 return; 286 287 287 - flush_dcache_range((unsigned int)crc->sg_cpu, 288 - (unsigned int)crc->sg_cpu + 289 - i * sizeof(struct dma_desc_array)); 290 - 291 288 /* Set the last descriptor to stop mode */ 292 289 crc->sg_cpu[i - 1].cfg &= ~(DMAFLOW | NDSIZE); 293 290 crc->sg_cpu[i - 1].cfg |= DI_EN; 294 291 set_dma_curr_desc_addr(crc->dma_ch, (unsigned long *)crc->sg_dma); 295 292 set_dma_x_count(crc->dma_ch, 0); 296 293 set_dma_x_modify(crc->dma_ch, 0); 297 - SSYNC(); 298 294 set_dma_config(crc->dma_ch, dma_config); 299 295 } 300 296 ··· 409 415 410 416 /* finally kick off CRC operation */ 411 417 crc->regs->control |= BLKEN; 412 - SSYNC(); 413 418 414 419 return -EINPROGRESS; 415 420 } ··· 532 539 533 540 if (crc->regs->status & DCNTEXP) { 534 541 crc->regs->status = DCNTEXP; 535 - SSYNC(); 536 542 537 543 /* prepare results */ 538 544 put_unaligned_le32(crc->regs->result, crc->req->result); ··· 586 594 unsigned int timeout = 100000; 587 595 int ret; 588 596 589 - crc = kzalloc(sizeof(*crc), GFP_KERNEL); 597 + crc = devm_kzalloc(dev, sizeof(*crc), GFP_KERNEL); 590 598 if (!crc) { 591 599 dev_err(&pdev->dev, "fail to malloc bfin_crypto_crc\n"); 592 600 return -ENOMEM; ··· 602 610 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 603 611 if (res == NULL) { 604 612 dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); 605 - ret = -ENOENT; 606 - goto out_error_free_mem; 613 + return -ENOENT; 607 614 } 608 615 609 - crc->regs = ioremap(res->start, resource_size(res)); 610 - if (!crc->regs) { 616 + crc->regs = devm_ioremap_resource(dev, res); 617 + if (IS_ERR((void *)crc->regs)) { 611 618 dev_err(&pdev->dev, "Cannot map CRC IO\n"); 612 - ret = -ENXIO; 613 - goto out_error_free_mem; 619 + return PTR_ERR((void *)crc->regs); 614 620 } 615 621 616 622 crc->irq = platform_get_irq(pdev, 0); 617 623 if (crc->irq < 0) { 618 624 dev_err(&pdev->dev, "No CRC DCNTEXP IRQ specified\n"); 619 - ret = -ENOENT; 620 - goto out_error_unmap; 625 + return -ENOENT; 621 626 } 622 627 623 - ret = request_irq(crc->irq, bfin_crypto_crc_handler, IRQF_SHARED, dev_name(dev), crc); 628 + ret = devm_request_irq(dev, crc->irq, bfin_crypto_crc_handler, 629 + IRQF_SHARED, dev_name(dev), crc); 624 630 if (ret) { 625 631 dev_err(&pdev->dev, "Unable to request blackfin crc irq\n"); 626 - goto out_error_unmap; 632 + return ret; 627 633 } 628 634 629 635 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 630 636 if (res == NULL) { 631 637 dev_err(&pdev->dev, "No CRC DMA channel specified\n"); 632 - ret = -ENOENT; 633 - goto out_error_irq; 638 + return -ENOENT; 634 639 } 635 640 crc->dma_ch = res->start; 636 641 637 642 ret = request_dma(crc->dma_ch, dev_name(dev)); 638 643 if (ret) { 639 644 dev_err(&pdev->dev, "Unable to attach Blackfin CRC DMA channel\n"); 640 - goto out_error_irq; 645 + return ret; 641 646 } 642 647 643 648 crc->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &crc->sg_dma, GFP_KERNEL); ··· 649 660 crc->sg_mid_buf = (u8 *)(crc->sg_cpu + ((CRC_MAX_DMA_DESC + 1) << 1)); 650 661 651 662 crc->regs->control = 0; 652 - SSYNC(); 653 663 crc->regs->poly = crc->poly = (u32)pdev->dev.platform_data; 654 - SSYNC(); 655 664 656 665 while (!(crc->regs->status & LUTDONE) && (--timeout) > 0) 657 666 cpu_relax(); ··· 680 693 if (crc->sg_cpu) 681 694 dma_free_coherent(&pdev->dev, PAGE_SIZE, crc->sg_cpu, crc->sg_dma); 682 695 free_dma(crc->dma_ch); 683 - out_error_irq: 684 - free_irq(crc->irq, crc); 685 - out_error_unmap: 686 - iounmap((void *)crc->regs); 687 - out_error_free_mem: 688 - kfree(crc); 689 696 690 697 return ret; 691 698 } ··· 702 721 crypto_unregister_ahash(&algs); 703 722 tasklet_kill(&crc->done_task); 704 723 free_dma(crc->dma_ch); 705 - if (crc->irq > 0) 706 - free_irq(crc->irq, crc); 707 - iounmap((void *)crc->regs); 708 - kfree(crc); 709 724 710 725 return 0; 711 726 }