From: Jiang Liu <jiang.liu@huawei.com> To: Yinghai Lu <yinghai@kernel.org>, Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>, Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>, Wen Congyang <wency@cn.fujitsu.com>, Tang Chen <tangchen@cn.fujitsu.com>, Taku Izumi <izumi.taku@jp.fujitsu.com> Cc: Jiang Liu <jiang.liu@huawei.com>, Tony Luck <tony.luck@intel.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>, Bjorn Helgaas <bhelgaas@google.com>, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu <liuj97@gmail.com>, Hanjun Guo <guohanjun@huawei.com> Subject: [RFC PATCH v2 09/16] ACPIHP: implement utility functions to support system device hotplug Date: Sat, 4 Aug 2012 20:13:56 +0800 [thread overview] Message-ID: <1344082443-4608-10-git-send-email-jiang.liu@huawei.com> (raw) In-Reply-To: <1344082443-4608-1-git-send-email-jiang.liu@huawei.com> From: Jiang Liu <jiang.liu@huawei.com> This patch implements some utility funcitons to support system device hotplug. Signed-off-by: Jiang Liu <liuj97@gmail.com> Signed-off-by: Hanjun Guo <guohanjun@huawei.com> --- drivers/acpi/hotplug/core.c | 80 +++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_hotplug.h | 9 +++++ 2 files changed, 89 insertions(+) diff --git a/drivers/acpi/hotplug/core.c b/drivers/acpi/hotplug/core.c index 5e78867..230375e 100644 --- a/drivers/acpi/hotplug/core.c +++ b/drivers/acpi/hotplug/core.c @@ -634,6 +634,86 @@ 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; + + /* A hotplug slot must implement ACPI _STA method */ + status = acpi_evaluate_integer(slot->handle, + METHOD_NAME__STA, NULL, &sta); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to evaluate _STA for %p.\n", slot->name); + 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 = acpi_evaluate_integer(slot->handle, + METHOD_NAME__STA, NULL, &sta); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to evaluate _STA for %p.\n", slot->name); + 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_WARN("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 1d43079..a13d9f0 100644 --- a/include/acpi/acpi_hotplug.h +++ b/include/acpi/acpi_hotplug.h @@ -289,6 +289,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 Functions */ +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_DEBUG(fmt, ...) \ -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Jiang Liu <jiang.liu@huawei.com> To: Yinghai Lu <yinghai@kernel.org>, Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>, Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>, Wen Congyang <wency@cn.fujitsu.com>, Tang Chen <tangchen@cn.fujitsu.com>, Taku Izumi <izumi.taku@jp.fujitsu.com> Cc: Jiang Liu <jiang.liu@huawei.com>, Tony Luck <tony.luck@intel.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>, Bjorn Helgaas <bhelgaas@google.com>, <linux-kernel@vger.kernel.org>, <linux-acpi@vger.kernel.org>, <linux-pci@vger.kernel.org>, Jiang Liu <liuj97@gmail.com>, Hanjun Guo <guohanjun@huawei.com> Subject: [RFC PATCH v2 09/16] ACPIHP: implement utility functions to support system device hotplug Date: Sat, 4 Aug 2012 20:13:56 +0800 [thread overview] Message-ID: <1344082443-4608-10-git-send-email-jiang.liu@huawei.com> (raw) In-Reply-To: <1344082443-4608-1-git-send-email-jiang.liu@huawei.com> From: Jiang Liu <jiang.liu@huawei.com> This patch implements some utility funcitons to support system device hotplug. Signed-off-by: Jiang Liu <liuj97@gmail.com> Signed-off-by: Hanjun Guo <guohanjun@huawei.com> --- drivers/acpi/hotplug/core.c | 80 +++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_hotplug.h | 9 +++++ 2 files changed, 89 insertions(+) diff --git a/drivers/acpi/hotplug/core.c b/drivers/acpi/hotplug/core.c index 5e78867..230375e 100644 --- a/drivers/acpi/hotplug/core.c +++ b/drivers/acpi/hotplug/core.c @@ -634,6 +634,86 @@ 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; + + /* A hotplug slot must implement ACPI _STA method */ + status = acpi_evaluate_integer(slot->handle, + METHOD_NAME__STA, NULL, &sta); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to evaluate _STA for %p.\n", slot->name); + 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 = acpi_evaluate_integer(slot->handle, + METHOD_NAME__STA, NULL, &sta); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to evaluate _STA for %p.\n", slot->name); + 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_WARN("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 1d43079..a13d9f0 100644 --- a/include/acpi/acpi_hotplug.h +++ b/include/acpi/acpi_hotplug.h @@ -289,6 +289,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 Functions */ +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_DEBUG(fmt, ...) \ -- 1.7.9.5
next prev parent reply other threads:[~2012-08-04 12:20 UTC|newest] Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-04 12:13 [RFC PATCH v2 00/16] ACPI based system device hotplug framework Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 01/16] ACPIHP: introduce a framework for ACPI based system device hotplug Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 02/16] ACPIHP: ACPI system device hotplug slot enumerator Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 03/16] ACPIHP: detect ACPI hotplug slots by checking ACPI _EJ0 method Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 04/16] ACPI: introduce interfaces to manage ACPI device reference count Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 05/16] ACPIHP: scan and walk ACPI devices connecting to an ACPI hotplug slot Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 06/16] ACPIHP: group devices connecting to a hotplug slot according to device types Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 07/16] ACPIHP: add callbacks into acpi_device_ops to support new hotplug framework Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 08/16] ACPIHP: provide interfaces to associate driver specific data to hotplug slots Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` Jiang Liu [this message] 2012-08-04 12:13 ` [RFC PATCH v2 09/16] ACPIHP: implement utility functions to support system device hotplug Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 10/16] ACPIHP: system device hotplug driver skeleton Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-09 7:12 ` Tang Chen 2012-08-09 7:40 ` Jiang Liu 2012-08-09 7:40 ` Jiang Liu 2012-08-09 8:41 ` Tang Chen 2012-08-09 9:36 ` Jiang Liu 2012-08-09 9:36 ` Jiang Liu 2012-08-10 4:39 ` Tang Chen 2012-08-04 12:13 ` [RFC PATCH v2 11/16] ACPIHP: analyse dependences among ACPI system device hotplug slots Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 12/16] ACPIHP: cancel inprogress ACPI system device hotplug operations Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 13/16] ACPIHP: configure/unconfigure system devices connecting to a hotplug slot Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 14/16] ACPIHP: implement the state machine for ACPI hotplug slots Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 15/16] ACPIHP: implement ACPI hotplug sysfs interfaces Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 16/16] ACPIHP: enhance ACPI container driver to support new hotplug framework Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-07 23:38 ` [RFC PATCH v2 00/16] ACPI based system device " Toshi Kani 2012-08-08 15:44 ` Jiang Liu 2012-08-08 16:27 ` Bjorn Helgaas 2012-08-09 15:24 ` Jiang Liu 2012-08-08 21:05 ` Toshi Kani
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=1344082443-4608-10-git-send-email-jiang.liu@huawei.com \ --to=jiang.liu@huawei.com \ --cc=bhelgaas@google.com \ --cc=guohanjun@huawei.com \ --cc=isimatu.yasuaki@jp.fujitsu.com \ --cc=izumi.taku@jp.fujitsu.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-pci@vger.kernel.org \ --cc=liuj97@gmail.com \ --cc=robert.moore@intel.com \ --cc=srivatsa.bhat@linux.vnet.ibm.com \ --cc=tangchen@cn.fujitsu.com \ --cc=tony.luck@intel.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.