linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Remove struct device_connection
@ 2020-09-04 12:51 Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 1/4] device connection: Remove device_connection_find() Heikki Krogerus
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Heikki Krogerus @ 2020-09-04 12:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Greg Kroah-Hartman, linux-kernel, linux-acpi

Hi,

The purpose of the struct device_connection was to allow
connections between devices to be described somehow when the
firmware did not do that. Later support for also firmware
described connections, for example walking device graph, was
added to the API. But now software nodes make it possible to
describe for example device graph if needed, so we don't
need a separate method of describing the connections.

All the users of struct device_connection have now been
concerted to use software nodes instead, so we can remove
the data structure, and the list for it.

thanks,

Heikki Krogerus (4):
  device connection: Remove device_connection_find()
  device connection: Remove device_connection_add()
  device connection: Remove struct device_connection
  device property: Move fwnode_connection_find_match() under
    drivers/base/property.c

 .../driver-api/device_connection.rst          |  43 ----
 drivers/base/Makefile                         |   2 +-
 drivers/base/devcon.c                         | 231 ------------------
 drivers/base/property.c                       |  73 ++++++
 drivers/usb/roles/class.c                     |  12 +-
 drivers/usb/typec/mux.c                       |  19 +-
 include/linux/device.h                        |  56 -----
 include/linux/property.h                      |  14 ++
 8 files changed, 102 insertions(+), 348 deletions(-)
 delete mode 100644 Documentation/driver-api/device_connection.rst
 delete mode 100644 drivers/base/devcon.c

-- 
2.28.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] device connection: Remove device_connection_find()
  2020-09-04 12:51 [PATCH 0/4] Remove struct device_connection Heikki Krogerus
@ 2020-09-04 12:51 ` Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 2/4] device connection: Remove device_connection_add() Heikki Krogerus
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2020-09-04 12:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Greg Kroah-Hartman, linux-kernel, linux-acpi

There are no users for that function.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/base/devcon.c  | 73 ------------------------------------------
 include/linux/device.h |  2 --
 2 files changed, 75 deletions(-)

diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 14e2178e09f83..51ad546303ddb 100644
--- a/drivers/base/devcon.c
+++ b/drivers/base/devcon.c
@@ -133,79 +133,6 @@ void *device_connection_find_match(struct device *dev, const char *con_id,
 }
 EXPORT_SYMBOL_GPL(device_connection_find_match);
 
-extern struct bus_type platform_bus_type;
-extern struct bus_type pci_bus_type;
-extern struct bus_type i2c_bus_type;
-extern struct bus_type spi_bus_type;
-
-static struct bus_type *generic_match_buses[] = {
-	&platform_bus_type,
-#ifdef CONFIG_PCI
-	&pci_bus_type,
-#endif
-#ifdef CONFIG_I2C
-	&i2c_bus_type,
-#endif
-#ifdef CONFIG_SPI_MASTER
-	&spi_bus_type,
-#endif
-	NULL,
-};
-
-static void *device_connection_fwnode_match(struct device_connection *con)
-{
-	struct bus_type *bus;
-	struct device *dev;
-
-	for (bus = generic_match_buses[0]; bus; bus++) {
-		dev = bus_find_device_by_fwnode(bus, con->fwnode);
-		if (dev && !strncmp(dev_name(dev), con->id, strlen(con->id)))
-			return dev;
-
-		put_device(dev);
-	}
-	return NULL;
-}
-
-/* This tries to find the device from the most common bus types by name. */
-static void *generic_match(struct device_connection *con, int ep, void *data)
-{
-	struct bus_type *bus;
-	struct device *dev;
-
-	if (con->fwnode)
-		return device_connection_fwnode_match(con);
-
-	for (bus = generic_match_buses[0]; bus; bus++) {
-		dev = bus_find_device_by_name(bus, NULL, con->endpoint[ep]);
-		if (dev)
-			return dev;
-	}
-
-	/*
-	 * We only get called if a connection was found, tell the caller to
-	 * wait for the other device to show up.
-	 */
-	return ERR_PTR(-EPROBE_DEFER);
-}
-
-/**
- * device_connection_find - Find two devices connected together
- * @dev: Device with the connection
- * @con_id: Identifier for the connection
- *
- * Find a connection with unique identifier @con_id between @dev and
- * another device. On success returns handle to the device that is connected
- * to @dev, with the reference count for the found device incremented. Returns
- * NULL if no matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a
- * connection was found but the other device has not been enumerated yet.
- */
-struct device *device_connection_find(struct device *dev, const char *con_id)
-{
-	return device_connection_find_match(dev, con_id, NULL, generic_match);
-}
-EXPORT_SYMBOL_GPL(device_connection_find);
-
 /**
  * device_connection_add - Register a connection description
  * @con: The connection description to be registered
diff --git a/include/linux/device.h b/include/linux/device.h
index 1c78621fc3c01..4a98cd2d442c7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -319,8 +319,6 @@ void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
 void *device_connection_find_match(struct device *dev, const char *con_id,
 				   void *data, devcon_match_fn_t match);
 
-struct device *device_connection_find(struct device *dev, const char *con_id);
-
 void device_connection_add(struct device_connection *con);
 void device_connection_remove(struct device_connection *con);
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] device connection: Remove device_connection_add()
  2020-09-04 12:51 [PATCH 0/4] Remove struct device_connection Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 1/4] device connection: Remove device_connection_find() Heikki Krogerus
@ 2020-09-04 12:51 ` Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 3/4] device connection: Remove struct device_connection Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c Heikki Krogerus
  3 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2020-09-04 12:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Greg Kroah-Hartman, linux-kernel, linux-acpi

