Commit 2b553d80 authored by Patrick Mochel's avatar Patrick Mochel

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. 
parent 9e27f077
# Makefile for the Linux device tree # 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 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 include $(TOPDIR)/Rules.make
...@@ -12,10 +12,15 @@ extern spinlock_t device_lock; ...@@ -12,10 +12,15 @@ extern spinlock_t device_lock;
extern int bus_add_device(struct device * dev); extern int bus_add_device(struct device * dev);
extern void bus_remove_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 int device_make_dir(struct device * dev);
extern void device_remove_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 int device_bus_link(struct device * dev);
extern void device_remove_symlink(struct driver_dir_entry * dir, const char * name); extern void device_remove_symlink(struct driver_dir_entry * dir, const char * name);
......
...@@ -12,17 +12,10 @@ ...@@ -12,17 +12,10 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/stat.h>
#include <linux/init.h>
#include "base.h" #include "base.h"
static LIST_HEAD(bus_driver_list); 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_for_each_dev - walk list of devices and do something to each
* @bus: bus in question * @bus: bus in question
...@@ -148,23 +141,6 @@ void bus_remove_device(struct device * dev) ...@@ -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) int bus_register(struct bus_type * bus)
{ {
rwlock_init(&bus->lock); rwlock_init(&bus->lock);
...@@ -191,21 +167,9 @@ void put_bus(struct bus_type * bus) ...@@ -191,21 +167,9 @@ void put_bus(struct bus_type * bus)
return; return;
list_del_init(&bus->node); list_del_init(&bus->node);
spin_unlock(&device_lock); spin_unlock(&device_lock);
bus_remove_dir(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);
EXPORT_SYMBOL(bus_for_each_dev); EXPORT_SYMBOL(bus_for_each_dev);
EXPORT_SYMBOL(bus_for_each_drv); EXPORT_SYMBOL(bus_for_each_drv);
EXPORT_SYMBOL(bus_add_device); EXPORT_SYMBOL(bus_add_device);
......
...@@ -43,16 +43,6 @@ int driver_for_each_dev(struct device_driver * drv, void * data, int (*callback) ...@@ -43,16 +43,6 @@ int driver_for_each_dev(struct device_driver * drv, void * data, int (*callback)
return error; return error;
} }
/**
* 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 * driver_register - register driver with bus
* @drv: driver to register * @drv: driver to register
...@@ -83,7 +73,7 @@ static void __remove_driver(struct device_driver * drv) ...@@ -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); pr_debug("Unregistering driver '%s' from bus '%s'\n",drv->name,drv->bus->name);
driver_detach(drv); driver_detach(drv);
driverfs_remove_dir(&drv->dir); driver_remove_dir(drv);
if (drv->release) if (drv->release)
drv->release(drv); drv->release(drv);
put_bus(drv->bus); put_bus(drv->bus);
......
obj-y := device.o bus.o driver.o
export-objs := device.o bus.o driver.o
include $(TOPDIR)/Rules.make
#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);
#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);
}
extern int device_create_dir(struct driver_dir_entry * dir, struct driver_dir_entry * parent);
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