switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
- if (data->pdata->chg) {
+ if (gpio_is_valid(data->pdata->chg)) {
if (gpio_get_value(data->pdata->chg) == 0)
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (data->usb_in || data->ta_in)
data->ta_in = ta_in;
/* Set Current-Limit-Mode 1:DC 0:USB */
- if (pdata->dcm)
+ if (gpio_is_valid(pdata->dcm))
gpio_set_value(pdata->dcm, ta_in ? 1 : 0);
/* Charger Enable / Disable (cen is negated) */
- if (pdata->cen)
+ if (gpio_is_valid(pdata->cen))
gpio_set_value(pdata->cen, ta_in ? 0 :
(data->usb_in ? 0 : 1));
/* Do not touch Current-Limit-Mode */
/* Charger Enable / Disable (cen is negated) */
- if (pdata->cen)
+ if (gpio_is_valid(pdata->cen))
gpio_set_value(pdata->cen, usb_in ? 0 :
(data->ta_in ? 0 : 1));
int usb_in = 0;
if (pdata->dc_valid) {
- if (pdata->dok && gpio_is_valid(pdata->dok)) {
+ if (gpio_is_valid(pdata->dok)) {
ret = devm_gpio_request(dev, pdata->dok,
data->psy_desc.name);
if (ret) {
}
}
- if (pdata->dcm) {
- if (gpio_is_valid(pdata->dcm)) {
- ret = devm_gpio_request(dev, pdata->dcm,
- data->psy_desc.name);
- if (ret) {
- dev_err(dev,
- "Failed GPIO request for dcm: %d err %d\n",
- pdata->dcm, ret);
- return ret;
- }
-
- gpio = pdata->dcm; /* Output */
- gpio_set_value(gpio, ta_in);
- } else {
- dev_err(dev, "Invalid pin: dcm.\n");
- return -EINVAL;
+ if (gpio_is_valid(pdata->dcm)) {
+ ret = devm_gpio_request(dev, pdata->dcm, data->psy_desc.name);
+ if (ret) {
+ dev_err(dev,
+ "Failed GPIO request for dcm: %d err %d\n",
+ pdata->dcm, ret);
+ return ret;
}
+
+ gpio = pdata->dcm; /* Output */
+ gpio_set_value(gpio, ta_in);
}
if (pdata->usb_valid) {
- if (pdata->uok && gpio_is_valid(pdata->uok)) {
+ if (gpio_is_valid(pdata->uok)) {
ret = devm_gpio_request(dev, pdata->uok,
data->psy_desc.name);
if (ret) {
}
}
- if (pdata->cen) {
- if (gpio_is_valid(pdata->cen)) {
- ret = devm_gpio_request(dev, pdata->cen,
- data->psy_desc.name);
- if (ret) {
- dev_err(dev,
- "Failed GPIO request for cen: %d err %d\n",
- pdata->cen, ret);
- return ret;
- }
-
- gpio_set_value(pdata->cen, (ta_in || usb_in) ? 0 : 1);
- } else {
- dev_err(dev, "Invalid pin: cen.\n");
- return -EINVAL;
+ if (gpio_is_valid(pdata->cen)) {
+ ret = devm_gpio_request(dev, pdata->cen, data->psy_desc.name);
+ if (ret) {
+ dev_err(dev,
+ "Failed GPIO request for cen: %d err %d\n",
+ pdata->cen, ret);
+ return ret;
}
+
+ gpio_set_value(pdata->cen, (ta_in || usb_in) ? 0 : 1);
}
- if (pdata->chg) {
- if (gpio_is_valid(pdata->chg)) {
- ret = devm_gpio_request(dev, pdata->chg,
- data->psy_desc.name);
- if (ret) {
- dev_err(dev,
- "Failed GPIO request for chg: %d err %d\n",
- pdata->chg, ret);
- return ret;
- }
+ if (gpio_is_valid(pdata->chg)) {
+ ret = devm_gpio_request(dev, pdata->chg, data->psy_desc.name);
+ if (ret) {
+ dev_err(dev,
+ "Failed GPIO request for chg: %d err %d\n",
+ pdata->chg, ret);
+ return ret;
}
}
- if (pdata->flt) {
- if (gpio_is_valid(pdata->flt)) {
- ret = devm_gpio_request(dev, pdata->flt,
- data->psy_desc.name);
- if (ret) {
- dev_err(dev,
- "Failed GPIO request for flt: %d err %d\n",
- pdata->flt, ret);
- return ret;
- }
+ if (gpio_is_valid(pdata->flt)) {
+ ret = devm_gpio_request(dev, pdata->flt, data->psy_desc.name);
+ if (ret) {
+ dev_err(dev,
+ "Failed GPIO request for flt: %d err %d\n",
+ pdata->flt, ret);
+ return ret;
}
}
- if (pdata->usus) {
- if (gpio_is_valid(pdata->usus)) {
- ret = devm_gpio_request(dev, pdata->usus,
- data->psy_desc.name);
- if (ret) {
- dev_err(dev,
- "Failed GPIO request for usus: %d err %d\n",
- pdata->usus, ret);
- return ret;
- }
+ if (gpio_is_valid(pdata->usus)) {
+ ret = devm_gpio_request(dev, pdata->usus, data->psy_desc.name);
+ if (ret) {
+ dev_err(dev,
+ "Failed GPIO request for usus: %d err %d\n",
+ pdata->usus, ret);
+ return ret;
}
}
}
}
- if (pdata->flt) {
+ if (gpio_is_valid(pdata->flt)) {
ret = devm_request_threaded_irq(dev, gpio_to_irq(pdata->flt),
NULL, max8903_fault,
IRQF_TRIGGER_FALLING |