aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-01-10 20:48:19 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2022-01-10 20:48:19 -0800
commitfe8152b38d3a994c4c6fdbc0cd6551d569a5715a (patch)
tree4e8e2e918aa692c52439b2f72795e7f98bb94066 /drivers
parentMerge tag 'thermal-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (diff)
parentsoftware node: Update MAINTAINERS data base (diff)
downloadlinux-dev-fe8152b38d3a994c4c6fdbc0cd6551d569a5715a.tar.xz
linux-dev-fe8152b38d3a994c4c6fdbc0cd6551d569a5715a.zip
Merge tag 'devprop-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "These update the handling of software nodes and graph properties, and the MAINTAINERS entry for the former. Specifics: - Remove device_add_properties() which does not work correctly if software nodes holding additional device properties are shared or reused (Heikki Krogerus). - Fix nargs_prop property handling for software nodes (Clément Léger). - Update documentation of ACPI device properties (Sakari Ailus). - Update the handling of graph properties in the generic framework to match the DT case (Sakari Ailus). - Update software nodes entry in MAINTAINERS (Andy Shevchenko)" * tag 'devprop-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: software node: Update MAINTAINERS data base software node: fix wrong node passed to find nargs_prop device property: Drop fwnode_graph_get_remote_node() device property: Use fwnode_graph_for_each_endpoint() macro device property: Implement fwnode_graph_get_endpoint_count() Documentation: ACPI: Update references Documentation: ACPI: Fix data node reference documentation device property: Fix documentation for FWNODE_GRAPH_DEVICE_DISABLED device property: Fix fwnode_graph_devcon_match() fwnode leak device property: Remove device_add_properties() API driver core: Don't call device_remove_properties() from device_del() PCI: Convert to device_create_managed_software_node()
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/core.c1
-rw-r--r--drivers/base/property.c137
-rw-r--r--drivers/base/swnode.c2
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/staging/media/tegra-video/vi.c12
5 files changed, 51 insertions, 103 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b191bd17de89..63e769057487 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3581,7 +3581,6 @@ void device_del(struct device *dev)
device_pm_remove(dev);
driver_deferred_probe_del(dev);
device_platform_notify_remove(dev);
- device_remove_properties(dev);
device_links_purge(dev);
if (dev->bus)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index f1f35b48ab8b..5379eae478b1 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -508,54 +508,6 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
EXPORT_SYMBOL_GPL(fwnode_find_reference);
/**
- * device_remove_properties - Remove properties from a device object.
- * @dev: Device whose properties to remove.
- *
- * The function removes properties previously associated to the device
- * firmware node with device_add_properties(). Memory allocated to the
- * properties will also be released.
- */
-void device_remove_properties(struct device *dev)
-{
- struct fwnode_handle *fwnode = dev_fwnode(dev);
-
- if (!fwnode)
- return;
-
- if (is_software_node(fwnode->secondary)) {
- fwnode_remove_software_node(fwnode->secondary);
- set_secondary_fwnode(dev, NULL);
- }
-}
-EXPORT_SYMBOL_GPL(device_remove_properties);
-
-/**
- * device_add_properties - Add a collection of properties to a device object.
- * @dev: Device to add properties to.
- * @properties: Collection of properties to add.
- *
- * Associate a collection of device properties represented by @properties with
- * @dev. The function takes a copy of @properties.
- *
- * WARNING: The callers should not use this function if it is known that there
- * is no real firmware node associated with @dev! In that case the callers
- * should create a software node and assign it to @dev directly.
- */
-int device_add_properties(struct device *dev,
- const struct property_entry *properties)
-{
- struct fwnode_handle *fwnode;
-
- fwnode = fwnode_create_software_node(properties, NULL);
- if (IS_ERR(fwnode))
- return PTR_ERR(fwnode);
-
- set_secondary_fwnode(dev, fwnode);
- return 0;
-}
-EXPORT_SYMBOL_GPL(device_add_properties);
-
-/**
* fwnode_get_name - Return the name of a node
* @fwnode: The firmware node
*
@@ -1059,43 +1011,17 @@ fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
}
EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
-/**
- * fwnode_graph_get_remote_node - get remote parent node for given port/endpoint
- * @fwnode: pointer to parent fwnode_handle containing graph port/endpoint
- * @port_id: identifier of the parent port node
- * @endpoint_id: identifier of the endpoint node
- *
- * Return: Remote fwnode handle associated with remote endpoint node linked
- * to @node. Use fwnode_node_put() on it when done.
- */
-struct fwnode_handle *
-fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port_id,
- u32 endpoint_id)
+static bool fwnode_graph_remote_available(struct fwnode_handle *ep)
{
- struct fwnode_handle *endpoint = NULL;
-
- while ((endpoint = fwnode_graph_get_next_endpoint(fwnode, endpoint))) {
- struct fwnode_endpoint fwnode_ep;
- struct fwnode_handle *remote;
- int ret;
+ struct fwnode_handle *dev_node;
+ bool available;
- ret = fwnode_graph_parse_endpoint(endpoint, &fwnode_ep);
- if (ret < 0)
- continue;
+ dev_node = fwnode_graph_get_remote_port_parent(ep);
+ available = fwnode_device_is_available(dev_node);
+ fwnode_handle_put(dev_node);
- if (fwnode_ep.port != port_id || fwnode_ep.id != endpoint_id)
- continue;
-
- remote = fwnode_graph_get_remote_port_parent(endpoint);
- if (!remote)
- return NULL;
-
- return fwnode_device_is_available(remote) ? remote : NULL;
- }
-
- return NULL;
+ return available;
}
-EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
/**
* fwnode_graph_get_endpoint_by_id - get endpoint by port and endpoint numbers
@@ -1111,8 +1037,8 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
* has not been found, look for the closest endpoint ID greater than the
* specified one and return the endpoint that corresponds to it, if present.
*
- * Do not return endpoints that belong to disabled devices, unless
- * FWNODE_GRAPH_DEVICE_DISABLED is passed in @flags.
+ * Does not return endpoints that belong to disabled devices or endpoints that
+ * are unconnected, unless FWNODE_GRAPH_DEVICE_DISABLED is passed in @flags.
*
* The returned endpoint needs to be released by calling fwnode_handle_put() on
* it when it is not needed any more.
@@ -1121,25 +1047,17 @@ struct fwnode_handle *
fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
u32 port, u32 endpoint, unsigned long flags)
{
- struct fwnode_handle *ep = NULL, *best_ep = NULL;
+ struct fwnode_handle *ep, *best_ep = NULL;
unsigned int best_ep_id = 0;
bool endpoint_next = flags & FWNODE_GRAPH_ENDPOINT_NEXT;
bool enabled_only = !(flags & FWNODE_GRAPH_DEVICE_DISABLED);
- while ((ep = fwnode_graph_get_next_endpoint(fwnode, ep))) {
+ fwnode_graph_for_each_endpoint(fwnode, ep) {
struct fwnode_endpoint fwnode_ep = { 0 };
int ret;
- if (enabled_only) {
- struct fwnode_handle *dev_node;
- bool available;
-
- dev_node = fwnode_graph_get_remote_port_parent(ep);
- available = fwnode_device_is_available(dev_node);
- fwnode_handle_put(dev_node);
- if (!available)
- continue;
- }
+ if (enabled_only && !fwnode_graph_remote_available(ep))
+ continue;
ret = fwnode_graph_parse_endpoint(ep, &fwnode_ep);
if (ret < 0)
@@ -1173,6 +1091,31 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
EXPORT_SYMBOL_GPL(fwnode_graph_get_endpoint_by_id);
/**
+ * fwnode_graph_get_endpoint_count - Count endpoints on a device node
+ * @fwnode: The node related to a device
+ * @flags: fwnode lookup flags
+ * Count endpoints in a device node.
+ *
+ * If FWNODE_GRAPH_DEVICE_DISABLED flag is specified, also unconnected endpoints
+ * and endpoints connected to disabled devices are counted.
+ */
+unsigned int fwnode_graph_get_endpoint_count(struct fwnode_handle *fwnode,
+ unsigned long flags)
+{
+ struct fwnode_handle *ep;
+ unsigned int count = 0;
+
+ fwnode_graph_for_each_endpoint(fwnode, ep) {
+ if (flags & FWNODE_GRAPH_DEVICE_DISABLED ||
+ fwnode_graph_remote_available(ep))
+ count++;
+ }
+
+ return count;
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_get_endpoint_count);
+
+/**
* fwnode_graph_parse_endpoint - parse common endpoint node properties
* @fwnode: pointer to endpoint fwnode_handle
* @endpoint: pointer to the fwnode endpoint data structure
@@ -1206,8 +1149,10 @@ fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
fwnode_graph_for_each_endpoint(fwnode, ep) {
node = fwnode_graph_get_remote_port_parent(ep);
- if (!fwnode_device_is_available(node))
+ if (!fwnode_device_is_available(node)) {
+ fwnode_handle_put(node);
continue;
+ }
ret = match(node, con_id, data);
fwnode_handle_put(node);
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 4debcea4fb12..0a482212c7e8 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -529,7 +529,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
return -ENOENT;
if (nargs_prop) {
- error = property_entry_read_int_array(swnode->node->properties,
+ error = property_entry_read_int_array(ref->node->properties,
nargs_prop, sizeof(u32),
&nargs_prop_val, 1);
if (error)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 003950c738d2..b4cb658cce2b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1850,7 +1850,7 @@ static void quirk_huawei_pcie_sva(struct pci_dev *pdev)
* can set it directly.
*/
if (!pdev->dev.of_node &&
- device_add_properties(&pdev->dev, properties))
+ device_create_managed_software_node(&pdev->dev, properties, NULL))
pci_warn(pdev, "could not add stall property");
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa250, quirk_huawei_pcie_sva);
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 69d9787d5338..d1f43f465c22 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -1845,7 +1845,6 @@ static int tegra_vi_graph_init(struct tegra_vi *vi)
struct tegra_vi_channel *chan;
struct fwnode_handle *fwnode = dev_fwnode(vi->dev);
int ret;
- struct fwnode_handle *remote = NULL;
/*
* Walk the links to parse the full graph. Each channel will have
@@ -1857,11 +1856,16 @@ static int tegra_vi_graph_init(struct tegra_vi *vi)
* next channels.
*/
list_for_each_entry(chan, &vi->vi_chans, list) {
- remote = fwnode_graph_get_remote_node(fwnode, chan->portnos[0],
- 0);
- if (!remote)
+ struct fwnode_handle *ep, *remote;
+
+ ep = fwnode_graph_get_endpoint_by_id(fwnode,
+ chan->portnos[0], 0, 0);
+ if (!ep)
continue;
+ remote = fwnode_graph_get_remote_port_parent(ep);
+ fwnode_handle_put(ep);
+
ret = tegra_vi_graph_parse_one(chan, remote);
fwnode_handle_put(remote);
if (ret < 0 || list_empty(&chan->notifier.asd_list))