mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
ARM: bcm: Use of_address_to_resource()
Replace open coded parsing of "reg" with of_address_to_resource(). Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230319163125.224833-1-robh@kernel.org Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
This commit is contained in:
parent
fe15c26ee2
commit
3c01b05407
1 changed files with 6 additions and 17 deletions
|
@ -31,34 +31,23 @@ static const struct of_device_id bcm_kona_smc_ids[] __initconst = {
|
||||||
int __init bcm_kona_smc_init(void)
|
int __init bcm_kona_smc_init(void)
|
||||||
{
|
{
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
const __be32 *prop_val;
|
struct resource res;
|
||||||
u64 prop_size = 0;
|
int ret;
|
||||||
unsigned long buffer_size;
|
|
||||||
u32 buffer_phys;
|
|
||||||
|
|
||||||
/* Read buffer addr and size from the device tree node */
|
/* Read buffer addr and size from the device tree node */
|
||||||
node = of_find_matching_node(NULL, bcm_kona_smc_ids);
|
node = of_find_matching_node(NULL, bcm_kona_smc_ids);
|
||||||
if (!node)
|
if (!node)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
prop_val = of_get_address(node, 0, &prop_size, NULL);
|
ret = of_address_to_resource(node, 0, &res);
|
||||||
of_node_put(node);
|
of_node_put(node);
|
||||||
if (!prop_val)
|
if (ret)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* We assume space for four 32-bit arguments */
|
bcm_smc_buffer = ioremap(res.start, resource_size(&res));
|
||||||
if (prop_size < 4 * sizeof(u32) || prop_size > (u64)ULONG_MAX)
|
|
||||||
return -EINVAL;
|
|
||||||
buffer_size = (unsigned long)prop_size;
|
|
||||||
|
|
||||||
buffer_phys = be32_to_cpup(prop_val);
|
|
||||||
if (!buffer_phys)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
bcm_smc_buffer = ioremap(buffer_phys, buffer_size);
|
|
||||||
if (!bcm_smc_buffer)
|
if (!bcm_smc_buffer)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
bcm_smc_buffer_phys = buffer_phys;
|
bcm_smc_buffer_phys = res.start;
|
||||||
|
|
||||||
pr_info("Kona Secure API initialized\n");
|
pr_info("Kona Secure API initialized\n");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue