summaryrefslogtreecommitdiff
path: root/drivers/of/property.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of/property.c')
-rw-r--r--drivers/of/property.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 8e90071de6ed..967f79b59016 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -22,6 +22,7 @@
#define pr_fmt(fmt) "OF: " fmt
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/of_irq.h>
@@ -431,6 +432,9 @@ EXPORT_SYMBOL_GPL(of_property_read_variable_u64_array);
* property does not have a value, and -EILSEQ if the string is not
* null-terminated within the length of the property data.
*
+ * Note that the empty string "" has length of 1, thus -ENODATA cannot
+ * be interpreted as an empty string.
+ *
* The out_string pointer is modified only if a valid string can be decoded.
*/
int of_property_read_string(const struct device_node *np, const char *propname,
@@ -439,7 +443,7 @@ int of_property_read_string(const struct device_node *np, const char *propname,
const struct property *prop = of_find_property(np, propname, NULL);
if (!prop)
return -EINVAL;
- if (!prop->value)
+ if (!prop->length)
return -ENODATA;
if (strnlen(prop->value, prop->length) >= prop->length)
return -EILSEQ;
@@ -872,6 +876,20 @@ static bool of_fwnode_device_is_available(const struct fwnode_handle *fwnode)
return of_device_is_available(to_of_node(fwnode));
}
+static bool of_fwnode_device_dma_supported(const struct fwnode_handle *fwnode)
+{
+ return true;
+}
+
+static enum dev_dma_attr
+of_fwnode_device_get_dma_attr(const struct fwnode_handle *fwnode)
+{
+ if (of_dma_is_coherent(to_of_node(fwnode)))
+ return DEV_DMA_COHERENT;
+ else
+ return DEV_DMA_NON_COHERENT;
+}
+
static bool of_fwnode_property_present(const struct fwnode_handle *fwnode,
const char *propname)
{
@@ -1450,6 +1468,21 @@ static int of_link_property(struct device_node *con_np, const char *prop_name)
return 0;
}
+static void __iomem *of_fwnode_iomap(struct fwnode_handle *fwnode, int index)
+{
+#ifdef CONFIG_OF_ADDRESS
+ return of_iomap(to_of_node(fwnode), index);
+#else
+ return NULL;
+#endif
+}
+
+static int of_fwnode_irq_get(const struct fwnode_handle *fwnode,
+ unsigned int index)
+{
+ return of_irq_get(to_of_node(fwnode), index);
+}
+
static int of_fwnode_add_links(struct fwnode_handle *fwnode)
{
struct property *p;
@@ -1472,6 +1505,8 @@ const struct fwnode_operations of_fwnode_ops = {
.put = of_fwnode_put,
.device_is_available = of_fwnode_device_is_available,
.device_get_match_data = of_fwnode_device_get_match_data,
+ .device_dma_supported = of_fwnode_device_dma_supported,
+ .device_get_dma_attr = of_fwnode_device_get_dma_attr,
.property_present = of_fwnode_property_present,
.property_read_int_array = of_fwnode_property_read_int_array,
.property_read_string_array = of_fwnode_property_read_string_array,
@@ -1485,6 +1520,8 @@ const struct fwnode_operations of_fwnode_ops = {
.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
.graph_get_port_parent = of_fwnode_graph_get_port_parent,
.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
+ .iomap = of_fwnode_iomap,
+ .irq_get = of_fwnode_irq_get,
.add_links = of_fwnode_add_links,
};
EXPORT_SYMBOL_GPL(of_fwnode_ops);