O_TARGET := base.o
-obj-y := core.o sys.o interface.o fs.o power.o
+obj-y := core.o sys.o interface.o fs.o power.o bus.o
-export-objs := core.o fs.o power.o sys.o
+export-objs := core.o fs.o power.o sys.o bus.o
include $(TOPDIR)/Rules.make
extern struct device device_root;
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);
#include <linux/device.h>
#include <linux/module.h>
#include <linux/errno.h>
-
+#include <linux/stat.h>
+#include "base.h"
static LIST_HEAD(bus_driver_list);
driverfs_remove_dir(&bus->driver_dir);
driverfs_remove_dir(&bus->device_dir);
driverfs_remove_dir(&bus->dir);
-
- /* tell the driver it can go away now */
- if (bus->release)
- bus->release();
}
static int __init bus_init(void)
subsys_initcall(bus_init);
-EXPORT_SYMBOL(bus_for_each_dev);
EXPORT_SYMBOL(bus_add_device);
EXPORT_SYMBOL(bus_remove_device);
EXPORT_SYMBOL(bus_register);
if ((error = device_make_dir(dev)))
goto register_done;
+ bus_add_device(dev);
+
/* notify platform of device entry */
if (platform_notify)
platform_notify(dev);
if (platform_notify_remove)
platform_notify_remove(dev);
+ bus_remove_device(dev);
+
/* Tell the driver to clean up after itself.
* Note that we likely didn't allocate the device,
* so this is the driver's chance to free that up...
driverfs_remove_dir(&dev->dir);
}
+int device_create_dir(struct driver_dir_entry * dir, struct driver_dir_entry * parent)
+{
+ INIT_LIST_HEAD(&dir->files);
+ dir->mode = (S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO);
+ return driverfs_create_dir(dir,parent);
+}
+
/**
* device_make_dir - create a driverfs directory
* @name: name of directory
int error;
int i;
- INIT_LIST_HEAD(&dev->dir.files);
- dev->dir.mode = (S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO);
- dev->dir.name = dev->bus_id;
-
if (dev->parent)
parent = &dev->parent->dir;
+ dev->dir.name = dev->bus_id;
- if ((error = driverfs_create_dir(&dev->dir,parent)))
+ if ((error = device_create_dir(&dev->dir,parent)))
return error;
for (i = 0; (entry = *(device_default_files + i)); i++) {
if ((error = device_create_file(dev,entry))) {
device_remove_dir(dev);
- return error;
+ break;
}
}
- return 0;
+ return error;
}
EXPORT_SYMBOL(device_create_file);
list_t node;
list_t devices;
+ list_t drivers;
+
+ struct driver_dir_entry dir;
+ struct driver_dir_entry device_dir;
+ struct driver_dir_entry driver_dir;
};
atomic_t refcount; /* refcount to make sure the device
* persists for the right amount of time */
+ struct bus_type * bus; /* type of bus device is on */
struct driver_dir_entry dir;
struct device_driver *driver; /* which driver has allocated this