Skip to contentSkip to conversation

i2c: Adding support for software nodes

PATCH In review Heikki Krogerus 10 participants 38 messages Mar 29, 2021 – Apr 10, 2021

Subsystems (14)
lore
Share & tools
lore
#0 lore raw

cover i2c: Adding support for software nodes

Hi,

The old device property API (device_add_properties()) is going to be removed. These prepare the i2c subsystem and drivers for the change. The change is fairly trivial in case of i2c. All we need to do is add complete software nodes to the devices instead of only the device properties in those nodes.

thanks,

Heikki Krogerus (12):
i2c: Add support for software nodes
ARM: davinci: Constify the software nodes
ARM: omap1: osk: Constify the software node
ARM: pxa: stargate2: Constify the software node
ARM: s3c: mini2440: Constify the software node platform/x86: intel_cht_int33fe_microb: Constify the software node
i2c: cht-wc: Constify the software node
i2c: nvidia-gpu: Constify the software node
i2c: icy: Constify the software node
platform/chrome: chromeos_laptop - Prepare complete software nodes
Input: elantech - Prepare a complete software node for the device
i2c: Remove support for dangling device properties

 arch/arm/mach-davinci/board-da830-evm.c       |   6 +-
 arch/arm/mach-davinci/board-dm365-evm.c       |   6 +-
 arch/arm/mach-davinci/board-dm644x-evm.c      |   6 +-
 arch/arm/mach-davinci/board-dm646x-evm.c      |   6 +-
 arch/arm/mach-davinci/board-mityomapl138.c    |   6 +-
 arch/arm/mach-davinci/board-sffsdr.c          |   6 +-
 arch/arm/mach-omap1/board-osk.c               |   6 +-
 arch/arm/mach-pxa/stargate2.c                 |   6 +-
 arch/arm/mach-s3c/mach-mini2440.c             |   6 +-
 drivers/i2c/busses/i2c-cht-wc.c               |   6 +-
 drivers/i2c/busses/i2c-icy.c                  |  32 ++----
 drivers/i2c/busses/i2c-nvidia-gpu.c           |   6 +-
 drivers/i2c/i2c-boardinfo.c                   |  11 --
 drivers/i2c/i2c-core-base.c                   |  14 +--
 drivers/input/mouse/elantech.c                |   6 +-
 drivers/platform/chrome/chromeos_laptop.c     | 100 +++++++++++-------
 .../platform/x86/intel_cht_int33fe_microb.c   |   6 +-
 include/linux/i2c.h                           |   4 +-
 18 files changed, 142 insertions(+), 97 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/12 i2c: Add support for software nodes

This makes it possible for the drivers to assign complete software fwnodes to the devices instead of only the device properties in those nodes.

---
 drivers/i2c/i2c-core-base.c | 15 ++++++++++++++-
 include/linux/i2c.h         |  4 +++-
 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/i2c/i2c-core-base.c +14 -1
index f21362355973e..a6a68081f54e1 100644
@@ -920,15 +920,27 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
 		}
 	}
 
+	if (info->swnode) {
+		status = device_add_software_node(&client->dev, info->swnode);
+		if (status) {
+			dev_err(&adap->dev,
+				"Failed to add software node to client %s: %d\n",
+				client->name, status);
+			goto out_free_props;
+		}
+	}
+
 	status = device_register(&client->dev);
 	if (status)
-		goto out_free_props;
+		goto out_remove_swnode;
 
 	dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n",
 		client->name, dev_name(&client->dev));
 
 	return client;
 
+out_remove_swnode:
+	device_remove_software_node(&client->dev);
 out_free_props:
 	if (info->properties)
 		device_remove_properties(&client->dev);
@@ -961,6 +973,7 @@ void i2c_unregister_device(struct i2c_client *client)
 
 	if (ACPI_COMPANION(&client->dev))
 		acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev));
+	device_remove_software_node(&client->dev);
 	device_unregister(&client->dev);
 }
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
include/linux/i2c.h +3 -1
index 56622658b2158..cb1f882a3e88e 100644
@@ -391,7 +391,8 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
  * @platform_data: stored in i2c_client.dev.platform_data
  * @of_node: pointer to OpenFirmware device node
  * @fwnode: device node supplied by the platform firmware
- * @properties: additional device properties for the device
+ * @properties: Deprecated - use swnode instead
+ * @swnode: software node for the device
  * @resources: resources associated with the device
  * @num_resources: number of resources in the @resources array
  * @irq: stored in i2c_client.irq
@@ -416,6 +417,7 @@ struct i2c_board_info {
 	struct device_node *of_node;
 	struct fwnode_handle *fwnode;
 	const struct property_entry *properties;
+	const struct software_node *swnode;
 	const struct resource *resources;
 	unsigned int	num_resources;
 	int		irq;
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/12 ARM: davinci: Constify the software nodes

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Sekhar Nori <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
---
 arch/arm/mach-davinci/board-da830-evm.c    | 6 +++++-
 arch/arm/mach-davinci/board-dm365-evm.c    | 6 +++++-
 arch/arm/mach-davinci/board-dm644x-evm.c   | 6 +++++-
 arch/arm/mach-davinci/board-dm646x-evm.c   | 6 +++++-
 arch/arm/mach-davinci/board-mityomapl138.c | 6 +++++-
 arch/arm/mach-davinci/board-sffsdr.c       | 6 +++++-
 6 files changed, 30 insertions(+), 6 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +5 -1
index a20ba12d876c6..823c9cc98f18b 100644
@@ -454,6 +454,10 @@ static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
 	{ }
 };
 
