diff options
author | Clément Péron <peron.clem@gmail.com> | 2020-07-10 11:54:04 +0200 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2020-08-07 10:11:26 -0600 |
commit | 512f21227fd3d2dbe7aad57a995b9732229c9b56 (patch) | |
tree | c50c554c12fe41b37f33199534e3805d35f5676c /drivers/gpu/drm/panfrost/panfrost_device.c | |
parent | 25e247bbf85af3ad721dfeb2e2caf405f43b7e66 (diff) | |
download | linux-stable-512f21227fd3d2dbe7aad57a995b9732229c9b56.tar.gz linux-stable-512f21227fd3d2dbe7aad57a995b9732229c9b56.tar.bz2 linux-stable-512f21227fd3d2dbe7aad57a995b9732229c9b56.zip |
drm/panfrost: dynamically alloc regulators
We will later introduce regulators managed by OPP.
Only alloc regulators when it's needed. This also help use
to release the regulators only when they are allocated.
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200710095409.407087-10-peron.clem@gmail.com
Diffstat (limited to 'drivers/gpu/drm/panfrost/panfrost_device.c')
-rw-r--r-- | drivers/gpu/drm/panfrost/panfrost_device.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 36b5c8fea3eb..f1474b961def 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -90,9 +90,11 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev) { int ret, i; - if (WARN(pfdev->comp->num_supplies > ARRAY_SIZE(pfdev->regulators), - "Too many supplies in compatible structure.\n")) - return -EINVAL; + pfdev->regulators = devm_kcalloc(pfdev->dev, pfdev->comp->num_supplies, + sizeof(*pfdev->regulators), + GFP_KERNEL); + if (!pfdev->regulators) + return -ENOMEM; for (i = 0; i < pfdev->comp->num_supplies; i++) pfdev->regulators[i].supply = pfdev->comp->supply_names[i]; @@ -119,8 +121,10 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev) static void panfrost_regulator_fini(struct panfrost_device *pfdev) { - regulator_bulk_disable(pfdev->comp->num_supplies, - pfdev->regulators); + if (!pfdev->regulators) + return; + + regulator_bulk_disable(pfdev->comp->num_supplies, pfdev->regulators); } static void panfrost_pm_domain_fini(struct panfrost_device *pfdev) |