if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
val = S2MPS14_ENABLE_SUSPEND;
- else if (s2mps11->ext_control_gpio[rdev_get_id(rdev)])
+ else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
val = S2MPS14_ENABLE_EXT_CONTROL;
else
val = rdev->desc->enable_mask;
gpio[reg] = of_get_named_gpio(rdata[reg].of_node,
"samsung,ext-control-gpios", 0);
- if (!gpio_is_valid(gpio[reg]))
- gpio[reg] = 0;
- else
+ if (gpio_is_valid(gpio[reg]))
dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n",
gpio[reg], reg, rdata[reg].name);
}
GFP_KERNEL);
if (!s2mps11->ext_control_gpio)
return -ENOMEM;
+ /*
+ * 0 is a valid GPIO so initialize all GPIO-s to negative value
+ * to indicate that external control won't be used for this regulator.
+ */
+ for (i = 0; i < s2mps11->rdev_num; i++)
+ s2mps11->ext_control_gpio[i] = -EINVAL;
if (!iodev->dev->of_node) {
if (iodev->pdata) {
config.dev = &pdev->dev;
config.regmap = iodev->regmap_pmic;
config.driver_data = s2mps11;
+ config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
for (i = 0; i < s2mps11->rdev_num; i++) {
struct regulator_dev *regulator;
config.init_data = rdata[i].init_data;
config.of_node = rdata[i].of_node;
}
-
- if (s2mps11->ext_control_gpio[i]) {
- config.ena_gpio = s2mps11->ext_control_gpio[i];
- config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
- } else
- config.ena_gpio = config.ena_gpio_flags = 0;
+ config.ena_gpio = s2mps11->ext_control_gpio[i];
regulator = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
goto out;
}
- if (s2mps11->ext_control_gpio[i]) {
+ if (gpio_is_valid(s2mps11->ext_control_gpio[i])) {
ret = s2mps14_pmic_enable_ext_control(s2mps11,
regulator);
if (ret < 0) {