From: Jiang Liu <liuj97@gmail.com>
To: "Rafael J . Wysocki" <rjw@sisk.pl>,
Yinghai Lu <yinghai@kernel.org>, Tony Luck <tony.luck@intel.com>,
Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
Wen Congyang <wency@cn.fujitsu.com>,
Tang Chen <tangchen@cn.fujitsu.com>,
Taku Izumi <izumi.taku@jp.fujitsu.com>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: Jiang Liu <jiang.liu@huawei.com>,
Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
Huang Ying <ying.huang@intel.com>,
Bob Moore <robert.moore@intel.com>, Len Brown <lenb@kernel.org>,
"Srivatsa S . Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
Yijing Wang <wangyijing@huawei.com>,
Hanjun Guo <guohanjun@huawei.com>, Jiang Liu <liuj97@gmail.com>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-pci@vger.kernel.org, linux-mm@kvack.org
Subject: [ACPIHP PATCH part2 05/13] ACPIHP: implement utility interfaces to support system device hotplug
Date: Sun, 4 Nov 2012 20:50:07 +0800 [thread overview]
Message-ID: <1352033415-5606-6-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1352033415-5606-1-git-send-email-jiang.liu@huawei.com>
This patch implements some utility interfaces to support ACPI based
system device hotplug.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
drivers/acpi/hotplug/core.c | 77 +++++++++++++++++++++++++++++++++++++++++++
include/acpi/acpi_hotplug.h | 9 +++++
2 files changed, 86 insertions(+)
diff --git a/drivers/acpi/hotplug/core.c b/drivers/acpi/hotplug/core.c
index bad8e99..139b9c2 100644
--- a/drivers/acpi/hotplug/core.c
+++ b/drivers/acpi/hotplug/core.c
@@ -591,6 +591,83 @@ int acpihp_remove_device_list(struct klist *dev_list)
}
EXPORT_SYMBOL_GPL(acpihp_remove_device_list);
+bool acpihp_slot_present(struct acpihp_slot *slot)
+{
+ acpi_status status;
+ unsigned long long sta;
+
+ status = acpihp_slot_get_status(slot, &sta);
+ if (ACPI_FAILURE(status)) {
+ ACPIHP_SLOT_WARN(slot, "fails to get status.\n");
+ return false;
+ }
+
+ return !!(sta & ACPI_STA_DEVICE_PRESENT);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_present);
+
+bool acpihp_slot_powered(struct acpihp_slot *slot)
+{
+ acpi_status status;
+ unsigned long long sta;
+
+ /* hotplug slot must implement _STA method */
+ status = acpihp_slot_get_status(slot, &sta);
+ if (ACPI_FAILURE(status)) {
+ ACPIHP_SLOT_WARN(slot, "fails to get status.\n");
+ return false;
+ }
+
+ if ((sta & ACPI_STA_DEVICE_PRESENT) &&
+ ((sta & ACPI_STA_DEVICE_ENABLED) ||
+ (sta & ACPI_STA_DEVICE_FUNCTIONING)))
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_powered);
+
+void acpihp_slot_set_flag(struct acpihp_slot *slot, u32 flags)
+{
+ mutex_lock(&slot->slot_mutex);
+ slot->flags |= flags;
+ mutex_unlock(&slot->slot_mutex);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_set_flag);
+
+void acpihp_slot_clear_flag(struct acpihp_slot *slot, u32 flags)
+{
+ mutex_lock(&slot->slot_mutex);
+ slot->flags &= ~flags;
+ mutex_unlock(&slot->slot_mutex);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_clear_flag);
+
+u32 acpihp_slot_get_flag(struct acpihp_slot *slot, u32 flags)
+{
+ mutex_lock(&slot->slot_mutex);
+ flags &= slot->flags;
+ mutex_unlock(&slot->slot_mutex);
+
+ return flags;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_get_flag);
+
+void acpihp_slot_change_state(struct acpihp_slot *slot,
+ enum acpihp_slot_state state)
+{
+ if (state < ACPIHP_SLOT_STATE_UNKNOWN ||
+ state > ACPIHP_SLOT_STATE_MAX) {
+ ACPIHP_SLOT_WARN(slot, "slot state %d is invalid.\n", state);
+ BUG_ON(state);
+ }
+
+ mutex_lock(&slot->slot_mutex);
+ slot->state = state;
+ mutex_unlock(&slot->slot_mutex);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_change_state);
+
/* SYSFS interfaces */
static ssize_t acpihp_slot_object_show(struct device *d,
struct device_attribute *attr, char *buf)
diff --git a/include/acpi/acpi_hotplug.h b/include/acpi/acpi_hotplug.h
index 9d466ea..3297f51 100644
--- a/include/acpi/acpi_hotplug.h
+++ b/include/acpi/acpi_hotplug.h
@@ -295,6 +295,15 @@ extern int acpihp_slot_remove_device(struct acpihp_slot *slot,
struct device *dev);
extern int acpihp_remove_device_list(struct klist *dev_list);
+/* Utility Interfaces */
+extern bool acpihp_slot_present(struct acpihp_slot *slot);
+extern bool acpihp_slot_powered(struct acpihp_slot *slot);
+extern void acpihp_slot_set_flag(struct acpihp_slot *slot, u32 flags);
+extern void acpihp_slot_clear_flag(struct acpihp_slot *slot, u32 flags);
+extern u32 acpihp_slot_get_flag(struct acpihp_slot *slot, u32 flags);
+extern void acpihp_slot_change_state(struct acpihp_slot *slot,
+ enum acpihp_slot_state state);
+
extern int acpihp_debug;
#define ACPIHP_WARN(fmt, ...) \
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-11-04 12:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-04 12:50 [ACPIHP PATCH part2 00/13] introduce ACPI based system device hotplug driver Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 01/13] ACPIHP: introduce interfaces to scan and walk ACPI devices attached to a slot Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 02/13] ACPIHP: use klist to manage " Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 03/13] ACPIHP: add callbacks into acpi_device_ops to support new hotplug framework Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 04/13] ACPIHP: provide interfaces to manage driver data associated with hotplug slots Jiang Liu
2012-11-04 12:50 ` Jiang Liu [this message]
2012-11-04 12:50 ` [ACPIHP PATCH part2 06/13] ACPIHP: implement ACPI system device hotplug driver skeleton Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 07/13] ACPIHP: analyse dependencies among ACPI hotplug slots Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 08/13] ACPIHP: provide interface to cancel inprogress hotplug operations Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 09/13] ACPIHP: configure/unconfigure system devices attached to a hotplug slot Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 10/13] ACPIHP: implement the core state machine to manage hotplug slots Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 11/13] ACPIHP: block ACPI device driver from unloading when doing hotplug Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 12/13] ACPIHP: implement sysfs interfaces for system device hotplug Jiang Liu
2012-11-04 12:50 ` [ACPIHP PATCH part2 13/13] ACPIHP: handle ACPI device hotplug events Jiang Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352033415-5606-6-git-send-email-jiang.liu@huawei.com \
--to=liuj97@gmail.com \
--cc=bhelgaas@google.com \
--cc=guohanjun@huawei.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=kaneshige.kenji@jp.fujitsu.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pci@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=robert.moore@intel.com \
--cc=srivatsa.bhat@linux.vnet.ibm.com \
--cc=tangchen@cn.fujitsu.com \
--cc=tony.luck@intel.com \
--cc=wangyijing@huawei.com \
--cc=wency@cn.fujitsu.com \
--cc=ying.huang@intel.com \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).