Skip to content

Commit 0415052

Browse files
committed
Merge tag 'devprop-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "These add helpers for counting items in a property array and extend the "software nodes" support to be more convenient for representing device properties supplied by drivers and make the intel_cht_int33fe driver use that. Specifics: - Add helpers to count items in a property array (Andy Shevchenko). - Extend "software nodes" support to be more convenient for representing device properties supplied by drivers (Heikki Krogerus). - Add device_find_child_by_name() helper to the driver core (Heikki Krogerus). - Extend device connection code to also look for references provided via fwnode pointers (Heikki Krogerus). - Start to register proper struct device objects for USB Type-C muxes and orientation switches (Heikki Krogerus). - Update the intel_cht_int33fe driver to describe devices in a more general way with the help of "software nodes" (Heikki Krogerus)" * tag 'devprop-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: device property: Add helpers to count items in an array platform/x86: intel_cht_int33fe: Replacing the old connections with references platform/x86: intel_cht_int33fe: Supply fwnodes for the external dependencies platform/x86: intel_cht_int33fe: Provide fwnode for the USB connector platform/x86: intel_cht_int33fe: Provide software nodes for the devices platform/x86: intel_cht_int33fe: Remove unused fusb302 device property platform/x86: intel_cht_int33fe: Register max17047 in its own function usb: typec: Registering real device entries for the muxes device connection: Find connections also by checking the references device property: Introduce fwnode_find_reference() ACPI / property: Don't limit named child node matching to data nodes driver core: Add helper device_find_child_by_name() software node: Add software_node_get_reference_args() software node: Use kobject name when finding child nodes by name software node: Add support for static node descriptors software node: Simplify software_node_release() function software node: Allow node creation without properties
2 parents 4b47045 + 33ee09c commit 0415052

File tree

14 files changed

+947
-249
lines changed

14 files changed

+947
-249
lines changed

drivers/acpi/property.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,15 +600,29 @@ static struct fwnode_handle *
600600
acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
601601
const char *childname)
602602
{
603+
char name[ACPI_PATH_SEGMENT_LENGTH];
603604
struct fwnode_handle *child;
605+
struct acpi_buffer path;
606+
acpi_status status;
604607

605-
/*
606-
* Find first matching named child node of this fwnode.
607-
* For ACPI this will be a data only sub-node.
608-
*/
609-
fwnode_for_each_child_node(fwnode, child)
610-
if (acpi_data_node_match(child, childname))
608+
path.length = sizeof(name);
609+
path.pointer = name;
610+
611+
fwnode_for_each_child_node(fwnode, child) {
612+
if (is_acpi_data_node(child)) {
613+
if (acpi_data_node_match(child, childname))
614+
return child;
615+
continue;
616+
}
617+
618+
status = acpi_get_name(ACPI_HANDLE_FWNODE(child),
619+
ACPI_SINGLE_NAME, &path);
620+
if (ACPI_FAILURE(status))
621+
break;
622+
623+
if (!strncmp(name, childname, ACPI_NAMESEG_SIZE))
611624
return child;
625+
}
612626

613627
return NULL;
614628
}

drivers/base/core.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,34 @@ struct device *device_find_child(struct device *parent, void *data,
24742474
}
24752475
EXPORT_SYMBOL_GPL(device_find_child);
24762476

2477+
/**
2478+
* device_find_child_by_name - device iterator for locating a child device.
2479+
* @parent: parent struct device
2480+
* @name: name of the child device
2481+
*
2482+
* This is similar to the device_find_child() function above, but it
2483+
* returns a reference to a device that has the name @name.
2484+
*
2485+
* NOTE: you will need to drop the reference with put_device() after use.
2486+
*/
2487+
struct device *device_find_child_by_name(struct device *parent,
2488+
const char *name)
2489+
{
2490+
struct klist_iter i;
2491+
struct device *child;
2492+
2493+
if (!parent)
2494+
return NULL;
2495+
2496+
klist_iter_init(&parent->p->klist_children, &i);
2497+
while ((child = next_device(&i)))
2498+
if (!strcmp(dev_name(child), name) && get_device(child))
2499+
break;
2500+
klist_iter_exit(&i);
2501+
return child;
2502+
}
2503+
EXPORT_SYMBOL_GPL(device_find_child_by_name);
2504+
24772505
int __init devices_init(void)
24782506
{
24792507
devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);

drivers/base/devcon.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
3838
return NULL;
3939
}
4040

41+
static void *
42+
fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
43+
void *data, devcon_match_fn_t match)
44+
{
45+
struct device_connection con = { };
46+
void *ret;
47+
int i;
48+
49+
for (i = 0; ; i++) {
50+
con.fwnode = fwnode_find_reference(fwnode, con_id, i);
51+
if (IS_ERR(con.fwnode))
52+
break;
53+
54+
ret = match(&con, -1, data);
55+
fwnode_handle_put(con.fwnode);
56+
if (ret)
57+
return ret;
58+
}
59+
60+
return NULL;
61+
}
62+
4163
/**
4264
* device_connection_find_match - Find physical connection to a device
4365
* @dev: Device with the connection
@@ -65,6 +87,10 @@ void *device_connection_find_match(struct device *dev, const char *con_id,
6587
ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
6688
if (ret)
6789
return ret;
90+
91+
ret = fwnode_devcon_match(fwnode, con_id, data, match);
92+
if (ret)
93+
return ret;
6894
}
6995

7096
mutex_lock(&devcon_lock);

drivers/base/property.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,30 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
484484
}
485485
EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);
486486

487+
/**
488+
* fwnode_find_reference - Find named reference to a fwnode_handle
489+
* @fwnode: Firmware node where to look for the reference
490+
* @name: The name of the reference
491+
* @index: Index of the reference
492+
*
493+
* @index can be used when the named reference holds a table of references.
494+
*
495+
* Returns pointer to the reference fwnode, or ERR_PTR. Caller is responsible to
496+
* call fwnode_handle_put() on the returned fwnode pointer.
497+
*/
498+
struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
499+
const char *name,
500+
unsigned int index)
501+
{
502+
struct fwnode_reference_args args;
503+
int ret;
504+
505+
ret = fwnode_property_get_reference_args(fwnode, name, NULL, 0, index,
506+
&args);
507+
return ret ? ERR_PTR(ret) : args.fwnode;
508+
}
509+
EXPORT_SYMBOL_GPL(fwnode_find_reference);
510+
487511
/**
488512
* device_remove_properties - Remove properties from a device object.
489513
* @dev: Device whose properties to remove.

0 commit comments

Comments
 (0)