Commit dfb48f5c authored by Patrick Mochel's avatar Patrick Mochel

ACPI: Don't use driver model for struct acpi_device; use driverfs directly.

Instead of initializing and registering a struct device for each acpi_device, just
initialize and create a driverfs directory for each one. ACPI devices aren't devices,
and shouldn't be treated as such. They are firmware objects that describe devices.
They should still have representation in driverfs (and symlinks to the devices they
describe), but none of the other driver model overhead. 

In order to do this, we also add some ACPI bindings for driverfs. It gets its own top-
level directory now (though it will soon be under a more generic 'platform' directory).
parent 6ade0eeb
...@@ -32,7 +32,7 @@ obj-$(CONFIG_ACPI_INTERPRETER) += osl.o utils.o \ ...@@ -32,7 +32,7 @@ obj-$(CONFIG_ACPI_INTERPRETER) += osl.o utils.o \
# #
# ACPI Bus and Device Drivers # ACPI Bus and Device Drivers
# #
obj-$(CONFIG_ACPI_BUS) += bus.o obj-$(CONFIG_ACPI_BUS) += bus.o driverfs.o
obj-$(CONFIG_ACPI_AC) += ac.o obj-$(CONFIG_ACPI_AC) += ac.o
obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_BUTTON) += button.o obj-$(CONFIG_ACPI_BUTTON) += button.o
......
...@@ -27,11 +27,7 @@ ...@@ -27,11 +27,7 @@
#define __ACPI_BUS_H__ #define __ACPI_BUS_H__
#include <linux/version.h> #include <linux/version.h>
#include <linux/driverfs_fs.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,4))
#include <linux/device.h>
#define CONFIG_LDM
#endif
#include "include/acpi.h" #include "include/acpi.h"
...@@ -258,9 +254,7 @@ struct acpi_device { ...@@ -258,9 +254,7 @@ struct acpi_device {
struct acpi_device_ops ops; struct acpi_device_ops ops;
struct acpi_driver *driver; struct acpi_driver *driver;
void *driver_data; void *driver_data;
#ifdef CONFIG_LDM struct driver_dir_entry driverfs_dir;
struct device dev;
#endif
}; };
#define acpi_driver_data(d) ((d)->driver_data) #define acpi_driver_data(d) ((d)->driver_data)
...@@ -293,6 +287,9 @@ int acpi_bus_receive_event (struct acpi_bus_event *event); ...@@ -293,6 +287,9 @@ int acpi_bus_receive_event (struct acpi_bus_event *event);
int acpi_bus_register_driver (struct acpi_driver *driver); int acpi_bus_register_driver (struct acpi_driver *driver);
int acpi_bus_unregister_driver (struct acpi_driver *driver); int acpi_bus_unregister_driver (struct acpi_driver *driver);
int acpi_create_dir(struct acpi_device *);
void acpi_remove_dir(struct acpi_device *);
#endif /*CONFIG_ACPI_BUS*/ #endif /*CONFIG_ACPI_BUS*/
#endif /*__ACPI_BUS_H__*/ #endif /*__ACPI_BUS_H__*/
/*
* 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);
...@@ -31,16 +31,10 @@ acpi_device_register ( ...@@ -31,16 +31,10 @@ acpi_device_register (
ACPI_FUNCTION_TRACE("acpi_device_register"); ACPI_FUNCTION_TRACE("acpi_device_register");
if (!device) if (device)
return_VALUE(-EINVAL); result = acpi_create_dir(device);
else
sprintf(device->dev.name, "ACPI device %s:%s", result = -EINVAL;
device->pnp.hardware_id, device->pnp.unique_id);
strncpy(device->dev.bus_id, device->pnp.bus_id, sizeof(acpi_bus_id));
if (parent)
device->dev.parent = &parent->dev;
result = device_register(&device->dev);
return_VALUE(result); return_VALUE(result);
} }
...@@ -52,9 +46,7 @@ acpi_device_unregister ( ...@@ -52,9 +46,7 @@ acpi_device_unregister (
{ {
ACPI_FUNCTION_TRACE("acpi_device_unregister"); ACPI_FUNCTION_TRACE("acpi_device_unregister");
if (device) acpi_remove_dir(device);
put_device(&device->dev);
return_VALUE(0); return_VALUE(0);
} }
...@@ -384,15 +376,6 @@ acpi_bus_driver_init ( ...@@ -384,15 +376,6 @@ acpi_bus_driver_init (
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n"));
#ifdef CONFIG_LDM
/*
* Update the device information (in the global device hierarchy) now
* that there's a driver bound to it.
*/
strncpy(device->dev.name, device->pnp.device_name,
sizeof(device->dev.name));
#endif
if (driver->ops.scan) { if (driver->ops.scan) {
driver->ops.scan(device); driver->ops.scan(device);
} }
......
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