Skip to content

Commit

Permalink
Revert "UPSTREAM: PM / wakeup updates"
Browse files Browse the repository at this point in the history
This is a preparation change for merging android-4.19.95 into
msm-4.19 branch.

The following changes are reverted. They will be reintroduced to
msm-4.19 at later stage.

2d67117 UPSTREAM: PM / wakeup: Drop wakeup_source_drop()
8f35ee2 UPSTREAM: PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare()
5bc2bdf UPSTREAM: PM / wakeup: Use wakeup_source_register() in wakelock.c
2c9f5fa UPSTREAM: PM / wakeup: Show wakeup sources stats in sysfs
b5e87d6 UPSTREAM: PM / wakeup: Fix sysfs registration error path
845f643 UPSTREAM: PM / wakeup: Register wakeup class kobj after device is added
47b8294 UPSTREAM: PM / wakeup: Unexport wakeup_source_sysfs_{add,remove}()

Change-Id: Ie43df2e4d512d4641030dcd7b4c608fb51da802a
Signed-off-by: Ivaylo Georgiev <[email protected]>
  • Loading branch information
Ivaylo Georgiev committed Mar 24, 2020
1 parent c049e41 commit 45417b1
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 394 deletions.
76 changes: 0 additions & 76 deletions Documentation/ABI/testing/sysfs-class-wakeup

This file was deleted.

3 changes: 1 addition & 2 deletions drivers/acpi/device_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
goto out;

mutex_lock(&acpi_pm_notifier_lock);
adev->wakeup.ws = wakeup_source_register(&adev->dev,
dev_name(&adev->dev));
adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev));
adev->wakeup.context.dev = dev;
adev->wakeup.context.func = func;
adev->wakeup.flags.notifier_present = true;
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/power/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_PM) += sysfs.o generic_ops.o common.o qos.o runtime.o wakeirq.o
obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o wakeup_stats.o
obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
obj-$(CONFIG_PM_TRACE_RTC) += trace.o
obj-$(CONFIG_PM_GENERIC_DOMAINS) += domain.o domain_governor.o
obj-$(CONFIG_HAVE_CLK) += clock_ops.o
Expand Down
18 changes: 0 additions & 18 deletions drivers/base/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,3 @@ static inline void device_pm_init(struct device *dev)
device_pm_sleep_init(dev);
pm_runtime_init(dev);
}

#ifdef CONFIG_PM_SLEEP

/* drivers/base/power/wakeup_stats.c */
extern int wakeup_source_sysfs_add(struct device *parent,
struct wakeup_source *ws);
extern void wakeup_source_sysfs_remove(struct wakeup_source *ws);

extern int pm_wakeup_source_sysfs_add(struct device *parent);

#else /* !CONFIG_PM_SLEEP */

static inline int pm_wakeup_source_sysfs_add(struct device *parent)
{
return 0;
}

#endif /* CONFIG_PM_SLEEP */
6 changes: 0 additions & 6 deletions drivers/base/power/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <linux/export.h>
#include <linux/pm_qos.h>
#include <linux/pm_runtime.h>
#include <linux/pm_wakeup.h>
#include <linux/atomic.h>
#include <linux/jiffies.h>
#include "power.h"
Expand Down Expand Up @@ -673,13 +672,8 @@ int dpm_sysfs_add(struct device *dev)
if (rc)
goto err_wakeup;
}
rc = pm_wakeup_source_sysfs_add(dev);
if (rc)
goto err_latency;
return 0;

err_latency:
sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group);
err_wakeup:
sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
err_runtime:
Expand Down
88 changes: 42 additions & 46 deletions drivers/base/power/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,22 @@ static struct wakeup_source deleted_ws = {
.lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
};

static DEFINE_IDA(wakeup_ida);
/**
* wakeup_source_prepare - Prepare a new wakeup source for initialization.
* @ws: Wakeup source to prepare.
* @name: Pointer to the name of the new wakeup source.
*
* Callers must ensure that the @name string won't be freed when @ws is still in
* use.
*/
void wakeup_source_prepare(struct wakeup_source *ws, const char *name)
{
if (ws) {
memset(ws, 0, sizeof(*ws));
ws->name = name;
}
}
EXPORT_SYMBOL_GPL(wakeup_source_prepare);

/**
* wakeup_source_create - Create a struct wakeup_source object.
Expand All @@ -82,34 +97,32 @@ static DEFINE_IDA(wakeup_ida);
struct wakeup_source *wakeup_source_create(const char *name)
{
struct wakeup_source *ws;
const char *ws_name;
int id;

ws = kzalloc(sizeof(*ws), GFP_KERNEL);
ws = kmalloc(sizeof(*ws), GFP_KERNEL);
if (!ws)
goto err_ws;

ws_name = kstrdup_const(name, GFP_KERNEL);
if (!ws_name)
goto err_name;
ws->name = ws_name;

id = ida_alloc(&wakeup_ida, GFP_KERNEL);
if (id < 0)
goto err_id;
ws->id = id;
return NULL;

wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_KERNEL) : NULL);
return ws;

err_id:
kfree_const(ws->name);
err_name:
kfree(ws);
err_ws:
return NULL;
}
EXPORT_SYMBOL_GPL(wakeup_source_create);

/**
* wakeup_source_drop - Prepare a struct wakeup_source object for destruction.
* @ws: Wakeup source to prepare for destruction.
*
* Callers must ensure that __pm_stay_awake() or __pm_wakeup_event() will never
* be run in parallel with this function for the same wakeup source object.
*/
void wakeup_source_drop(struct wakeup_source *ws)
{
if (!ws)
return;

__pm_relax(ws);
}
EXPORT_SYMBOL_GPL(wakeup_source_drop);

/*
* Record wakeup_source statistics being deleted into a dummy wakeup_source.
*/
Expand Down Expand Up @@ -138,13 +151,6 @@ static void wakeup_source_record(struct wakeup_source *ws)
spin_unlock_irqrestore(&deleted_ws.lock, flags);
}

static void wakeup_source_free(struct wakeup_source *ws)
{
ida_free(&wakeup_ida, ws->id);
kfree_const(ws->name);
kfree(ws);
}

/**
* wakeup_source_destroy - Destroy a struct wakeup_source object.
* @ws: Wakeup source to destroy.
Expand All @@ -156,9 +162,10 @@ void wakeup_source_destroy(struct wakeup_source *ws)
if (!ws)
return;

__pm_relax(ws);
wakeup_source_drop(ws);
wakeup_source_record(ws);
wakeup_source_free(ws);
kfree_const(ws->name);
kfree(ws);
}
EXPORT_SYMBOL_GPL(wakeup_source_destroy);

Expand Down Expand Up @@ -210,26 +217,16 @@ EXPORT_SYMBOL_GPL(wakeup_source_remove);

/**
* wakeup_source_register - Create wakeup source and add it to the list.
* @dev: Device this wakeup source is associated with (or NULL if virtual).
* @name: Name of the wakeup source to register.
*/
struct wakeup_source *wakeup_source_register(struct device *dev,
const char *name)
struct wakeup_source *wakeup_source_register(const char *name)
{
struct wakeup_source *ws;
int ret;

ws = wakeup_source_create(name);
if (ws) {
if (!dev || device_is_registered(dev)) {
ret = wakeup_source_sysfs_add(dev, ws);
if (ret) {
wakeup_source_free(ws);
return NULL;
}
}
if (ws)
wakeup_source_add(ws);
}

return ws;
}
EXPORT_SYMBOL_GPL(wakeup_source_register);
Expand All @@ -242,7 +239,6 @@ void wakeup_source_unregister(struct wakeup_source *ws)
{
if (ws) {
wakeup_source_remove(ws);
wakeup_source_sysfs_remove(ws);
wakeup_source_destroy(ws);
}
}
Expand Down Expand Up @@ -286,7 +282,7 @@ int device_wakeup_enable(struct device *dev)
if (pm_suspend_target_state != PM_SUSPEND_ON)
dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__);

ws = wakeup_source_register(dev, dev_name(dev));
ws = wakeup_source_register(dev_name(dev));
if (!ws)
return -ENOMEM;

Expand Down
Loading

0 comments on commit 45417b1

Please sign in to comment.