memory: tegra: Introduce struct tegra_mc_ops
authorThierry Reding <treding@nvidia.com>
Wed, 2 Jun 2021 16:32:53 +0000 (18:32 +0200)
committerKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Thu, 3 Jun 2021 19:49:40 +0000 (21:49 +0200)
Subsequent patches will introduce further callbacks, so create a new
struct tegra_mc_ops to collect all of them in a single place. Move the
existing ->init() callback into the new structure.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20210602163302.120041-4-thierry.reding@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
drivers/memory/tegra/mc.c
drivers/memory/tegra/tegra20.c
include/soc/tegra/mc.h

index b7e104bf6614589d1537cedcc311ec2d87c37877..559ae1ef5633d177adc5f4501d6b7b553bdcb33d 100644 (file)
@@ -829,8 +829,8 @@ static int tegra_mc_probe(struct platform_device *pdev)
 
        mc->debugfs.root = debugfs_create_dir("mc", NULL);
 
-       if (mc->soc->init) {
-               err = mc->soc->init(mc);
+       if (mc->soc->ops && mc->soc->ops->init) {
+               err = mc->soc->ops->init(mc);
                if (err < 0)
                        dev_err(&pdev->dev, "failed to initialize SoC driver: %d\n",
                                err);
index 2db68a913b7af0af5a3b9ee23282e77db3887ff7..3b7b93b96480dbc9906673d1e8053b4407fa6d4d 100644 (file)
@@ -687,6 +687,10 @@ static int tegra20_mc_init(struct tegra_mc *mc)
        return 0;
 }
 
+static const struct tegra_mc_ops tegra20_mc_ops = {
+       .init = tegra20_mc_init,
+};
+
 const struct tegra_mc_soc tegra20_mc_soc = {
        .clients = tegra20_mc_clients,
        .num_clients = ARRAY_SIZE(tegra20_mc_clients),
@@ -698,5 +702,5 @@ const struct tegra_mc_soc tegra20_mc_soc = {
        .resets = tegra20_mc_resets,
        .num_resets = ARRAY_SIZE(tegra20_mc_resets),
        .icc_ops = &tegra20_mc_icc_ops,
-       .init = tegra20_mc_init,
+       .ops = &tegra20_mc_ops,
 };
index 9da4ef52ce301609de9dd6b890a8fbd5bf5fa8e0..4f88da907a026cc26d3fdce3bdda4a4d39dd73fb 100644 (file)
@@ -169,6 +169,10 @@ struct tegra_mc_icc_ops {
                                                void *data);
 };
 
+struct tegra_mc_ops {
+       int (*init)(struct tegra_mc *mc);
+};
+
 struct tegra_mc_soc {
        const struct tegra_mc_client *clients;
        unsigned int num_clients;
@@ -190,8 +194,7 @@ struct tegra_mc_soc {
        unsigned int num_resets;
 
        const struct tegra_mc_icc_ops *icc_ops;
-
-       int (*init)(struct tegra_mc *mc);
+       const struct tegra_mc_ops *ops;
 };
 
 struct tegra_mc {