aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-06-10 05:22:26 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-10 05:22:26 -0400
commit65b53e4cc90e59936733b3b95b9451d2ca47528d (patch)
tree29932718192962671c48c3fd1ea017a6112459e8 /drivers/base
parent788c0a53164c05c5ccdb1472474372b72ba74644 (diff)
parent2e761e0532a784816e7e822dbaaece8c5d4be14d (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts: drivers/net/tg3.c drivers/net/wireless/rt2x00/rt2x00dev.c net/mac80211/ieee80211_i.h
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c100
-rw-r--r--drivers/base/power/main.c2
2 files changed, 95 insertions, 7 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3eeac5a78581..422cfcad486d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -760,6 +760,21 @@ 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 */
766int dev_set_name(struct device *dev, const char *fmt, ...)
767{
768 va_list vargs;
769
770 va_start(vargs, fmt);
771 vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
772 va_end(vargs);
773 return 0;
774}
775EXPORT_SYMBOL_GPL(dev_set_name);
776
777/**
763 * device_add - add device to device hierarchy. 778 * device_add - add device to device hierarchy.
764 * @dev: device. 779 * @dev: device.
765 * 780 *
@@ -1084,11 +1099,13 @@ static void device_create_release(struct device *dev)
1084} 1099}
1085 1100
1086/** 1101/**
1087 * device_create - creates a device and registers it with sysfs 1102 * 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 1103 * @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 1104 * @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 1105 * @devt: the dev_t for the char device to be added
1106 * @drvdata: the data to be added to the device for callbacks
1091 * @fmt: string for the device's name 1107 * @fmt: string for the device's name
1108 * @args: va_list for the device's name
1092 * 1109 *
1093 * This function can be used by char device classes. A struct device 1110 * This function can be used by char device classes. A struct device
1094 * will be created in sysfs, registered to the specified class. 1111 * will be created in sysfs, registered to the specified class.
@@ -1104,10 +1121,10 @@ static void device_create_release(struct device *dev)
1104 * Note: the struct class passed to this function must have previously 1121 * Note: the struct class passed to this function must have previously
1105 * been created with a call to class_create(). 1122 * been created with a call to class_create().
1106 */ 1123 */
1107struct device *device_create(struct class *class, struct device *parent, 1124struct device *device_create_vargs(struct class *class, struct device *parent,
1108 dev_t devt, const char *fmt, ...) 1125 dev_t devt, void *drvdata, const char *fmt,
1126 va_list args)
1109{ 1127{
1110 va_list args;
1111 struct device *dev = NULL; 1128 struct device *dev = NULL;
1112 int retval = -ENODEV; 1129 int retval = -ENODEV;
1113 1130
@@ -1124,10 +1141,9 @@ struct device *device_create(struct class *class, struct device *parent,
1124 dev->class = class; 1141 dev->class = class;
1125 dev->parent = parent; 1142 dev->parent = parent;
1126 dev->release = device_create_release; 1143 dev->release = device_create_release;
1144 dev_set_drvdata(dev, drvdata);
1127 1145
1128 va_start(args, fmt);
1129 vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); 1146 vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args);
1130 va_end(args);
1131 retval = device_register(dev); 1147 retval = device_register(dev);
1132 if (retval) 1148 if (retval)
1133 goto error; 1149 goto error;
@@ -1138,6 +1154,78 @@ error:
1138 kfree(dev); 1154 kfree(dev);
1139 return ERR_PTR(retval); 1155 return ERR_PTR(retval);
1140} 1156}
1157EXPORT_SYMBOL_GPL(device_create_vargs);
1158
1159/**
1160 * device_create_drvdata - creates a device and registers it with sysfs
1161 * @class: pointer to the struct class that this device should be registered to
1162 * @parent: pointer to the parent struct device of this new device, if any
1163 * @devt: the dev_t for the char device to be added
1164 * @drvdata: the data to be added to the device for callbacks
1165 * @fmt: string for the device's name
1166 *
1167 * This function can be used by char device classes. A struct device
1168 * will be created in sysfs, registered to the specified class.
1169 *
1170 * A "dev" file will be created, showing the dev_t for the device, if
1171 * the dev_t is not 0,0.
1172 * If a pointer to a parent struct device is passed in, the newly created
1173 * struct device will be a child of that device in sysfs.
1174 * The pointer to the struct device will be returned from the call.
1175 * Any further sysfs files that might be required can be created using this
1176 * pointer.
1177 *
1178 * Note: the struct class passed to this function must have previously
1179 * been created with a call to class_create().
1180 */
1181struct device *device_create_drvdata(struct class *class,
1182 struct device *parent,
1183 dev_t devt,
1184 void *drvdata,
1185 const char *fmt, ...)
1186{
1187 va_list vargs;
1188 struct device *dev;
1189
1190 va_start(vargs, fmt);
1191 dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
1192 va_end(vargs);
1193 return dev;
1194}
1195EXPORT_SYMBOL_GPL(device_create_drvdata);
1196
1197/**
1198 * device_create - creates a device and registers it with sysfs
1199 * @class: pointer to the struct class that this device should be registered to
1200 * @parent: pointer to the parent struct device of this new device, if any
1201 * @devt: the dev_t for the char device to be added
1202 * @fmt: string for the device's name
1203 *
1204 * This function can be used by char device classes. A struct device
1205 * will be created in sysfs, registered to the specified class.
1206 *
1207 * A "dev" file will be created, showing the dev_t for the device, if
1208 * the dev_t is not 0,0.
1209 * If a pointer to a parent struct device is passed in, the newly created
1210 * struct device will be a child of that device in sysfs.
1211 * The pointer to the struct device will be returned from the call.
1212 * Any further sysfs files that might be required can be created using this
1213 * pointer.
1214 *
1215 * Note: the struct class passed to this function must have previously
1216 * been created with a call to class_create().
1217 */
1218struct device *device_create(struct class *class, struct device *parent,
1219 dev_t devt, const char *fmt, ...)
1220{
1221 va_list vargs;
1222 struct device *dev;
1223
1224 va_start(vargs, fmt);
1225 dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs);
1226 va_end(vargs);
1227 return dev;
1228}
1141EXPORT_SYMBOL_GPL(device_create); 1229EXPORT_SYMBOL_GPL(device_create);
1142 1230
1143static int __match_devt(struct device *dev, void *data) 1231static int __match_devt(struct device *dev, void *data)
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}