All the users of that API have now been converted to use
software fwnodes instead.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/base/devcon.c  | 59 +-----------------------------------------
 include/linux/device.h | 29 ---------------------
 2 files changed, 1 insertion(+), 87 deletions(-)

diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 51ad546303ddb..94ab22a451ce3 100644
--- a/drivers/base/devcon.c
+++ b/drivers/base/devcon.c
@@ -9,9 +9,6 @@
 #include <linux/device.h>
 #include <linux/property.h>
 
-static DEFINE_MUTEX(devcon_lock);
-static LIST_HEAD(devcon_list);
-
 static void *
 fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
 			  void *data, devcon_match_fn_t match)
@@ -99,60 +96,6 @@ EXPORT_SYMBOL_GPL(fwnode_connection_find_match);
 void *device_connection_find_match(struct device *dev, const char *con_id,
 				   void *data, devcon_match_fn_t match)
 {
-	struct fwnode_handle *fwnode = dev_fwnode(dev);
-	const char *devname = dev_name(dev);
-	struct device_connection *con;
-	void *ret = NULL;
-	int ep;
-
-	if (!match)
-		return NULL;
-
-	ret = fwnode_connection_find_match(fwnode, con_id, data, match);
-	if (ret)
-		return ret;
-
-	mutex_lock(&devcon_lock);
-
-	list_for_each_entry(con, &devcon_list, list) {
-		ep = match_string(con->endpoint, 2, devname);
-		if (ep < 0)
-			continue;
-
-		if (con_id && strcmp(con->id, con_id))
-			continue;
-
-		ret = match(con, !ep, data);
-		if (ret)
-			break;
-	}
-
-	mutex_unlock(&devcon_lock);
-
-	return ret;
+	return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
 }
 EXPORT_SYMBOL_GPL(device_connection_find_match);
