Skip to content

Commit 0daaf99

Browse files
committed
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 <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 00a06c2 commit 0daaf99

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/i2c/i2c-boardinfo.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/export.h>
1616
#include <linux/i2c.h>
1717
#include <linux/kernel.h>
18+
#include <linux/property.h>
1819
#include <linux/rwsem.h>
1920
#include <linux/slab.h>
2021

@@ -55,6 +56,7 @@ EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num);
5556
*
5657
* The board info passed can safely be __initdata, but be careful of embedded
5758
* pointers (for platform_data, functions, etc) since that won't be copied.
59+
* Device properties are deep-copied though.
5860
*/
5961
int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len)
6062
{
@@ -78,6 +80,16 @@ int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsig
7880

7981
devinfo->busnum = busnum;
8082
devinfo->board_info = *info;
83+
84+
if (info->properties) {
85+
devinfo->board_info.properties =
86+
property_entries_dup(info->properties);
87+
if (IS_ERR(devinfo->board_info.properties)) {
88+
status = PTR_ERR(devinfo->board_info.properties);
89+
break;
90+
}
91+
}
92+
8193
list_add_tail(&devinfo->list, &__i2c_board_list);
8294
}
8395

0 commit comments

Comments
 (0)