[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200720074249.596364-2-jiaxun.yang@flygoat.com>
Date: Mon, 20 Jul 2020 15:42:34 +0800
From: Jiaxun Yang <jiaxun.yang@...goat.com>
To: linux-mips@...r.kernel.org
Cc: Jiaxun Yang <jiaxun.yang@...goat.com>,
Rob Herring <robh+dt@...nel.org>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Huacai Chen <chenhc@...ote.com>,
Frank Rowand <frowand.list@...il.com>,
Paul Burton <paulburton@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Arnd Bergmann <arnd@...db.de>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/5] of_address: Add bus type match for pci ranges parser
So the parser can be used to parse range property of different bus
types, such as ISA bus.
As they're all using PCI-like method of range property, there is no need
start a new parser.
Signed-off-by: Jiaxun Yang <jiaxun.yang@...goat.com>
---
drivers/of/address.c | 15 +++++++++++----
include/linux/of_address.h | 3 +++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 8eea3f6e29a4..250c91767648 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -702,6 +702,10 @@ static int parser_init(struct of_pci_range_parser *parser,
parser->ns = of_bus_n_size_cells(node);
parser->dma = !strcmp(name, "dma-ranges");
+ parser->bus = of_match_bus(node);
+ if (!parser->bus)
+ return -ENOENT;
+
parser->range = of_get_property(node, name, &rlen);
if (parser->range == NULL)
return -ENOENT;
@@ -732,6 +736,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
int na = parser->na;
int ns = parser->ns;
int np = parser->pna + na + ns;
+ int bus_na = 0;
if (!range)
return NULL;
@@ -739,8 +744,10 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
if (!parser->range || parser->range + np > parser->end)
return NULL;
- if (parser->na == 3)
- range->flags = of_bus_pci_get_flags(parser->range);
+ parser->bus->count_cells(parser->node, &bus_na, NULL);
+
+ if (parser->na == bus_na)
+ range->flags = parser->bus->get_flags(parser->range);
else
range->flags = 0;
@@ -761,8 +768,8 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
u32 flags = 0;
u64 pci_addr, cpu_addr, size;
- if (parser->na == 3)
- flags = of_bus_pci_get_flags(parser->range);
+ if (parser->na == bus_na)
+ flags = parser->bus->get_flags(parser->range);
pci_addr = of_read_number(parser->range, na);
if (parser->dma)
cpu_addr = of_translate_dma_address(parser->node,
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 763022ed3456..3929b4637033 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -6,8 +6,11 @@
#include <linux/of.h>
#include <linux/io.h>
+struct of_bus;
+
struct of_pci_range_parser {
struct device_node *node;
+ struct of_bus *bus;
const __be32 *range;
const __be32 *end;
int na;
--
2.28.0.rc1
Powered by blists - more mailing lists