From nobody Sat Nov 30 01:31:09 2024 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (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 D5747145B38 for ; Fri, 13 Sep 2024 19:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726254695; cv=none; b=rRbRZdix+es3K762FpFZ/WjNl/ZgrMW4IBH7hfpH1JfFLlLFSqRHLFBQF79ZId/nZZKKanOyCLKYPcNLoFzbwcLOpDXXZOtqbjyPeuJvXzoago0nEq0/2GgjOGXnQW/BH7wNaFJY54iYEK6JtW8nySqIhl2J3xBdVOC//c3GJQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726254695; c=relaxed/simple; bh=TPbtuH0PfEASNwT0mwy76n+RBKool/go49V2qgw5fyk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rpfIqLGA6sF8jCIH+z/BeyB5MJ7BJQUj01FpR6X+7mKVaupGiWZLbwmoo3u9h3iulAgwupmiqxaGtraz6Nv6baO0vzkbcSL+CMNjttpuATF1gmfXktfRqBBBlE5HjdByajs4Ch7G+fxwt1cd7YhuLQnZPoc0DzxREecPHZKKPNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com; spf=pass smtp.mailfrom=protonmail.com; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b=cQMitmDG; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="cQMitmDG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1726254690; x=1726513890; bh=gSGZ3f3KQMewMhm5mliqBd4quudBj5oL7MAWoUnLvBo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=cQMitmDGVlnCNttxGLqzhclwkfxaT4MRu2uh11nJnssE2exkIHYaoDkAyuinCwBRJ IAIsWblw7ji4GCIkdlIJYig8EEhHfsF8SS15x0P2OpHousqJ3bQPDGy/W0ya5QnBz1 Guglyo7QeqvwV6g+D/NGx1BlE+FTbaZLXWfUu43HyGpZgnQN5sdliWqHZl5Qex8SO1 PzjwxqtmXoaewYYQ6QCPQ/KXb5tN0/9lx66zhXIeQz4SJxbLm155nrSMBvozINIG8D 4cRpePs7FdvknFssjgPw5DnIi4aVM15PM7P0hIY6OpdVmk8HZt0tEcKW/SKRDRRGWK 5FYUM6vbRVdyg== Date: Fri, 13 Sep 2024 19:11:26 +0000 To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michal Simek From: Harry Austen Cc: Shubhrajyoti Datta , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Harry Austen Subject: [PATCH v2 3/6] clk: clocking-wizard: use devres versions of clk_hw API Message-ID: <20240913191037.2690-4-hpausten@protonmail.com> In-Reply-To: <20240913191037.2690-1-hpausten@protonmail.com> References: <20240913191037.2690-1-hpausten@protonmail.com> Feedback-ID: 53116287:user:proton X-Pm-Message-ID: 5bfac4b87ba107d357aad9c062f9c9ef07fa19b2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use device managed versions of the clk_hw API, entirely removing the need for the driver's remove() callback and greatly simplifying the probe() function's error paths. Signed-off-by: Harry Austen --- v1 -> v2: No change drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 52 +++++----------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilin= x/clk-xlnx-clock-wizard.c index cd795a4952099..f332e0eee56c8 100644 --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c @@ -1082,7 +1082,7 @@ static int clk_wzrd_probe(struct platform_device *pde= v) clk_name =3D devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul", dev_name(&p= dev->dev)); if (!clk_name) return -ENOMEM; - clk_wzrd->clks_internal[wzrd_clk_mul] =3D clk_hw_register_fixed_factor + clk_wzrd->clks_internal[wzrd_clk_mul] =3D devm_clk_hw_register_fixed_fact= or (&pdev->dev, clk_name, __clk_get_name(clk_wzrd->clk_in1), 0, mult, div); @@ -1092,10 +1092,8 @@ static int clk_wzrd_probe(struct platform_device *pd= ev) } =20 clk_name =3D devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul_div", dev_nam= e(&pdev->dev)); - if (!clk_name) { - ret =3D -ENOMEM; - goto err_rm_int_clk; - } + if (!clk_name) + return -ENOMEM; =20 if (is_versal) { edged =3D !!(readl(clk_wzrd->base + WZRD_CLK_CFG_REG(is_versal, 20)) & @@ -1110,11 +1108,11 @@ static int clk_wzrd_probe(struct platform_device *p= dev) =20 clk_mul_name =3D clk_hw_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]); clk_wzrd->clks_internal[wzrd_clk_mul_div] =3D - clk_hw_register_fixed_factor(&pdev->dev, clk_name, - clk_mul_name, 0, 1, div); + devm_clk_hw_register_fixed_factor(&pdev->dev, clk_name, + clk_mul_name, 0, 1, div); } else { ctrl_reg =3D clk_wzrd->base + WZRD_CLK_CFG_REG(is_versal, 0); - clk_wzrd->clks_internal[wzrd_clk_mul_div] =3D clk_hw_register_divider + clk_wzrd->clks_internal[wzrd_clk_mul_div] =3D devm_clk_hw_register_divid= er (&pdev->dev, clk_name, clk_hw_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]), flags, ctrl_reg, 0, 8, CLK_DIVIDER_ONE_BASED | @@ -1122,18 +1120,15 @@ static int clk_wzrd_probe(struct platform_device *p= dev) } if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div])) { dev_err(&pdev->dev, "unable to register divider clock\n"); - ret =3D PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]); - goto err_rm_int_clk; + return PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]); } =20 /* register div per output */ for (i =3D nr_outputs - 1; i >=3D 0 ; i--) { clkout_name =3D devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_out%d", dev_name(&pdev->dev), i); - if (!clkout_name) { - ret =3D -ENOMEM; - goto err_rm_int_clk; - } + if (!clkout_name) + return -ENOMEM; =20 if (is_versal) { clk_wzrd->clk_data.hws[i] =3D clk_wzrd_ver_register_divider @@ -1165,20 +1160,15 @@ static int clk_wzrd_probe(struct platform_device *p= dev) DIV_O, &clkwzrd_lock); } if (IS_ERR(clk_wzrd->clk_data.hws[i])) { - int j; - - for (j =3D i + 1; j < nr_outputs; j++) - clk_hw_unregister(clk_wzrd->clk_data.hws[j]); dev_err(&pdev->dev, "unable to register divider clock\n"); - ret =3D PTR_ERR(clk_wzrd->clk_data.hws[i]); - goto err_rm_int_clks; + return PTR_ERR(clk_wzrd->clk_data.hws[i]); } } =20 out: clk_wzrd->clk_data.num =3D nr_outputs; - ret =3D of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_onecell_get, = &clk_wzrd->clk_data); + ret =3D devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_get, &c= lk_wzrd->clk_data); if (ret) { dev_err(&pdev->dev, "unable to register clock provider\n"); return ret; @@ -1201,25 +1191,6 @@ static int clk_wzrd_probe(struct platform_device *pd= ev) } =20 return 0; - -err_rm_int_clks: - clk_hw_unregister(clk_wzrd->clks_internal[1]); -err_rm_int_clk: - clk_hw_unregister(clk_wzrd->clks_internal[0]); - return ret; -} - -static void clk_wzrd_remove(struct platform_device *pdev) -{ - int i; - struct clk_wzrd *clk_wzrd =3D platform_get_drvdata(pdev); - - of_clk_del_provider(pdev->dev.of_node); - - for (i =3D 0; i < WZRD_NUM_OUTPUTS; i++) - clk_hw_unregister(clk_wzrd->clk_data.hws[i]); - for (i =3D 0; i < wzrd_clk_int_max; i++) - clk_hw_unregister(clk_wzrd->clks_internal[i]); } =20 static const struct of_device_id clk_wzrd_ids[] =3D { @@ -1238,7 +1209,6 @@ static struct platform_driver clk_wzrd_driver =3D { .pm =3D &clk_wzrd_dev_pm_ops, }, .probe =3D clk_wzrd_probe, - .remove_new =3D clk_wzrd_remove, }; module_platform_driver(clk_wzrd_driver); =20 --=20 2.46.0