Subject: [PATCH] [acpi driver model] Add device registration functions - Create drivers/acpi/drivers/core/device.c - Create (simple) acpi_device_register() and acpi_device_unregister() - Add declarations to drivers/acpi/drivers/core/core.h (Not added to global include, since it should only be acpi core code that discovers devices). Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/core/Makefile | 2 +- drivers/acpi/drivers/core/core.h | 6 ++++++ drivers/acpi/drivers/core/device.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletions(-) create mode 100644 drivers/acpi/drivers/core/device.c applies-to: ed38ffc0fc9c5e8cdc9fea3774f929fd1bb81ad1 2844fff1800f54d05d0c16156baeeb050e7406dd diff --git a/drivers/acpi/drivers/core/Makefile b/drivers/acpi/drivers/core/Makefile index 65a03b8..193e558 100644 --- a/drivers/acpi/drivers/core/Makefile +++ b/drivers/acpi/drivers/core/Makefile @@ -1,4 +1,4 @@ -obj-y := bus.o +obj-y := bus.o device.o obj-y := lib.o diff --git a/drivers/acpi/drivers/core/core.h b/drivers/acpi/drivers/core/core.h index b7301a8..201a5d7 100644 --- a/drivers/acpi/drivers/core/core.h +++ b/drivers/acpi/drivers/core/core.h @@ -22,3 +22,9 @@ static inline struct acpi_device_driver extern struct bus_type acpi_bus; +/* + * For use by other core code + */ + +extern int acpi_device_register(struct acpi_dev *); +extern void acpi_device_unregister(struct acpi_dev *); diff --git a/drivers/acpi/drivers/core/device.c b/drivers/acpi/drivers/core/device.c new file mode 100644 index 0000000..79c03e8 --- /dev/null +++ b/drivers/acpi/drivers/core/device.c @@ -0,0 +1,33 @@ +/* + * drivers/acpi/drivers/device.c - ACPI device management. + * + * Copyright (C) 2005 Patrick Mochel + * + * Some parts are based loosely on patches that were + * Copyright (C) 2005 Shaohua Li + * + * This file is released under the GPLv2 + * + */ + +#include "core.h" + + +static void acpi_dev_release(struct device * dev) +{ + struct acpi_dev * ad = to_acpi_dev(dev); + kfree(ad); +} + +int acpi_device_register(struct acpi_dev * ad) +{ + ad->dev.bus = &acpi_bus; + ad->dev.release = acpi_dev_release; + return device_register(&ad->dev); + +} + +void acpi_device_unregister(struct acpi_dev * ad) +{ + device_unregister(&ad->dev); +} --- 0.99.9.GIT