-
-/**
- * device_connection_add - Register a connection description
- * @con: The connection description to be registered
- */
-void device_connection_add(struct device_connection *con)
-{
-	mutex_lock(&devcon_lock);
-	list_add_tail(&con->list, &devcon_list);
-	mutex_unlock(&devcon_lock);
-}
-EXPORT_SYMBOL_GPL(device_connection_add);
-
-/**
- * device_connections_remove - Unregister connection description
- * @con: The connection description to be unregistered
- */
-void device_connection_remove(struct device_connection *con)
-{
-	mutex_lock(&devcon_lock);
-	list_del(&con->list);
-	mutex_unlock(&devcon_lock);
-}
-EXPORT_SYMBOL_GPL(device_connection_remove);
diff --git a/include/linux/device.h b/include/linux/device.h
index 4a98cd2d442c7..43569297c6cc1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -297,7 +297,6 @@ struct device_dma_parameters {
  * @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
@@ -307,7 +306,6 @@ struct device_connection {
 	struct fwnode_handle	*fwnode;
 	const char		*endpoint[2];
 	const char		*id;
-	struct list_head	list;
 };
 
 typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep,
@@ -319,33 +317,6 @@ void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
 void *device_connection_find_match(struct device *dev, const char *con_id,
 				   void *data, devcon_match_fn_t match);
 
-void device_connection_add(struct device_connection *con);
-void device_connection_remove(struct device_connection *con);
-
-/**
- * device_connections_add - Add multiple device connections at once
- * @cons: Zero terminated array of device connection descriptors
- */
-static inline void device_connections_add(struct device_connection *cons)
-{
-	struct device_connection *c;
-
-	for (c = cons; c->endpoint[0]; c++)
-		device_connection_add(c);
-}
-
-/**
- * device_connections_remove - Remove multiple device connections at once
- * @cons: Zero terminated array of device connection descriptors
- */
-static inline void device_connections_remove(struct device_connection *cons)
-{
-	struct device_connection *c;
-
-	for (c = cons; c->endpoint[0]; c++)
-		device_connection_remove(c);
-}
-
 /**
  * enum device_link_state - Device link states.
  * @DL_STATE_NONE: The presence of the drivers is not being tracked.
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] device connection: Remove struct device_connection
  2020-09-04 12:51 [PATCH 0/4] Remove struct device_connection Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 1/4] device connection: Remove device_connection_find() Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 2/4] device connection: Remove device_connection_add() Heikki Krogerus
@ 2020-09-04 12:51 ` Heikki Krogerus
  2020-09-04 12:51 ` [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c Heikki Krogerus
  3 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2020-09-04 12:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Greg Kroah-Hartman, linux-kernel, linux-acpi

Since the connection descriptors can't be stored into the
list anymore, there is no need for the data structure.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/base/devcon.c     | 20 ++++++++++----------
 drivers/usb/roles/class.c | 12 ++++--------
 drivers/usb/typec/mux.c   | 19 ++++++++++---------
 include/linux/device.h    | 18 +-----------------
 4 files changed, 25 insertions(+), 44 deletions(-)

diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 94ab22a451ce3..1790e84dbe7c2 100644
--- a/drivers/base/devcon.c
+++ b/drivers/base/devcon.c
@@ -13,17 +13,17 @@ static void *
 fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
 			  void *data, devcon_match_fn_t match)
 {
-	struct device_connection con = { .id = con_id };
+	struct fwnode_handle *node;
 	struct fwnode_handle *ep;
 	void *ret;
 
 	fwnode_graph_for_each_endpoint(fwnode, ep) {
-		con.fwnode = fwnode_graph_get_remote_port_parent(ep);
-		if (!fwnode_device_is_available(con.fwnode))
+		node = fwnode_graph_get_remote_port_parent(ep);
+		if (!fwnode_device_is_available(node))
 			continue;
 
-		ret = match(&con, -1, data);
-		fwnode_handle_put(con.fwnode);
+		ret = match(node, con_id, data);
+		fwnode_handle_put(node);
 		if (ret) {
 			fwnode_handle_put(ep);
 			return ret;
@@ -36,17 +36,17 @@ static void *
 fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
 		    void *data, devcon_match_fn_t match)
 {
-	struct device_connection con = { };
+	struct fwnode_handle *node;
 	void *ret;
 	int i;
 
 	for (i = 0; ; i++) {
-		con.fwnode = fwnode_find_reference(fwnode, con_id, i);
-		if (IS_ERR(con.fwnode))
+		node = fwnode_find_reference(fwnode, con_id, i);
+		if (IS_ERR(node))
 			break;
 
-		ret = match(&con, -1, data);
-		fwnode_handle_put(con.fwnode);
+		ret = match(node, NULL, data);
+		fwnode_handle_put(node);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 27d92af296351..97f37077b7f97 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -87,19 +87,15 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
 }
 EXPORT_SYMBOL_GPL(usb_role_switch_get_role);
 
-static void *usb_role_switch_match(struct device_connection *con, int ep,
+static void *usb_role_switch_match(struct fwnode_handle *fwnode, const char *id,
 				   void *data)
 {
 	struct device *dev;
 
-	if (con->fwnode) {
-		if (con->id && !fwnode_property_present(con->fwnode, con->id))
-			return NULL;
+	if (id && !fwnode_property_present(fwnode, id))
+		return NULL;
 
-		dev = class_find_device_by_fwnode(role_class, con->fwnode);
-	} else {
-		dev = class_find_device_by_name(role_class, con->endpoint[ep]);
-	}
+	dev = class_find_device_by_fwnode(role_class, fwnode);
 
 	return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER);
 }
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index 52ad277e4565b..b069a5122aaa9 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -34,15 +34,15 @@ static int switch_fwnode_match(struct device *dev, const void *fwnode)
 	return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-switch");
 }
 
-static void *typec_switch_match(struct device_connection *con, int ep,
+static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
 				void *data)
 {
 	struct device *dev;
 
-	if (con->id && !fwnode_property_present(con->fwnode, con->id))
+	if (id && !fwnode_property_present(fwnode, id))
 		return NULL;
 
-	dev = class_find_device(&typec_mux_class, NULL, con->fwnode,
+	dev = class_find_device(&typec_mux_class, NULL, fwnode,
 				switch_fwnode_match);
 
 	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
@@ -183,7 +183,8 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode)
 	return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-mux");
 }
 
-static void *typec_mux_match(struct device_connection *con, int ep, void *data)
+static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
+			     void *data)
 {
 	const struct typec_altmode_desc *desc = data;
 	struct device *dev;
@@ -196,20 +197,20 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
 	 * Check has the identifier already been "consumed". If it
 	 * has, no need to do any extra connection identification.
 	 */
-	match = !con->id;
+	match = !id;
 	if (match)
 		goto find_mux;
 
 	/* Accessory Mode muxes */
 	if (!desc) {
-		match = fwnode_property_present(con->fwnode, "accessory");
+		match = fwnode_property_present(fwnode, "accessory");
 		if (match)
 			goto find_mux;
 		return NULL;
 	}
 
 	/* Alternate Mode muxes */
-	nval = fwnode_property_count_u16(con->fwnode, "svid");
+	nval = fwnode_property_count_u16(fwnode, "svid");
 	if (nval <= 0)
 		return NULL;
 
@@ -217,7 +218,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
 	if (!val)
 		return ERR_PTR(-ENOMEM);
 
-	nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval);
+	nval = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
 	if (nval < 0) {
 		kfree(val);
 		return ERR_PTR(nval);
@@ -234,7 +235,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
 	return NULL;
 
 find_mux:
-	dev = class_find_device(&typec_mux_class, NULL, con->fwnode,
+	dev = class_find_device(&typec_mux_class, NULL, fwnode,
 				mux_fwnode_match);
 
 	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
diff --git a/include/linux/device.h b/include/linux/device.h
index 43569297c6cc1..c3ced17d91ee6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -292,23 +292,7 @@ struct device_dma_parameters {
 	unsigned long segment_boundary_mask;
 };
 
-/**
- * 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
- *
- * 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;
-};
-
-typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep,
+typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
 				   void *data);
 
 void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c
  2020-09-04 12:51 [PATCH 0/4] Remove struct device_connection Heikki Krogerus
                   ` (2 preceding siblings ...)
  2020-09-04 12:51 ` [PATCH 3/4] device connection: Remove struct device_connection Heikki Krogerus
@ 2020-09-04 12:51 ` Heikki Krogerus
  2020-09-07  9:04   ` Greg Kroah-Hartman
  3 siblings, 1 reply; 7+ messages in thread
From: Heikki Krogerus @ 2020-09-04 12:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Greg Kroah-Hartman, linux-kernel, linux-acpi

The function is now only a helper that searches the
connection from device graph and then by checking if the
supplied connection identifier matches a property that
contains reference.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 .../driver-api/device_connection.rst          |  43 --------
 drivers/base/Makefile                         |   2 +-
 drivers/base/devcon.c                         | 101 ------------------
 drivers/base/property.c                       |  73 +++++++++++++
 include/linux/device.h                        |   9 --
 include/linux/property.h                      |  14 +++
 6 files changed, 88 insertions(+), 154 deletions(-)
 delete mode 100644 Documentation/driver-api/device_connection.rst
 delete mode 100644 drivers/base/devcon.c

diff --git a/Documentation/driver-api/device_connection.rst b/Documentation/driver-api/device_connection.rst
deleted file mode 100644
index ba364224c349b..0000000000000
--- a/Documentation/driver-api/device_connection.rst
+++ /dev/null
@@ -1,43 +0,0 @@
-==================
-Device connections
-==================
-
-Introduction
-------------
-
-Devices often have connections to other devices that are outside of the direct
-child/parent relationship. A serial or network communication controller, which
-could be a PCI device, may need to be able to get a reference to its PHY
-component, which could be attached for example to the I2C bus. Some device
-drivers need to be able to control the clocks or the GPIOs for their devices,
-and so on.
-
-Device connections are generic descriptions of any type of connection between
-two separate devices.
-
-Device connections alone do not create a dependency between the two devices.
-They are only descriptions which are not tied to either of the devices directly.
-A dependency between the two devices exists only if one of the two endpoint
-devices requests a reference to the other. The descriptions themselves can be
-defined in firmware (not yet supported) or they can be built-in.
-
-Usage
------
-
-Device connections should exist before device ``->probe`` callback is called for
-either endpoint device in the description. If the connections are defined in
-firmware, this is not a problem. It should be considered if the connection
-descriptions are "built-in", and need to be added separately.
-
-The connection description consists of the names of the two devices with the
-connection, i.e. the endpoints, and unique identifier for the connection which
-is needed if there are multiple connections between the two devices.
-
-After a description exists, the devices in it can request reference to the other
-endpoint device, or they can request the description itself.
-
-API
----
-
-.. kernel-doc:: drivers/base/devcon.c
-   :functions: device_connection_find_match device_connection_find device_connection_add device_connection_remove
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 157452080f3d7..41369fc7004fd 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -6,7 +6,7 @@ obj-y			:= component.o core.o bus.o dd.o syscore.o \
 			   cpu.o firmware.o init.o map.o devres.o \
 			   attribute_container.o transport_class.o \
 			   topology.o container.o property.o cacheinfo.o \
-			   devcon.o swnode.o
+			   swnode.o
 obj-$(CONFIG_DEVTMPFS)	+= devtmpfs.o
 obj-y			+= power/
 obj-$(CONFIG_ISA_BUS_API)	+= isa.o
diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
deleted file mode 100644
index 1790e84dbe7c2..0000000000000
--- a/drivers/base/devcon.c
+++ /dev/null
@@ -1,101 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/**
- * Device connections
- *
- * Copyright (C) 2018 Intel Corporation
- * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
- */
-
-#include <linux/device.h>
-#include <linux/property.h>
-
-static void *
-fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
-			  void *data, devcon_match_fn_t match)
-{
-	struct fwnode_handle *node;
-	struct fwnode_handle *ep;
-	void *ret;
-
-	fwnode_graph_for_each_endpoint(fwnode, ep) {
-		node = fwnode_graph_get_remote_port_parent(ep);
-		if (!fwnode_device_is_available(node))
-			continue;
-
-		ret = match(node, con_id, data);
-		fwnode_handle_put(node);
-		if (ret) {
-			fwnode_handle_put(ep);
-			return ret;
-		}
-	}
-	return NULL;
-}
-
-static void *
-fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
-		    void *data, devcon_match_fn_t match)
-{
-	struct fwnode_handle *node;
-	void *ret;
-	int i;
-
-	for (i = 0; ; i++) {
-		node = fwnode_find_reference(fwnode, con_id, i);
-		if (IS_ERR(node))
-			break;
-
-		ret = match(node, NULL, data);
-		fwnode_handle_put(node);
-		if (ret)
-			return ret;
-	}
-
-	return NULL;
-}
-
-/**
- * fwnode_connection_find_match - Find connection from a device node
- * @fwnode: Device node with the connection
- * @con_id: Identifier for the connection
- * @data: Data for the match function
- * @match: Function to check and convert the connection description
- *
- * Find a connection with unique identifier @con_id between @fwnode and another
- * device node. @match will be used to convert the connection description to
- * data the caller is expecting to be returned.
- */
-void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
-				   const char *con_id, void *data,
-				   devcon_match_fn_t match)
-{
-	void *ret;
-
-	if (!fwnode || !match)
-		return NULL;
-
-	ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
-	if (ret)
-		return ret;
-
-	return fwnode_devcon_match(fwnode, con_id, data, match);
-}
-EXPORT_SYMBOL_GPL(fwnode_connection_find_match);
-
-/**
- * device_connection_find_match - Find physical connection to a device
- * @dev: Device with the connection
- * @con_id: Identifier for the connection
- * @data: Data for the match function
- * @match: Function to check and convert the connection description
- *
- * Find a connection with unique identifier @con_id between @dev and another
- * device. @match will be used to convert the connection description to data the
- * caller is expecting to be returned.
- */
-void *device_connection_find_match(struct device *dev, const char *con_id,
-				   void *data, devcon_match_fn_t match)
-{
-	return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
-}
-EXPORT_SYMBOL_GPL(device_connection_find_match);
diff --git a/drivers/base/property.c b/drivers/base/property.c
index d58aa98fe9645..4c43d30145c6b 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1184,3 +1184,76 @@ const void *device_get_match_data(struct device *dev)
 	return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
 }
 EXPORT_SYMBOL_GPL(device_get_match_data);