+static const struct software_node da830_evm_i2c_eeprom_node = {
+	.properties = da830_evm_i2c_eeprom_properties,
+};
+
 static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
 		int gpio, unsigned ngpio, void *context)
 {
@@ -485,7 +489,7 @@ static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.properties = da830_evm_i2c_eeprom_properties,
+		.swnode = &da830_evm_i2c_eeprom_node,
 	},
 	{
 		I2C_BOARD_INFO("tlv320aic3x", 0x18),
arch/arm/mach-davinci/board-dm365-evm.c +5 -1
index bdf31eb776204..b3bef74c982a3 100644
@@ -232,10 +232,14 @@ static const struct property_entry eeprom_properties[] = {
 	{ }
 };
 
+static const struct software_node eeprom_node = {
+	.properties = eeprom_properties,
+};
+
 static struct i2c_board_info i2c_info[] = {
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.properties = eeprom_properties,
+		.swnode = &eeprom_node,
 	},
 	{
 		I2C_BOARD_INFO("tlv320aic3x", 0x18),
arch/arm/mach-davinci/board-dm644x-evm.c +5 -1
index 7755cccec550c..cce3a621eb20b 100644
@@ -541,6 +541,10 @@ static const struct property_entry eeprom_properties[] = {
 	{ }
 };
 
+static const struct software_node eeprom_node = {
+	.properties = eeprom_properties,
+};
+
 /*
  * MSP430 supports RTC, card detection, input from IR remote, and
  * a bit more.  It triggers interrupts on GPIO(7) from pressing
@@ -647,7 +651,7 @@ static struct i2c_board_info __initdata i2c_info[] =  {
 	},
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.properties = eeprom_properties,
+		.swnode = &eeprom_node,
 	},
 	{
 		I2C_BOARD_INFO("tlv320aic33", 0x1b),
arch/arm/mach-davinci/board-dm646x-evm.c +5 -1
index 952ddabc743e0..ee91d81ebbfdf 100644
@@ -362,6 +362,10 @@ static const struct property_entry eeprom_properties[] = {
 	PROPERTY_ENTRY_U32("pagesize", 64),
 	{ }
 };
+
+static const struct software_node eeprom_node = {
+	.properties = eeprom_properties,
+};
 #endif
 
 static u8 dm646x_iis_serializer_direction[] = {
@@ -430,7 +434,7 @@ static void evm_init_cpld(void)
 static struct i2c_board_info __initdata i2c_info[] =  {
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.properties  = eeprom_properties,
+		.swnode = &eeprom_node,
 	},
 	{
 		I2C_BOARD_INFO("pcf8574a", 0x38),
arch/arm/mach-davinci/board-mityomapl138.c +5 -1
index 5205008c8061b..2127969beb965 100644
@@ -197,6 +197,10 @@ static const struct property_entry mityomapl138_fd_chip_properties[] = {
 	{ }
 };
 
+static const struct software_node mityomapl138_fd_chip_node = {
+	.properties = mityomapl138_fd_chip_properties,
+};
+
 static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
 	.bus_freq	= 100,	/* kHz */
 	.bus_delay	= 0,	/* usec */
@@ -323,7 +327,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = {
 	},
 	{
 		I2C_BOARD_INFO("24c02", 0x50),
-		.properties = mityomapl138_fd_chip_properties,
+		.swnode = &mityomapl138_fd_chip_node,
 	},
 };
 
arch/arm/mach-davinci/board-sffsdr.c +5 -1
index 79b47958e9926..6930b2f485d19 100644
@@ -84,10 +84,14 @@ static const struct property_entry eeprom_properties[] = {
 	{ }
 };
 
+static const struct software_node eeprom_node = {
+	.properties = eeprom_properties,
+};
+
 static struct i2c_board_info __initdata i2c_info[] =  {
 	{
 		I2C_BOARD_INFO("24c64", 0x50),
-		.properties = eeprom_properties,
+		.swnode = &eeprom_node,
 	},
 	/* Other I2C devices:
 	 * MSP430,  addr 0x23 (not used)
Signature · 1 line
2.30.2
#3 lore raw

Re: [PATCH 02/12] ARM: davinci: Constify the software nodes

Quoted 7 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Sekhar Nori <[email protected]>
Cc Bartosz Golaszewski <[email protected]>

I like to apply it soon. Can we get an ack, please?

#4 lore raw

Re: [PATCH 02/12] ARM: davinci: Constify the software nodes

Quoted 6 lines · Wolfram Sang
Quoted 4 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Quoted 6 lines
Quoted 3 lines
Cc Sekhar Nori <[email protected]>
Cc Bartosz Golaszewski <[email protected]>

I like to apply it soon. Can we get an ack, please?

Looks good to me.

#5 lore raw

PATCH 3/12 ARM: omap1: osk: Constify the software node

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Aaro Koskinen <[email protected]>
Cc Tony Lindgren <[email protected]>
---
 arch/arm/mach-omap1/board-osk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-omap1/board-osk.c +5 -1
index 0a4c9b0b13b0c..e18b6f13300eb 100644
@@ -332,11 +332,15 @@ static const struct property_entry mistral_at24_properties[] = {
 	{ }
 };
 
+static const struct software_node mistral_at24_node = {
+	.properties = mistral_at24_properties,
+};
+
 static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
 	{
 		/* NOTE:  powered from LCD supply */
 		I2C_BOARD_INFO("24c04", 0x50),
-		.properties = mistral_at24_properties,
+		.swnode = &mistral_at24_node,
 	},
 	/* TODO when driver support is ready:
 	 *  - optionally ov9640 camera sensor at 0x30
Signature · 1 line
2.30.2
reviewer Acked-by on v1 3/12
#6 lore raw

Re: [PATCH 03/12] ARM: omap1: osk: Constify the software node

Quoted 7 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Aaro Koskinen <[email protected]>
Cc Tony Lindgren <[email protected]>

Probably best to merge this via the rest of the series:

Quoted 28 lines
---
 arch/arm/mach-omap1/board-osk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-omap1/board-osk.c +5 -1
index 0a4c9b0b13b0c..e18b6f13300eb 100644
@@ -332,11 +332,15 @@ static const struct property_entry mistral_at24_properties[] = {
 	{ }
 };
 
+static const struct software_node mistral_at24_node = {
+	.properties = mistral_at24_properties,
+};
+
 static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
 	{
 		/* NOTE:  powered from LCD supply */
 		I2C_BOARD_INFO("24c04", 0x50),
-		.properties = mistral_at24_properties,
+		.swnode = &mistral_at24_node,
 	},
 	/* TODO when driver support is ready:
 	 *  - optionally ov9640 camera sensor at 0x30
Signature · 1 line
2.30.2
#7 lore raw

PATCH 4/12 ARM: pxa: stargate2: Constify the software node

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Jonathan Cameron <[email protected]>
Cc Daniel Mack <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Robert Jarzmik <[email protected]>
---
 arch/arm/mach-pxa/stargate2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-pxa/stargate2.c +5 -1
index e2353f7dcf01a..7ad6274657686 100644
@@ -794,6 +794,10 @@ static const struct property_entry pca9500_eeprom_properties[] = {
 	{ }
 };
 
+static const struct software_node pca9500_eeprom_node = {
+	.properties = pca9500_eeprom_properties,
+};
+
 /**
  * stargate2_reset_bluetooth() reset the bluecore to ensure consistent state
  **/
