Commit 8bebafe7 authored by Patrick Mochel's avatar Patrick Mochel

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.
parent c408284c
......@@ -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
......
......@@ -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
......
......@@ -675,6 +675,9 @@ acpi_bus_init (void)
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) {
......
/*
* 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);
......@@ -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);
......
......@@ -437,6 +437,11 @@ extern int device_suspend(u32 state, u32 level);
extern void device_resume(u32 level);
extern void device_shutdown(void);
/* drivrs/base/firmware.c */
extern int firmware_register(struct subsystem *);
extern void firmware_uregister(struct subsystem *);
/* debugging and troubleshooting/diagnostic helpers. */
#ifdef DEBUG
#define dev_dbg(dev, format, arg...) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment