Re: [PATCH] regulator: Add driver for gpio-controlled regulators

From: Mark Brown
Date: Mon Oct 03 2011 - 15:57:17 EST


On Mon, Oct 03, 2011 at 09:11:57PM +0200, Heiko Stübner wrote:
> This patch adds support for regulators that can be controlled via gpios.

> Examples for such regulators are the TI-tps65024x voltage regulators
> with 4 fixed and 1 runtime-switchable voltage regulators
> or the TI-bq240XX charger regulators.

What's the difference between this and the patch you posted on Friday?

> + drvdata->gpios = kmalloc(config->nr_gpios * sizeof(int), GFP_KERNEL);

calloc.

> + /* set output direction without changing state
> + * to prevent glitch
> + */
> + drvdata->is_enabled = config->enabled_at_boot;
> + ret = drvdata->is_enabled ?
> + config->enable_high : !config->enable_high;

I'm fairly sure this could be written more cleanly.

> + drvdata->nr_gpios = config->nr_gpios;
> + for (ptr = 0; ptr < drvdata->nr_gpios; ptr++) {
> + ret = gpio_request(config->gpios[ptr], config->supply_name);
> + if (ret) {
> + dev_err(&pdev->dev,
> + "Could not obtain regulator setting GPIO %d: %d\n",
> + config->gpios[ptr], ret);
> + goto err_stategpio;
> + }

This might be easier written using gpio_request_array().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/