diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 6ab73f5c799a..8615b42b517a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -154,6 +154,13 @@ static struct kset_hotplug_ops device_hotplug_ops = { | |||
154 | .hotplug = dev_hotplug, | 154 | .hotplug = dev_hotplug, |
155 | }; | 155 | }; |
156 | 156 | ||
157 | static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, | ||
158 | const char *buf, size_t count) | ||
159 | { | ||
160 | kobject_hotplug(&dev->kobj, KOBJ_ADD); | ||
161 | return count; | ||
162 | } | ||
163 | |||
157 | /** | 164 | /** |
158 | * device_subsys - structure to be registered with kobject core. | 165 | * device_subsys - structure to be registered with kobject core. |
159 | */ | 166 | */ |
@@ -225,6 +232,7 @@ void device_initialize(struct device *dev) | |||
225 | klist_children_put); | 232 | klist_children_put); |
226 | INIT_LIST_HEAD(&dev->dma_pools); | 233 | INIT_LIST_HEAD(&dev->dma_pools); |
227 | init_MUTEX(&dev->sem); | 234 | init_MUTEX(&dev->sem); |
235 | device_init_wakeup(dev, 0); | ||
228 | } | 236 | } |
229 | 237 | ||
230 | /** | 238 | /** |
@@ -258,6 +266,14 @@ int device_add(struct device *dev) | |||
258 | 266 | ||
259 | if ((error = kobject_add(&dev->kobj))) | 267 | if ((error = kobject_add(&dev->kobj))) |
260 | goto Error; | 268 | goto Error; |
269 | |||
270 | dev->uevent_attr.attr.name = "uevent"; | ||
271 | dev->uevent_attr.attr.mode = S_IWUSR; | ||
272 | if (dev->driver) | ||
273 | dev->uevent_attr.attr.owner = dev->driver->owner; | ||
274 | dev->uevent_attr.store = store_uevent; | ||
275 | device_create_file(dev, &dev->uevent_attr); | ||
276 | |||
261 | kobject_hotplug(&dev->kobj, KOBJ_ADD); | 277 | kobject_hotplug(&dev->kobj, KOBJ_ADD); |
262 | if ((error = device_pm_add(dev))) | 278 | if ((error = device_pm_add(dev))) |
263 | goto PMError; | 279 | goto PMError; |
@@ -349,6 +365,7 @@ void device_del(struct device * dev) | |||
349 | 365 | ||
350 | if (parent) | 366 | if (parent) |
351 | klist_del(&dev->knode_parent); | 367 | klist_del(&dev->knode_parent); |
368 | device_remove_file(dev, &dev->uevent_attr); | ||
352 | 369 | ||
353 | /* Notify the platform of the removal, in case they | 370 | /* Notify the platform of the removal, in case they |
354 | * need to do anything... | 371 | * need to do anything... |
@@ -390,11 +407,11 @@ static struct device * next_device(struct klist_iter * i) | |||
390 | 407 | ||
391 | /** | 408 | /** |
392 | * device_for_each_child - device child iterator. | 409 | * device_for_each_child - device child iterator. |
393 | * @dev: parent struct device. | 410 | * @parent: parent struct device. |
394 | * @data: data for the callback. | 411 | * @data: data for the callback. |
395 | * @fn: function to be called for each device. | 412 | * @fn: function to be called for each device. |
396 | * | 413 | * |
397 | * Iterate over @dev's child devices, and call @fn for each, | 414 | * Iterate over @parent's child devices, and call @fn for each, |
398 | * passing it @data. | 415 | * passing it @data. |
399 | * | 416 | * |
400 | * We check the return of @fn each time. If it returns anything | 417 | * We check the return of @fn each time. If it returns anything |