summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2002-10-30 20:15:25 -0800
committerPatrick Mochel <mochel@osdl.org>2002-10-30 20:15:25 -0800
commit8bebafe72c29ad129f449d1850efdafd699e36fa (patch)
tree2cf47178c92dccbea43327b3e024459ef3b1794b /drivers
parentc408284c216f2dd045fa7ad28cb011637dedbc2f (diff)
acpi: convert to use kobjects and sysfs.
- replace driver_dir_entry in acpi_device with struct kobject. - register acpi with firmware subsystem on startup. - register sub-subsystem. - put namespace hierarchy under that.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/acpi_bus.h5
-rw-r--r--drivers/acpi/bus.c5
-rw-r--r--drivers/acpi/driverfs.c46
-rw-r--r--drivers/acpi/scan.c84
5 files changed, 52 insertions, 90 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d4b67800a629..9311d367e96e 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -32,7 +32,7 @@ obj-$(CONFIG_ACPI_INTERPRETER) += osl.o utils.o \
#
# ACPI Bus and Device Drivers
#
-obj-$(CONFIG_ACPI_BUS) += bus.o driverfs.o
+obj-$(CONFIG_ACPI_BUS) += bus.o
obj-$(CONFIG_ACPI_AC) += ac.o
obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_BUTTON) += button.o
diff --git a/drivers/acpi/acpi_bus.h b/drivers/acpi/acpi_bus.h
index 8ad14bfb7360..50c8374094e6 100644
--- a/drivers/acpi/acpi_bus.h
+++ b/drivers/acpi/acpi_bus.h
@@ -27,7 +27,7 @@
#define __ACPI_BUS_H__
#include <linux/version.h>
-#include <linux/driverfs_fs.h>
+#include <linux/kobject.h>
#include "include/acpi.h"
@@ -255,7 +255,7 @@ struct acpi_device {
struct acpi_device_ops ops;
struct acpi_driver *driver;
void *driver_data;
- struct driver_dir_entry driverfs_dir;
+ struct kobject kobj;
};
#define acpi_driver_data(d) ((d)->driver_data)
@@ -274,6 +274,7 @@ struct acpi_bus_event {
u32 data;
};
+extern struct subsystem acpi_subsys;
/*
* External Functions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 3c89b289651c..12423b6d5d5c 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -675,6 +675,9 @@ error0:
return_VALUE(-ENODEV);
}
+struct subsystem acpi_subsys = {
+ .kobj = { .name = "acpi" },
+};
static int __init acpi_init (void)
{
@@ -693,6 +696,8 @@ static int __init acpi_init (void)
return -ENODEV;
}
+ firmware_register(&acpi_subsys);
+
result = acpi_bus_init();
if (!result) {
diff --git a/drivers/acpi/driverfs.c b/drivers/acpi/driverfs.c
deleted file mode 100644
index 0c61f97933b7..000000000000
--- a/drivers/acpi/driverfs.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * driverfs.c - ACPI bindings for driverfs.
- *
- * Copyright (c) 2002 Patrick Mochel
- * Copyright (c) 2002 The Open Source Development Lab
- *
- */
-
-#include <linux/stat.h>
-#include <linux/init.h>
-#include <linux/driverfs_fs.h>
-
-#include "acpi_bus.h"
-
-static struct driver_dir_entry acpi_dir = {
- .name = "acpi",
- .mode = (S_IRWXU | S_IRUGO | S_IXUGO),
-};
-
-/* driverfs ops for ACPI attribute files go here, when/if
- * there are ACPI attribute files.
- * For now, we just have directory creation and removal.
- */
-
-void acpi_remove_dir(struct acpi_device * dev)
-{
- if (dev)
- driverfs_remove_dir(&dev->driverfs_dir);
-}
-
-int acpi_create_dir(struct acpi_device * dev)
-{
- struct driver_dir_entry * parent;
-
- parent = dev->parent ? &dev->parent->driverfs_dir : &acpi_dir;
- dev->driverfs_dir.name = dev->pnp.bus_id;
- dev->driverfs_dir.mode = (S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO);
- return driverfs_create_dir(&dev->driverfs_dir,parent);
-}
-
-static int __init acpi_driverfs_init(void)
-{
- return driverfs_create_dir(&acpi_dir,NULL);
-}
-
-subsys_initcall(acpi_driverfs_init);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c5b8a92514e6..7bc3fd86ac03 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -25,20 +25,52 @@ extern struct acpi_device *acpi_root;
static LIST_HEAD(acpi_device_list);
static spinlock_t acpi_device_lock = SPIN_LOCK_UNLOCKED;
-static int
-acpi_device_register (
- struct acpi_device *device,
- struct acpi_device *parent)
+static void acpi_device_release(struct kobject * kobj)
{
- return acpi_create_dir(device);
+ struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj);
+ kfree(dev);
}
+static struct subsystem acpi_namespace_subsys = {
+ .kobj = { .name = "namespace" },
+ .parent = &acpi_subsys,
+ .release = acpi_device_release,
+};
+
+
+static void acpi_device_register(struct acpi_device * device, struct acpi_device * parent)
+{
+ /*
+ * Linkage
+ * -------
+ * Link this device to its parent and siblings.
+ */
+ INIT_LIST_HEAD(&device->children);
+ INIT_LIST_HEAD(&device->node);
+ INIT_LIST_HEAD(&device->g_list);
+
+ spin_lock(&acpi_device_lock);
+ if (device->parent) {
+ list_add_tail(&device->node, &device->parent->children);
+ list_add_tail(&device->g_list,&device->parent->g_list);
+ } else
+ list_add_tail(&device->g_list,&acpi_device_list);
+ spin_unlock(&acpi_device_lock);
+
+ kobject_init(&device->kobj);
+ strncpy(device->kobj.name,device->pnp.bus_id,KOBJ_NAME_LEN);
+ if (parent)
+ device->kobj.parent = &parent->kobj;
+ device->kobj.subsys = &acpi_namespace_subsys;
+ kobject_register(&device->kobj);
+}
static int
acpi_device_unregister (
- struct acpi_device *device)
+ struct acpi_device *device,
+ int type)
{
- acpi_remove_dir(device);
+ kobject_unregister(&device->kobj);
return 0;
}
@@ -443,16 +475,6 @@ acpi_bus_get_flags (
return_VALUE(0);
}
-static int
-acpi_bus_remove (
- struct acpi_device *device,
- int type)
-{
- acpi_device_unregister(device);
- kfree(device);
- return 0;
-}
-
static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handle, int type)
{
char bus_id[5] = {'?',0};
@@ -621,28 +643,6 @@ void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle handle,
#endif /*CONFIG_ACPI_DEBUG*/
}
-static void acpi_device_attach(struct acpi_device * device, struct acpi_device * parent)
-{
- /*
- * Linkage
- * -------
- * Link this device to its parent and siblings.
- */
- INIT_LIST_HEAD(&device->children);
- INIT_LIST_HEAD(&device->node);
- INIT_LIST_HEAD(&device->g_list);
-
- spin_lock(&acpi_device_lock);
- if (device->parent) {
- list_add_tail(&device->node, &device->parent->children);
- list_add_tail(&device->g_list,&device->parent->g_list);
- } else
- list_add_tail(&device->g_list,&acpi_device_list);
- spin_unlock(&acpi_device_lock);
-
- acpi_device_register(device, parent);
-}
-
static int
acpi_bus_add (
struct acpi_device **child,
@@ -741,7 +741,7 @@ acpi_bus_add (
acpi_device_get_debug_info(device,handle,type);
- acpi_device_attach(device,parent);
+ acpi_device_register(device,parent);
/*
* Bind _ADR-Based Devices
@@ -919,6 +919,8 @@ static int __init acpi_scan_init(void)
if (acpi_disabled)
return_VALUE(0);
+ subsystem_register(&acpi_namespace_subsys);
+
/*
* Create the root device in the bus's device tree
*/
@@ -935,7 +937,7 @@ static int __init acpi_scan_init(void)
result = acpi_bus_scan(acpi_root);
if (result)
- acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
+ acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
Done:
return_VALUE(result);