// SPDX-License-Identifier: GPL-2.0+
/*
* drivers/of/property.c - Procedures for accessing and interpreting
* Devicetree properties and graphs.
*
* Initially created by copying procedures from drivers/of/base.c. This
* file contains the OF property as well as the OF graph interface
* functions.
*
* Paul Mackerras August 1996.
* Copyright (C) 1996-2005 Paul Mackerras.
*
* Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
* {engebret|bergner}@us.ibm.com
*
* Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net
*
* Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and
* Grant Likely.
*/
#define pr_fmt(fmt) "OF: " fmt
#include <linux/ctype.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/of_irq.h>
#include <linux/string.h>
#include <linux/moduleparam.h>
#include "of_private.h"
/**
* of_property_read_bool - Find a property
* @np: device node from which the property value is to be read.
* @propname: name of the property to be searched.
*
* Search for a boolean property in a device node. Usage on non-boolean
* property types is deprecated.
*
* Return: true if the property exists false otherwise.
*/
bool of_property_read_bool(const struct device_node *np, const char *propname)
{
struct property *prop = of_find_property(np, propname, NULL);
/*
* Boolean properties should not have a value. Testing for property
* presence should either use of_property_present() or just read the
* property value and check the returned error code.
*/
if (prop && prop->length)
pr_warn("%pOF: Read of boolean property '%s' with a value.\n", np, propname);
return prop ?
|