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

remoteproc: Introduce rproc_of_parse_firmware() helper

Add a new helper function rproc_of_parse_firmware() to the remoteproc
core that can be used by various remoteproc drivers to look up the
the "firmware-name" property from a rproc device node. This property
is already being used by multiple drivers, so this helper can avoid
repeating equivalent code in remoteproc drivers.

Signed-off-by: Suman Anna <s-anna@ti.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200721223617.20312-3-s-anna@ti.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Suman Anna and committed by
Bjorn Andersson
a8aa5ee1 44aa656f

+25
+23
drivers/remoteproc/remoteproc_core.c
··· 1046 1046 } 1047 1047 EXPORT_SYMBOL(rproc_of_resm_mem_entry_init); 1048 1048 1049 + /** 1050 + * rproc_of_parse_firmware() - parse and return the firmware-name 1051 + * @dev: pointer on device struct representing a rproc 1052 + * @index: index to use for the firmware-name retrieval 1053 + * @fw_name: pointer to a character string, in which the firmware 1054 + * name is returned on success and unmodified otherwise. 1055 + * 1056 + * This is an OF helper function that parses a device's DT node for 1057 + * the "firmware-name" property and returns the firmware name pointer 1058 + * in @fw_name on success. 1059 + * 1060 + * Return: 0 on success, or an appropriate failure. 1061 + */ 1062 + int rproc_of_parse_firmware(struct device *dev, int index, const char **fw_name) 1063 + { 1064 + int ret; 1065 + 1066 + ret = of_property_read_string_index(dev->of_node, "firmware-name", 1067 + index, fw_name); 1068 + return ret ? ret : 0; 1069 + } 1070 + EXPORT_SYMBOL(rproc_of_parse_firmware); 1071 + 1049 1072 /* 1050 1073 * A lookup table for resource handlers. The indices are defined in 1051 1074 * enum fw_resource_type.
+2
drivers/remoteproc/remoteproc_internal.h
··· 28 28 void rproc_release(struct kref *kref); 29 29 irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); 30 30 void rproc_vdev_release(struct kref *ref); 31 + int rproc_of_parse_firmware(struct device *dev, int index, 32 + const char **fw_name); 31 33 32 34 /* from remoteproc_virtio.c */ 33 35 int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);