diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-06-23 05:53:03 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-23 05:53:03 -0400 |
commit | 009b9fc98ddd83f9139fdabb12c0d7a8535d5421 (patch) | |
tree | f7d3e182407d2ebe50a9b8db6361ac910027a1cf /drivers/base | |
parent | 3711ccb07b7f0a13f4f1aa16a8fdca9c930f21ca (diff) | |
parent | 481c5346d0981940ee63037eb53e4e37b0735c10 (diff) |
Merge branch 'linus' into x86/threadinfo
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/class.c | 1 | ||||
-rw-r--r-- | drivers/base/core.c | 109 | ||||
-rw-r--r-- | drivers/base/memory.c | 2 | ||||
-rw-r--r-- | drivers/base/power/main.c | 2 |
4 files changed, 101 insertions, 13 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 0ef00e8d4153..e085af0ff94f 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -140,7 +140,6 @@ int class_register(struct class *cls) | |||
140 | 140 | ||
141 | pr_debug("device class '%s': registering\n", cls->name); | 141 | pr_debug("device class '%s': registering\n", cls->name); |
142 | 142 | ||
143 | INIT_LIST_HEAD(&cls->children); | ||
144 | INIT_LIST_HEAD(&cls->devices); | 143 | INIT_LIST_HEAD(&cls->devices); |
145 | INIT_LIST_HEAD(&cls->interfaces); | 144 | INIT_LIST_HEAD(&cls->interfaces); |
146 | kset_init(&cls->class_dirs); | 145 | kset_init(&cls->class_dirs); |
diff --git a/drivers/base/core.c b/drivers/base/core.c index be288b5e4180..ee0a51a3a41d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -760,6 +760,22 @@ static void device_remove_class_symlinks(struct device *dev) | |||
760 | } | 760 | } |
761 | 761 | ||
762 | /** | 762 | /** |
763 | * dev_set_name - set a device name | ||
764 | * @dev: device | ||
765 | * @fmt: format string for the device's name | ||
766 | */ | ||
767 | int dev_set_name(struct device *dev, const char *fmt, ...) | ||
768 | { | ||
769 | va_list vargs; | ||
770 | |||
771 | va_start(vargs, fmt); | ||
772 | vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs); | ||
773 | va_end(vargs); | ||
774 | return 0; | ||
775 | } | ||
776 | EXPORT_SYMBOL_GPL(dev_set_name); | ||
777 | |||
778 | /** | ||
763 | * device_add - add device to device hierarchy. | 779 | * device_add - add device to device hierarchy. |
764 | * @dev: device. | 780 | * @dev: device. |
765 | * | 781 | * |
@@ -1084,11 +1100,13 @@ static void device_create_release(struct device *dev) | |||
1084 | } | 1100 | } |
1085 | 1101 | ||
1086 | /** | 1102 | /** |
1087 | * device_create - creates a device and registers it with sysfs | 1103 | * device_create_vargs - creates a device and registers it with sysfs |
1088 | * @class: pointer to the struct class that this device should be registered to | 1104 | * @class: pointer to the struct class that this device should be registered to |
1089 | * @parent: pointer to the parent struct device of this new device, if any | 1105 | * @parent: pointer to the parent struct device of this new device, if any |
1090 | * @devt: the dev_t for the char device to be added | 1106 | * @devt: the dev_t for the char device to be added |
1107 | * @drvdata: the data to be added to the device for callbacks | ||
1091 | * @fmt: string for the device's name | 1108 | * @fmt: string for the device's name |
1109 | * @args: va_list for the device's name | ||
1092 | * | 1110 | * |
1093 | * This function can be used by char device classes. A struct device | 1111 | * This function can be used by char device classes. A struct device |
1094 | * will be created in sysfs, registered to the specified class. | 1112 | * will be created in sysfs, registered to the specified class. |
@@ -1104,10 +1122,10 @@ static void device_create_release(struct device *dev) | |||
1104 | * Note: the struct class passed to this function must have previously | 1122 | * Note: the struct class passed to this function must have previously |
1105 | * been created with a call to class_create(). | 1123 | * been created with a call to class_create(). |
1106 | */ | 1124 | */ |
1107 | struct device *device_create(struct class *class, struct device *parent, | 1125 | struct device *device_create_vargs(struct class *class, struct device *parent, |
1108 | dev_t devt, const char *fmt, ...) | 1126 | dev_t devt, void *drvdata, const char *fmt, |
1127 | va_list args) | ||
1109 | { | 1128 | { |
1110 | va_list args; | ||
1111 | struct device *dev = NULL; | 1129 | struct device *dev = NULL; |
1112 | int retval = -ENODEV; | 1130 | int retval = -ENODEV; |
1113 | 1131 | ||
@@ -1124,10 +1142,9 @@ struct device *device_create(struct class *class, struct device *parent, | |||
1124 | dev->class = class; | 1142 | dev->class = class; |
1125 | dev->parent = parent; | 1143 | dev->parent = parent; |
1126 | dev->release = device_create_release; | 1144 | dev->release = device_create_release; |
1145 | dev_set_drvdata(dev, drvdata); | ||
1127 | 1146 | ||
1128 | va_start(args, fmt); | ||
1129 | vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); | 1147 | vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); |
1130 | va_end(args); | ||
1131 | retval = device_register(dev); | 1148 | retval = device_register(dev); |
1132 | if (retval) | 1149 | if (retval) |
1133 | goto error; | 1150 | goto error; |
@@ -1138,6 +1155,78 @@ error: | |||
1138 | kfree(dev); | 1155 | kfree(dev); |
1139 | return ERR_PTR(retval); | 1156 | return ERR_PTR(retval); |
1140 | } | 1157 | } |
1158 | EXPORT_SYMBOL_GPL(device_create_vargs); | ||
1159 | |||
1160 | /** | ||
1161 | * device_create_drvdata - creates a device and registers it with sysfs | ||
1162 | * @class: pointer to the struct class that this device should be registered to | ||
1163 | * @parent: pointer to the parent struct device of this new device, if any | ||
1164 | * @devt: the dev_t for the char device to be added | ||
1165 | * @drvdata: the data to be added to the device for callbacks | ||
1166 | * @fmt: string for the device's name | ||
1167 | * | ||
1168 | * This function can be used by char device classes. A struct device | ||
1169 | * will be created in sysfs, registered to the specified class. | ||
1170 | * | ||
1171 | * A "dev" file will be created, showing the dev_t for the device, if | ||
1172 | * the dev_t is not 0,0. | ||
1173 | * If a pointer to a parent struct device is passed in, the newly created | ||
1174 | * struct device will be a child of that device in sysfs. | ||
1175 | * The pointer to the struct device will be returned from the call. | ||
1176 | * Any further sysfs files that might be required can be created using this | ||
1177 | * pointer. | ||
1178 | * | ||
1179 | * Note: the struct class passed to this function must have previously | ||
1180 | * been created with a call to class_create(). | ||
1181 | */ | ||
1182 | struct device *device_create_drvdata(struct class *class, | ||
1183 | struct device *parent, | ||
1184 | dev_t devt, | ||
1185 | void *drvdata, | ||
1186 | const char *fmt, ...) | ||
1187 | { | ||
1188 | va_list vargs; | ||
1189 | struct device *dev; | ||
1190 | |||
1191 | va_start(vargs, fmt); | ||
1192 | dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs); | ||
1193 | va_end(vargs); | ||
1194 | return dev; | ||
1195 | } | ||
1196 | EXPORT_SYMBOL_GPL(device_create_drvdata); | ||
1197 | |||
1198 | /** | ||
1199 | * device_create - creates a device and registers it with sysfs | ||
1200 | * @class: pointer to the struct class that this device should be registered to | ||
1201 | * @parent: pointer to the parent struct device of this new device, if any | ||
1202 | * @devt: the dev_t for the char device to be added | ||
1203 | * @fmt: string for the device's name | ||
1204 | * | ||
1205 | * This function can be used by char device classes. A struct device | ||
1206 | * will be created in sysfs, registered to the specified class. | ||
1207 | * | ||
1208 | * A "dev" file will be created, showing the dev_t for the device, if | ||
1209 | * the dev_t is not 0,0. | ||
1210 | * If a pointer to a parent struct device is passed in, the newly created | ||
1211 | * struct device will be a child of that device in sysfs. | ||
1212 | * The pointer to the struct device will be returned from the call. | ||
1213 | * Any further sysfs files that might be required can be created using this | ||
1214 | * pointer. | ||
1215 | * | ||
1216 | * Note: the struct class passed to this function must have previously | ||
1217 | * been created with a call to class_create(). | ||
1218 | */ | ||
1219 | struct device *device_create(struct class *class, struct device *parent, | ||
1220 | dev_t devt, const char *fmt, ...) | ||
1221 | { | ||
1222 | va_list vargs; | ||
1223 | struct device *dev; | ||
1224 | |||
1225 | va_start(vargs, fmt); | ||
1226 | dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs); | ||
1227 | va_end(vargs); | ||
1228 | return dev; | ||
1229 | } | ||
1141 | EXPORT_SYMBOL_GPL(device_create); | 1230 | EXPORT_SYMBOL_GPL(device_create); |
1142 | 1231 | ||
1143 | static int __match_devt(struct device *dev, void *data) | 1232 | static int __match_devt(struct device *dev, void *data) |
@@ -1218,13 +1307,11 @@ int device_rename(struct device *dev, char *new_name) | |||
1218 | } | 1307 | } |
1219 | #else | 1308 | #else |
1220 | if (dev->class) { | 1309 | if (dev->class) { |
1221 | sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); | ||
1222 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 1310 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, |
1223 | dev->bus_id); | 1311 | dev->bus_id); |
1224 | if (error) { | 1312 | if (error) |
1225 | dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", | 1313 | goto out; |
1226 | __func__, error); | 1314 | sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); |
1227 | } | ||
1228 | } | 1315 | } |
1229 | #endif | 1316 | #endif |
1230 | 1317 | ||
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 8ce6de5a7e28..937e8258981d 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -53,11 +53,13 @@ int register_memory_notifier(struct notifier_block *nb) | |||
53 | { | 53 | { |
54 | return blocking_notifier_chain_register(&memory_chain, nb); | 54 | return blocking_notifier_chain_register(&memory_chain, nb); |
55 | } | 55 | } |
56 | EXPORT_SYMBOL(register_memory_notifier); | ||
56 | 57 | ||
57 | void unregister_memory_notifier(struct notifier_block *nb) | 58 | void unregister_memory_notifier(struct notifier_block *nb) |
58 | { | 59 | { |
59 | blocking_notifier_chain_unregister(&memory_chain, nb); | 60 | blocking_notifier_chain_unregister(&memory_chain, nb); |
60 | } | 61 | } |
62 | EXPORT_SYMBOL(unregister_memory_notifier); | ||
61 | 63 | ||
62 | /* | 64 | /* |
63 | * register_memory - Setup a sysfs device for a memory block | 65 | * register_memory - Setup a sysfs device for a memory block |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 7b76fd3b93a4..45cc3d9eacb8 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -418,7 +418,7 @@ void __suspend_report_result(const char *function, void *fn, int ret) | |||
418 | { | 418 | { |
419 | if (ret) { | 419 | if (ret) { |
420 | printk(KERN_ERR "%s(): ", function); | 420 | printk(KERN_ERR "%s(): ", function); |
421 | print_fn_descriptor_symbol("%s() returns ", (unsigned long)fn); | 421 | print_fn_descriptor_symbol("%s returns ", fn); |
422 | printk("%d\n", ret); | 422 | printk("%d\n", ret); |
423 | } | 423 | } |
424 | } | 424 | } |