diff mbox series

[v2,4.19.y-cip,01/22] device connection: Add fwnode member to struct device_connection

Message ID 1582303929-5773-2-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com (mailing list archive)
State Accepted, archived
Delegated to: Pavel Machek
Headers show
Series Renesas RZ/G2E USB Type-C Backport | expand

Commit Message

Marian-Cristian Rotariu Feb. 21, 2020, 4:51 p.m. UTC
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>

commit 09aa11cfda9d8186046bcd1adcd6498b688114f4 upstream.

This will prepare the device connection API for connections
described in firmware.

Acked-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(added 0-initializations for the newly added field)
Signed-off-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com>
---
 drivers/extcon/extcon-axp288.c           | 1 +
 drivers/platform/x86/intel_cht_int33fe.c | 4 ++++
 include/linux/device.h                   | 6 ++++++
 3 files changed, 11 insertions(+)

Comments

Pavel Machek Feb. 23, 2020, 8:11 p.m. UTC | #1
Hi!

> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 
> commit 09aa11cfda9d8186046bcd1adcd6498b688114f4 upstream.
> 
> This will prepare the device connection API for connections
> described in firmware.

Ok, I made you do this. Sorry. I assumed it you'd just audit
initializers. I suggest to take this, anyway, but:

> +++ b/drivers/extcon/extcon-axp288.c
> @@ -446,6 +446,7 @@ static struct platform_driver axp288_extcon_driver = {
>  };
>  
>  static struct device_connection axp288_extcon_role_sw_conn = {
> +	.fwnode = NULL,
>  	.endpoint[0] = "axp288_extcon",
>  	.endpoint[1] = "intel_xhci_usb_sw-role-switch",
>  	.id = "usb-role-switch",

This one is not neccessary as struct initializers are "filled" with 0s
when no other value is present.

> diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
> index f40b1c19..1fa77e4 100644
> --- a/drivers/platform/x86/intel_cht_int33fe.c
> +++ b/drivers/platform/x86/intel_cht_int33fe.c
> @@ -175,15 +175,19 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  			return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
>  	}
>  
> +	data->connections[0].fwnode = NULL;

And these should be already zero-initialized by

	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);

Anyway, extra initializations will not hurt.

Best regards,
									Pavel
diff mbox series

Patch

diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index a983708..8c5fd81 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -446,6 +446,7 @@  static struct platform_driver axp288_extcon_driver = {
 };
 
 static struct device_connection axp288_extcon_role_sw_conn = {
+	.fwnode = NULL,
 	.endpoint[0] = "axp288_extcon",
 	.endpoint[1] = "intel_xhci_usb_sw-role-switch",
 	.id = "usb-role-switch",
diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
index f40b1c19..1fa77e4 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -175,15 +175,19 @@  static int cht_int33fe_probe(struct platform_device *pdev)
 			return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
 	}
 
+	data->connections[0].fwnode = NULL;
 	data->connections[0].endpoint[0] = "port0";
 	data->connections[0].endpoint[1] = "i2c-pi3usb30532";
 	data->connections[0].id = "typec-switch";
+	data->connections[1].fwnode = NULL;
 	data->connections[1].endpoint[0] = "port0";
 	data->connections[1].endpoint[1] = "i2c-pi3usb30532";
 	data->connections[1].id = "typec-mux";
+	data->connections[2].fwnode = NULL;
 	data->connections[2].endpoint[0] = "port0";
 	data->connections[2].endpoint[1] = "i2c-pi3usb30532";
 	data->connections[2].id = "idff01m01";
+	data->connections[3].fwnode = NULL;
 	data->connections[3].endpoint[0] = "i2c-fusb302";
 	data->connections[3].endpoint[1] = "intel_xhci_usb_sw-role-switch";
 	data->connections[3].id = "usb-role-switch";
diff --git a/include/linux/device.h b/include/linux/device.h
index 19dd885..ceb69b9 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -753,11 +753,17 @@  struct device_dma_parameters {
 
 /**
  * struct device_connection - Device Connection Descriptor
+ * @fwnode: The device node of the connected device
  * @endpoint: The names of the two devices connected together
  * @id: Unique identifier for the connection
  * @list: List head, private, for internal use only
+ *
+ * NOTE: @fwnode is not used together with @endpoint. @fwnode is used when
+ * platform firmware defines the connection. When the connection is registered
+ * with device_connection_add() @endpoint is used instead.
  */
 struct device_connection {
+	struct fwnode_handle	*fwnode;
 	const char		*endpoint[2];
 	const char		*id;
 	struct list_head	list;