Merge branch 'for-next-manual/oftree-linux-sync'
This commit is contained in:
commit
8afe2cb4d4
|
@ -234,13 +234,9 @@ static int cm_cogent_fixup(struct device_node *root)
|
|||
int ret;
|
||||
struct device_node *node;
|
||||
|
||||
of_tree_for_each_node(node, root) {
|
||||
struct device_node *slotnode;
|
||||
|
||||
if (!of_device_is_compatible(node, "atmel,hsmci"))
|
||||
continue;
|
||||
|
||||
slotnode = of_find_child_by_name(node, "slot");
|
||||
for_each_compatible_node(node, NULL, "atmel,hsmci") {
|
||||
struct device_node *slotnode =
|
||||
of_get_child_by_name(node, "slot");
|
||||
if (!slotnode)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -35,25 +35,21 @@ static int hb_fixup(struct device_node *root)
|
|||
__be32 latency;
|
||||
|
||||
if (!(reg & HB_PWRDOM_STAT_SATA)) {
|
||||
of_tree_for_each_node(node, root) {
|
||||
if (of_device_is_compatible(node, "calxeda,hb-ahci"))
|
||||
of_set_property(node, "status", "disabled",
|
||||
sizeof("disabled"), 1);
|
||||
}
|
||||
for_each_compatible_node(node, NULL, "calxeda,hb-ahci")
|
||||
of_set_property(node, "status", "disabled",
|
||||
sizeof("disabled"), 1);
|
||||
}
|
||||
|
||||
if (!(reg & HB_PWRDOM_STAT_EMMC)) {
|
||||
of_tree_for_each_node(node, root) {
|
||||
if (of_device_is_compatible(node, "calxeda,hb-sdhci"))
|
||||
of_set_property(node, "status", "disabled",
|
||||
sizeof("disabled"), 1);
|
||||
}
|
||||
for_each_compatible_node(node, NULL, "calxeda,hb-sdhci")
|
||||
of_set_property(node, "status", "disabled",
|
||||
sizeof("disabled"), 1);
|
||||
}
|
||||
|
||||
if ((opp_table[0] >> 16) != HB_OPP_VERSION)
|
||||
return 0;
|
||||
|
||||
node = of_find_node_by_path(root, "/cpus/cpu@0");
|
||||
node = of_find_node_by_path("/cpus/cpu@0");
|
||||
if (!node)
|
||||
return 0;
|
||||
|
||||
|
@ -89,7 +85,7 @@ static int highbank_mem_init(void)
|
|||
|
||||
of_set_root_node(root);
|
||||
|
||||
np = of_find_node_by_path(root, "/memory");
|
||||
np = of_find_node_by_path("/memory");
|
||||
if (!np) {
|
||||
pr_warn("no memory node use default configuration\n");
|
||||
goto not_found;
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#define __HAVE_ARCH_MEMCMP
|
||||
#define __HAVE_ARCH_MEMCHR
|
||||
|
||||
extern int strcasecmp(const char *, const char *);
|
||||
extern int strncasecmp(const char *, const char *, int);
|
||||
extern char * strcpy(char *,const char *);
|
||||
extern char * strncpy(char *,const char *, __kernel_size_t);
|
||||
extern __kernel_size_t strlen(const char *);
|
||||
|
|
|
@ -83,7 +83,7 @@ static int of_mpc5200_fixup(struct device_node *root)
|
|||
|
||||
int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4;
|
||||
|
||||
node = of_find_node_by_path(root, "/cpus/PowerPC,5200@0");
|
||||
node = of_find_node_by_path("/cpus/PowerPC,5200@0");
|
||||
if (!node)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -91,7 +91,7 @@ static int of_mpc5200_fixup(struct device_node *root)
|
|||
of_property_write_u32(node, "bus-frequency", get_bus_clock());
|
||||
of_property_write_u32(node, "clock-frequency", get_cpu_clock());
|
||||
|
||||
node = of_find_node_by_path(root, "/soc5200@f0000000");
|
||||
node = of_find_node_by_path("/soc5200@f0000000");
|
||||
if (!node)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ static int do_of_node(int argc, char *argv[])
|
|||
if (!path)
|
||||
return COMMAND_ERROR_USAGE;
|
||||
|
||||
node = of_find_node_by_path(root, path);
|
||||
node = of_find_node_by_path(path);
|
||||
if (!node) {
|
||||
printf("Cannot find nodepath %s\n", path);
|
||||
return -ENOENT;
|
||||
|
|
|
@ -175,7 +175,7 @@ static int do_of_property(int argc, char *argv[])
|
|||
int set = 0;
|
||||
int ret;
|
||||
char *path = NULL, *propname = NULL;
|
||||
struct device_node *root, *node = NULL;
|
||||
struct device_node *node = NULL;
|
||||
struct property *pp = NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ds")) > 0) {
|
||||
|
@ -194,15 +194,9 @@ static int do_of_property(int argc, char *argv[])
|
|||
if (optind == argc)
|
||||
return COMMAND_ERROR_USAGE;
|
||||
|
||||
root = of_get_root_node();
|
||||
if (!root) {
|
||||
printf("root node not set\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
path = argv[optind];
|
||||
node = of_find_node_by_path(root, path);
|
||||
node = of_find_node_by_path(path);
|
||||
if (!node) {
|
||||
printf("Cannot find nodepath %s\n", path);
|
||||
return -ENOENT;
|
||||
|
@ -212,7 +206,7 @@ static int do_of_property(int argc, char *argv[])
|
|||
if (optind + 1 < argc) {
|
||||
propname = argv[optind + 1];
|
||||
|
||||
pp = of_find_property(node, propname);
|
||||
pp = of_find_property(node, propname, NULL);
|
||||
if (!set && !pp) {
|
||||
printf("Cannot find property %s\n", propname);
|
||||
return -ENOENT;
|
||||
|
|
|
@ -164,16 +164,7 @@ static int do_oftree(int argc, char *argv[])
|
|||
of_print_nodes(root, 0);
|
||||
of_free(root);
|
||||
} else {
|
||||
struct device_node *root, *n;
|
||||
|
||||
root = of_get_root_node();
|
||||
if (!root) {
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
n = of_find_node_by_path(root, node);
|
||||
|
||||
struct device_node *n = of_find_node_by_path(node);
|
||||
if (!n) {
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
|
|
|
@ -100,7 +100,7 @@ void of_print_property(const void *data, int len)
|
|||
|
||||
void of_print_cmdline(struct device_node *root)
|
||||
{
|
||||
struct device_node *node = of_find_node_by_path(root, "/chosen");
|
||||
struct device_node *node = of_find_node_by_path("/chosen");
|
||||
const char *cmdline;
|
||||
|
||||
if (!node) {
|
||||
|
|
|
@ -278,7 +278,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
|
|||
if (!IS_ENABLED(CONFIG_OFDEVICE) || !adap->dev.device_node)
|
||||
return;
|
||||
|
||||
device_node_for_nach_child(adap->dev.device_node, n) {
|
||||
for_each_child_of_node(adap->dev.device_node, n) {
|
||||
struct i2c_board_info info = {};
|
||||
struct i2c_client *result;
|
||||
const __be32 *addr;
|
||||
|
|
|
@ -116,7 +116,7 @@ static struct stmpe_platform_data *stmpe_of_probe(struct device_d *dev)
|
|||
|
||||
pdata = xzalloc(sizeof(*pdata));
|
||||
|
||||
device_node_for_nach_child(dev->device_node, node) {
|
||||
for_each_child_of_node(dev->device_node, node) {
|
||||
if (!strcmp(node->name, "stmpe_gpio")) {
|
||||
pdata->blocks |= STMPE_BLOCK_GPIO;
|
||||
}
|
||||
|
|
1274
drivers/of/base.c
1274
drivers/of/base.c
File diff suppressed because it is too large
Load Diff
|
@ -61,7 +61,7 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
|
|||
int len; /* length of the property */
|
||||
const struct fdt_property *fdt_prop;
|
||||
const char *pathp, *name;
|
||||
struct device_node *node = NULL, *n;
|
||||
struct device_node *node = NULL;
|
||||
struct property *p;
|
||||
uint32_t dt_struct;
|
||||
struct fdt_node_header *fnh;
|
||||
|
@ -135,9 +135,10 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
|
|||
if (!node) {
|
||||
node = root;
|
||||
} else {
|
||||
if (merge && (n = of_find_child_by_name(node, pathp)))
|
||||
node = n;
|
||||
else
|
||||
if (merge)
|
||||
node = of_get_child_by_name(node,
|
||||
pathp);
|
||||
if (!merge || !node)
|
||||
node = of_new_node(node, pathp);
|
||||
}
|
||||
|
||||
|
@ -178,7 +179,10 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (merge && (p = of_find_property(node, name))) {
|
||||
p = NULL;
|
||||
if (merge)
|
||||
p = of_find_property(node, name, NULL);
|
||||
if (merge && p) {
|
||||
free(p->value);
|
||||
p->value = xzalloc(len);
|
||||
memcpy(p->value, nodep, len);
|
||||
|
|
|
@ -9,17 +9,16 @@ int of_get_named_gpio(struct device_node *np,
|
|||
const char *propname, int index)
|
||||
{
|
||||
int ret;
|
||||
struct device_node *gpio_np;
|
||||
const void *gpio_spec;
|
||||
struct of_phandle_args out_args;
|
||||
|
||||
ret = of_parse_phandles_with_args(np, propname, "#gpio-cells", index,
|
||||
&gpio_np, &gpio_spec);
|
||||
ret = of_parse_phandle_with_args(np, propname, "#gpio-cells",
|
||||
index, &out_args);
|
||||
if (ret) {
|
||||
pr_debug("%s: can't parse gpios property: %d\n", __func__, ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = gpio_get_num(gpio_np->device, be32_to_cpup(gpio_spec));
|
||||
ret = gpio_get_num(out_args.np->device, out_args.args[0]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -76,15 +76,15 @@ const void *of_get_mac_address(struct device_node *np)
|
|||
{
|
||||
struct property *pp;
|
||||
|
||||
pp = of_find_property(np, "mac-address");
|
||||
pp = of_find_property(np, "mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "local-mac-address");
|
||||
pp = of_find_property(np, "local-mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "address");
|
||||
pp = of_find_property(np, "address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
|
|||
const char *partname;
|
||||
char *filename;
|
||||
|
||||
device_node_for_nach_child(node, n) {
|
||||
for_each_child_of_node(node, n) {
|
||||
const __be32 *reg;
|
||||
unsigned long offset, size;
|
||||
const char *name;
|
||||
|
|
|
@ -64,14 +64,14 @@ int pinctrl_select_state(struct device_d *dev, const char *name)
|
|||
if (!np)
|
||||
return 0;
|
||||
|
||||
if (!of_find_property(np, "pinctrl-0"))
|
||||
if (!of_find_property(np, "pinctrl-0", NULL))
|
||||
return 0;
|
||||
|
||||
/* For each defined state ID */
|
||||
for (state = 0; ; state++) {
|
||||
/* Retrieve the pinctrl-* property */
|
||||
propname = asprintf("pinctrl-%d", state);
|
||||
prop = of_find_property(np, propname);
|
||||
prop = of_find_property(np, propname, NULL);
|
||||
free(propname);
|
||||
|
||||
if (!prop) {
|
||||
|
|
|
@ -107,22 +107,22 @@ void spi_of_register_slaves(struct spi_master *master, struct device_node *node)
|
|||
struct spi_board_info chip;
|
||||
struct property *reg;
|
||||
|
||||
device_node_for_nach_child(node, n) {
|
||||
for_each_child_of_node(node, n) {
|
||||
memset(&chip, 0, sizeof(chip));
|
||||
chip.name = xstrdup(n->name);
|
||||
chip.bus_num = master->bus_num;
|
||||
/* Mode (clock phase/polarity/etc.) */
|
||||
if (of_find_property(n, "spi-cpha"))
|
||||
if (of_find_property(n, "spi-cpha", NULL))
|
||||
chip.mode |= SPI_CPHA;
|
||||
if (of_find_property(n, "spi-cpol"))
|
||||
if (of_find_property(n, "spi-cpol", NULL))
|
||||
chip.mode |= SPI_CPOL;
|
||||
if (of_find_property(n, "spi-cs-high"))
|
||||
if (of_find_property(n, "spi-cs-high", NULL))
|
||||
chip.mode |= SPI_CS_HIGH;
|
||||
if (of_find_property(n, "spi-3wire"))
|
||||
if (of_find_property(n, "spi-3wire", NULL))
|
||||
chip.mode |= SPI_3WIRE;
|
||||
of_property_read_u32(n, "spi-max-frequency",
|
||||
&chip.max_speed_hz);
|
||||
reg = of_find_property(n, "reg");
|
||||
reg = of_find_property(n, "reg", NULL);
|
||||
if (!reg)
|
||||
continue;
|
||||
chip.chip_select = of_read_number(reg->value, 1);
|
||||
|
|
|
@ -76,16 +76,15 @@ static int imx_chipidea_port_post_init(void *drvdata)
|
|||
|
||||
static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
|
||||
{
|
||||
const void *out_args;
|
||||
struct device_node *usbmisc_np;
|
||||
struct of_phandle_args out_args;
|
||||
enum usb_dr_mode mode;
|
||||
enum usb_phy_interface phymode;
|
||||
|
||||
of_parse_phandles_with_args(ci->dev->device_node, "fsl,usbmisc",
|
||||
"#index-cells", 0, &usbmisc_np, &out_args);
|
||||
|
||||
ci->portno = be32_to_cpup(out_args);
|
||||
if (of_parse_phandle_with_args(ci->dev->device_node, "fsl,usbmisc",
|
||||
"#index-cells", 0, &out_args))
|
||||
return -ENODEV;
|
||||
|
||||
ci->portno = out_args.args[0];
|
||||
ci->flags = MXC_EHCI_MODE_UTMI_8BIT;
|
||||
|
||||
mode = of_usb_get_dr_mode(ci->dev->device_node, NULL);
|
||||
|
@ -122,7 +121,8 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (of_find_property(ci->dev->device_node, "disable-over-current"))
|
||||
if (of_find_property(ci->dev->device_node,
|
||||
"disable-over-current", NULL))
|
||||
ci->flags |= MXC_EHCI_DISABLE_OVERCURRENT;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -53,6 +53,15 @@ extern int strcmp(const char *,const char *);
|
|||
#ifndef __HAVE_ARCH_STRNCMP
|
||||
extern int strncmp(const char *,const char *,__kernel_size_t);
|
||||
#endif
|
||||
#ifndef __HAVE_ARCH_STRNICMP
|
||||
extern int strnicmp(const char *, const char *, __kernel_size_t);
|
||||
#endif
|
||||
#ifndef __HAVE_ARCH_STRCASECMP
|
||||
extern int strcasecmp(const char *s1, const char *s2);
|
||||
#endif
|
||||
#ifndef __HAVE_ARCH_STRNCASECMP
|
||||
extern int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
#endif
|
||||
#ifndef __HAVE_ARCH_STRCHR
|
||||
extern char * _strchr(const char *,int);
|
||||
#endif
|
||||
|
|
620
include/of.h
620
include/of.h
|
@ -5,6 +5,11 @@
|
|||
#include <errno.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
/* Default string compare functions */
|
||||
#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
|
||||
#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
|
||||
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
|
||||
|
||||
#define OF_BAD_ADDR ((u64)-1)
|
||||
|
||||
typedef u32 phandle;
|
||||
|
@ -37,6 +42,13 @@ struct of_device_id {
|
|||
unsigned long data;
|
||||
};
|
||||
|
||||
#define MAX_PHANDLE_ARGS 8
|
||||
struct of_phandle_args {
|
||||
struct device_node *np;
|
||||
int args_count;
|
||||
uint32_t args[MAX_PHANDLE_ARGS];
|
||||
};
|
||||
|
||||
#define OF_MAX_RESERVE_MAP 16
|
||||
struct of_reserve_map {
|
||||
uint64_t start[OF_MAX_RESERVE_MAP];
|
||||
|
@ -59,32 +71,10 @@ int of_match(struct device_d *dev, struct driver_d *drv);
|
|||
int of_add_initrd(struct device_node *root, resource_size_t start,
|
||||
resource_size_t end);
|
||||
|
||||
int of_n_addr_cells(struct device_node *np);
|
||||
int of_n_size_cells(struct device_node *np);
|
||||
|
||||
struct property *of_find_property(const struct device_node *node, const char *name);
|
||||
|
||||
struct device_node *of_find_node_by_path(struct device_node *root, const char *path);
|
||||
|
||||
struct device_node *of_find_child_by_name(struct device_node *node, const char *name);
|
||||
|
||||
struct fdt_header *fdt_get_tree(void);
|
||||
|
||||
struct fdt_header *of_get_fixed_tree(struct device_node *node);
|
||||
|
||||
int of_modalias_node(struct device_node *node, char *modalias, int len);
|
||||
|
||||
#define device_node_for_nach_child(node, child) \
|
||||
list_for_each_entry(child, &node->children, parent_list)
|
||||
|
||||
/*
|
||||
* Iterate over all nodes of a tree. As a devicetree does not
|
||||
* have a dedicated list head, the start node (usually the root
|
||||
* node) will not be iterated over.
|
||||
*/
|
||||
#define of_tree_for_each_node(node, root) \
|
||||
list_for_each_entry(node, &root->list, list)
|
||||
|
||||
/* Helper to read a big number; size is in cells (not bytes) */
|
||||
static inline u64 of_read_number(const __be32 *cell, int size)
|
||||
{
|
||||
|
@ -105,48 +95,12 @@ static inline void of_write_number(void *__cell, u64 val, int size)
|
|||
}
|
||||
}
|
||||
|
||||
int of_property_read_u32_array(const struct device_node *np,
|
||||
const char *propname, u32 *out_values,
|
||||
size_t sz);
|
||||
|
||||
static inline int of_property_read_u32(const struct device_node *np,
|
||||
const char *propname,
|
||||
u32 *out_value)
|
||||
{
|
||||
return of_property_read_u32_array(np, propname, out_value, 1);
|
||||
}
|
||||
|
||||
int of_property_write_u32_array(struct device_node *np,
|
||||
const char *propname, const u32 *values,
|
||||
size_t sz);
|
||||
|
||||
static inline int of_property_write_u32(struct device_node *np,
|
||||
const char *propname,
|
||||
u32 value)
|
||||
{
|
||||
return of_property_write_u32_array(np, propname, &value, 1);
|
||||
}
|
||||
|
||||
const void *of_get_property(const struct device_node *np, const char *name,
|
||||
int *lenp);
|
||||
|
||||
int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
|
||||
const char *cells_name, int index,
|
||||
struct device_node **out_node,
|
||||
const void **out_args);
|
||||
|
||||
int of_get_named_gpio(struct device_node *np,
|
||||
const char *propname, int index);
|
||||
|
||||
struct device_node *of_find_node_by_phandle(phandle phandle);
|
||||
void of_print_property(const void *data, int len);
|
||||
void of_print_cmdline(struct device_node *root);
|
||||
|
||||
int of_device_is_compatible(const struct device_node *device,
|
||||
const char *compat);
|
||||
|
||||
int of_machine_is_compatible(const char *compat);
|
||||
|
||||
u64 of_translate_address(struct device_node *node, const __be32 *in_addr);
|
||||
|
||||
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
||||
|
@ -155,40 +109,130 @@ u64 of_translate_address(struct device_node *node, const __be32 *in_addr);
|
|||
void of_print_nodes(struct device_node *node, int indent);
|
||||
int of_probe(void);
|
||||
int of_parse_dtb(struct fdt_header *fdt);
|
||||
void of_free(struct device_node *node);
|
||||
struct device_node *of_unflatten_dtb(struct device_node *root, void *fdt);
|
||||
struct device_node *of_new_node(struct device_node *parent, const char *name);
|
||||
struct property *of_new_property(struct device_node *node, const char *name,
|
||||
const void *data, int len);
|
||||
void of_delete_property(struct property *pp);
|
||||
|
||||
int of_property_read_string(struct device_node *np, const char *propname,
|
||||
const char **out_string);
|
||||
int of_property_read_string_index(struct device_node *np, const char *propname,
|
||||
int index, const char **output);
|
||||
int of_set_property(struct device_node *node, const char *p, const void *val, int len,
|
||||
int create);
|
||||
struct device_node *of_create_node(struct device_node *root, const char *path);
|
||||
|
||||
int of_set_root_node(struct device_node *);
|
||||
|
||||
const struct of_device_id *of_match_node(const struct of_device_id *matches,
|
||||
const struct device_node *node);
|
||||
|
||||
struct cdev;
|
||||
|
||||
#ifdef CONFIG_OFTREE
|
||||
int of_parse_partitions(struct cdev *cdev, struct device_node *node);
|
||||
extern int of_n_addr_cells(struct device_node *np);
|
||||
extern int of_n_size_cells(struct device_node *np);
|
||||
|
||||
int of_alias_get_id(struct device_node *np, const char *stem);
|
||||
const char *of_alias_get(struct device_node *np);
|
||||
extern struct property *of_find_property(const struct device_node *np,
|
||||
const char *name, int *lenp);
|
||||
extern const void *of_get_property(const struct device_node *np,
|
||||
const char *name, int *lenp);
|
||||
|
||||
extern int of_set_property(struct device_node *node, const char *p,
|
||||
const void *val, int len, int create);
|
||||
extern struct property *of_new_property(struct device_node *node,
|
||||
const char *name, const void *data, int len);
|
||||
extern void of_delete_property(struct property *pp);
|
||||
|
||||
extern struct device_node *of_find_node_by_name(struct device_node *from,
|
||||
const char *name);
|
||||
extern struct device_node *of_find_node_by_path_from(struct device_node *from,
|
||||
const char *path);
|
||||
extern struct device_node *of_find_node_by_path(const char *path);
|
||||
extern struct device_node *of_find_node_by_phandle(phandle phandle);
|
||||
extern struct device_node *of_find_compatible_node(struct device_node *from,
|
||||
const char *type, const char *compat);
|
||||
extern const struct of_device_id *of_match_node(
|
||||
const struct of_device_id *matches, const struct device_node *node);
|
||||
extern struct device_node *of_find_matching_node_and_match(
|
||||
struct device_node *from,
|
||||
const struct of_device_id *matches,
|
||||
const struct of_device_id **match);
|
||||
extern struct device_node *of_find_node_with_property(
|
||||
struct device_node *from, const char *prop_name);
|
||||
|
||||
extern struct device_node *of_new_node(struct device_node *parent,
|
||||
const char *name);
|
||||
extern struct device_node *of_create_node(struct device_node *root,
|
||||
const char *path);
|
||||
extern void of_free(struct device_node *node);
|
||||
|
||||
extern int of_machine_is_compatible(const char *compat);
|
||||
extern int of_device_is_compatible(const struct device_node *device,
|
||||
const char *compat);
|
||||
extern int of_device_is_available(const struct device_node *device);
|
||||
|
||||
extern struct device_node *of_get_parent(const struct device_node *node);
|
||||
extern struct device_node *of_get_next_available_child(
|
||||
const struct device_node *node, struct device_node *prev);
|
||||
extern int of_get_child_count(const struct device_node *parent);
|
||||
extern int of_get_available_child_count(const struct device_node *parent);
|
||||
extern struct device_node *of_get_child_by_name(const struct device_node *node,
|
||||
const char *name);
|
||||
|
||||
extern int of_property_read_u32_index(const struct device_node *np,
|
||||
const char *propname,
|
||||
u32 index, u32 *out_value);
|
||||
extern int of_property_read_u8_array(const struct device_node *np,
|
||||
const char *propname, u8 *out_values, size_t sz);
|
||||
extern int of_property_read_u16_array(const struct device_node *np,
|
||||
const char *propname, u16 *out_values, size_t sz);
|
||||
extern int of_property_read_u32_array(const struct device_node *np,
|
||||
const char *propname,
|
||||
u32 *out_values,
|
||||
size_t sz);
|
||||
extern int of_property_read_u64(const struct device_node *np,
|
||||
const char *propname, u64 *out_value);
|
||||
|
||||
extern int of_property_read_string(struct device_node *np,
|
||||
const char *propname,
|
||||
const char **out_string);
|
||||
extern int of_property_read_string_index(struct device_node *np,
|
||||
const char *propname,
|
||||
int index, const char **output);
|
||||
extern int of_property_match_string(struct device_node *np,
|
||||
const char *propname,
|
||||
const char *string);
|
||||
extern int of_property_count_strings(struct device_node *np,
|
||||
const char *propname);
|
||||
|
||||
extern const __be32 *of_prop_next_u32(struct property *prop,
|
||||
const __be32 *cur, u32 *pu);
|
||||
extern const char *of_prop_next_string(struct property *prop, const char *cur);
|
||||
|
||||
extern int of_property_write_bool(struct device_node *np,
|
||||
const char *propname, const bool value);
|
||||
extern int of_property_write_u8_array(struct device_node *np,
|
||||
const char *propname, const u8 *values,
|
||||
size_t sz);
|
||||
extern int of_property_write_u16_array(struct device_node *np,
|
||||
const char *propname, const u16 *values,
|
||||
size_t sz);
|
||||
extern int of_property_write_u32_array(struct device_node *np,
|
||||
const char *propname, const u32 *values,
|
||||
size_t sz);
|
||||
extern int of_property_write_u64_array(struct device_node *np,
|
||||
const char *propname, const u64 *values,
|
||||
size_t sz);
|
||||
|
||||
extern struct device_node *of_parse_phandle(const struct device_node *np,
|
||||
const char *phandle_name,
|
||||
int index);
|
||||
extern int of_parse_phandle_with_args(const struct device_node *np,
|
||||
const char *list_name, const char *cells_name, int index,
|
||||
struct of_phandle_args *out_args);
|
||||
extern int of_count_phandle_with_args(const struct device_node *np,
|
||||
const char *list_name, const char *cells_name);
|
||||
|
||||
extern void of_alias_scan(void);
|
||||
extern int of_alias_get_id(struct device_node *np, const char *stem);
|
||||
extern const char *of_alias_get(struct device_node *np);
|
||||
extern int of_modalias_node(struct device_node *node, char *modalias, int len);
|
||||
|
||||
extern struct device_node *of_get_root_node(void);
|
||||
extern int of_set_root_node(struct device_node *node);
|
||||
|
||||
int of_parse_partitions(struct cdev *cdev, struct device_node *node);
|
||||
int of_device_is_stdout_path(struct device_d *dev);
|
||||
const char *of_get_model(void);
|
||||
void *of_flatten_dtb(struct device_node *node);
|
||||
int of_add_memory(struct device_node *node, bool dump);
|
||||
void of_add_memory_bank(struct device_node *node, bool dump, int r,
|
||||
u64 base, u64 size);
|
||||
struct device_node *of_get_root_node(void);
|
||||
#else
|
||||
static inline int of_parse_partitions(struct cdev *cdev,
|
||||
struct device_node *node)
|
||||
|
@ -196,16 +240,6 @@ static inline int of_parse_partitions(struct cdev *cdev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int of_alias_get_id(struct device_node *np, const char *stem)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static inline const char *of_alias_get(struct device_node *np)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_device_is_stdout_path(struct device_d *dev)
|
||||
{
|
||||
return 0;
|
||||
|
@ -230,6 +264,412 @@ static inline struct device_node *of_get_root_node(void)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_set_root_node(struct device_node *node)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_n_addr_cells(struct device_node *np)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int of_n_size_cells(struct device_node *np)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_get_parent(const struct device_node *node)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_get_next_available_child(
|
||||
const struct device_node *node, struct device_node *prev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_get_child_count(const struct device_node *parent)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_get_available_child_count(const struct device_node *parent)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_get_child_by_name(
|
||||
const struct device_node *node, const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct property *of_find_property(const struct device_node *np,
|
||||
const char *name,
|
||||
int *lenp)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const void *of_get_property(const struct device_node *np,
|
||||
const char *name, int *lenp)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_set_property(struct device_node *node, const char *p,
|
||||
const void *val, int len, int create)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline struct property *of_new_property(struct device_node *node,
|
||||
const char *name, const void *data, int len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void of_delete_property(struct property *pp)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int of_property_read_u32_index(const struct device_node *np,
|
||||
const char *propname, u32 index, u32 *out_value)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_read_u8_array(const struct device_node *np,
|
||||
const char *propname, u8 *out_values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_read_u16_array(const struct device_node *np,
|
||||
const char *propname, u16 *out_values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_read_u32_array(const struct device_node *np,
|
||||
const char *propname, u32 *out_values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_read_u64(const struct device_node *np,
|
||||
const char *propname, u64 *out_value)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_read_string(struct device_node *np,
|
||||
const char *propname, const char **out_string)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_read_string_index(struct device_node *np,
|
||||
const char *propname, int index, const char **output)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_match_string(struct device_node *np,
|
||||
const char *propname, const char *string)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_count_strings(struct device_node *np,
|
||||
const char *propname)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline const __be32 *of_prop_next_u32(struct property *prop,
|
||||
const __be32 *cur, u32 *pu)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline const char *of_prop_next_string(struct property *prop,
|
||||
const char *cur)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_property_write_bool(struct device_node *np,
|
||||
const char *propname, const bool value)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_write_u8_array(struct device_node *np,
|
||||
const char *propname, const u8 *values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_write_u16_array(struct device_node *np,
|
||||
const char *propname, const u16 *values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_write_u32_array(struct device_node *np,
|
||||
const char *propname, const u32 *values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_property_write_u64_array(struct device_node *np,
|
||||
const char *propname, const u64 *values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_parse_phandle(const struct device_node *np,
|
||||
const char *phandle_name, int index)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_parse_phandle_with_args(const struct device_node *np,
|
||||
const char *list_name, const char *cells_name, int index,
|
||||
struct of_phandle_args *out_args)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int of_count_phandle_with_args(const struct device_node *np,
|
||||
const char *list_name, const char *cells_name)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_node_by_path_from(
|
||||
struct device_node *from, const char *path)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_node_by_path(const char *path)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_node_by_name(struct device_node *from,
|
||||
const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_node_by_phandle(phandle phandle)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_compatible_node(
|
||||
struct device_node *from,
|
||||
const char *type,
|
||||
const char *compat)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const struct of_device_id *of_match_node(
|
||||
const struct of_device_id *matches, const struct device_node *node)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_matching_node_and_match(
|
||||
struct device_node *from,
|
||||
const struct of_device_id *matches,
|
||||
const struct of_device_id **match)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_find_node_with_property(
|
||||
struct device_node *from, const char *prop_name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_new_node(struct device_node *parent,
|
||||
const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device_node *of_create_node(struct device_node *root,
|
||||
const char *path)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void of_free(struct device_node *node)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int of_machine_is_compatible(const char *compat)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int of_device_is_compatible(const struct device_node *device,
|
||||
const char *compat)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int of_device_is_available(const struct device_node *device)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void of_alias_scan(void)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int of_alias_get_id(struct device_node *np, const char *stem)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline const char *of_alias_get(struct device_node *np)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int of_modalias_node(struct device_node *node, char *modalias,
|
||||
int len)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define for_each_node_by_name(dn, name) \
|
||||
for (dn = of_find_node_by_name(NULL, name); dn; \
|
||||
dn = of_find_node_by_name(dn, name))
|
||||
#define for_each_compatible_node(dn, type, compatible) \
|
||||
for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
|
||||
dn = of_find_compatible_node(dn, type, compatible))
|
||||
static inline struct device_node *of_find_matching_node(
|
||||
struct device_node *from,
|
||||
const struct of_device_id *matches)
|
||||
{
|
||||
return of_find_matching_node_and_match(from, matches, NULL);
|
||||
}
|
||||
#define for_each_matching_node(dn, matches) \
|
||||
for (dn = of_find_matching_node(NULL, matches); dn; \
|
||||
dn = of_find_matching_node(dn, matches))
|
||||
#define for_each_matching_node_and_match(dn, matches, match) \
|
||||
for (dn = of_find_matching_node_and_match(NULL, matches, match); \
|
||||
dn; dn = of_find_matching_node_and_match(dn, matches, match))
|
||||
#define for_each_node_with_property(dn, prop_name) \
|
||||
for (dn = of_find_node_with_property(NULL, prop_name); dn; \
|
||||
dn = of_find_node_with_property(dn, prop_name))
|
||||
|
||||
#define for_each_child_of_node(parent, child) \
|
||||
list_for_each_entry(child, &parent->children, parent_list)
|
||||
#define for_each_available_child_of_node(parent, child) \
|
||||
for (child = of_get_next_available_child(parent, NULL); child != NULL; \
|
||||
child = of_get_next_available_child(parent, child))
|
||||
|
||||
/**
|
||||
* of_property_read_bool - Findfrom 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 property in a device node.
|
||||
* Returns true if the property exist false otherwise.
|
||||
*/
|
||||
static inline bool of_property_read_bool(const struct device_node *np,
|
||||
const char *propname)
|
||||
{
|
||||
struct property *prop = of_find_property(np, propname, NULL);
|
||||
|
||||
return prop ? true : false;
|
||||
}
|
||||
|
||||
static inline int of_property_read_u8(const struct device_node *np,
|
||||
const char *propname,
|
||||
u8 *out_value)
|
||||
{
|
||||
return of_property_read_u8_array(np, propname, out_value, 1);
|
||||
}
|
||||
|
||||
static inline int of_property_read_u16(const struct device_node *np,
|
||||
const char *propname,
|
||||
u16 *out_value)
|
||||
{
|
||||
return of_property_read_u16_array(np, propname, out_value, 1);
|
||||
}
|
||||
|
||||
static inline int of_property_read_u32(const struct device_node *np,
|
||||
const char *propname,
|
||||
u32 *out_value)
|
||||
{
|
||||
return of_property_read_u32_array(np, propname, out_value, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* struct property *prop;
|
||||
* const __be32 *p;
|
||||
* u32 u;
|
||||
*
|
||||
* of_property_for_each_u32(np, "propname", prop, p, u)
|
||||
* printk("U32 value: %x\n", u);
|
||||
*/
|
||||
#define of_property_for_each_u32(np, propname, prop, p, u) \
|
||||
for (prop = of_find_property(np, propname, NULL), \
|
||||
p = of_prop_next_u32(prop, NULL, &u); \
|
||||
p; \
|
||||
p = of_prop_next_u32(prop, p, &u))
|
||||
|
||||
/*
|
||||
* struct property *prop;
|
||||
* const char *s;
|
||||
*
|
||||
* of_property_for_each_string(np, "propname", prop, s)
|
||||
* printk("String value: %s\n", s);
|
||||
*/
|
||||
#define of_property_for_each_string(np, propname, prop, s) \
|
||||
for (prop = of_find_property(np, propname, NULL), \
|
||||
s = of_prop_next_string(prop, NULL); \
|
||||
s; \
|
||||
s = of_prop_next_string(prop, s))
|
||||
|
||||
static inline int of_property_write_u8(struct device_node *np,
|
||||
const char *propname, u8 value)
|
||||
{
|
||||
return of_property_write_u8_array(np, propname, &value, 1);
|
||||
}
|
||||
|
||||
static inline int of_property_write_u16(struct device_node *np,
|
||||
const char *propname, u16 value)
|
||||
{
|
||||
return of_property_write_u16_array(np, propname, &value, 1);
|
||||
}
|
||||
|
||||
static inline int of_property_write_u32(struct device_node *np,
|
||||
const char *propname,
|
||||
u32 value)
|
||||
{
|
||||
return of_property_write_u32_array(np, propname, &value, 1);
|
||||
}
|
||||
|
||||
static inline int of_property_write_u64(struct device_node *np,
|
||||
const char *propname,
|
||||
u64 value)
|
||||
{
|
||||
return of_property_write_u64_array(np, propname, &value, 1);
|
||||
}
|
||||
|
||||
#endif /* __OF_H */
|
||||
|
|
60
lib/string.c
60
lib/string.c
|
@ -22,6 +22,66 @@
|
|||
|
||||
char * ___strtok;
|
||||
|
||||
#ifndef __HAVE_ARCH_STRNICMP
|
||||
/**
|
||||
* strnicmp - Case insensitive, length-limited string comparison
|
||||
* @s1: One string
|
||||
* @s2: The other string
|
||||
* @len: the maximum number of characters to compare
|
||||
*/
|
||||
int strnicmp(const char *s1, const char *s2, size_t len)
|
||||
{
|
||||
/* Yes, Virginia, it had better be unsigned */
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
if (!c1 || !c2)
|
||||
break;
|
||||
if (c1 == c2)
|
||||
continue;
|
||||
c1 = tolower(c1);
|
||||
c2 = tolower(c2);
|
||||
if (c1 != c2)
|
||||
break;
|
||||
} while (--len);
|
||||
return (int)c1 - (int)c2;
|
||||
}
|
||||
EXPORT_SYMBOL(strnicmp);
|
||||
#endif
|
||||
|
||||
#ifndef __HAVE_ARCH_STRCASECMP
|
||||
int strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
do {
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
} while (c1 == c2 && c1 != 0);
|
||||
return c1 - c2;
|
||||
}
|
||||
EXPORT_SYMBOL(strcasecmp);
|
||||
#endif
|
||||
|
||||
#ifndef __HAVE_ARCH_STRNCASECMP
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
do {
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
} while ((--n > 0) && c1 == c2 && c1 != 0);
|
||||
return c1 - c2;
|
||||
}
|
||||
EXPORT_SYMBOL(strncasecmp);
|
||||
#endif
|
||||
|
||||
#ifndef __HAVE_ARCH_STRCPY
|
||||
/**
|
||||
* strcpy - Copy a %NUL terminated string
|
||||
|
|
Loading…
Reference in New Issue