Exemple #1
0
/**
 * fwnode_property_present - check if a property of a firmware node is present
 * @fwnode: Firmware node whose property to check
 * @propname: Name of the property
 */
bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
{
    if (is_of_node(fwnode))
        return of_property_read_bool(to_of_node(fwnode), propname);
    else if (is_acpi_node(fwnode))
        return !acpi_dev_prop_get(to_acpi_node(fwnode), propname, NULL);

    return !!pset_prop_get(to_pset(fwnode), propname);
}
Exemple #2
0
/**
 * fwnode_property_read_string - return a string property of a firmware node
 * @fwnode: Firmware node to get the property of
 * @propname: Name of the property
 * @val: The value is stored here
 *
 * Read property @propname from the given firmware node and store the value into
 * @val if found.  The value is checked to be a string.
 *
 * Return: %0 if the property was found (success),
 *	   %-EINVAL if given arguments are not valid,
 *	   %-ENODATA if the property does not have a value,
 *	   %-EPROTO or %-EILSEQ if the property is not a string,
 *	   %-ENXIO if no suitable firmware interface is present.
 */
int fwnode_property_read_string(struct fwnode_handle *fwnode,
                                const char *propname, const char **val)
{
    if (is_of_node(fwnode))
        return of_property_read_string(to_of_node(fwnode), propname, val);
    else if (is_acpi_node(fwnode))
        return acpi_dev_prop_read(to_acpi_node(fwnode), propname,
                                  DEV_PROP_STRING, val, 1);

    return -ENXIO;
}
Exemple #3
0
/**
 * fwnode_property_read_string_array - return string array property of a node
 * @fwnode: Firmware node to get the property of
 * @propname: Name of the property
 * @val: The values are stored here or %NULL to return the number of values
 * @nval: Size of the @val array
 *
 * Read an string list property @propname from the given firmware node and store
 * them to @val if found.
 *
 * Return: number of values if @val was %NULL,
 *         %0 if the property was found (success),
 *	   %-EINVAL if given arguments are not valid,
 *	   %-ENODATA if the property does not have a value,
 *	   %-EPROTO if the property is not an array of strings,
 *	   %-EOVERFLOW if the size of the property is not as expected,
 *	   %-ENXIO if no suitable firmware interface is present.
 */
int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
                                      const char *propname, const char **val,
                                      size_t nval)
{
    if (is_of_node(fwnode))
        return val ?
               of_property_read_string_array(to_of_node(fwnode),
                                             propname, val, nval) :
               of_property_count_strings(to_of_node(fwnode), propname);
    else if (is_acpi_node(fwnode))
        return acpi_dev_prop_read(to_acpi_node(fwnode), propname,
                                  DEV_PROP_STRING, val, nval);

    return pset_prop_read_array(to_pset(fwnode), propname,
                                DEV_PROP_STRING, val, nval);
}
Exemple #4
0
/**
 * fwnode_get_reference_node - Find the firmware node referenced
 * @fwnode: Firmware node to get the property from.
 * @propname: Name of the property
 * @index: Index of the reference
 *
 * Returns referenced fwnode handler pointer, or an NULL if not found
 */
struct fwnode_handle *fwnode_get_reference_node(struct fwnode_handle *fwnode,
					 const char *propname, int index)
{
	if (is_of_node(fwnode)) {
		struct device_node *np;
		np = of_parse_phandle(to_of_node(fwnode), propname, index);
		if(!np)
			return NULL;
		return &np->fwnode;
	} else if (is_acpi_node(fwnode)) {
		struct acpi_device *adev;
		adev = acpi_dev_get_reference_device(to_acpi_device_node(fwnode),
						     propname, index);
		if(!adev)
			return NULL;
		return acpi_fwnode_handle(adev);
	}
	return NULL;
}
Exemple #5
0
static int __fwnode_property_read_string_array(struct fwnode_handle *fwnode,
					       const char *propname,
					       const char **val, size_t nval)
{
	if (is_of_node(fwnode))
		return val ?
			of_property_read_string_array(to_of_node(fwnode),
						      propname, val, nval) :
			of_property_count_strings(to_of_node(fwnode), propname);
	else if (is_acpi_node(fwnode))
		return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING,
					   val, nval);
	else if (is_pset_node(fwnode))
		return val ?
			pset_prop_read_string_array(to_pset_node(fwnode),
						    propname, val, nval) :
			pset_prop_count_elems_of_size(to_pset_node(fwnode),
						      propname,
						      sizeof(const char *));
	return -ENXIO;
}