aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCesar Eduardo Barros <cesarb@cesarb.net>2008-11-19 17:10:03 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-19 17:10:03 +0000
commitd24c06f073742d1458d513401e5e9b7df66801f7 (patch)
treec83909648515682bbbde84d1fc305d294b829ec1
parenta79a5b55e287dcf73d8acd92089aea1b1d8bf9c3 (diff)
device model: Allow the creation of symlinks on /sys/bus/*/devices
Allows the direct creation of symlinks on /sys/bus/*/devices. This is needed for a compat symlink from gta01-pm-gps.0 to neo1973-pm-gps.0 on the Openmoko Neo1973 GTA01. Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
-rw-r--r--drivers/base/bus.c23
-rw-r--r--include/linux/device.h5
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5aee1c0169e..e98d36d9710 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -141,6 +141,29 @@ void bus_remove_file(struct bus_type *bus, struct bus_attribute *attr)
}
EXPORT_SYMBOL_GPL(bus_remove_file);
+int bus_create_device_link(struct bus_type *bus, struct kobject *target,
+ const char *name)
+{
+ int error;
+ if (bus_get(bus)) {
+ error = sysfs_create_link(&bus->p->devices_kset->kobj, target,
+ name);
+ bus_put(bus);
+ } else
+ error = -EINVAL;
+ return error;
+}
+EXPORT_SYMBOL_GPL(bus_create_device_link);
+
+void bus_remove_device_link(struct bus_type *bus, const char *name)
+{
+ if (bus_get(bus)) {
+ sysfs_remove_link(&bus->p->devices_kset->kobj, name);
+ bus_put(bus);
+ }
+}
+EXPORT_SYMBOL_GPL(bus_remove_device_link);
+
static struct kobj_type bus_ktype = {
.sysfs_ops = &bus_sysfs_ops,
};
diff --git a/include/linux/device.h b/include/linux/device.h
index 1a3686d15f9..9dbff9579ef 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -48,6 +48,11 @@ extern int __must_check bus_create_file(struct bus_type *,
struct bus_attribute *);
extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
+extern int __must_check bus_create_device_link(struct bus_type *bus,
+ struct kobject *target,
+ const char *name);
+extern void bus_remove_device_link(struct bus_type *bus, const char *name);
+
struct bus_type {
const char *name;
struct bus_attribute *bus_attrs;