summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2002-08-01 21:57:14 -0700
committerPatrick Mochel <mochel@osdl.org>2002-08-01 21:57:14 -0700
commit2b553d802fe33fb2276853d1a0c63bb86806dbea (patch)
treed9fd2d32c031644bc76cb5b50a6748228141a0ef /drivers/base
parent9e27f077152b4aa70184166406eed14005a83faa (diff)
driverfs: Move driverfs calls from drivers/base/*.c to drivers/base/fs/*.c
This cleans up the drivers/base/ files, so they deal mainly with registration. It also provides a good place to put the glue needed for bus and driver files in driverfs.
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/Makefile6
-rw-r--r--drivers/base/base.h7
-rw-r--r--drivers/base/bus.c38
-rw-r--r--drivers/base/driver.c12
-rw-r--r--drivers/base/fs/Makefile5
-rw-r--r--drivers/base/fs/bus.c42
-rw-r--r--drivers/base/fs/device.c (renamed from drivers/base/fs.c)0
-rw-r--r--drivers/base/fs/driver.c18
-rw-r--r--drivers/base/fs/fs.h2
9 files changed, 79 insertions, 51 deletions
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index bd239b127484..aa3f1ae4d3d7 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,8 +1,10 @@
# Makefile for the Linux device tree
-obj-y := core.o sys.o interface.o fs.o power.o bus.o \
+obj-y := core.o sys.o interface.o power.o bus.o \
driver.o
-export-objs := core.o fs.o power.o sys.o bus.o driver.o
+obj-y += fs/
+
+export-objs := core.o power.o sys.o bus.o driver.o
include $(TOPDIR)/Rules.make
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 35f09fc219e1..c2a1f9b1e9af 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -12,10 +12,15 @@ extern spinlock_t device_lock;
extern int bus_add_device(struct device * dev);
extern void bus_remove_device(struct device * dev);
-extern int device_create_dir(struct driver_dir_entry * dir, struct driver_dir_entry * parent);
extern int device_make_dir(struct device * dev);
extern void device_remove_dir(struct device * dev);
+extern int bus_make_dir(struct bus_type * bus);
+extern void bus_remove_dir(struct bus_type * bus);
+
+extern int driver_make_dir(struct device_driver * drv);
+extern void driver_remove_dir(struct device_driver * drv);
+
extern int device_bus_link(struct device * dev);
extern void device_remove_symlink(struct driver_dir_entry * dir, const char * name);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 4f9affd88253..e85af605a07f 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -12,17 +12,10 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/errno.h>
-#include <linux/stat.h>
-#include <linux/init.h>
#include "base.h"
static LIST_HEAD(bus_driver_list);
-static struct driver_dir_entry bus_dir = {
- name: "bus",
- mode: (S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO),
-};
-
/**
* bus_for_each_dev - walk list of devices and do something to each
* @bus: bus in question
@@ -148,23 +141,6 @@ void bus_remove_device(struct device * dev)
}
}
-static int bus_make_dir(struct bus_type * bus)
-{
- int error;
- bus->dir.name = bus->name;
-
- error = device_create_dir(&bus->dir,&bus_dir);
- if (!error) {
- bus->device_dir.name = "devices";
- device_create_dir(&bus->device_dir,&bus->dir);
-
- bus->driver_dir.name = "drivers";
- device_create_dir(&bus->driver_dir,&bus->dir);
- }
- return error;
-}
-
-
int bus_register(struct bus_type * bus)
{
rwlock_init(&bus->lock);
@@ -191,21 +167,9 @@ void put_bus(struct bus_type * bus)
return;
list_del_init(&bus->node);
spin_unlock(&device_lock);
-
- /* remove driverfs entries */
- driverfs_remove_dir(&bus->driver_dir);
- driverfs_remove_dir(&bus->device_dir);
- driverfs_remove_dir(&bus->dir);
+ bus_remove_dir(bus);
}
-static int __init bus_init(void)
-{
- /* make 'bus' driverfs directory */
- return driverfs_create_dir(&bus_dir,NULL);
-}
-
-core_initcall(bus_init);
-
EXPORT_SYMBOL(bus_for_each_dev);
EXPORT_SYMBOL(bus_for_each_drv);
EXPORT_SYMBOL(bus_add_device);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 2c9d43c05bc0..2b4aa02a0683 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -44,16 +44,6 @@ int driver_for_each_dev(struct device_driver * drv, void * data, int (*callback)
}
/**
- * driver_make_dir - create a driverfs directory for a driver
- * @drv: driver in question
- */
-static int driver_make_dir(struct device_driver * drv)
-{
- drv->dir.name = drv->name;
- return device_create_dir(&drv->dir,&drv->bus->driver_dir);
-}
-
-/**
* driver_register - register driver with bus
* @drv: driver to register
*
@@ -83,7 +73,7 @@ static void __remove_driver(struct device_driver * drv)
{
pr_debug("Unregistering driver '%s' from bus '%s'\n",drv->name,drv->bus->name);
driver_detach(drv);
- driverfs_remove_dir(&drv->dir);
+ driver_remove_dir(drv);
if (drv->release)
drv->release(drv);
put_bus(drv->bus);
diff --git a/drivers/base/fs/Makefile b/drivers/base/fs/Makefile
new file mode 100644
index 000000000000..5a0bd4312ec0
--- /dev/null
+++ b/drivers/base/fs/Makefile
@@ -0,0 +1,5 @@
+obj-y := device.o bus.o driver.o
+
+export-objs := device.o bus.o driver.o
+
+include $(TOPDIR)/Rules.make
diff --git a/drivers/base/fs/bus.c b/drivers/base/fs/bus.c
new file mode 100644
index 000000000000..8ccc250ef55c
--- /dev/null
+++ b/drivers/base/fs/bus.c
@@ -0,0 +1,42 @@
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/stat.h>
+#include "fs.h"
+
+static struct driver_dir_entry bus_dir = {
+ name: "bus",
+ mode: (S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO),
+};
+
+int bus_make_dir(struct bus_type * bus)
+{
+ int error;
+ bus->dir.name = bus->name;
+
+ error = device_create_dir(&bus->dir,&bus_dir);
+ if (!error) {
+ bus->device_dir.name = "devices";
+ device_create_dir(&bus->device_dir,&bus->dir);
+
+ bus->driver_dir.name = "drivers";
+ device_create_dir(&bus->driver_dir,&bus->dir);
+ }
+ return error;
+}
+
+void bus_remove_dir(struct bus_type * bus)
+{
+ /* remove driverfs entries */
+ driverfs_remove_dir(&bus->driver_dir);
+ driverfs_remove_dir(&bus->device_dir);
+ driverfs_remove_dir(&bus->dir);
+}
+
+static int __init bus_init(void)
+{
+ /* make 'bus' driverfs directory */
+ return driverfs_create_dir(&bus_dir,NULL);
+}
+
+core_initcall(bus_init);
+
diff --git a/drivers/base/fs.c b/drivers/base/fs/device.c
index 62df2c48be3f..62df2c48be3f 100644
--- a/drivers/base/fs.c
+++ b/drivers/base/fs/device.c
diff --git a/drivers/base/fs/driver.c b/drivers/base/fs/driver.c
new file mode 100644
index 000000000000..9da487f16acd
--- /dev/null
+++ b/drivers/base/fs/driver.c
@@ -0,0 +1,18 @@
+#include <linux/device.h>
+#include "fs.h"
+
+/**
+ * driver_make_dir - create a driverfs directory for a driver
+ * @drv: driver in question
+ */
+int driver_make_dir(struct device_driver * drv)
+{
+ drv->dir.name = drv->name;
+ return device_create_dir(&drv->dir,&drv->bus->driver_dir);
+}
+
+void driver_remove_dir(struct device_driver * drv)
+{
+ driverfs_remove_dir(&drv->dir);
+}
+
diff --git a/drivers/base/fs/fs.h b/drivers/base/fs/fs.h
new file mode 100644
index 000000000000..ba9d9fc34383
--- /dev/null
+++ b/drivers/base/fs/fs.h
@@ -0,0 +1,2 @@
+
+extern int device_create_dir(struct driver_dir_entry * dir, struct driver_dir_entry * parent);