PM: QoS: Clean up pm_qos_update_target() and pm_qos_update_flags()

Clean up the pm_qos_update_target() function:
 * Update its kerneldoc comment.
 * Drop the redundant ret local variable from it.
 * Reorder definitions of local variables in it.
 * Update a comment in it.

Also update the kerneldoc comment of pm_qos_update_flags() (e.g.
notifiers are not called by it any more) and add one emtpy line
to its body (for more visual clarity).

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Tested-by: Amit Kucheria <amit.kucheria@linaro.org>
This commit is contained in:
Rafael J. Wysocki 2020-02-11 23:58:33 +01:00
parent 87ad735679
commit 7b35370b2e
1 changed files with 29 additions and 27 deletions

View File

@ -129,24 +129,30 @@ static inline void pm_qos_set_value(struct pm_qos_constraints *c, s32 value)
} }
/** /**
* pm_qos_update_target - manages the constraints list and calls the notifiers * pm_qos_update_target - Update a list of PM QoS constraint requests.
* if needed * @c: List of PM QoS requests.
* @c: constraints data struct * @node: Target list entry.
* @node: request to add to the list, to update or to remove * @action: Action to carry out (add, update or remove).
* @action: action to take on the constraints list * @value: New request value for the target list entry.
* @value: value of the request to add or update
* *
* This function returns 1 if the aggregated constraint value has changed, 0 * Update the given list of PM QoS constraint requests, @c, by carrying an
* otherwise. * @action involving the @node list entry and @value on it.
*
* The recognized values of @action are PM_QOS_ADD_REQ (store @value in @node
* and add it to the list), PM_QOS_UPDATE_REQ (remove @node from the list, store
* @value in it and add it to the list again), and PM_QOS_REMOVE_REQ (remove
* @node from the list, ignore @value).
*
* Return: 1 if the aggregate constraint value has changed, 0 otherwise.
*/ */
int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
enum pm_qos_req_action action, int value) enum pm_qos_req_action action, int value)
{ {
unsigned long flags;
int prev_value, curr_value, new_value; int prev_value, curr_value, new_value;
int ret; unsigned long flags;
spin_lock_irqsave(&pm_qos_lock, flags); spin_lock_irqsave(&pm_qos_lock, flags);
prev_value = pm_qos_get_value(c); prev_value = pm_qos_get_value(c);
if (value == PM_QOS_DEFAULT_VALUE) if (value == PM_QOS_DEFAULT_VALUE)
new_value = c->default_value; new_value = c->default_value;
@ -159,9 +165,8 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
break; break;
case PM_QOS_UPDATE_REQ: case PM_QOS_UPDATE_REQ:
/* /*
* to change the list, we atomically remove, reinit * To change the list, atomically remove, reinit with new value
* with new value and add, then see if the extremal * and add, then see if the aggregate has changed.
* changed
*/ */
plist_del(node, &c->list); plist_del(node, &c->list);
/* fall through */ /* fall through */
@ -180,16 +185,14 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
spin_unlock_irqrestore(&pm_qos_lock, flags); spin_unlock_irqrestore(&pm_qos_lock, flags);
trace_pm_qos_update_target(action, prev_value, curr_value); trace_pm_qos_update_target(action, prev_value, curr_value);
if (prev_value != curr_value) {
ret = 1; if (prev_value == curr_value)
if (c->notifiers) return 0;
blocking_notifier_call_chain(c->notifiers,
(unsigned long)curr_value, if (c->notifiers)
NULL); blocking_notifier_call_chain(c->notifiers, curr_value, NULL);
} else {
ret = 0; return 1;
}
return ret;
} }
/** /**
@ -211,14 +214,12 @@ static void pm_qos_flags_remove_req(struct pm_qos_flags *pqf,
/** /**
* pm_qos_update_flags - Update a set of PM QoS flags. * pm_qos_update_flags - Update a set of PM QoS flags.
* @pqf: Set of flags to update. * @pqf: Set of PM QoS flags to update.
* @req: Request to add to the set, to modify, or to remove from the set. * @req: Request to add to the set, to modify, or to remove from the set.
* @action: Action to take on the set. * @action: Action to take on the set.
* @val: Value of the request to add or modify. * @val: Value of the request to add or modify.
* *
* Update the given set of PM QoS flags and call notifiers if the aggregate * Return: 1 if the aggregate constraint value has changed, 0 otherwise.
* value has changed. Returns 1 if the aggregate constraint value has changed,
* 0 otherwise.
*/ */
bool pm_qos_update_flags(struct pm_qos_flags *pqf, bool pm_qos_update_flags(struct pm_qos_flags *pqf,
struct pm_qos_flags_request *req, struct pm_qos_flags_request *req,
@ -254,6 +255,7 @@ bool pm_qos_update_flags(struct pm_qos_flags *pqf,
spin_unlock_irqrestore(&pm_qos_lock, irqflags); spin_unlock_irqrestore(&pm_qos_lock, irqflags);
trace_pm_qos_update_flags(action, prev_value, curr_value); trace_pm_qos_update_flags(action, prev_value, curr_value);
return prev_value != curr_value; return prev_value != curr_value;
} }