Skip to content

Commit

Permalink
PM / OPP: using kfree_rcu() to simplify the code
Browse files Browse the repository at this point in the history
The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Wei Yongjun authored and Rafael J. Wysocki committed Nov 14, 2012
1 parent 0779726 commit ea83f81
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions drivers/base/power/opp.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,6 @@ int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
return 0;
}

/**
* opp_free_rcu() - helper to clear the struct opp when grace period has
* elapsed without blocking the the caller of opp_set_availability
*/
static void opp_free_rcu(struct rcu_head *head)
{
struct opp *opp = container_of(head, struct opp, head);

kfree(opp);
}

/**
* opp_set_availability() - helper to set the availability of an opp
* @dev: device for which we do this operation
Expand Down Expand Up @@ -542,7 +531,7 @@ static int opp_set_availability(struct device *dev, unsigned long freq,

list_replace_rcu(&opp->node, &new_opp->node);
mutex_unlock(&dev_opp_list_lock);
call_rcu(&opp->head, opp_free_rcu);
kfree_rcu(opp, head);

/* Notify the change of the OPP availability */
if (availability_req)
Expand Down

0 comments on commit ea83f81

Please sign in to comment.