/* * Translate OpenFirmware node properties into platform_data */ static int gpio_ir_recv_get_devtree_pdata(struct device *dev, struct gpio_ir_recv_platform_data *pdata) { struct device_node *np = dev->of_node; enum of_gpio_flags flags; int gpio; gpio = of_get_gpio_flags(np, 0, &flags); if (gpio < 0) { if (gpio != -EPROBE_DEFER) dev_err(dev, "Failed to get gpio flags (%d)\n", gpio); return gpio; } pdata->gpio_nr = gpio; pdata->active_low = (flags & OF_GPIO_ACTIVE_LOW); if (of_property_read_u32(np, "min-delay", &pdata->min_delay)) pdata->min_delay = 0; /* probe() takes care of map_name == NULL or allowed_protos == 0 */ pdata->map_name = of_get_property(np, "linux,rc-map-name", NULL); if (of_property_read_u64(np, "allowed-protos", &pdata->allowed_protos)) pdata->allowed_protos = 0; return 0; }
static int bootloader_time_checker_probe(struct platform_device *pdev) { int ret = 0; uint64_t temp; struct device_node *node; data = kmalloc(sizeof(struct bootloader_time_checker_data), GFP_KERNEL); node = of_find_node_by_path("/chosen"); if (node == NULL) { pr_err("%s: of_find_node_by_path failed\n", __func__); return -EINVAL; } of_property_read_u32(node, "lge,sbl_delta_time", (u32 *)&data->sbl_time); if (data->sbl_time < 0) { pr_err("Wroing SBL Time. Please check 'lge,sbl_delta_time'\n"); data->sbl_time = 0; } of_property_read_u64(node, "lge,lk_delta_time", &temp); data->lk_time = (uint32_t)temp; if (data->lk_time < 0) { pr_err("Wroing LK Time. Please check 'lge,lk_delta_time'\n"); data->lk_time = 0; } return ret; }
static int __init smp_spin_table_init_cpu(struct device_node *dn, int cpu) { /* * Determine the address from which the CPU is polling. */ if (of_property_read_u64(dn, "cpu-release-addr", &cpu_release_addr[cpu])) { pr_err("CPU %d: missing or invalid cpu-release-addr property\n", cpu); return -1; } return 0; }
static int smp_spin_table_cpu_init(unsigned int cpu) { struct device_node *dn; dn = of_get_cpu_node(cpu, NULL); if (!dn) return -ENODEV; /* * Determine the address from which the CPU is polling. */ if (of_property_read_u64(dn, "cpu-release-addr", &cpu_release_addr[cpu])) { pr_err("CPU %d: missing or invalid cpu-release-addr property\n", cpu); return -1; } return 0; }
/** * powernv_flash_set_driver_info - Fill the mtd_info structure and docg3 * structure @pdev: The platform device * @mtd: The structure to fill */ static int powernv_flash_set_driver_info(struct device *dev, struct mtd_info *mtd) { u64 size; u32 erase_size; int rc; rc = of_property_read_u32(dev->of_node, "ibm,flash-block-size", &erase_size); if (rc) { dev_err(dev, "couldn't get resource block size information\n"); return rc; } rc = of_property_read_u64(dev->of_node, "reg", &size); if (rc) { dev_err(dev, "couldn't get resource size information\n"); return rc; } /* * Going to have to check what details I need to set and how to * get them */ mtd->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node); mtd->type = MTD_NORFLASH; mtd->flags = MTD_WRITEABLE; mtd->size = size; mtd->erasesize = erase_size; mtd->writebufsize = mtd->writesize = 1; mtd->owner = THIS_MODULE; mtd->_erase = powernv_flash_erase; mtd->_read = powernv_flash_read; mtd->_write = powernv_flash_write; mtd->dev.parent = dev; mtd_set_of_node(mtd, dev->of_node); return 0; }
int get_hw_config_u64(const char *node_name, const char *prop_name, u64 *pvalue) { struct device_node *np; int ret; if(node_name == NULL || prop_name == NULL || pvalue == NULL) { hwlog_err("Invalid Argument, NULL passed\n"); return -EINVAL; } np = of_find_node_by_name(NULL, node_name); if (!np) { hwlog_err("can not get device node with node_name: %s\n", node_name); return -ENODEV; } if(0 == is_property_public(np, prop_name)) { hwlog_err("property to read is not public, permission denied\n"); ret = -EACCES; goto OUT; } ret = of_property_read_u64(np, prop_name, pvalue); if (ret != 0) { hwlog_err("can not get prop values with prop_name: %s\n", prop_name); goto OUT; } OUT: of_node_put(np); return ret; }