@@ -929,7 +933,7 @@ static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
 	}, {
 		.type = "24c02",
 		.addr = 0x57,
-		.properties = pca9500_eeprom_properties,
+		.swnode = &pca9500_eeprom_node,
 	}, {
 		.type = "max1238",
 		.addr = 0x35,
Signature · 1 line
2.30.2
#8 lore raw

Re: [PATCH 04/12] ARM: pxa: stargate2: Constify the software node

Quoted 9 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Jonathan Cameron <[email protected]>
Cc Daniel Mack <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Robert Jarzmik <[email protected]>

I like to apply it soon. Can we get an ack, please?

maintainer Acked-by
#9 lore raw

Re: [PATCH 04/12] ARM: pxa: stargate2: Constify the software node

Quoted 5 lines · Wolfram Sang
Quoted 4 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Quoted 7 lines
Quoted 5 lines
Cc Jonathan Cameron <[email protected]>
Cc Daniel Mack <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Robert Jarzmik <[email protected]>

I like to apply it soon. Can we get an ack, please?

Cheers.

Signature · 1 line
Robert
#10 lore raw

PATCH 5/12 ARM: s3c: mini2440: Constify the software node

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Cc Krzysztof Kozlowski <[email protected]>
---
 arch/arm/mach-s3c/mach-mini2440.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-s3c/mach-mini2440.c +5 -1
index 4100905dfbd0c..551ec660ab599 100644
@@ -542,10 +542,14 @@ static const struct property_entry mini2440_at24_properties[] = {
 	{ }
 };
 
+static const struct software_node mini2440_at24_node = {
+	.properties = mini2440_at24_properties,
+};
+
 static struct i2c_board_info mini2440_i2c_devs[] __initdata = {
 	{
 		I2C_BOARD_INFO("24c08", 0x50),
-		.properties = mini2440_at24_properties,
+		.swnode = &mini2440_at24_node,
 	},
 };
 
Signature · 1 line
2.30.2
#11 lore raw

Re: [PATCH 05/12] ARM: s3c: mini2440: Constify the software node

Quoted 4 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Hi,

Thanks for your work.

I did not get the cover letter nor other patches from this set and I don't see how the i2c uses the swnode. This makes difficult to judge whether this looks reasonable. At least without the context the title looks misleading - you add software_node or change to use software_node instead of constifying it.

Best regards,
Krzysztof

#12 lore raw

Re: [PATCH 05/12] ARM: s3c: mini2440: Constify the software node

Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Hi,

Quoted 7 lines

Thanks for your work.

I did not get the cover letter nor other patches from this set and I don't see how the i2c uses the swnode. This makes difficult to judge whether this looks reasonable. At least without the context the title looks misleading - you add software_node or change to use software_node instead of constifying it.

OK, I'll try to open this up somehow...

Whenever additional device properties are added to devices by using the old device property API (device_add_properties()) that also i2c core code uses, in reality a software node is always created to hold those properties. It's just always dynamically allocated.

The goal of this series is to prepare the i2c subsystem and drivers for the removal of that old device property API, but I did not see that as relevant info for this patch, because even if we did not in the end remove that old API, this change is still useful.

The patch does exactly what the subject says. After this we supply the device a constant software node instead of a dynamically allocated one.

thanks,

Signature · 1 line
heikki
#13 lore raw

Re: [PATCH 05/12] ARM: s3c: mini2440: Constify the software node

Quoted 23 lines · Heikki Krogerus
Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Hi,

Quoted 7 lines

Thanks for your work.

I did not get the cover letter nor other patches from this set and I don't see how the i2c uses the swnode. This makes difficult to judge whether this looks reasonable. At least without the context the title looks misleading - you add software_node or change to use software_node instead of constifying it.

OK, I'll try to open this up somehow...

Whenever additional device properties are added to devices by using the old device property API (device_add_properties()) that also i2c core code uses, in reality a software node is always created to hold those properties. It's just always dynamically allocated.

Quoted 7 lines

The goal of this series is to prepare the i2c subsystem and drivers for the removal of that old device property API, but I did not see that as relevant info for this patch, because even if we did not in the end remove that old API, this change is still useful.

The patch does exactly what the subject says. After this we supply the device a constant software node instead of a dynamically allocated one.

Thanks for explanation. The follow up question is - can I take it independently via ARM Samsung/S3C tree?

Best regards,
Krzysztof

#14 lore raw

Re: [PATCH 05/12] ARM: s3c: mini2440: Constify the software node

Quoted 3 lines

Thanks for explanation. The follow up question is - can I take it independently via ARM Samsung/S3C tree?

Is it possible to just ack it, so I can take this all via I2C? Or will there be merge conflicts. I can provide an immutable branch, of course.

maintainer Acked-by
#15 lore raw

Re: [PATCH 05/12] ARM: s3c: mini2440: Constify the software node

Quoted 7 lines · Wolfram Sang
Quoted 3 lines

Thanks for explanation. The follow up question is - can I take it independently via ARM Samsung/S3C tree?

Is it possible to just ack it, so I can take this all via I2C? Or will there be merge conflicts. I can provide an immutable branch, of course.

Sure, ack is possible (from my currently used email):

Best regards,
Krzysztof

#16 lore raw

PATCH 6/12 platform/x86: intel_cht_int33fe_microb: Constify the software node

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

---
 drivers/platform/x86/intel_cht_int33fe_microb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/intel_cht_int33fe_microb.c +5 -1
index 20b11e0d9a758..673f41cd14b52 100644
@@ -35,6 +35,10 @@ static const struct property_entry bq27xxx_props[] = {
 	{ }
 };
 
+static const struct software_node bq27xxx_node = {
+	.properties = bq27xxx_props,
+};
+
 int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
 {
 	struct device *dev = data->dev;
@@ -43,7 +47,7 @@ int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
 	memset(&board_info, 0, sizeof(board_info));
 	strscpy(board_info.type, "bq27542", ARRAY_SIZE(board_info.type));
 	board_info.dev_name = "bq27542";
-	board_info.properties = bq27xxx_props;
+	board_info.swnode = &bq27xxx_node;
 	data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
 
 	return PTR_ERR_OR_ZERO(data->battery_fg);
Signature · 1 line
2.30.2
Reviewed-by on v1 6/12
#17 lore raw

Re: [PATCH 06/12] platform/x86: intel_cht_int33fe_microb: Constify the software node

Hi,

Quoted 6 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Thanks, patch looks good to me:

What is the plan for merging this patch / this series ?

Regards,

Hans

Quoted 29 lines
---
 drivers/platform/x86/intel_cht_int33fe_microb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/intel_cht_int33fe_microb.c +5 -1
index 20b11e0d9a758..673f41cd14b52 100644
@@ -35,6 +35,10 @@ static const struct property_entry bq27xxx_props[] = {
 	{ }
 };
 
+static const struct software_node bq27xxx_node = {
+	.properties = bq27xxx_props,
+};
+
 int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
 {
 	struct device *dev = data->dev;
@@ -43,7 +47,7 @@ int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
 	memset(&board_info, 0, sizeof(board_info));
 	strscpy(board_info.type, "bq27542", ARRAY_SIZE(board_info.type));
 	board_info.dev_name = "bq27542";
-	board_info.properties = bq27xxx_props;
+	board_info.swnode = &bq27xxx_node;
 	data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
 
 	return PTR_ERR_OR_ZERO(data->battery_fg);
#18 lore raw

Re: [PATCH 06/12] platform/x86: intel_cht_int33fe_microb: Constify the software node

Quoted 2 lines

What is the plan for merging this patch / this series ?

I'll take the series via I2C.

#19 lore raw

Re: [PATCH 06/12] platform/x86: intel_cht_int33fe_microb: Constify the software node

Hi,

Quoted 4 lines · Wolfram Sang
Quoted 2 lines

What is the plan for merging this patch / this series ?

I'll take the series via I2C.

Ok, that works for me.

Regards,

Hans

#20 lore raw

PATCH 7/12 i2c: cht-wc: Constify the software node

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

---
 drivers/i2c/busses/i2c-cht-wc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-cht-wc.c +5 -1
index f80d79e973cd2..08f491ea21ac9 100644
@@ -280,6 +280,10 @@ static const struct property_entry bq24190_props[] = {
 	{ }
 };
 
+static const struct software_node bq24190_node = {
+	.properties = bq24190_props,
+};
+
 static struct regulator_consumer_supply fusb302_consumer = {
 	.supply = "vbus",
 	/* Must match fusb302 dev_name in intel_cht_int33fe.c */
@@ -308,7 +312,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
 		.type = "bq24190",
 		.addr = 0x6b,
 		.dev_name = "bq24190",
-		.properties = bq24190_props,
+		.swnode = &bq24190_node,
 		.platform_data = &bq24190_pdata,
 	};
 	int ret, reg, irq;
Signature · 1 line
2.30.2
Reviewed-by on v1 7/12
#21 lore raw

Re: [PATCH 07/12] i2c: cht-wc: Constify the software node

Hi,

Quoted 6 lines · Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 29 lines
---
 drivers/i2c/busses/i2c-cht-wc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-cht-wc.c +5 -1
index f80d79e973cd2..08f491ea21ac9 100644
@@ -280,6 +280,10 @@ static const struct property_entry bq24190_props[] = {
 	{ }
 };
 
+static const struct software_node bq24190_node = {
+	.properties = bq24190_props,
+};
+
 static struct regulator_consumer_supply fusb302_consumer = {
 	.supply = "vbus",
 	/* Must match fusb302 dev_name in intel_cht_int33fe.c */
@@ -308,7 +312,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
 		.type = "bq24190",
 		.addr = 0x6b,
 		.dev_name = "bq24190",
-		.properties = bq24190_props,
+		.swnode = &bq24190_node,
 		.platform_data = &bq24190_pdata,
 	};
 	int ret, reg, irq;
#22 lore raw

PATCH 8/12 i2c: nvidia-gpu: Constify the software node

In reply to Heikki Krogerus

Additional device properties are always just a part of a software fwnode. If the device properties are constant, the software node can also be constant.

---
 drivers/i2c/busses/i2c-nvidia-gpu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-nvidia-gpu.c +5 -1
index 6b20601ffb139..b5055a3cbd935 100644
@@ -262,6 +262,10 @@ static const struct property_entry ccgx_props[] = {
 	{ }
 };
 
+static const struct software_node ccgx_node = {
+	.properties = ccgx_props,
+};
+
 static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
 {
 	i2cd->gpu_ccgx_ucsi = devm_kzalloc(i2cd->dev,
@@ -274,7 +278,7 @@ static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
 		sizeof(i2cd->gpu_ccgx_ucsi->type));
 	i2cd->gpu_ccgx_ucsi->addr = 0x8;
 	i2cd->gpu_ccgx_ucsi->irq = irq;
-	i2cd->gpu_ccgx_ucsi->properties = ccgx_props;
+	i2cd->gpu_ccgx_ucsi->swnode = &ccgx_node;
 	i2cd->ccgx_client = i2c_new_client_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
 	return PTR_ERR_OR_ZERO(i2cd->ccgx_client);
 }
Signature · 1 line
2.30.2
#23 lore raw

PATCH 9/12 i2c: icy: Constify the software node

In reply to Heikki Krogerus

Complete software node can now be supplied to the device with struct i2c_board_info.

---
 drivers/i2c/busses/i2c-icy.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/i2c/busses/i2c-icy.c +9 -23
index 66c9923fc7665..c8c422e9dda43 100644
@@ -54,7 +54,6 @@ struct icy_i2c {
 
 	void __iomem *reg_s0;
 	void __iomem *reg_s1;
-	struct fwnode_handle *ltc2990_fwnode;
 	struct i2c_client *ltc2990_client;
 };
 
@@ -115,6 +114,10 @@ static const struct property_entry icy_ltc2990_props[] = {
 	{ }
 };
 
+static const struct software_node icy_ltc2990_node = {
+	.properties = icy_ltc2990_props,
+};
+
 static int icy_probe(struct zorro_dev *z,
 		     const struct zorro_device_id *ent)
 {
@@ -123,6 +126,7 @@ static int icy_probe(struct zorro_dev *z,
 	struct fwnode_handle *new_fwnode;
 	struct i2c_board_info ltc2990_info = {
 		.type		= "ltc2990",
+		.swnode		= &icy_ltc2990_node,
 	};
 
 	i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL);
@@ -174,26 +178,10 @@ static int icy_probe(struct zorro_dev *z,
 	 *
 	 * See property_entry above for in1, in2, temp3.
 	 */
-	new_fwnode = fwnode_create_software_node(icy_ltc2990_props, NULL);
-	if (IS_ERR(new_fwnode)) {
-		dev_info(&z->dev, "Failed to create fwnode for LTC2990, error: %ld\n",
-			 PTR_ERR(new_fwnode));
-	} else {
-		/*
-		 * Store the fwnode so we can destroy it on .remove().
-		 * Only store it on success, as fwnode_remove_software_node()
-		 * is NULL safe, but not PTR_ERR safe.
-		 */
-		i2c->ltc2990_fwnode = new_fwnode;
-		ltc2990_info.fwnode = new_fwnode;
-
-		i2c->ltc2990_client =
-			i2c_new_scanned_device(&i2c->adapter,
-					       &ltc2990_info,
-					       icy_ltc2990_addresses,
-					       NULL);
-	}
-
+	i2c->ltc2990_client = i2c_new_scanned_device(&i2c->adapter,
+						     &ltc2990_info,
+						     icy_ltc2990_addresses,
+						     NULL);
 	return 0;
 }
 
@@ -202,8 +190,6 @@ static void icy_remove(struct zorro_dev *z)
 	struct icy_i2c *i2c = dev_get_drvdata(&z->dev);
 
 	i2c_unregister_device(i2c->ltc2990_client);
-	fwnode_remove_software_node(i2c->ltc2990_fwnode);
-
 	i2c_del_adapter(&i2c->adapter);
 }
 
Signature · 1 line
2.30.2
maintainer
#24 lore raw

Re: [PATCH 09/12] i2c: icy: Constify the software node

This looks great, thank you for constifying this.

Finally it's clean again, yet much more flexible than the original platform_data approach when I first submitted the driver.

Thanks everyone for your work

Max

#25 lore raw

Re: [PATCH 09/12] i2c: icy: Constify the software node

Quoted 4 lines · Max Staudt

This looks great, thank you for constifying this.

Finally it's clean again, yet much more flexible than the original platform_data approach when I first submitted the driver.

I read this as "Reviewed-by" ;)

#27 lore raw

PATCH 10/12 platform/chrome: chromeos_laptop - Prepare complete software nodes

In reply to Heikki Krogerus

The older device property API is going to be removed soon and that will affect also I2C subystem. Supplying complete software nodes instead of only the properties in them for the I2C devices.

Cc Benson Leung <[email protected]>
Cc Enric Balletbo i Serra <[email protected]>
---
 drivers/platform/chrome/chromeos_laptop.c | 100 +++++++++++++---------
 1 file changed, 60 insertions(+), 40 deletions(-)
drivers/platform/chrome/chromeos_laptop.c +60 -40
index 472a03daa8693..4e14b4d6635d7 100644
@@ -52,12 +52,15 @@ struct i2c_peripheral {
 	enum i2c_adapter_type type;
 	u32 pci_devid;
 
+	const struct property_entry *properties;
+
 	struct i2c_client *client;
 };
 
 struct acpi_peripheral {
 	char hid[ACPI_ID_LEN];
-	const struct property_entry *properties;
+	struct software_node swnode;
+	struct i2c_client *client;
 };
 
 struct chromeos_laptop {
@@ -68,7 +71,7 @@ struct chromeos_laptop {
 	struct i2c_peripheral *i2c_peripherals;
 	unsigned int num_i2c_peripherals;
 
-	const struct acpi_peripheral *acpi_peripherals;
+	struct acpi_peripheral *acpi_peripherals;
 	unsigned int num_acpi_peripherals;
 };
 
@@ -161,7 +164,7 @@ static void chromeos_laptop_check_adapter(struct i2c_adapter *adapter)
 
 static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 {
-	const struct acpi_peripheral *acpi_dev;
+	struct acpi_peripheral *acpi_dev;
 	struct acpi_device_id acpi_ids[2] = { };
 	int i;
 	int error;
@@ -175,8 +178,7 @@ static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 		memcpy(acpi_ids[0].id, acpi_dev->hid, ACPI_ID_LEN);
 
 		if (acpi_match_device(acpi_ids, &client->dev)) {
-			error = device_add_properties(&client->dev,
-						      acpi_dev->properties);
+			error = device_add_software_node(&client->dev, &acpi_dev->swnode);
 			if (error) {
 				dev_err(&client->dev,
 					"failed to add properties: %d\n",
@@ -184,6 +186,8 @@ static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 				break;
 			}
 
+			acpi_dev->client = client;
+
 			return true;
 		}
 	}
@@ -193,15 +197,28 @@ static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 
 static void chromeos_laptop_detach_i2c_client(struct i2c_client *client)
 {
+	struct acpi_peripheral *acpi_dev;
 	struct i2c_peripheral *i2c_dev;
 	int i;
 
-	for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) {
-		i2c_dev = &cros_laptop->i2c_peripherals[i];
+	if (has_acpi_companion(&client->dev))
+		for (i = 0; i < cros_laptop->num_acpi_peripherals; i++) {
+			acpi_dev = &cros_laptop->acpi_peripherals[i];
 
-		if (i2c_dev->client == client)
-			i2c_dev->client = NULL;
-	}
+			if (acpi_dev->client == client) {
+				acpi_dev->client = NULL;
+				return;
+			}
+		}
+	else
+		for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) {
+			i2c_dev = &cros_laptop->i2c_peripherals[i];
+
+			if (i2c_dev->client == client) {
+				i2c_dev->client = NULL;
+				return;
+			}
+		}
 }
 
 static int chromeos_laptop_i2c_notifier_call(struct notifier_block *nb,
@@ -302,28 +319,26 @@ static struct i2c_peripheral chromebook_pixel_peripherals[] __initdata = {
 		.board_info	= {
 			I2C_BOARD_INFO("atmel_mxt_ts",
 					ATMEL_TS_I2C_ADDR),
-			.properties	=
-				chromebook_atmel_touchscreen_props,
 			.flags		= I2C_CLIENT_WAKE,
 		},
 		.dmi_name	= "touchscreen",
 		.irqflags	= IRQF_TRIGGER_FALLING,
 		.type		= I2C_ADAPTER_PANEL,
 		.alt_addr	= ATMEL_TS_I2C_BL_ADDR,
+		.properties	= chromebook_atmel_touchscreen_props,
 	},
 	/* Touchpad. */
 	{
 		.board_info	= {
 			I2C_BOARD_INFO("atmel_mxt_tp",
 					ATMEL_TP_I2C_ADDR),
-			.properties	=
-				chromebook_pixel_trackpad_props,
 			.flags		= I2C_CLIENT_WAKE,
 		},
 		.dmi_name	= "trackpad",
 		.irqflags	= IRQF_TRIGGER_FALLING,
 		.type		= I2C_ADAPTER_VGADDC,
 		.alt_addr	= ATMEL_TP_I2C_BL_ADDR,
+		.properties	= chromebook_pixel_trackpad_props,
 	},
 	/* Light Sensor. */
 	{
@@ -414,8 +429,6 @@ static struct i2c_peripheral acer_c720_peripherals[] __initdata = {
 		.board_info	= {
 			I2C_BOARD_INFO("atmel_mxt_ts",
 					ATMEL_TS_I2C_ADDR),
-			.properties	=
-				chromebook_atmel_touchscreen_props,
 			.flags		= I2C_CLIENT_WAKE,
 		},
 		.dmi_name	= "touchscreen",
@@ -423,6 +436,7 @@ static struct i2c_peripheral acer_c720_peripherals[] __initdata = {
 		.type		= I2C_ADAPTER_DESIGNWARE,
 		.pci_devid	= PCI_DEVID(0, PCI_DEVFN(0x15, 0x2)),
 		.alt_addr	= ATMEL_TS_I2C_BL_ADDR,
+		.properties	= chromebook_atmel_touchscreen_props,
 	},
 	/* Touchpad. */
 	{
@@ -498,12 +512,16 @@ static struct acpi_peripheral samus_peripherals[] __initdata = {
 	/* Touchpad */
 	{
 		.hid		= "ATML0000",
-		.properties	= samus_trackpad_props,
+		.swnode		= {
+			.properties = samus_trackpad_props,
+		},
 	},
 	/* Touchsceen */
 	{
 		.hid		= "ATML0001",
-		.properties	= chromebook_atmel_touchscreen_props,
+		.swnode		= {
+			.properties = chromebook_atmel_touchscreen_props,
+		},
 	},
 };
 DECLARE_ACPI_CROS_LAPTOP(samus);
@@ -512,12 +530,16 @@ static struct acpi_peripheral generic_atmel_peripherals[] __initdata = {
 	/* Touchpad */
 	{
 		.hid		= "ATML0000",
-		.properties	= chromebook_pixel_trackpad_props,
+		.swnode		= {
+			.properties = chromebook_pixel_trackpad_props,
+		},
 	},
 	/* Touchsceen */
 	{
 		.hid		= "ATML0001",
-		.properties	= chromebook_atmel_touchscreen_props,
+		.swnode		= {
+			.properties = chromebook_atmel_touchscreen_props,
+		},
 	},
 };
 DECLARE_ACPI_CROS_LAPTOP(generic_atmel);
@@ -743,12 +765,11 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
 		if (error)
 			goto err_out;
 
-		/* We need to deep-copy properties */
-		if (info->properties) {
-			info->properties =
-				property_entries_dup(info->properties);
-			if (IS_ERR(info->properties)) {
-				error = PTR_ERR(info->properties);
+		/* Create primary fwnode for the device - copies everything */
+		if (i2c_dev->properties) {
+			info->fwnode = fwnode_create_software_node(i2c_dev->properties, NULL);
+			if (IS_ERR(info->fwnode)) {
+				error = PTR_ERR(info->fwnode);
 				goto err_out;
 			}
 		}
@@ -760,8 +781,8 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
 	while (--i >= 0) {
 		i2c_dev = &cros_laptop->i2c_peripherals[i];
 		info = &i2c_dev->board_info;
-		if (info->properties)
-			property_entries_free(info->properties);
+		if (!IS_ERR_OR_NULL(info->fwnode))
+			fwnode_remove_software_node(info->fwnode);
 	}
 	kfree(cros_laptop->i2c_peripherals);
 	return error;
@@ -801,11 +822,11 @@ chromeos_laptop_prepare_acpi_peripherals(struct chromeos_laptop *cros_laptop,
 		*acpi_dev = *src_dev;
 
 		/* We need to deep-copy properties */
-		if (src_dev->properties) {
-			acpi_dev->properties =
-				property_entries_dup(src_dev->properties);
-			if (IS_ERR(acpi_dev->properties)) {
-				error = PTR_ERR(acpi_dev->properties);
+		if (src_dev->swnode.properties) {
+			acpi_dev->swnode.properties =
+				property_entries_dup(src_dev->swnode.properties);
+			if (IS_ERR(acpi_dev->swnode.properties)) {
+				error = PTR_ERR(acpi_dev->swnode.properties);
 				goto err_out;
 			}
 		}
@@ -821,8 +842,8 @@ chromeos_laptop_prepare_acpi_peripherals(struct chromeos_laptop *cros_laptop,
 err_out:
 	while (--i >= 0) {
 		acpi_dev = &acpi_peripherals[i];
-		if (acpi_dev->properties)
-			property_entries_free(acpi_dev->properties);
+		if (!IS_ERR_OR_NULL(acpi_dev->swnode.properties))
+			property_entries_free(acpi_dev->swnode.properties);
 	}
 
 	kfree(acpi_peripherals);
@@ -833,21 +854,20 @@ static void chromeos_laptop_destroy(const struct chromeos_laptop *cros_laptop)
 {
 	const struct acpi_peripheral *acpi_dev;
 	struct i2c_peripheral *i2c_dev;
-	struct i2c_board_info *info;
 	int i;
 
 	for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) {
 		i2c_dev = &cros_laptop->i2c_peripherals[i];
-		info = &i2c_dev->board_info;
-
 		i2c_unregister_device(i2c_dev->client);
-		property_entries_free(info->properties);
 	}
 
 	for (i = 0; i < cros_laptop->num_acpi_peripherals; i++) {
 		acpi_dev = &cros_laptop->acpi_peripherals[i];
 
-		property_entries_free(acpi_dev->properties);
+		if (acpi_dev->client)
+			device_remove_software_node(&acpi_dev->client->dev);
+
+		property_entries_free(acpi_dev->swnode.properties);
 	}
 
 	kfree(cros_laptop->i2c_peripherals);
Signature · 1 line
2.30.2
Acked-by on v1 10/12
#28 lore raw

Re: [PATCH 10/12] platform/chrome: chromeos_laptop - Prepare complete software nodes

Hi Heikki,

Thank you for your patch.

Quoted 8 lines · Heikki Krogerus

The older device property API is going to be removed soon and that will affect also I2C subystem. Supplying complete software nodes instead of only the properties in them for the I2C devices.

Cc Benson Leung <[email protected]>
Cc Enric Balletbo i Serra <[email protected]>
Quoted 266 lines
---
 drivers/platform/chrome/chromeos_laptop.c | 100 +++++++++++++---------
 1 file changed, 60 insertions(+), 40 deletions(-)
drivers/platform/chrome/chromeos_laptop.c +60 -40
index 472a03daa8693..4e14b4d6635d7 100644
@@ -52,12 +52,15 @@ struct i2c_peripheral {
 	enum i2c_adapter_type type;
 	u32 pci_devid;
 
+	const struct property_entry *properties;
+
 	struct i2c_client *client;
 };
 
 struct acpi_peripheral {
 	char hid[ACPI_ID_LEN];
-	const struct property_entry *properties;
+	struct software_node swnode;
+	struct i2c_client *client;
 };
 
 struct chromeos_laptop {
@@ -68,7 +71,7 @@ struct chromeos_laptop {
 	struct i2c_peripheral *i2c_peripherals;
 	unsigned int num_i2c_peripherals;
 
-	const struct acpi_peripheral *acpi_peripherals;
+	struct acpi_peripheral *acpi_peripherals;
 	unsigned int num_acpi_peripherals;
 };
 
@@ -161,7 +164,7 @@ static void chromeos_laptop_check_adapter(struct i2c_adapter *adapter)
 
 static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 {
-	const struct acpi_peripheral *acpi_dev;
+	struct acpi_peripheral *acpi_dev;
 	struct acpi_device_id acpi_ids[2] = { };
 	int i;
 	int error;
@@ -175,8 +178,7 @@ static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 		memcpy(acpi_ids[0].id, acpi_dev->hid, ACPI_ID_LEN);
 
 		if (acpi_match_device(acpi_ids, &client->dev)) {
-			error = device_add_properties(&client->dev,
-						      acpi_dev->properties);
+			error = device_add_software_node(&client->dev, &acpi_dev->swnode);
 			if (error) {
 				dev_err(&client->dev,
 					"failed to add properties: %d\n",
@@ -184,6 +186,8 @@ static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 				break;
 			}
 
+			acpi_dev->client = client;
+
 			return true;
 		}
 	}
@@ -193,15 +197,28 @@ static bool chromeos_laptop_adjust_client(struct i2c_client *client)
 
 static void chromeos_laptop_detach_i2c_client(struct i2c_client *client)
 {
+	struct acpi_peripheral *acpi_dev;
 	struct i2c_peripheral *i2c_dev;
 	int i;
 
-	for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) {
-		i2c_dev = &cros_laptop->i2c_peripherals[i];
+	if (has_acpi_companion(&client->dev))
+		for (i = 0; i < cros_laptop->num_acpi_peripherals; i++) {
+			acpi_dev = &cros_laptop->acpi_peripherals[i];
 
-		if (i2c_dev->client == client)
-			i2c_dev->client = NULL;
-	}
+			if (acpi_dev->client == client) {
+				acpi_dev->client = NULL;
+				return;
+			}
+		}
+	else
+		for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) {
+			i2c_dev = &cros_laptop->i2c_peripherals[i];
+
+			if (i2c_dev->client == client) {
+				i2c_dev->client = NULL;
+				return;
+			}
+		}
 }
 
 static int chromeos_laptop_i2c_notifier_call(struct notifier_block *nb,
@@ -302,28 +319,26 @@ static struct i2c_peripheral chromebook_pixel_peripherals[] __initdata = {
 		.board_info	= {
 			I2C_BOARD_INFO("atmel_mxt_ts",
 					ATMEL_TS_I2C_ADDR),
-			.properties	=
-				chromebook_atmel_touchscreen_props,
 			.flags		= I2C_CLIENT_WAKE,
 		},
 		.dmi_name	= "touchscreen",
 		.irqflags	= IRQF_TRIGGER_FALLING,
 		.type		= I2C_ADAPTER_PANEL,
 		.alt_addr	= ATMEL_TS_I2C_BL_ADDR,
+		.properties	= chromebook_atmel_touchscreen_props,
 	},
 	/* Touchpad. */
 	{
 		.board_info	= {
 			I2C_BOARD_INFO("atmel_mxt_tp",
 					ATMEL_TP_I2C_ADDR),
-			.properties	=
-				chromebook_pixel_trackpad_props,
 			.flags		= I2C_CLIENT_WAKE,
 		},
 		.dmi_name	= "trackpad",
 		.irqflags	= IRQF_TRIGGER_FALLING,
 		.type		= I2C_ADAPTER_VGADDC,
 		.alt_addr	= ATMEL_TP_I2C_BL_ADDR,
+		.properties	= chromebook_pixel_trackpad_props,
 	},
 	/* Light Sensor. */
 	{
@@ -414,8 +429,6 @@ static struct i2c_peripheral acer_c720_peripherals[] __initdata = {
 		.board_info	= {
 			I2C_BOARD_INFO("atmel_mxt_ts",
 					ATMEL_TS_I2C_ADDR),
-			.properties	=
-				chromebook_atmel_touchscreen_props,
 			.flags		= I2C_CLIENT_WAKE,
 		},
 		.dmi_name	= "touchscreen",
@@ -423,6 +436,7 @@ static struct i2c_peripheral acer_c720_peripherals[] __initdata = {
 		.type		= I2C_ADAPTER_DESIGNWARE,
 		.pci_devid	= PCI_DEVID(0, PCI_DEVFN(0x15, 0x2)),
 		.alt_addr	= ATMEL_TS_I2C_BL_ADDR,
+		.properties	= chromebook_atmel_touchscreen_props,
 	},
 	/* Touchpad. */
 	{
@@ -498,12 +512,16 @@ static struct acpi_peripheral samus_peripherals[] __initdata = {
 	/* Touchpad */
 	{
 		.hid		= "ATML0000",
-		.properties	= samus_trackpad_props,
+		.swnode		= {
+			.properties = samus_trackpad_props,
+		},
 	},
 	/* Touchsceen */
 	{
 		.hid		= "ATML0001",
-		.properties	= chromebook_atmel_touchscreen_props,
+		.swnode		= {
+			.properties = chromebook_atmel_touchscreen_props,
+		},
 	},
 };
 DECLARE_ACPI_CROS_LAPTOP(samus);
@@ -512,12 +530,16 @@ static struct acpi_peripheral generic_atmel_peripherals[] __initdata = {
 	/* Touchpad */
 	{
 		.hid		= "ATML0000",
-		.properties	= chromebook_pixel_trackpad_props,
+		.swnode		= {
+			.properties = chromebook_pixel_trackpad_props,
+		},
 	},
 	/* Touchsceen */
 	{
 		.hid		= "ATML0001",
-		.properties	= chromebook_atmel_touchscreen_props,
+		.swnode		= {
+			.properties = chromebook_atmel_touchscreen_props,
+		},
 	},
 };
 DECLARE_ACPI_CROS_LAPTOP(generic_atmel);
@@ -743,12 +765,11 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
 		if (error)
 			goto err_out;
 
-		/* We need to deep-copy properties */
-		if (info->properties) {
-			info->properties =
-				property_entries_dup(info->properties);
-			if (IS_ERR(info->properties)) {
-				error = PTR_ERR(info->properties);
+		/* Create primary fwnode for the device - copies everything */
+		if (i2c_dev->properties) {
+			info->fwnode = fwnode_create_software_node(i2c_dev->properties, NULL);
+			if (IS_ERR(info->fwnode)) {
+				error = PTR_ERR(info->fwnode);
 				goto err_out;
 			}
 		}
@@ -760,8 +781,8 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
 	while (--i >= 0) {
 		i2c_dev = &cros_laptop->i2c_peripherals[i];
 		info = &i2c_dev->board_info;
-		if (info->properties)
-			property_entries_free(info->properties);
+		if (!IS_ERR_OR_NULL(info->fwnode))
+			fwnode_remove_software_node(info->fwnode);
 	}
 	kfree(cros_laptop->i2c_peripherals);
 	return error;
@@ -801,11 +822,11 @@ chromeos_laptop_prepare_acpi_peripherals(struct chromeos_laptop *cros_laptop,
 		*acpi_dev = *src_dev;
 
 		/* We need to deep-copy properties */
-		if (src_dev->properties) {
-			acpi_dev->properties =
-				property_entries_dup(src_dev->properties);
-			if (IS_ERR(acpi_dev->properties)) {
-				error = PTR_ERR(acpi_dev->properties);
+		if (src_dev->swnode.properties) {
+			acpi_dev->swnode.properties =
+				property_entries_dup(src_dev->swnode.properties);
+			if (IS_ERR(acpi_dev->swnode.properties)) {
+				error = PTR_ERR(acpi_dev->swnode.properties);
 				goto err_out;
 			}
 		}
@@ -821,8 +842,8 @@ chromeos_laptop_prepare_acpi_peripherals(struct chromeos_laptop *cros_laptop,
 err_out:
 	while (--i >= 0) {
 		acpi_dev = &acpi_peripherals[i];
-		if (acpi_dev->properties)
-			property_entries_free(acpi_dev->properties);
+		if (!IS_ERR_OR_NULL(acpi_dev->swnode.properties))
+			property_entries_free(acpi_dev->swnode.properties);
 	}
 
 	kfree(acpi_peripherals);
@@ -833,21 +854,20 @@ static void chromeos_laptop_destroy(const struct chromeos_laptop *cros_laptop)
 {
 	const struct acpi_peripheral *acpi_dev;
 	struct i2c_peripheral *i2c_dev;
-	struct i2c_board_info *info;
 	int i;
 
 	for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) {
 		i2c_dev = &cros_laptop->i2c_peripherals[i];
-		info = &i2c_dev->board_info;
-
 		i2c_unregister_device(i2c_dev->client);
-		property_entries_free(info->properties);
 	}
 
 	for (i = 0; i < cros_laptop->num_acpi_peripherals; i++) {
 		acpi_dev = &cros_laptop->acpi_peripherals[i];
 
-		property_entries_free(acpi_dev->properties);
+		if (acpi_dev->client)
+			device_remove_software_node(&acpi_dev->client->dev);
+
+		property_entries_free(acpi_dev->swnode.properties);
 	}
 
 	kfree(cros_laptop->i2c_peripherals);
#29 lore raw

PATCH 11/12 Input: elantech - Prepare a complete software node for the device

In reply to Heikki Krogerus

Creating a software node and supplying that for the device instead of only the device properties in it. A software node was always created in any case to hold the additional device properties, so this change does not have any real effect.

This change makes it possible to remove support for the problematic "dangling" device properties from i2c subsystem, i.e. the "properties" member from struct i2c_board_info. The problems caused by them are not related to this driver.

---
 drivers/input/mouse/elantech.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/input/mouse/elantech.c +4 -2
index 97381e2e03bae..2d0bc029619ff 100644
@@ -1885,8 +1885,6 @@ static int elantech_create_smbus(struct psmouse *psmouse,
 	};
 	unsigned int idx = 0;
 
-	smbus_board.properties = i2c_props;
-
 	i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-x",
 						   info->x_max + 1);
 	i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-y",
@@ -1918,6 +1916,10 @@ static int elantech_create_smbus(struct psmouse *psmouse,
 	if (elantech_is_buttonpad(info))
 		i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,clickpad");
 
+	smbus_board.fwnode = fwnode_create_software_node(i2c_props, NULL);
+	if (IS_ERR(smbus_board.fwnode))
+		return PTR_ERR(smbus_board.fwnode);
+
 	return psmouse_smbus_init(psmouse, &smbus_board, NULL, 0, false,
 				  leave_breadcrumbs);
 }
Signature · 1 line
2.30.2
maintainer Acked-by on v1 11/12
#30 lore raw

Re: [PATCH 11/12] Input: elantech - Prepare a complete software node for the device

Quoted 6 lines · Heikki Krogerus

Creating a software node and supplying that for the device instead of only the device properties in it. A software node was always created in any case to hold the additional device properties, so this change does not have any real effect.

Quoted 7 lines

This change makes it possible to remove support for the problematic "dangling" device properties from i2c subsystem, i.e. the "properties" member from struct i2c_board_info. The problems caused by them are not related to this driver.

Thanks.

Signature · 1 line
Dmitry
#31 lore raw

PATCH 12/12 i2c: Remove support for dangling device properties

In reply to Heikki Krogerus

From now on only accepting complete software nodes.

---
 drivers/i2c/i2c-boardinfo.c | 11 -----------
 drivers/i2c/i2c-core-base.c | 15 +--------------
 include/linux/i2c.h         |  2 --
 3 files changed, 1 insertion(+), 27 deletions(-)
drivers/i2c/i2c-boardinfo.c +0 -11
index 8bc51d4e69df3..4df8ad092df38 100644
@@ -47,7 +47,6 @@ 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)
 {
@@ -72,16 +71,6 @@ 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);
-				kfree(devinfo);
-				break;
-			}
-		}
-
 		if (info->resources) {
 			devinfo->board_info.resources =
 				kmemdup(info->resources,
drivers/i2c/i2c-core-base.c +1 -14
index a6a68081f54e1..916899ee1115f 100644
@@ -910,23 +910,13 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
 
 	i2c_dev_set_name(adap, client, info);
 
-	if (info->properties) {
-		status = device_add_properties(&client->dev, info->properties);
-		if (status) {
-			dev_err(&adap->dev,
-				"Failed to add properties to client %s: %d\n",
-				client->name, status);
-			goto out_err_put_of_node;
-		}
-	}
-
 	if (info->swnode) {
 		status = device_add_software_node(&client->dev, info->swnode);
 		if (status) {
 			dev_err(&adap->dev,
 				"Failed to add software node to client %s: %d\n",
 				client->name, status);
-			goto out_free_props;
+			goto out_err_put_of_node;
 		}
 	}
 
@@ -941,9 +931,6 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
 
 out_remove_swnode:
 	device_remove_software_node(&client->dev);
-out_free_props:
-	if (info->properties)
-		device_remove_properties(&client->dev);
 out_err_put_of_node:
 	of_node_put(info->of_node);
 out_err:
include/linux/i2c.h +0 -2
index cb1f882a3e88e..54b3ccc71e372 100644
@@ -391,7 +391,6 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
  * @platform_data: stored in i2c_client.dev.platform_data
  * @of_node: pointer to OpenFirmware device node
  * @fwnode: device node supplied by the platform firmware
- * @properties: Deprecated - use swnode instead
  * @swnode: software node for the device
  * @resources: resources associated with the device
  * @num_resources: number of resources in the @resources array
@@ -416,7 +415,6 @@ struct i2c_board_info {
 	void		*platform_data;
 	struct device_node *of_node;
 	struct fwnode_handle *fwnode;
-	const struct property_entry *properties;
 	const struct software_node *swnode;
 	const struct resource *resources;
 	unsigned int	num_resources;
Signature · 1 line
2.30.2
Reviewed-by on the v1 series
#32 lore raw
In reply to Heikki Krogerus
Quoted 6 lines

The old device property API (device_add_properties()) is going to be removed. These prepare the i2c subsystem and drivers for the change. The change is fairly trivial in case of i2c. All we need to do is add complete software nodes to the devices instead of only the device properties in those nodes.

This looks like a nice cleanup!

Which tree should this go into? I can offer I2C but am also fine with another one...

#33 lore raw
Quoted 7 lines · Wolfram Sang
Quoted 6 lines

The old device property API (device_add_properties()) is going to be removed. These prepare the i2c subsystem and drivers for the change. The change is fairly trivial in case of i2c. All we need to do is add complete software nodes to the devices instead of only the device properties in those nodes.

Quoted 6 lines

This looks like a nice cleanup!

Which tree should this go into? I can offer I2C but am also fine with another one...

I think these go via I2C tree.

thanks,

Signature · 1 line
heikki
#34 lore raw
Quoted 2 lines

I think these go via I2C tree.

Good, I'll apply it this weekend. Until then, let's hope we can get some more acks.

#35 lore raw
In reply to Heikki Krogerus
Quoted 10 lines · Heikki Krogerus

Hi,

The old device property API (device_add_properties()) is going to be removed. These prepare the i2c subsystem and drivers for the change. The change is fairly trivial in case of i2c. All we need to do is add complete software nodes to the devices instead of only the device properties in those nodes.

thanks,

Quoted 13 lines

Heikki Krogerus (12):
i2c: Add support for software nodes
ARM: davinci: Constify the software nodes
ARM: omap1: osk: Constify the software node
ARM: pxa: stargate2: Constify the software node
ARM: s3c: mini2440: Constify the software node platform/x86: intel_cht_int33fe_microb: Constify the software node
i2c: cht-wc: Constify the software node
i2c: nvidia-gpu: Constify the software node
i2c: icy: Constify the software node
platform/chrome: chromeos_laptop - Prepare complete software nodes
Input: elantech - Prepare a complete software node for the device
i2c: Remove support for dangling device properties

I applied all patches to an immutable branch "i2c/software-nodes" now. Once buildbot successfully checked this branch, I will merge it into for-next and advertise it to interested parties.

Thanks for this work!

#36 lore raw
Quoted 25 lines · Wolfram Sang
Quoted 10 lines · Heikki Krogerus

Hi,

The old device property API (device_add_properties()) is going to be removed. These prepare the i2c subsystem and drivers for the change. The change is fairly trivial in case of i2c. All we need to do is add complete software nodes to the devices instead of only the device properties in those nodes.

thanks,

Quoted 13 lines

Heikki Krogerus (12):
i2c: Add support for software nodes
ARM: davinci: Constify the software nodes
ARM: omap1: osk: Constify the software node
ARM: pxa: stargate2: Constify the software node
ARM: s3c: mini2440: Constify the software node platform/x86: intel_cht_int33fe_microb: Constify the software node
i2c: cht-wc: Constify the software node
i2c: nvidia-gpu: Constify the software node
i2c: icy: Constify the software node
platform/chrome: chromeos_laptop - Prepare complete software nodes
Input: elantech - Prepare a complete software node for the device
i2c: Remove support for dangling device properties

Quoted 3 lines

I applied all patches to an immutable branch "i2c/software-nodes" now. Once buildbot successfully checked this branch, I will merge it into for-next and advertise it to interested parties.

Thank you!

Signature · 1 line
heikki
#37 lore raw
In reply to Heikki Krogerus
Quoted 10 lines · Heikki Krogerus

Hi,

The old device property API (device_add_properties()) is going to be removed. These prepare the i2c subsystem and drivers for the change. The change is fairly trivial in case of i2c. All we need to do is add complete software nodes to the devices instead of only the device properties in those nodes.

thanks,

Quoted 13 lines

Heikki Krogerus (12):
i2c: Add support for software nodes
ARM: davinci: Constify the software nodes
ARM: omap1: osk: Constify the software node
ARM: pxa: stargate2: Constify the software node
ARM: s3c: mini2440: Constify the software node platform/x86: intel_cht_int33fe_microb: Constify the software node
i2c: cht-wc: Constify the software node
i2c: nvidia-gpu: Constify the software node
i2c: icy: Constify the software node
platform/chrome: chromeos_laptop - Prepare complete software nodes
Input: elantech - Prepare a complete software node for the device
i2c: Remove support for dangling device properties

Merged the immutable branch (with added tag from Robert) to for-next now. Branch is here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/software-nodes

tag: <i2c-software-nodes-20210410>

Thank you, Heikki and all reviewers!