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

Configure Feed

Select the types of activity you want to include in your feed.

Improve error handling in Rockchip SPI drivers

Merge series from Dragan Simic <dsimic@manjaro.org>:

This is a small series that improves error handling in the probe path
of the Rockchip SPI drivers, by using dev_err_probe() properly in multiple
places. It also performs a bunch of small, rather trivial code
cleanups, to make the code neater and a bit easier to read.

+21 -29
+8 -13
drivers/spi/spi-rockchip-sfc.c
··· 580 580 return PTR_ERR(sfc->regbase); 581 581 582 582 sfc->clk = devm_clk_get(&pdev->dev, "clk_sfc"); 583 - if (IS_ERR(sfc->clk)) { 584 - dev_err(&pdev->dev, "Failed to get sfc interface clk\n"); 585 - return PTR_ERR(sfc->clk); 586 - } 583 + if (IS_ERR(sfc->clk)) 584 + return dev_err_probe(&pdev->dev, PTR_ERR(sfc->clk), 585 + "Failed to get sfc interface clk\n"); 587 586 588 587 sfc->hclk = devm_clk_get(&pdev->dev, "hclk_sfc"); 589 - if (IS_ERR(sfc->hclk)) { 590 - dev_err(&pdev->dev, "Failed to get sfc ahb clk\n"); 591 - return PTR_ERR(sfc->hclk); 592 - } 588 + if (IS_ERR(sfc->hclk)) 589 + return dev_err_probe(&pdev->dev, PTR_ERR(sfc->hclk), 590 + "Failed to get sfc ahb clk\n"); 593 591 594 - sfc->use_dma = !of_property_read_bool(sfc->dev->of_node, 595 - "rockchip,sfc-no-dma"); 592 + sfc->use_dma = !of_property_read_bool(sfc->dev->of_node, "rockchip,sfc-no-dma"); 596 593 597 594 if (sfc->use_dma) { 598 595 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); ··· 599 602 } 600 603 601 604 sfc->buffer = dmam_alloc_coherent(dev, SFC_MAX_IOSIZE_VER3, 602 - &sfc->dma_buffer, 603 - GFP_KERNEL); 605 + &sfc->dma_buffer, GFP_KERNEL); 604 606 if (!sfc->buffer) 605 607 return -ENOMEM; 606 608 } ··· 625 629 0, pdev->name, sfc); 626 630 if (ret) { 627 631 dev_err(dev, "Failed to request irq\n"); 628 - 629 632 goto err_irq; 630 633 } 631 634
+13 -16
drivers/spi/spi-rockchip.c
··· 742 742 743 743 static int rockchip_spi_probe(struct platform_device *pdev) 744 744 { 745 - int ret; 746 - struct rockchip_spi *rs; 747 - struct spi_controller *ctlr; 748 - struct resource *mem; 749 745 struct device_node *np = pdev->dev.of_node; 746 + struct spi_controller *ctlr; 747 + struct rockchip_spi *rs; 748 + struct resource *mem; 750 749 u32 rsd_nsecs, num_cs; 751 750 bool target_mode; 751 + int ret; 752 752 753 753 target_mode = of_property_read_bool(np, "spi-slave"); 754 754 755 755 if (target_mode) 756 - ctlr = spi_alloc_target(&pdev->dev, 757 - sizeof(struct rockchip_spi)); 756 + ctlr = spi_alloc_target(&pdev->dev, sizeof(struct rockchip_spi)); 758 757 else 759 - ctlr = spi_alloc_host(&pdev->dev, 760 - sizeof(struct rockchip_spi)); 758 + ctlr = spi_alloc_host(&pdev->dev, sizeof(struct rockchip_spi)); 761 759 762 760 if (!ctlr) 763 761 return -ENOMEM; ··· 767 769 /* Get basic io resource and map it */ 768 770 rs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); 769 771 if (IS_ERR(rs->regs)) { 770 - ret = PTR_ERR(rs->regs); 772 + ret = PTR_ERR(rs->regs); 771 773 goto err_put_ctlr; 772 774 } 773 775 ··· 792 794 goto err_put_ctlr; 793 795 794 796 ret = devm_request_threaded_irq(&pdev->dev, ret, rockchip_spi_isr, NULL, 795 - IRQF_ONESHOT, dev_name(&pdev->dev), ctlr); 797 + IRQF_ONESHOT, dev_name(&pdev->dev), ctlr); 796 798 if (ret) 797 799 goto err_put_ctlr; 798 800 ··· 802 804 if (!of_property_read_u32(pdev->dev.of_node, "rx-sample-delay-ns", 803 805 &rsd_nsecs)) { 804 806 /* rx sample delay is expressed in parent clock cycles (max 3) */ 805 - u32 rsd = DIV_ROUND_CLOSEST(rsd_nsecs * (rs->freq >> 8), 806 - 1000000000 >> 8); 807 + u32 rsd = DIV_ROUND_CLOSEST(rsd_nsecs * (rs->freq >> 8), 1000000000 >> 8); 807 808 if (!rsd) { 808 809 dev_warn(rs->dev, "%u Hz are too slow to express %u ns delay\n", 809 - rs->freq, rsd_nsecs); 810 + rs->freq, rsd_nsecs); 810 811 } else if (rsd > CR0_RSD_MAX) { 811 812 rsd = CR0_RSD_MAX; 812 - dev_warn(rs->dev, "%u Hz are too fast to express %u ns delay, clamping at %u ns\n", 813 - rs->freq, rsd_nsecs, 814 - CR0_RSD_MAX * 1000000000U / rs->freq); 813 + dev_warn(rs->dev, 814 + "%u Hz are too fast to express %u ns delay, clamping at %u ns\n", 815 + rs->freq, rsd_nsecs, CR0_RSD_MAX * 1000000000U / rs->freq); 815 816 } 816 817 rs->rsd = rsd; 817 818 }