aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 66b710c28812..dfcbfe504867 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -394,6 +394,53 @@ error:
394} 394}
395EXPORT_SYMBOL_GPL(platform_device_register_simple); 395EXPORT_SYMBOL_GPL(platform_device_register_simple);
396 396
397/**
398 * platform_device_register_data
399 * @parent: parent device for the device we're adding
400 * @name: base name of the device we're adding
401 * @id: instance id
402 * @data: platform specific data for this platform device
403 * @size: size of platform specific data
404 *
405 * This function creates a simple platform device that requires minimal
406 * resource and memory management. Canned release function freeing memory
407 * allocated for the device allows drivers using such devices to be
408 * unloaded without waiting for the last reference to the device to be
409 * dropped.
410 */
411struct platform_device *platform_device_register_data(
412 struct device *parent,
413 const char *name, int id,
414 const void *data, size_t size)
415{
416 struct platform_device *pdev;
417 int retval;
418
419 pdev = platform_device_alloc(name, id);
420 if (!pdev) {
421 retval = -ENOMEM;
422 goto error;
423 }
424
425 pdev->dev.parent = parent;
426
427 if (size) {
428 retval = platform_device_add_data(pdev, data, size);
429 if (retval)
430 goto error;
431 }
432
433 retval = platform_device_add(pdev);
434 if (retval)
435 goto error;
436
437 return pdev;
438
439error:
440 platform_device_put(pdev);
441 return ERR_PTR(retval);
442}
443
397static int platform_drv_probe(struct device *_dev) 444static int platform_drv_probe(struct device *_dev)
398{ 445{
399 struct platform_driver *drv = to_platform_driver(_dev->driver); 446 struct platform_driver *drv = to_platform_driver(_dev->driver);
@@ -865,7 +912,7 @@ static int platform_pm_restore_noirq(struct device *dev)
865 912
866#endif /* !CONFIG_HIBERNATION */ 913#endif /* !CONFIG_HIBERNATION */
867 914
868struct pm_ext_ops platform_pm_ops = { 915static struct pm_ext_ops platform_pm_ops = {
869 .base = { 916 .base = {
870 .prepare = platform_pm_prepare, 917 .prepare = platform_pm_prepare,
871 .complete = platform_pm_complete, 918 .complete = platform_pm_complete,