From 11885dc8d5b1151ada4a9d31654e5cd4b2613bd5 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 6 Jan 2014 17:35:47 +1100 Subject: [PATCH] Revert "regulator: act8865: register all regulators regardless of how many are used" This reverts commit d04b755273683ed31043563b8a3a2716bd8aa6a9. --- drivers/regulator/act8865-regulator.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 5e3e1d270328..f816ad866a43 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c @@ -225,8 +225,8 @@ static int act8865_pdata_from_dt(struct device *dev, return matched; pdata->regulators = devm_kzalloc(dev, - sizeof(struct act8865_regulator_data) * - ARRAY_SIZE(act8865_matches), GFP_KERNEL); + sizeof(struct act8865_regulator_data) * matched, + GFP_KERNEL); if (!pdata->regulators) { dev_err(dev, "%s: failed to allocate act8865 registor\n", __func__); @@ -236,7 +236,10 @@ static int act8865_pdata_from_dt(struct device *dev, pdata->num_regulators = matched; regulator = pdata->regulators; - for (i = 0; i < ARRAY_SIZE(act8865_matches); i++) { + for (i = 0; i < matched; i++) { + if (!act8865_matches[i].init_data) + continue; + regulator->id = i; regulator->name = act8865_matches[i].name; regulator->platform_data = act8865_matches[i].init_data; @@ -303,7 +306,7 @@ static int act8865_pmic_probe(struct i2c_client *client, } /* Finally register devices */ - for (i = 0; i < ARRAY_SIZE(act8865_matches); i++) { + for (i = 0; i < pdata->num_regulators; i++) { id = pdata->regulators[i].id; -- 2.39.5