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

mmc: moxart-mmc: Use devm_mmc_alloc_host() helper

Use new function devm_mmc_alloc_host() to simplify the code.

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/c2bdcea3720b81660b3226180640e32fffefc464.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Binbin Zhou and committed by
Ulf Hansson
973aa22b c799f3a1

+14 -26
+14 -26
drivers/mmc/host/moxart-mmc.c
··· 558 558 int irq, ret; 559 559 u32 i; 560 560 561 - mmc = mmc_alloc_host(sizeof(struct moxart_host), dev); 561 + mmc = devm_mmc_alloc_host(dev, sizeof(*host)); 562 562 if (!mmc) { 563 - dev_err(dev, "mmc_alloc_host failed\n"); 564 - ret = -ENOMEM; 565 - goto out_mmc; 563 + dev_err(dev, "devm_mmc_alloc_host failed\n"); 564 + return -ENOMEM; 566 565 } 567 566 568 567 ret = of_address_to_resource(node, 0, &res_mmc); 569 - if (ret) { 570 - dev_err(dev, "of_address_to_resource failed\n"); 571 - goto out_mmc; 572 - } 568 + if (ret) 569 + return dev_err_probe(dev, ret, 570 + "of_address_to_resource failed\n"); 573 571 574 572 irq = irq_of_parse_and_map(node, 0); 575 - if (irq <= 0) { 576 - dev_err(dev, "irq_of_parse_and_map failed\n"); 577 - ret = -EINVAL; 578 - goto out_mmc; 579 - } 573 + if (irq <= 0) 574 + return dev_err_probe(dev, -EINVAL, 575 + "irq_of_parse_and_map failed\n"); 580 576 581 577 clk = devm_clk_get(dev, NULL); 582 - if (IS_ERR(clk)) { 583 - ret = PTR_ERR(clk); 584 - goto out_mmc; 585 - } 578 + if (IS_ERR(clk)) 579 + return PTR_ERR(clk); 586 580 587 581 reg_mmc = devm_ioremap_resource(dev, &res_mmc); 588 - if (IS_ERR(reg_mmc)) { 589 - ret = PTR_ERR(reg_mmc); 590 - goto out_mmc; 591 - } 582 + if (IS_ERR(reg_mmc)) 583 + return PTR_ERR(reg_mmc); 592 584 593 585 ret = mmc_of_parse(mmc); 594 586 if (ret) 595 - goto out_mmc; 587 + return ret; 596 588 597 589 host = mmc_priv(mmc); 598 590 host->mmc = mmc; ··· 678 686 dma_release_channel(host->dma_chan_tx); 679 687 if (!IS_ERR_OR_NULL(host->dma_chan_rx)) 680 688 dma_release_channel(host->dma_chan_rx); 681 - out_mmc: 682 - if (mmc) 683 - mmc_free_host(mmc); 684 689 return ret; 685 690 } 686 691 ··· 696 707 writel(0, host->base + REG_POWER_CONTROL); 697 708 writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF, 698 709 host->base + REG_CLOCK_CONTROL); 699 - mmc_free_host(mmc); 700 710 } 701 711 702 712 static const struct of_device_id moxart_mmc_match[] = {