diff options
| author | Patrick Mochel <mochel@segfault.osdl.org> | 2002-03-25 17:51:26 -0800 |
|---|---|---|
| committer | Patrick Mochel <mochel@segfault.osdl.org> | 2002-03-25 17:51:26 -0800 |
| commit | e305166b86017833b6a0610174575f8fc8d9e41f (patch) | |
| tree | 9e69d9236dc6f4e69da6e33aae8da166c1c9daee | |
| parent | 9294c63a3b3ac327909fd59d67435af373d4487d (diff) | |
Ok, really add drivers/base/sys.c
| -rw-r--r-- | drivers/base/sys.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index e69de29bb2d1..2336bd2c2dd2 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c @@ -0,0 +1,48 @@ +/* + * sys.c - pseudo-bus for system 'devices' (cpus, PICs, timers, etc) + * + * Copyright (c) 2002 Patrick Mochel + * 2002 Open Source Development Lab + * + * This exports a 'system' bus type. + * By default, a 'sys' bus gets added to the root of the system. There will + * always be core system devices. Devices can use register_sys_device() to + * add themselves as children of the system bus. + */ + +#include <linux/device.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> + +static struct device system_bus = { + name: "System Bus", + bus_id: "sys", +}; + +int register_sys_device(struct device * dev) +{ + int error = -EINVAL; + + if (dev) { + if (!dev->parent) + dev->parent = &system_bus; + error = device_register(dev); + } + return error; +} + +void unregister_sys_device(struct device * dev) +{ + if (dev) + put_device(dev); +} + +static int sys_bus_init(void) +{ + return device_register(&system_bus); +} + +subsys_initcall(sys_bus_init); +EXPORT_SYMBOL(register_sys_device); +EXPORT_SYMBOL(unregister_sys_device); |
