interconnect: icc-rpm: move bus clocks handling into qnoc_probe
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fri, 3 Sep 2021 23:24:11 +0000 (02:24 +0300)
committerGeorgi Djakov <djakov@kernel.org>
Mon, 4 Oct 2021 10:37:47 +0000 (13:37 +0300)
All icc-rpm drivers use the same set of bus clocks. Move handling of bus
clocks to qnoc_probe. This both simplifies the code and allows using
qnoc_probe as device's probe function.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Link: https://lore.kernel.org/r/20210903232421.1384199-2-dmitry.baryshkov@linaro.org
Signed-off-by: Georgi Djakov <djakov@kernel.org>
drivers/interconnect/qcom/icc-rpm.c
drivers/interconnect/qcom/icc-rpm.h
drivers/interconnect/qcom/msm8916.c
drivers/interconnect/qcom/msm8939.c
drivers/interconnect/qcom/qcs404.c

index 54de49ca7808a861ec9f4857d954776634965b50..3049454685dc417f3e7b034899161ff44bf4f35c 100644 (file)
@@ -86,8 +86,11 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
        return 0;
 }
 
-int qnoc_probe(struct platform_device *pdev, size_t cd_size, int cd_num,
-              const struct clk_bulk_data *cd)
+static const char * const bus_clocks[] = {
+       "bus", "bus_a",
+};
+
+int qnoc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        const struct qcom_icc_desc *desc;
@@ -97,6 +100,8 @@ int qnoc_probe(struct platform_device *pdev, size_t cd_size, int cd_num,
        struct qcom_icc_provider *qp;
        struct icc_node *node;
        size_t num_nodes, i;
+       const char * const *cds;
+       int cd_num;
        int ret;
 
        /* wait for the RPM proxy */
@@ -110,7 +115,10 @@ int qnoc_probe(struct platform_device *pdev, size_t cd_size, int cd_num,
        qnodes = desc->nodes;
        num_nodes = desc->num_nodes;
 
-       qp = devm_kzalloc(dev, sizeof(*qp), GFP_KERNEL);
+       cds = bus_clocks;
+       cd_num = ARRAY_SIZE(bus_clocks);
+
+       qp = devm_kzalloc(dev, struct_size(qp, bus_clks, cd_num), GFP_KERNEL);
        if (!qp)
                return -ENOMEM;
 
@@ -119,12 +127,10 @@ int qnoc_probe(struct platform_device *pdev, size_t cd_size, int cd_num,
        if (!data)
                return -ENOMEM;
 
-       qp->bus_clks = devm_kmemdup(dev, cd, cd_size,
-                                   GFP_KERNEL);
-       if (!qp->bus_clks)
-               return -ENOMEM;
-
+       for (i = 0; i < cd_num; i++)
+               qp->bus_clks[i].id = cds[i];
        qp->num_clks = cd_num;
+
        ret = devm_clk_bulk_get(dev, qp->num_clks, qp->bus_clks);
        if (ret)
                return ret;
index 79a6f68249c10a637af753b5da91fb58322a8c51..f4b05c20c097cdf3b9747089ea000c67139e8301 100644 (file)
@@ -22,8 +22,8 @@
  */
 struct qcom_icc_provider {
        struct icc_provider provider;
-       struct clk_bulk_data *bus_clks;
        int num_clks;
+       struct clk_bulk_data bus_clks[];
 };
 
 /**
@@ -66,8 +66,7 @@ struct qcom_icc_desc {
        }
 
 
-int qnoc_probe(struct platform_device *pdev, size_t cd_size, int cd_num,
-              const struct clk_bulk_data *cd);
+int qnoc_probe(struct platform_device *pdev);
 int qnoc_remove(struct platform_device *pdev);
 
 #endif
index fc3689c8947a42d7c854f3e7174fb1b168efb392..fc0d48d2997ae01f27f8df5027fbd5a1af533cd8 100644 (file)
@@ -105,11 +105,6 @@ enum {
        MSM8916_SNOC_PNOC_SLV,
 };
 
-static const struct clk_bulk_data msm8916_bus_clocks[] = {
-       { .id = "bus" },
-       { .id = "bus_a" },
-};
-
 DEFINE_QNODE(bimc_snoc_mas, MSM8916_BIMC_SNOC_MAS, 8, -1, -1, MSM8916_BIMC_SNOC_SLV);
 DEFINE_QNODE(bimc_snoc_slv, MSM8916_BIMC_SNOC_SLV, 8, -1, -1, MSM8916_SNOC_INT_0, MSM8916_SNOC_INT_1);
 DEFINE_QNODE(mas_apss, MSM8916_MASTER_AMPSS_M0, 8, -1, -1, MSM8916_SLAVE_EBI_CH0, MSM8916_BIMC_SNOC_MAS, MSM8916_SLAVE_AMPSS_L2);
@@ -305,12 +300,6 @@ static struct qcom_icc_desc msm8916_pcnoc = {
        .num_nodes = ARRAY_SIZE(msm8916_pcnoc_nodes),
 };
 
-static int msm8916_qnoc_probe(struct platform_device *pdev)
-{
-       return qnoc_probe(pdev, sizeof(msm8916_bus_clocks),
-                         ARRAY_SIZE(msm8916_bus_clocks), msm8916_bus_clocks);
-}
-
 static const struct of_device_id msm8916_noc_of_match[] = {
        { .compatible = "qcom,msm8916-bimc", .data = &msm8916_bimc },
        { .compatible = "qcom,msm8916-pcnoc", .data = &msm8916_pcnoc },
@@ -320,7 +309,7 @@ static const struct of_device_id msm8916_noc_of_match[] = {
 MODULE_DEVICE_TABLE(of, msm8916_noc_of_match);
 
 static struct platform_driver msm8916_noc_driver = {
-       .probe = msm8916_qnoc_probe,
+       .probe = qnoc_probe,
        .remove = qnoc_remove,
        .driver = {
                .name = "qnoc-msm8916",
index 20f31a1b41923b722612bee20334c5e5578d1d90..4a5a2ec649605b6a41b6e3f0bf9e2ebc4d664558 100644 (file)
@@ -110,11 +110,6 @@ enum {
        MSM8939_SNOC_PNOC_SLV,
 };
 
-static const struct clk_bulk_data msm8939_bus_clocks[] = {
-       { .id = "bus" },
-       { .id = "bus_a" },
-};
-
 DEFINE_QNODE(bimc_snoc_mas, MSM8939_BIMC_SNOC_MAS, 8, -1, -1, MSM8939_BIMC_SNOC_SLV);
 DEFINE_QNODE(bimc_snoc_slv, MSM8939_BIMC_SNOC_SLV, 16, -1, 2, MSM8939_SNOC_INT_0, MSM8939_SNOC_INT_1);
 DEFINE_QNODE(mas_apss, MSM8939_MASTER_AMPSS_M0, 16, -1, -1, MSM8939_SLAVE_EBI_CH0, MSM8939_BIMC_SNOC_MAS, MSM8939_SLAVE_AMPSS_L2);
@@ -326,12 +321,6 @@ static struct qcom_icc_desc msm8939_pcnoc = {
        .num_nodes = ARRAY_SIZE(msm8939_pcnoc_nodes),
 };
 
-static int msm8939_qnoc_probe(struct platform_device *pdev)
-{
-       return qnoc_probe(pdev, sizeof(msm8939_bus_clocks),
-                         ARRAY_SIZE(msm8939_bus_clocks), msm8939_bus_clocks);
-}
-
 static const struct of_device_id msm8939_noc_of_match[] = {
        { .compatible = "qcom,msm8939-bimc", .data = &msm8939_bimc },
        { .compatible = "qcom,msm8939-pcnoc", .data = &msm8939_pcnoc },
@@ -342,7 +331,7 @@ static const struct of_device_id msm8939_noc_of_match[] = {
 MODULE_DEVICE_TABLE(of, msm8939_noc_of_match);
 
 static struct platform_driver msm8939_noc_driver = {
-       .probe = msm8939_qnoc_probe,
+       .probe = qnoc_probe,
        .remove = qnoc_remove,
        .driver = {
                .name = "qnoc-msm8939",
index 36a7e30a00be05543365206639b4eccfc9fffb1f..0f2fff230b1304f0c53f5f71e0556f375f36fa38 100644 (file)
@@ -92,11 +92,6 @@ enum {
        QCS404_SLAVE_LPASS,
 };
 
-static const struct clk_bulk_data qcs404_bus_clocks[] = {
-       { .id = "bus" },
-       { .id = "bus_a" },
-};
-
 DEFINE_QNODE(mas_apps_proc, QCS404_MASTER_AMPSS_M0, 8, 0, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
 DEFINE_QNODE(mas_oxili, QCS404_MASTER_GRAPHICS_3D, 8, -1, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
 DEFINE_QNODE(mas_mdp, QCS404_MASTER_MDP_PORT0, 8, -1, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
@@ -269,12 +264,6 @@ static struct qcom_icc_desc qcs404_snoc = {
 };
 
 
-static int qcs404_qnoc_probe(struct platform_device *pdev)
-{
-       return qnoc_probe(pdev, sizeof(qcs404_bus_clocks),
-                         ARRAY_SIZE(qcs404_bus_clocks), qcs404_bus_clocks);
-}
-
 static const struct of_device_id qcs404_noc_of_match[] = {
        { .compatible = "qcom,qcs404-bimc", .data = &qcs404_bimc },
        { .compatible = "qcom,qcs404-pcnoc", .data = &qcs404_pcnoc },
@@ -284,7 +273,7 @@ static const struct of_device_id qcs404_noc_of_match[] = {
 MODULE_DEVICE_TABLE(of, qcs404_noc_of_match);
 
 static struct platform_driver qcs404_noc_driver = {
-       .probe = qcs404_qnoc_probe,
+       .probe = qnoc_probe,
        .remove = qnoc_remove,
        .driver = {
                .name = "qnoc-qcs404",