Skip to content

Commit

Permalink
PM: Make dev_pm_get_subsys_data() always return 0 on success
Browse files Browse the repository at this point in the history
Commits 1d5fcfe (PM / Domains: Add device domain data reference
counter) and 62d4490 (PM / Domains: Allow device callbacks to be
added at any time) added checks for the return value of
dev_pm_get_subsys_data(), but those checks were incorrect, because
that function returned 1 on success in some cases.

Since all of the existing users of dev_pm_get_subsys_data() don't use
the positive value returned by it on success, change its definition
so that it always returns 0 when successful.

Reported-by: Heiko Stübner <heiko@sntech.de>
Reported-by: Tushar Behera <tushar.behera@linaro.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Rafael J. Wysocki committed Aug 8, 2012
1 parent d06a8a4 commit 7725495
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions drivers/base/power/clock_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ void pm_clk_init(struct device *dev)
*/
int pm_clk_create(struct device *dev)
{
int ret = dev_pm_get_subsys_data(dev);
return ret < 0 ? ret : 0;
return dev_pm_get_subsys_data(dev);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions drivers/base/power/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
int dev_pm_get_subsys_data(struct device *dev)
{
struct pm_subsys_data *psd;
int ret = 0;

psd = kzalloc(sizeof(*psd), GFP_KERNEL);
if (!psd)
Expand All @@ -40,15 +39,14 @@ int dev_pm_get_subsys_data(struct device *dev)
dev->power.subsys_data = psd;
pm_clk_init(dev);
psd = NULL;
ret = 1;
}

spin_unlock_irq(&dev->power.lock);

/* kfree() verifies that its argument is nonzero. */
kfree(psd);

return ret;
return 0;
}
EXPORT_SYMBOL_GPL(dev_pm_get_subsys_data);

Expand Down

0 comments on commit 7725495

Please sign in to comment.