linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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,
	Gaohuai Han <hangaohuai@huawei.com>
Subject: [ACPIHP PATCH part2 04/13] ACPIHP: provide interfaces to manage driver data associated with hotplug slots
Date: Sun,  4 Nov 2012 20:50:06 +0800	[thread overview]
Message-ID: <1352033415-5606-5-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1352033415-5606-1-git-send-email-jiang.liu@huawei.com>

This patch implements interfaces to manage driver data associated with
ACPI hotplug slots.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Gaohuai Han <hangaohuai@huawei.com>
---
 drivers/acpi/hotplug/core.c |   88 +++++++++++++++++++++++++++++++++++++++++++
 include/acpi/acpi_hotplug.h |    7 ++++
 2 files changed, 95 insertions(+)

diff --git a/drivers/acpi/hotplug/core.c b/drivers/acpi/hotplug/core.c
index 7ef8f9b..bad8e99 100644
--- a/drivers/acpi/hotplug/core.c
+++ b/drivers/acpi/hotplug/core.c
@@ -35,9 +35,16 @@
 #include <acpi/acpi_hotplug.h>
 #include "acpihp.h"
 
+struct acpihp_drv_data {
+	struct list_head		node;
+	struct class_interface		*key;
+	void				*data;
+};
+
 #define to_acpihp_slot(d) container_of(d, struct acpihp_slot, dev)
 
 static DEFINE_MUTEX(acpihp_mutex);
+static DEFINE_MUTEX(acpihp_drvdata_mutex);
 static int acpihp_class_count;
 static struct kset *acpihp_slot_kset;
 
@@ -355,6 +362,87 @@ char *acpihp_get_slot_type_name(enum acpihp_slot_type type)
 }
 EXPORT_SYMBOL_GPL(acpihp_get_slot_type_name);
 
+int acpihp_slot_attach_drv_data(struct acpihp_slot *slot,
+				struct class_interface *drv, void *data)
+{
+	struct acpihp_drv_data *dp, *cp;
+
+	if (slot == NULL || drv == NULL) {
+		ACPIHP_DEBUG("invalid parameters.\n");
+		return -EINVAL;
+	}
+
+	dp = kzalloc(sizeof(*dp), GFP_KERNEL);
+	if (dp == NULL)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&dp->node);
+	dp->key = drv;
+	dp->data = data;
+
+	mutex_lock(&acpihp_drvdata_mutex);
+	list_for_each_entry(cp, &slot->drvdata_list, node)
+		if (cp->key == drv) {
+			mutex_unlock(&acpihp_drvdata_mutex);
+			kfree(dp);
+			return -EEXIST;
+		}
+	list_add(&dp->node, &slot->drvdata_list);
+	mutex_unlock(&acpihp_drvdata_mutex);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_attach_drv_data);
+
+int acpihp_slot_detach_drv_data(struct acpihp_slot *slot,
+				struct class_interface *drv, void **data)
+{
+	struct acpihp_drv_data *cp;
+
+	if (slot == NULL || drv == NULL || data == NULL) {
+		ACPIHP_DEBUG("invalid parameters.\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&acpihp_drvdata_mutex);
+	list_for_each_entry(cp, &slot->drvdata_list, node)
+		if (cp->key == drv) {
+			list_del(&cp->node);
+			*data = cp->data;
+			mutex_unlock(&acpihp_drvdata_mutex);
+			kfree(cp);
+			return 0;
+		}
+	mutex_unlock(&acpihp_drvdata_mutex);
+
+	return -ENOENT;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_detach_drv_data);
+
+int acpihp_slot_get_drv_data(struct acpihp_slot *slot,
+			     struct class_interface *drv, void **data)
+{
+	int ret = -ENOENT;
+	struct acpihp_drv_data *cp;
+
+	if (slot == NULL || drv == NULL || data == NULL) {
+		ACPIHP_DEBUG("invalid parameters.\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&acpihp_drvdata_mutex);
+	list_for_each_entry(cp, &slot->drvdata_list, node)
+		if (cp->key == drv) {
+			*data = cp->data;
+			ret = 0;
+			break;
+		}
+	mutex_unlock(&acpihp_drvdata_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_get_drv_data);
+
 acpi_status acpihp_slot_get_status(struct acpihp_slot *slot, u64 *status)
 {
 	acpi_status rc;
diff --git a/include/acpi/acpi_hotplug.h b/include/acpi/acpi_hotplug.h
index 35f15a8..9d466ea 100644
--- a/include/acpi/acpi_hotplug.h
+++ b/include/acpi/acpi_hotplug.h
@@ -264,6 +264,13 @@ extern acpi_status acpihp_slot_get_status(struct acpihp_slot *slot,
 extern acpi_status acpihp_slot_poweron(struct acpihp_slot *slot);
 extern acpi_status acpihp_slot_poweroff(struct acpihp_slot *slot);
 
+extern int acpihp_slot_attach_drv_data(struct acpihp_slot *slot,
+			struct class_interface *drv, void *data);
+extern int acpihp_slot_detach_drv_data(struct acpihp_slot *slot,
+			struct class_interface *drv, void **data);
+extern int acpihp_slot_get_drv_data(struct acpihp_slot *slot,
+			struct class_interface *drv, void **data);
+
 /*
  * Scan and create ACPI device objects for devices attached to the handle,
  * but don't cross the hotplug slot boundary.
-- 
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>

  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 ` Jiang Liu [this message]
2012-11-04 12:50 ` [ACPIHP PATCH part2 05/13] ACPIHP: implement utility interfaces to support system device hotplug Jiang Liu
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-5-git-send-email-jiang.liu@huawei.com \
    --to=liuj97@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=guohanjun@huawei.com \
    --cc=hangaohuai@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).