struct regulator_state *rstate)
{
int ret = 0;
- bool can_set_state;
-
- can_set_state = rdev->desc->ops->set_suspend_enable &&
- rdev->desc->ops->set_suspend_disable;
/* If we have no suspend mode configration don't set anything;
- * only warn if the driver actually makes the suspend mode
- * configurable.
+ * only warn if the driver implements set_suspend_voltage or
+ * set_suspend_mode callback.
*/
if (!rstate->enabled && !rstate->disabled) {
- if (can_set_state)
+ if (rdev->desc->ops->set_suspend_voltage ||
+ rdev->desc->ops->set_suspend_mode)
rdev_warn(rdev, "No configuration\n");
return 0;
}
return -EINVAL;
}
- if (!can_set_state) {
- rdev_err(rdev, "no way to set suspend state\n");
- return -EINVAL;
- }
-
- if (rstate->enabled)
+ if (rstate->enabled && rdev->desc->ops->set_suspend_enable)
ret = rdev->desc->ops->set_suspend_enable(rdev);
- else
+ else if (rstate->disabled && rdev->desc->ops->set_suspend_disable)
ret = rdev->desc->ops->set_suspend_disable(rdev);
+ else /* OK if set_suspend_enable or set_suspend_disable is NULL */
+ ret = 0;
+
if (ret < 0) {
rdev_err(rdev, "failed to enabled/disable\n");
return ret;
return status;
}
- /* suspend mode constraints need multiple supporting methods */
- if (!(ops->set_suspend_enable && ops->set_suspend_disable))
- return status;
-
status = device_create_file(dev, &dev_attr_suspend_standby_state);
if (status < 0)
return status;