+
+static void *
+fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
+			  void *data, devcon_match_fn_t match)
+{
+	struct fwnode_handle *node;
+	struct fwnode_handle *ep;
+	void *ret;
+
+	fwnode_graph_for_each_endpoint(fwnode, ep) {
+		node = fwnode_graph_get_remote_port_parent(ep);
+		if (!fwnode_device_is_available(node))
+			continue;
+
+		ret = match(node, con_id, data);
+		fwnode_handle_put(node);
+		if (ret) {
+			fwnode_handle_put(ep);
+			return ret;
+		}
+	}
+	return NULL;
+}
+
+static void *
+fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
+		    void *data, devcon_match_fn_t match)
+{
+	struct fwnode_handle *node;
+	void *ret;
+	int i;
+
+	for (i = 0; ; i++) {
+		node = fwnode_find_reference(fwnode, con_id, i);
+		if (IS_ERR(node))
+			break;
+
+		ret = match(node, NULL, data);
+		fwnode_handle_put(node);
+		if (ret)
+			return ret;
+	}
+
+	return NULL;
+}
+
+/**
+ * fwnode_connection_find_match - Find connection from a device node
+ * @fwnode: Device node with the connection
+ * @con_id: Identifier for the connection
+ * @data: Data for the match function
+ * @match: Function to check and convert the connection description
+ *
+ * Find a connection with unique identifier @con_id between @fwnode and another
+ * device node. @match will be used to convert the connection description to
+ * data the caller is expecting to be returned.
+ */
+void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
+				   const char *con_id, void *data,
+				   devcon_match_fn_t match)
+{
+	void *ret;
+
+	if (!fwnode || !match)
+		return NULL;
+
+	ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
+	if (ret)
+		return ret;
+
+	return fwnode_devcon_match(fwnode, con_id, data, match);
+}
+EXPORT_SYMBOL_GPL(fwnode_connection_find_match);
diff --git a/include/linux/device.h b/include/linux/device.h
index c3ced17d91ee6..6f76c1f38e116 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -292,15 +292,6 @@ struct device_dma_parameters {
 	unsigned long segment_boundary_mask;
 };
 
-typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
-				   void *data);
-
-void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
-				   const char *con_id, void *data,
-				   devcon_match_fn_t match);
-void *device_connection_find_match(struct device *dev, const char *con_id,
-				   void *data, devcon_match_fn_t match);
-
 /**
  * enum device_link_state - Device link states.
  * @DL_STATE_NONE: The presence of the drivers is not being tracked.
diff --git a/include/linux/property.h b/include/linux/property.h
index 9f805c4428195..aedae94dcf41d 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -418,6 +418,20 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 				struct fwnode_endpoint *endpoint);
 
+typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
+				   void *data);
+
+void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
+				   const char *con_id, void *data,
+				   devcon_match_fn_t match);
+
+static inline void *device_connection_find_match(struct device *dev,
+						 const char *con_id, void *data,
+						 devcon_match_fn_t match)
+{
+	return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
+}
+
 /* -------------------------------------------------------------------------- */
 /* Software fwnode support - when HW description is incomplete or missing */
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c
  2020-09-04 12:51 ` [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c Heikki Krogerus
@ 2020-09-07  9:04   ` Greg Kroah-Hartman
  2020-09-07  9:13     ` Heikki Krogerus
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2020-09-07  9:04 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: Rafael J. Wysocki, linux-kernel, linux-acpi

On Fri, Sep 04, 2020 at 03:51:23PM +0300, Heikki Krogerus wrote:
> The function is now only a helper that searches the
> connection from device graph and then by checking if the
> supplied connection identifier matches a property that
> contains reference.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  .../driver-api/device_connection.rst          |  43 --------
>  drivers/base/Makefile                         |   2 +-
>  drivers/base/devcon.c                         | 101 ------------------
>  drivers/base/property.c                       |  73 +++++++++++++
>  include/linux/device.h                        |   9 --
>  include/linux/property.h                      |  14 +++
>  6 files changed, 88 insertions(+), 154 deletions(-)
>  delete mode 100644 Documentation/driver-api/device_connection.rst

You also removed the documentation in this patch, which would have been
fine if you had mentioned it in the changelog text :(

I'll go queue up the first 3 patches of this series, can you split this
up into two?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c
  2020-09-07  9:04   ` Greg Kroah-Hartman
