drm/msm/hdmi: use dynamic allocation for hdmi resources
authorStephane Viau <sviau@codeaurora.org>
Tue, 13 Jan 2015 19:33:40 +0000 (14:33 -0500)
committerRob Clark <robdclark@gmail.com>
Sun, 1 Feb 2015 20:32:45 +0000 (15:32 -0500)
Instead of reporting BUG_ON when resources arrays are not
dimensioned correctly, this patch does a dynamic allocation of
these arrays. This is needed for the following patches that add a
regulator for a new target.

Signed-off-by: Stephane Viau <sviau@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/hdmi/hdmi.c
drivers/gpu/drm/msm/hdmi/hdmi.h

index 95f7b8d0f3ef8f8fd7b2b8f5f56780b930cada47..99b83a6a6adc1a71cbab7700bc18856a7210638c 100644 (file)
@@ -106,7 +106,12 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
                goto fail;
        }
 
-       BUG_ON(config->hpd_reg_cnt > ARRAY_SIZE(hdmi->hpd_regs));
+       hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) *
+                       config->hpd_reg_cnt, GFP_KERNEL);
+       if (!hdmi->hpd_regs) {
+               ret = -ENOMEM;
+               goto fail;
+       }
        for (i = 0; i < config->hpd_reg_cnt; i++) {
                struct regulator *reg;
 
@@ -122,7 +127,12 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
                hdmi->hpd_regs[i] = reg;
        }
 
-       BUG_ON(config->pwr_reg_cnt > ARRAY_SIZE(hdmi->pwr_regs));
+       hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) *
+                       config->pwr_reg_cnt, GFP_KERNEL);
+       if (!hdmi->pwr_regs) {
+               ret = -ENOMEM;
+               goto fail;
+       }
        for (i = 0; i < config->pwr_reg_cnt; i++) {
                struct regulator *reg;
 
@@ -138,7 +148,12 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
                hdmi->pwr_regs[i] = reg;
        }
 
-       BUG_ON(config->hpd_clk_cnt > ARRAY_SIZE(hdmi->hpd_clks));
+       hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) *
+                       config->hpd_clk_cnt, GFP_KERNEL);
+       if (!hdmi->hpd_clks) {
+               ret = -ENOMEM;
+               goto fail;
+       }
        for (i = 0; i < config->hpd_clk_cnt; i++) {
                struct clk *clk;
 
@@ -153,7 +168,12 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
                hdmi->hpd_clks[i] = clk;
        }
 
-       BUG_ON(config->pwr_clk_cnt > ARRAY_SIZE(hdmi->pwr_clks));
+       hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) *
+                       config->pwr_clk_cnt, GFP_KERNEL);
+       if (!hdmi->pwr_clks) {
+               ret = -ENOMEM;
+               goto fail;
+       }
        for (i = 0; i < config->pwr_clk_cnt; i++) {
                struct clk *clk;
 
index 4d4cad42a776e9fb87ddb738e567613a20a11f29..68fdfb3622a5f6d754ed0e9b9e851f8775e08977 100644 (file)
@@ -52,10 +52,10 @@ struct hdmi {
 
        void __iomem *mmio;
 
-       struct regulator *hpd_regs[2];
-       struct regulator *pwr_regs[2];
-       struct clk *hpd_clks[3];
-       struct clk *pwr_clks[2];
+       struct regulator **hpd_regs;
+       struct regulator **pwr_regs;
+       struct clk **hpd_clks;
+       struct clk **pwr_clks;
 
        struct hdmi_phy *phy;
        struct i2c_adapter *i2c;