From nobody Fri Dec 19 17:37:46 2025 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C06B1EFFB8; Wed, 23 Apr 2025 12:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745411542; cv=none; b=sXkvZDLrkSQIkzh0u7vAPtTdBdaZuQJY9wzFDSkXjK4JVubv4uSDWzLvrhRNWE38HokIzEHeIf8Uy9aG9j8ge90huNgbJnI93MLlN6IHdycY1NApYapQTwomtqrJREJJtXu9i89yL9IfxTTyxo6xvSqvzMxgK8lPEb3VZ8I7aBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745411542; c=relaxed/simple; bh=8L+WUBxDYMa7/4G5Y02q3NkjPSEMnh6XiE98Bgepv30=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Tb8qN1KCVs2lhk83yzrUBR4pS7wDes7HY4NCGTgs3vSJlCyOhqxj5e6/EHsz6r59v1gPoMILvTMQjkeWPcppnceo6oKypHMVYKnbj47QJm1al3OLsYIIYFpopozxSvl15K63+F0YQs1P7nlsO7pVxz/rZjOkR8DtjsvK80RLiL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=tuKUANRi; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="tuKUANRi" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 233CDA043A; Wed, 23 Apr 2025 14:32:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:message-id:mime-version:reply-to:subject:subject:to :to; s=mail; bh=qoKuNtvRAd7bvDwHrWfXjADoX3OQphidioaO/OVYjNc=; b= tuKUANRih4/Dxdph7W7xvDzva3uWT36xx43YyIjv0PDVqESPGcp4L98sTUUF1SJQ pzUsXHZjseftl144EL9Ip2bmkEMdtI/+i2RCWrCbxl4Ks6j7OuLU7dINx5Dj4Foe XBUFbmxI6G3AONTspDM3BAMIh1R0dUhNPUnItIwWjX4LmltCzqWmJJasaY5fFTo8 yQIk0/L66jsYRD4VI7SeAYw1ZaSZfMnnkymHIXRlNYbS6JUbTqr5uo2NhRQdRfv9 9QE14hzgvFUg3++xrE3bBV90DzgLB6CBo8IPqWYEkm+D7wb4qBJIDZHwhJVuSCpu t3a/RyJEHzU/Mle271XF7BYgWbIRCmxSXKyWaU/08VldKytsQWP+ctHtWSO74ubp vZ6PLa3mF9ErYRNWyk1odrSz/zgaA/Rgj/fW8SJoVOXZIvxr5LJBB7NduNqVkUvb ZjG0HZ243YU5k4PJvVLdGbzQoiOLHhm/j45WbM9Yhl6+bk4IbUI4e3nf8ouPV1nM 1Sv5h4KfUJVob3XxSIbwSlSwQJ566Tx11pHLBWeJbGYhphv4s5WiqpEMWtukzkGf q3nVuZs5loMw8SOquWsnVksNfyaquUz80A1fCYpMMogtovRPa41v004PqrR899Rp fqjhlW3gXpT0FvN5tVsppeSmqVCw07iiOsoklJWoseU= From: =?UTF-8?q?Bence=20Cs=C3=B3k=C3=A1s?= To: , , , CC: =?UTF-8?q?Bence=20Cs=C3=B3k=C3=A1s?= , "Chen-Yu Tsai" , Jernej Skrabec , "Chen-Yu Tsai" , Julian Calaby , Vinod Koul , Samuel Holland Subject: [PATCH v7] dma-engine: sun4i: Simplify error handling in probe() Date: Wed, 23 Apr 2025 14:31:46 +0200 Message-ID: <20250423123146.76973-2-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1745411530;VERSION=7989;MC=226666071;ID=131881;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A2980D94853677466 Clean up error handling by using devm functions and dev_err_probe(). This should make it easier to add new code, as we can eliminate the "goto ladder" in sun4i_dma_probe(). Suggested-by: Chen-Yu Tsai Reviewed-by: Jernej Skrabec Acked-by: Chen-Yu Tsai Reviewed-by: Julian Calaby Signed-off-by: Bence Cs=C3=B3k=C3=A1s --- Notes: Changes in v2: * rebase on current next Changes in v3: * rebase on current next * collect Jernej's tag Changes in v4: * rebase on current next * collect Chen-Yu's tag Changes in v5: * reformat msg to 75 cols * keep `\n`s in error messages Changes in v6: * remove redundant braces * break lines to stay under 85 cols * reword subject and message Changes in v7: * rebase onto current next * collect Julian's tag drivers/dma/sun4i-dma.c | 46 ++++++++++++----------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c index 24796aaaddfa..00d2fd38d17f 100644 --- a/drivers/dma/sun4i-dma.c +++ b/drivers/dma/sun4i-dma.c @@ -1249,11 +1249,10 @@ static int sun4i_dma_probe(struct platform_device *= pdev) if (priv->irq < 0) return priv->irq; =20 - priv->clk =3D devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "No clock specified\n"); - return PTR_ERR(priv->clk); - } + priv->clk =3D devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk), + "Couldn't start the clock\n"); =20 if (priv->cfg->has_reset) { priv->rst =3D devm_reset_control_get_exclusive_deasserted(&pdev->dev, NU= LL); @@ -1328,12 +1327,6 @@ static int sun4i_dma_probe(struct platform_device *p= dev) vchan_init(&vchan->vc, &priv->slave); } =20 - ret =3D clk_prepare_enable(priv->clk); - if (ret) { - dev_err(&pdev->dev, "Couldn't enable the clock\n"); - return ret; - } - /* * Make sure the IRQs are all disabled and accounted for. The bootloader * likes to leave these dirty @@ -1343,33 +1336,23 @@ static int sun4i_dma_probe(struct platform_device *= pdev) =20 ret =3D devm_request_irq(&pdev->dev, priv->irq, sun4i_dma_interrupt, 0, dev_name(&pdev->dev), priv); - if (ret) { - dev_err(&pdev->dev, "Cannot request IRQ\n"); - goto err_clk_disable; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, "Cannot request IRQ\n"); =20 - ret =3D dma_async_device_register(&priv->slave); - if (ret) { - dev_warn(&pdev->dev, "Failed to register DMA engine device\n"); - goto err_clk_disable; - } + ret =3D dmaenginem_async_device_register(&priv->slave); + if (ret) + return dev_err_probe(&pdev->dev, ret, + "Failed to register DMA engine device\n"); =20 ret =3D of_dma_controller_register(pdev->dev.of_node, sun4i_dma_of_xlate, priv); - if (ret) { - dev_err(&pdev->dev, "of_dma_controller_register failed\n"); - goto err_dma_unregister; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, + "Failed to register translation function\n"); =20 dev_dbg(&pdev->dev, "Successfully probed SUN4I_DMA\n"); =20 return 0; - -err_dma_unregister: - dma_async_device_unregister(&priv->slave); -err_clk_disable: - clk_disable_unprepare(priv->clk); - return ret; } =20 static void sun4i_dma_remove(struct platform_device *pdev) @@ -1380,9 +1363,6 @@ static void sun4i_dma_remove(struct platform_device *= pdev) disable_irq(priv->irq); =20 of_dma_controller_free(pdev->dev.of_node); - dma_async_device_unregister(&priv->slave); - - clk_disable_unprepare(priv->clk); } =20 static struct sun4i_dma_config sun4i_a10_dma_cfg =3D { base-commit: 5d099706449d54b4693a1c6bb7c2251072234508 --=20 2.49.0