summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2017-02-27 20:09:09 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2017-04-01 09:36:12 -0700
commit0daaf99d8424f12cdf87e00c435c9cb93667f519 (patch)
treebfabd8700b2d8d7ceaced6fa2c255c08e3455978
parent00a06c22e9fc0a33ae0b6ca2d47938340dbcd539 (diff)
downloadop-kernel-dev-0daaf99d8424f12cdf87e00c435c9cb93667f519.zip
op-kernel-dev-0daaf99d8424f12cdf87e00c435c9cb93667f519.tar.gz
i2c: copy device properties when using i2c_register_board_info()
This will allow marking device property lists as __initdata, the same as board info structures themselves. Reviewed-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/i2c/i2c-boardinfo.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c
index 6e5fac6..0e285c6 100644
--- a/drivers/i2c/i2c-boardinfo.c
+++ b/drivers/i2c/i2c-boardinfo.c
@@ -15,6 +15,7 @@
#include <linux/export.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
+#include <linux/property.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
@@ -55,6 +56,7 @@ EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num);
*
* The board info passed can safely be __initdata, but be careful of embedded
* pointers (for platform_data, functions, etc) since that won't be copied.
+ * Device properties are deep-copied though.
*/
int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len)
{
@@ -78,6 +80,16 @@ int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsig
devinfo->busnum = busnum;
devinfo->board_info = *info;
+
+ if (info->properties) {
+ devinfo->board_info.properties =
+ property_entries_dup(info->properties);
+ if (IS_ERR(devinfo->board_info.properties)) {
+ status = PTR_ERR(devinfo->board_info.properties);
+ break;
+ }
+ }
+
list_add_tail(&devinfo->list, &__i2c_board_list);
}
OpenPOWER on IntegriCloud