From nobody Wed Feb 11 18:26:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34809C77B61 for ; Mon, 10 Apr 2023 11:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbjDJLJ2 (ORCPT ); Mon, 10 Apr 2023 07:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjDJLJZ (ORCPT ); Mon, 10 Apr 2023 07:09:25 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59B4DE6F; Mon, 10 Apr 2023 04:09:03 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id h24-20020a17090a9c1800b002404be7920aso4036664pjp.5; Mon, 10 Apr 2023 04:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681124942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hOql+bAuTzb4sNeAYIK71k2lMY+HYwNHUIwpssNISEY=; b=LIJvdbqRE/Z8QTufS+xs6GERTZy2dopVF8Z8woK9L7lhbNTknTxq8V/fW1Y/AwgeGl CtnySdYBQEQTVawIxEy/9RIYwMCh7ubWT/RpudZG2QD60efTn44hJmXeKqKwf1GRdwGF JNJO1uMljxZSyZh6PksPb4P5No/xH2FlmjYaHYR0VWMBzCg4ZET1w3s8Jz0f/O75Zkoa z26zAUdlEPfQFuKEyHp5a8SPOjKxSUzi+qiiHukkauL/mfMsPpxzkONJYlmRiMjcabk9 saG5UtDeKyI9lc9zxO4QozYrH5uGBu8bIYbI+P1Ii6cJJiA2BBLa2L5VJop/JtPMOv6B dZqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681124942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hOql+bAuTzb4sNeAYIK71k2lMY+HYwNHUIwpssNISEY=; b=blLNToktEDXb1c39Uj1tHMahZVtIS4yKOG2t9y+5QcPmSoA9nOkuW0iPY6jI9u9Fix bI/YuXzEH3DKvIGJNssn+wvHqLf9ALzVTqQKQPoPezjjUFuWdsLw84954rdxZ69MyviX 8ADawayvry0OpsW7oihXRQMu/23d+xdFcVFqNkVffknQIlfU34VNBhzIhFvojZ+LPsoZ j1evc9HRXpTmK3vWi1lDbpIn9zeq3a9bPvlWXvDHIOqDZwOD4nF2LHo7gpgN2dA+Lo5z 2xVl41UHVxNX9uK3aEDXvWeoUmYGaoIKBkBm6bLr4I8m+3yQN9jwHa53azKAHR761Ubf 2Hcw== X-Gm-Message-State: AAQBX9ckJt3+94ktSoyYyonzmKwP8SPLBU8ABYP6lOOEru4ol4A5pBn/ KVvCVq4L6kU54lLdGvuJjJHABfwDnDM5TvLD5mg= X-Google-Smtp-Source: AKy350YfnKAMFBIwvumZJGoc73P2fIZy2ZRrmGXb8B9bFKdADcOtdG6L19RwlIu2DuYGj7slqk5Hkg== X-Received: by 2002:a17:903:8cf:b0:1a5:167f:620f with SMTP id lk15-20020a17090308cf00b001a5167f620fmr8065493plb.15.1681124942145; Mon, 10 Apr 2023 04:09:02 -0700 (PDT) Received: from d.home.yangfl.dn42 ([104.28.213.201]) by smtp.gmail.com with ESMTPSA id r5-20020a170902be0500b001a076568da9sm7464728pls.216.2023.04.10.04.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 04:09:01 -0700 (PDT) From: David Yang To: linux-clk@vger.kernel.org Cc: David Yang , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH v3 06/14] clk: hisilicon: hi3519: Use helper functions Date: Mon, 10 Apr 2023 19:07:18 +0800 Message-Id: <20230410110733.192151-7-mmyangfl@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230410110733.192151-1-mmyangfl@gmail.com> References: <20230410110733.192151-1-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use common helper functions and register clks with a single of_device_id data. Signed-off-by: David Yang --- drivers/clk/hisilicon/clk-hi3519.c | 128 ++++------------------------- 1 file changed, 15 insertions(+), 113 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hi3519.c b/drivers/clk/hisilicon/clk= -hi3519.c index ad0c7f350cf0..eac66bde1361 100644 --- a/drivers/clk/hisilicon/clk-hi3519.c +++ b/drivers/clk/hisilicon/clk-hi3519.c @@ -10,7 +10,7 @@ #include #include #include "clk.h" -#include "reset.h" +#include "crg.h" =20 #define HI3519_INNER_CLK_OFFSET 64 #define HI3519_FIXED_24M 65 @@ -73,131 +73,33 @@ static const struct hisi_gate_clock hi3519_gate_clks[]= =3D { CLK_SET_RATE_PARENT, 0xe4, 18, 0, }, }; =20 -static struct hisi_clock_data *hi3519_clk_register(struct platform_device = *pdev) -{ - struct hisi_clock_data *clk_data; - int ret; - - clk_data =3D hisi_clk_alloc(pdev, HI3519_NR_CLKS); - if (!clk_data) - return ERR_PTR(-ENOMEM); - - ret =3D hisi_clk_register_fixed_rate(hi3519_fixed_rate_clks, - ARRAY_SIZE(hi3519_fixed_rate_clks), - clk_data); - if (ret) - return ERR_PTR(ret); - - ret =3D hisi_clk_register_mux(hi3519_mux_clks, - ARRAY_SIZE(hi3519_mux_clks), - clk_data); - if (ret) - goto unregister_fixed_rate; - - ret =3D hisi_clk_register_gate(hi3519_gate_clks, - ARRAY_SIZE(hi3519_gate_clks), - clk_data); - if (ret) - goto unregister_mux; - - ret =3D of_clk_add_provider(pdev->dev.of_node, - of_clk_src_onecell_get, &clk_data->clk_data); - if (ret) - goto unregister_gate; - - return clk_data; - -unregister_fixed_rate: - hisi_clk_unregister_fixed_rate(hi3519_fixed_rate_clks, - ARRAY_SIZE(hi3519_fixed_rate_clks), - clk_data); - -unregister_mux: - hisi_clk_unregister_mux(hi3519_mux_clks, - ARRAY_SIZE(hi3519_mux_clks), - clk_data); -unregister_gate: - hisi_clk_unregister_gate(hi3519_gate_clks, - ARRAY_SIZE(hi3519_gate_clks), - clk_data); - return ERR_PTR(ret); -} - -static void hi3519_clk_unregister(struct platform_device *pdev) -{ - struct hi3519_crg_data *crg =3D platform_get_drvdata(pdev); - - of_clk_del_provider(pdev->dev.of_node); - - hisi_clk_unregister_gate(hi3519_gate_clks, - ARRAY_SIZE(hi3519_mux_clks), - crg->clk_data); - hisi_clk_unregister_mux(hi3519_mux_clks, - ARRAY_SIZE(hi3519_mux_clks), - crg->clk_data); - hisi_clk_unregister_fixed_rate(hi3519_fixed_rate_clks, - ARRAY_SIZE(hi3519_fixed_rate_clks), - crg->clk_data); -} - -static int hi3519_clk_probe(struct platform_device *pdev) -{ - struct hi3519_crg_data *crg; - - crg =3D devm_kmalloc(&pdev->dev, sizeof(*crg), GFP_KERNEL); - if (!crg) - return -ENOMEM; - - crg->rstc =3D hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; - - crg->clk_data =3D hi3519_clk_register(pdev); - if (IS_ERR(crg->clk_data)) { - hisi_reset_exit(crg->rstc); - return PTR_ERR(crg->clk_data); - } - - platform_set_drvdata(pdev, crg); - return 0; -} - -static int hi3519_clk_remove(struct platform_device *pdev) -{ - struct hi3519_crg_data *crg =3D platform_get_drvdata(pdev); - - hisi_reset_exit(crg->rstc); - hi3519_clk_unregister(pdev); - return 0; -} - +static const struct hisi_clocks hi3519_crg_clks =3D { + .nr =3D HI3519_NR_CLKS, + .fixed_rate_clks =3D hi3519_fixed_rate_clks, + .fixed_rate_clks_num =3D ARRAY_SIZE(hi3519_fixed_rate_clks), + .mux_clks =3D hi3519_mux_clks, + .mux_clks_num =3D ARRAY_SIZE(hi3519_mux_clks), + .gate_clks =3D hi3519_gate_clks, + .gate_clks_num =3D ARRAY_SIZE(hi3519_gate_clks), +}; =20 static const struct of_device_id hi3519_clk_match_table[] =3D { - { .compatible =3D "hisilicon,hi3519-crg" }, + { .compatible =3D "hisilicon,hi3519-crg", + .data =3D &hi3519_crg_clks }, { } }; MODULE_DEVICE_TABLE(of, hi3519_clk_match_table); =20 static struct platform_driver hi3519_clk_driver =3D { - .probe =3D hi3519_clk_probe, - .remove =3D hi3519_clk_remove, + .probe =3D hisi_crg_probe, + .remove =3D hisi_crg_remove, .driver =3D { .name =3D "hi3519-clk", .of_match_table =3D hi3519_clk_match_table, }, }; =20 -static int __init hi3519_clk_init(void) -{ - return platform_driver_register(&hi3519_clk_driver); -} -core_initcall(hi3519_clk_init); - -static void __exit hi3519_clk_exit(void) -{ - platform_driver_unregister(&hi3519_clk_driver); -} -module_exit(hi3519_clk_exit); +module_platform_driver(hi3519_clk_driver); =20 MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("HiSilicon Hi3519 Clock Driver"); --=20 2.39.2