mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: linux-mips@vger.kernel.org
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Rob Herring <robh+dt@kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Huacai Chen <chenhc@lemote.com>,
	Frank Rowand <frowand.list@gmail.com>,
	Paul Burton <paulburton@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Arnd Bergmann <arnd@arndb.de>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] of_address: Add bus type match for pci ranges parser
Date: Mon, 20 Jul 2020 15:42:34 +0800	[thread overview]
Message-ID: <20200720074249.596364-2-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20200720074249.596364-1-jiaxun.yang@flygoat.com>

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@flygoat.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


  reply	other threads:[~2020-07-20  7:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20  7:42 [PATCH 0/5] MIPS: Loongson64: Process ISA Node in DeviceTree Jiaxun Yang
2020-07-20  7:42 ` Jiaxun Yang [this message]
2020-07-21  0:21   ` [PATCH 1/5] of_address: Add bus type match for pci ranges parser Rob Herring
2020-07-20  7:42 ` [PATCH 2/5] MIPS: Loongson64: Process ISA Node in DeviceTree Jiaxun Yang
2020-07-20 10:01   ` Huacai Chen
2020-07-20 10:18     ` Jiaxun Yang
2020-07-20 11:44       ` Huacai Chen
2020-07-20 11:58         ` Jiaxun Yang
2020-07-21  0:27   ` Rob Herring
2020-07-20  7:42 ` [PATCH 3/5] MIPS: Loongson64: Enlarge IO_SPACE_LIMIT Jiaxun Yang
2020-07-20 10:03   ` Huacai Chen
2020-07-20 10:45   ` Arnd Bergmann
2020-07-20 12:04     ` Jiaxun Yang
2020-07-20 12:20       ` Arnd Bergmann
2020-07-20  7:42 ` [PATCH 4/5] MIPS: Loongson64: DTS: Fix ISA range for RS780E PCH Jiaxun Yang
2020-07-20  7:42 ` [PATCH 5/5] MIPS: Loongson64: Add ISA node for LS7A PCH Jiaxun Yang
2020-07-20 10:04   ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200720074249.596364-2-jiaxun.yang@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=arnd@arndb.de \
    --cc=chenhc@lemote.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=paulburton@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®