|
|
7ef4087 |
From 00bbc1d8e46a92ce7bd80622cf4b09c3b727a741 Mon Sep 17 00:00:00 2001
|
|
|
7ef4087 |
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
7ef4087 |
Date: Mon, 30 Nov 2015 17:11:38 +0200
|
|
|
7ef4087 |
Subject: [PATCH 10/16] driver core: platform: Add support for built-in device
|
|
|
7ef4087 |
properties
|
|
|
7ef4087 |
|
|
|
7ef4087 |
Make it possible to pass built-in device properties to platform device
|
|
|
7ef4087 |
drivers. This is useful if the system does not have any firmware interface
|
|
|
7ef4087 |
like Device Tree or ACPI which provides these.
|
|
|
7ef4087 |
|
|
|
7ef4087 |
Properties associated with the platform device will be automatically
|
|
|
7ef4087 |
released when the corresponding device is removed.
|
|
|
7ef4087 |
|
|
|
7ef4087 |
Suggested-by: Arnd Bergmann <arnd@arndb.de>
|
|
|
7ef4087 |
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
7ef4087 |
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
|
|
7ef4087 |
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
|
|
7ef4087 |
---
|
|
|
7ef4087 |
drivers/base/platform.c | 25 +++++++++++++++++++++++++
|
|
|
7ef4087 |
include/linux/platform_device.h | 5 +++++
|
|
|
7ef4087 |
2 files changed, 30 insertions(+)
|
|
|
7ef4087 |
|
|
|
7ef4087 |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
|
|
|
7ef4087 |
index 1dd6d3b..d77ed0c 100644
|
|
|
7ef4087 |
--- a/drivers/base/platform.c
|
|
|
7ef4087 |
+++ b/drivers/base/platform.c
|
|
|
7ef4087 |
@@ -26,6 +26,7 @@
|
|
|
7ef4087 |
#include <linux/acpi.h>
|
|
|
7ef4087 |
#include <linux/clk/clk-conf.h>
|
|
|
7ef4087 |
#include <linux/limits.h>
|
|
|
7ef4087 |
+#include <linux/property.h>
|
|
|
7ef4087 |
|
|
|
7ef4087 |
#include "base.h"
|
|
|
7ef4087 |
#include "power/power.h"
|
|
|
7ef4087 |
@@ -299,6 +300,22 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
|
|
|
7ef4087 |
EXPORT_SYMBOL_GPL(platform_device_add_data);
|
|
|
7ef4087 |
|
|
|
7ef4087 |
/**
|
|
|
7ef4087 |
+ * platform_device_add_properties - add built-in properties to a platform device
|
|
|
7ef4087 |
+ * @pdev: platform device to add properties to
|
|
|
7ef4087 |
+ * @pset: properties to add
|
|
|
7ef4087 |
+ *
|
|
|
7ef4087 |
+ * The function will take deep copy of the properties in @pset and attach
|
|
|
7ef4087 |
+ * the copy to the platform device. The memory associated with properties
|
|
|
7ef4087 |
+ * will be freed when the platform device is released.
|
|
|
7ef4087 |
+ */
|
|
|
7ef4087 |
+int platform_device_add_properties(struct platform_device *pdev,
|
|
|
7ef4087 |
+ const struct property_set *pset)
|
|
|
7ef4087 |
+{
|
|
|
7ef4087 |
+ return device_add_property_set(&pdev->dev, pset);
|
|
|
7ef4087 |
+}
|
|
|
7ef4087 |
+EXPORT_SYMBOL_GPL(platform_device_add_properties);
|
|
|
7ef4087 |
+
|
|
|
7ef4087 |
+/**
|
|
|
7ef4087 |
* platform_device_add - add a platform device to device hierarchy
|
|
|
7ef4087 |
* @pdev: platform device we're adding
|
|
|
7ef4087 |
*
|
|
|
7ef4087 |
@@ -409,6 +426,8 @@ void platform_device_del(struct platform_device *pdev)
|
|
|
7ef4087 |
if (r->parent)
|
|
|
7ef4087 |
release_resource(r);
|
|
|
7ef4087 |
}
|
|
|
7ef4087 |
+
|
|
|
7ef4087 |
+ device_remove_property_set(&pdev->dev);
|
|
|
7ef4087 |
}
|
|
|
7ef4087 |
}
|
|
|
7ef4087 |
EXPORT_SYMBOL_GPL(platform_device_del);
|
|
|
7ef4087 |
@@ -487,6 +506,12 @@ struct platform_device *platform_device_register_full(
|
|
|
7ef4087 |
if (ret)
|
|
|
7ef4087 |
goto err;
|
|
|
7ef4087 |
|
|
|
7ef4087 |
+ if (pdevinfo->pset) {
|
|
|
7ef4087 |
+ ret = platform_device_add_properties(pdev, pdevinfo->pset);
|
|
|
7ef4087 |
+ if (ret)
|
|
|
7ef4087 |
+ goto err;
|
|
|
7ef4087 |
+ }
|
|
|
7ef4087 |
+
|
|
|
7ef4087 |
ret = platform_device_add(pdev);
|
|
|
7ef4087 |
if (ret) {
|
|
|
7ef4087 |
err:
|
|
|
7ef4087 |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
|
|
|
7ef4087 |
index dc777be..dba40b1 100644
|
|
|
7ef4087 |
--- a/include/linux/platform_device.h
|
|
|
7ef4087 |
+++ b/include/linux/platform_device.h
|
|
|
7ef4087 |
@@ -18,6 +18,7 @@
|
|
|
7ef4087 |
#define PLATFORM_DEVID_AUTO (-2)
|
|
|
7ef4087 |
|
|
|
7ef4087 |
struct mfd_cell;
|
|
|
7ef4087 |
+struct property_set;
|
|
|
7ef4087 |
|
|
|
7ef4087 |
struct platform_device {
|
|
|
7ef4087 |
const char *name;
|
|
|
7ef4087 |
@@ -70,6 +71,8 @@ struct platform_device_info {
|
|
|
7ef4087 |
const void *data;
|
|
|
7ef4087 |
size_t size_data;
|
|
|
7ef4087 |
u64 dma_mask;
|
|
|
7ef4087 |
+
|
|
|
7ef4087 |
+ const struct property_set *pset;
|
|
|
7ef4087 |
};
|
|
|
7ef4087 |
extern struct platform_device *platform_device_register_full(
|
|
|
7ef4087 |
const struct platform_device_info *pdevinfo);
|
|
|
7ef4087 |
@@ -167,6 +170,8 @@ extern int platform_device_add_resources(struct platform_device *pdev,
|
|
|
7ef4087 |
unsigned int num);
|
|
|
7ef4087 |
extern int platform_device_add_data(struct platform_device *pdev,
|
|
|
7ef4087 |
const void *data, size_t size);
|
|
|
7ef4087 |
+extern int platform_device_add_properties(struct platform_device *pdev,
|
|
|
7ef4087 |
+ const struct property_set *pset);
|
|
|
7ef4087 |
extern int platform_device_add(struct platform_device *pdev);
|
|
|
7ef4087 |
extern void platform_device_del(struct platform_device *pdev);
|
|
|
7ef4087 |
extern void platform_device_put(struct platform_device *pdev);
|
|
|
7ef4087 |
--
|
|
|
7ef4087 |
2.5.0
|
|
|
7ef4087 |
|