@ 2020-09-07  9:13     ` Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2020-09-07  9:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Rafael J. Wysocki, linux-kernel, linux-acpi

On Mon, Sep 07, 2020 at 11:04:14AM +0200, Greg Kroah-Hartman wrote:
> On Fri, Sep 04, 2020 at 03:51:23PM +0300, Heikki Krogerus wrote:
> > The function is now only a helper that searches the
> > connection from device graph and then by checking if the
> > supplied connection identifier matches a property that
> > contains reference.
> > 
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> >  .../driver-api/device_connection.rst          |  43 --------
> >  drivers/base/Makefile                         |   2 +-
> >  drivers/base/devcon.c                         | 101 ------------------
> >  drivers/base/property.c                       |  73 +++++++++++++
> >  include/linux/device.h                        |   9 --
> >  include/linux/property.h                      |  14 +++
> >  6 files changed, 88 insertions(+), 154 deletions(-)
> >  delete mode 100644 Documentation/driver-api/device_connection.rst
> 
> You also removed the documentation in this patch, which would have been
> fine if you had mentioned it in the changelog text :(
> 
> I'll go queue up the first 3 patches of this series, can you split this
> up into two?

Sure. I'll do that.

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-07  9:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 12:51 [PATCH 0/4] Remove struct device_connection Heikki Krogerus
2020-09-04 12:51 ` [PATCH 1/4] device connection: Remove device_connection_find() Heikki Krogerus
2020-09-04 12:51 ` [PATCH 2/4] device connection: Remove device_connection_add() Heikki Krogerus
2020-09-04 12:51 ` [PATCH 3/4] device connection: Remove struct device_connection Heikki Krogerus
2020-09-04 12:51 ` [PATCH 4/4] device property: Move fwnode_connection_find_match() under drivers/base/property.c Heikki Krogerus
2020-09-07  9:04   ` Greg Kroah-Hartman
2020-09-07  9:13     ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).