power-domain: Return 0 if ops unimplemented and remove empty functions
In case the ops is not implemented, return 0 in the core right away.
This is better than having multiple copies of functions which just
return 0 in each power domain driver. Drop all those empty functions.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Simon Glass <sjg@chromium.org>
diff --git a/drivers/power/domain/apple-pmgr.c b/drivers/power/domain/apple-pmgr.c
index 4d06e76..402c5b1 100644
--- a/drivers/power/domain/apple-pmgr.c
+++ b/drivers/power/domain/apple-pmgr.c
@@ -42,16 +42,6 @@
return 0;
}
-static int apple_reset_request(struct reset_ctl *reset_ctl)
-{
- return 0;
-}
-
-static int apple_reset_free(struct reset_ctl *reset_ctl)
-{
- return 0;
-}
-
static int apple_reset_assert(struct reset_ctl *reset_ctl)
{
struct apple_pmgr_priv *priv = dev_get_priv(reset_ctl->dev->parent);
@@ -80,8 +70,6 @@
struct reset_ops apple_reset_ops = {
.of_xlate = apple_reset_of_xlate,
- .request = apple_reset_request,
- .rfree = apple_reset_free,
.rst_assert = apple_reset_assert,
.rst_deassert = apple_reset_deassert,
};
@@ -92,16 +80,6 @@
.ops = &apple_reset_ops,
};
-static int apple_pmgr_request(struct power_domain *power_domain)
-{
- return 0;
-}
-
-static int apple_pmgr_rfree(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int apple_pmgr_ps_set(struct power_domain *power_domain, u32 pstate)
{
struct apple_pmgr_priv *priv = dev_get_priv(power_domain->dev);
@@ -121,11 +99,6 @@
return apple_pmgr_ps_set(power_domain, APPLE_PMGR_PS_ACTIVE);
}
-static int apple_pmgr_off(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int apple_pmgr_of_xlate(struct power_domain *power_domain,
struct ofnode_phandle_args *args)
{
@@ -167,10 +140,7 @@
}
struct power_domain_ops apple_pmgr_ops = {
- .request = apple_pmgr_request,
- .rfree = apple_pmgr_rfree,
.on = apple_pmgr_on,
- .off = apple_pmgr_off,
.of_xlate = apple_pmgr_of_xlate,
};
diff --git a/drivers/power/domain/bcm6328-power-domain.c b/drivers/power/domain/bcm6328-power-domain.c
index 6e720e0..80144dd 100644
--- a/drivers/power/domain/bcm6328-power-domain.c
+++ b/drivers/power/domain/bcm6328-power-domain.c
@@ -24,11 +24,6 @@
return 0;
}
-static int bcm6328_power_domain_free(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int bcm6328_power_domain_on(struct power_domain *power_domain)
{
struct bcm6328_power_domain *priv = dev_get_priv(power_domain->dev);
@@ -64,7 +59,6 @@
};
struct power_domain_ops bcm6328_power_domain_ops = {
- .rfree = bcm6328_power_domain_free,
.off = bcm6328_power_domain_off,
.on = bcm6328_power_domain_on,
.request = bcm6328_power_domain_request,
diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c
index e2fae2d..bf45891 100644
--- a/drivers/power/domain/imx8-power-domain-legacy.c
+++ b/drivers/power/domain/imx8-power-domain-legacy.c
@@ -84,20 +84,6 @@
return 0;
}
-static int imx8_power_domain_request(struct power_domain *power_domain)
-{
- debug("%s(power_domain=%p)\n", __func__, power_domain);
-
- return 0;
-}
-
-static int imx8_power_domain_free(struct power_domain *power_domain)
-{
- debug("%s(power_domain=%p)\n", __func__, power_domain);
-
- return 0;
-}
-
static int imx8_power_domain_on(struct power_domain *power_domain)
{
struct udevice *dev = power_domain->dev;
@@ -364,8 +350,6 @@
};
struct power_domain_ops imx8_power_domain_ops = {
- .request = imx8_power_domain_request,
- .rfree = imx8_power_domain_free,
.on = imx8_power_domain_on,
.off = imx8_power_domain_off,
.of_xlate = imx8_power_domain_of_xlate,
diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/imx8-power-domain.c
index 6461ab2..17b5d57 100644
--- a/drivers/power/domain/imx8-power-domain.c
+++ b/drivers/power/domain/imx8-power-domain.c
@@ -12,20 +12,6 @@
#include <asm/arch/power-domain.h>
#include <asm/arch/sci/sci.h>
-static int imx8_power_domain_request(struct power_domain *power_domain)
-{
- debug("%s(power_domain=%p)\n", __func__, power_domain);
-
- return 0;
-}
-
-static int imx8_power_domain_free(struct power_domain *power_domain)
-{
- debug("%s(power_domain=%p)\n", __func__, power_domain);
-
- return 0;
-}
-
static int imx8_power_domain_on(struct power_domain *power_domain)
{
u32 resource_id = power_domain->id;
@@ -60,13 +46,6 @@
return 0;
}
-static int imx8_power_domain_probe(struct udevice *dev)
-{
- debug("%s(dev=%s)\n", __func__, dev->name);
-
- return 0;
-}
-
static const struct udevice_id imx8_power_domain_ids[] = {
{ .compatible = "fsl,imx8qxp-scu-pd" },
{ .compatible = "fsl,scu-pd" },
@@ -74,8 +53,6 @@
};
struct power_domain_ops imx8_power_domain_ops_v2 = {
- .request = imx8_power_domain_request,
- .rfree = imx8_power_domain_free,
.on = imx8_power_domain_on,
.off = imx8_power_domain_off,
};
@@ -84,6 +61,5 @@
.name = "imx8_power_domain_v2",
.id = UCLASS_POWER_DOMAIN,
.of_match = imx8_power_domain_ids,
- .probe = imx8_power_domain_probe,
.ops = &imx8_power_domain_ops_v2,
};
diff --git a/drivers/power/domain/imx8m-power-domain.c b/drivers/power/domain/imx8m-power-domain.c
index 5d34bc1..6082ee6 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -18,16 +18,6 @@
DECLARE_GLOBAL_DATA_PTR;
-static int imx8m_power_domain_request(struct power_domain *power_domain)
-{
- return 0;
-}
-
-static int imx8m_power_domain_free(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int imx8m_power_domain_on(struct power_domain *power_domain)
{
struct udevice *dev = power_domain->dev;
@@ -97,11 +87,6 @@
dev->driver->name, ret);
}
- return 0;
-}
-
-static int imx8m_power_domain_probe(struct udevice *dev)
-{
return 0;
}
@@ -126,8 +111,6 @@
};
struct power_domain_ops imx8m_power_domain_ops = {
- .request = imx8m_power_domain_request,
- .rfree = imx8m_power_domain_free,
.on = imx8m_power_domain_on,
.off = imx8m_power_domain_off,
.of_xlate = imx8m_power_domain_of_xlate,
@@ -138,7 +121,6 @@
.id = UCLASS_POWER_DOMAIN,
.of_match = imx8m_power_domain_ids,
.bind = imx8m_power_domain_bind,
- .probe = imx8m_power_domain_probe,
.of_to_plat = imx8m_power_domain_of_to_plat,
.plat_auto = sizeof(struct imx8m_power_domain_plat),
.ops = &imx8m_power_domain_ops,
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index a4d50e7..676fded 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -273,16 +273,6 @@
return (reg & pwrc_domain->top_pd->sleep_mask);
}
-static int meson_ee_pwrc_request(struct power_domain *power_domain)
-{
- return 0;
-}
-
-static int meson_ee_pwrc_free(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int meson_ee_pwrc_off(struct power_domain *power_domain)
{
struct meson_ee_pwrc_priv *priv = dev_get_priv(power_domain->dev);
@@ -387,10 +377,8 @@
}
struct power_domain_ops meson_ee_pwrc_ops = {
- .rfree = meson_ee_pwrc_free,
.off = meson_ee_pwrc_off,
.on = meson_ee_pwrc_on,
- .request = meson_ee_pwrc_request,
.of_xlate = meson_ee_pwrc_of_xlate,
};
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index eb94af2..612660c 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -45,16 +45,6 @@
struct clk_bulk clks;
};
-static int meson_pwrc_vpu_request(struct power_domain *power_domain)
-{
- return 0;
-}
-
-static int meson_pwrc_vpu_free(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int meson_gx_pwrc_vpu_on(struct power_domain *power_domain)
{
struct meson_gx_pwrc_vpu_priv *priv = dev_get_priv(power_domain->dev);
@@ -274,10 +264,8 @@
}
struct power_domain_ops meson_gx_pwrc_vpu_ops = {
- .rfree = meson_pwrc_vpu_free,
.off = meson_pwrc_vpu_off,
.on = meson_pwrc_vpu_on,
- .request = meson_pwrc_vpu_request,
.of_xlate = meson_pwrc_vpu_of_xlate,
};
diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c
index ca2ded0..3b84147 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -317,11 +317,6 @@
return 0;
}
-static int scpsys_power_free(struct power_domain *power_domain)
-{
- return 0;
-}
-
static int mtk_power_domain_hook(struct udevice *dev)
{
struct scp_domain *scpd = dev_get_priv(dev);
@@ -399,7 +394,6 @@
};
struct power_domain_ops mtk_power_domain_ops = {
- .rfree = scpsys_power_free,
.off = scpsys_power_off,
.on = scpsys_power_on,
.request = scpsys_power_request,
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 33f9206..0c5823c 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -71,7 +71,7 @@
return ret;
}
- ret = ops->request(power_domain);
+ ret = ops->request ? ops->request(power_domain) : 0;
if (ret) {
debug("ops->request() failed: %d\n", ret);
return ret;
@@ -91,7 +91,7 @@
debug("%s(power_domain=%p)\n", __func__, power_domain);
- return ops->rfree(power_domain);
+ return ops->rfree ? ops->rfree(power_domain) : 0;
}
int power_domain_on(struct power_domain *power_domain)
@@ -100,7 +100,7 @@
debug("%s(power_domain=%p)\n", __func__, power_domain);
- return ops->on(power_domain);
+ return ops->on ? ops->on(power_domain) : 0;
}
int power_domain_off(struct power_domain *power_domain)
@@ -109,7 +109,7 @@
debug("%s(power_domain=%p)\n", __func__, power_domain);
- return ops->off(power_domain);
+ return ops->off ? ops->off(power_domain) : 0;
}
#if CONFIG_IS_ENABLED(OF_REAL)
diff --git a/drivers/power/domain/tegra186-power-domain.c b/drivers/power/domain/tegra186-power-domain.c
index 707735c..46da541 100644
--- a/drivers/power/domain/tegra186-power-domain.c
+++ b/drivers/power/domain/tegra186-power-domain.c
@@ -15,22 +15,6 @@
#define UPDATE BIT(0)
#define ON BIT(1)
-static int tegra186_power_domain_request(struct power_domain *power_domain)
-{
- debug("%s(power_domain=%p) (dev=%p, id=%lu)\n", __func__,
- power_domain, power_domain->dev, power_domain->id);
-
- return 0;
-}
-
-static int tegra186_power_domain_free(struct power_domain *power_domain)
-{
- debug("%s(power_domain=%p) (dev=%p, id=%lu)\n", __func__,
- power_domain, power_domain->dev, power_domain->id);
-
- return 0;
-}
-
static int tegra186_power_domain_common(struct power_domain *power_domain,
bool on)
{
@@ -73,22 +57,12 @@
}
struct power_domain_ops tegra186_power_domain_ops = {
- .request = tegra186_power_domain_request,
- .rfree = tegra186_power_domain_free,
.on = tegra186_power_domain_on,
.off = tegra186_power_domain_off,
};
-static int tegra186_power_domain_probe(struct udevice *dev)
-{
- debug("%s(dev=%p)\n", __func__, dev);
-
- return 0;
-}
-
U_BOOT_DRIVER(tegra186_power_domain) = {
.name = "tegra186_power_domain",
.id = UCLASS_POWER_DOMAIN,
- .probe = tegra186_power_domain_probe,
.ops = &tegra186_power_domain_ops,
};
diff --git a/drivers/power/domain/ti-power-domain.c b/drivers/power/domain/ti-power-domain.c
index 752e76b..292fff0 100644
--- a/drivers/power/domain/ti-power-domain.c
+++ b/drivers/power/domain/ti-power-domain.c
@@ -356,17 +356,6 @@
return 0;
}
-
-static int ti_power_domain_request(struct power_domain *pd)
-{
- return 0;
-}
-
-static int ti_power_domain_free(struct power_domain *pd)
-{
- return 0;
-}
-
static const struct udevice_id ti_power_domain_of_match[] = {
{ .compatible = "ti,sci-pm-domain" },
{ /* sentinel */ }
@@ -376,8 +365,6 @@
.on = ti_power_domain_on,
.off = ti_power_domain_off,
.of_xlate = ti_power_domain_of_xlate,
- .request = ti_power_domain_request,
- .rfree = ti_power_domain_free,
};
U_BOOT_DRIVER(ti_pm_domains) = {
diff --git a/drivers/power/domain/ti-sci-power-domain.c b/drivers/power/domain/ti-sci-power-domain.c
index f18e456..0140e5e 100644
--- a/drivers/power/domain/ti-sci-power-domain.c
+++ b/drivers/power/domain/ti-sci-power-domain.c
@@ -44,18 +44,6 @@
return 0;
}
-static int ti_sci_power_domain_request(struct power_domain *pd)
-{
- debug("%s(pd=%p)\n", __func__, pd);
- return 0;
-}
-
-static int ti_sci_power_domain_free(struct power_domain *pd)
-{
- debug("%s(pd=%p)\n", __func__, pd);
- return 0;
-}
-
static int ti_sci_power_domain_on(struct power_domain *pd)
{
struct ti_sci_power_domain_data *data = dev_get_priv(pd->dev);
@@ -123,8 +111,6 @@
};
static struct power_domain_ops ti_sci_power_domain_ops = {
- .request = ti_sci_power_domain_request,
- .rfree = ti_sci_power_domain_free,
.on = ti_sci_power_domain_on,
.off = ti_sci_power_domain_off,
.of_xlate = ti_sci_power_domain_of_xlate,