Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of: provide of_machine_read_compatible()

Provide a helper function allowing users to read the compatible string
of the machine, hiding the access to the root node.

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20260223-soc-of-root-v2-1-b45da45903c8@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bartosz Golaszewski and committed by
Greg Kroah-Hartman
59621105 2de27980

+23
+15
drivers/of/base.c
··· 435 435 EXPORT_SYMBOL(of_machine_compatible_match); 436 436 437 437 /** 438 + * of_machine_read_compatible - Get the compatible string of this machine 439 + * @compatible: address at which the address of the compatible string will be 440 + * stored 441 + * @index: index of the compatible entry in the list 442 + * 443 + * Returns: 444 + * 0 on success, negative error number on failure. 445 + */ 446 + int of_machine_read_compatible(const char **compatible, unsigned int index) 447 + { 448 + return of_property_read_string_index(of_root, "compatible", index, compatible); 449 + } 450 + EXPORT_SYMBOL_GPL(of_machine_read_compatible); 451 + 452 + /** 438 453 * of_machine_device_match - Test root of device tree against a of_device_id array 439 454 * @matches: NULL terminated array of of_device_id match structures to search in 440 455 *
+8
include/linux/of.h
··· 426 426 return of_machine_compatible_match(compats); 427 427 } 428 428 429 + int of_machine_read_compatible(const char **compatible, unsigned int index); 430 + 429 431 extern int of_add_property(struct device_node *np, struct property *prop); 430 432 extern int of_remove_property(struct device_node *np, struct property *prop); 431 433 extern int of_update_property(struct device_node *np, struct property *newprop); ··· 851 849 static inline int of_machine_is_compatible(const char *compat) 852 850 { 853 851 return 0; 852 + } 853 + 854 + static inline int of_machine_read_compatible(const char **compatible, 855 + unsigned int index) 856 + { 857 + return -ENOSYS; 854 858 } 855 859 856 860 static inline int of_add_property(struct device_node *np, struct property *prop)