[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110421104204.GB11788@opensource.wolfsonmicro.com>
Date: Thu, 21 Apr 2011 11:42:04 +0100
From: Mark Brown <broonie@...nsource.wolfsonmicro.com>
To: Haojian Zhuang <haojian.zhuang@...vell.com>
Cc: sameo@...ux.intel.com, haojian.zhuang@...il.com,
linux-kernel@...r.kernel.org, lrg@...mlogic.co.uk
Subject: Re: [PATCH 13/14] regulator: max8925: fix not add device if
missing init data
On Wed, Apr 20, 2011 at 07:55:39PM +0800, Haojian Zhuang wrote:
> If regulator[0] is missed in init data, all regulators of max8925 won't
> be initialized.
With a changelog like this I'd expect a small change to an error check
in the startup code or something but this is a very big change to the
driver initialisation.
> +static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
That looks really suspicious, what happens if there's two of these
devices in the system?
> + memcpy(®ulator_pdata[i], &pdata->regulator[i],
> + sizeof(struct regulator_init_data));
> + regulator_devs[i].platform_data = ®ulator_pdata[i];
> + regulator_devs[i].pdata_size = sizeof(regulator_pdata[i]);
> + regulator_devs[i].num_resources = 1;
> + regulator_devs[i].resources = ®ulator_resources[seq];
> +
> + ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
> + ®ulator_resources[seq], 0);
> + if (ret < 0) {
> + dev_err(chip->dev, "Failed to add regulator subdev\n");
> + goto out;
It's really unclear why the array is needed at all if you're registering
the devices one at a time.
> - if (pdata && pdata->regulator[0]) {
> - ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
> - ARRAY_SIZE(regulator_devs),
> - ®ulator_resources[0], 0);
> - if (ret < 0) {
> - dev_err(chip->dev, "Failed to add regulator subdev\n");
> - goto out_dev;
> - }
Surely the only change that's needed here is to remove the check to see
if pdata->regulator[0] is non-null?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists