diff mbox series

[5/5] riscv: use for_each_of_cpu_node iterator

Message ID 20190118140308.9599-6-johan@kernel.org (mailing list archive)
State New, archived
Headers show
Series riscv: minor fixes and cleanups | expand

Commit Message

Johan Hovold Jan. 18, 2019, 2:03 p.m. UTC
Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
instead of open coding. Note that this will allow matching also on the
node name instead of the (for FDT) deprecated device_type property.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 arch/riscv/kernel/cpufeature.c | 5 +++--
 arch/riscv/kernel/smpboot.c    | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Feb. 12, 2019, 7:13 a.m. UTC | #1
On Fri, Jan 18, 2019 at 03:03:08PM +0100, Johan Hovold wrote:
> Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
> instead of open coding. Note that this will allow matching also on the
> node name instead of the (for FDT) deprecated device_type property.
> 
> Signed-off-by: Johan Hovold <johan@kernel.org>

I think this is going to conflict with the ELF caps changes from
Atish.  Maybe the riscv_fill_hwcap hunk should be included in his
patch?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Johan Hovold Feb. 12, 2019, 8:26 a.m. UTC | #2
On Mon, Feb 11, 2019 at 11:13:39PM -0800, Christoph Hellwig wrote:
> On Fri, Jan 18, 2019 at 03:03:08PM +0100, Johan Hovold wrote:
> > Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
> > instead of open coding. Note that this will allow matching also on the
> > node name instead of the (for FDT) deprecated device_type property.
> > 
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> 
> I think this is going to conflict with the ELF caps changes from
> Atish.  Maybe the riscv_fill_hwcap hunk should be included in his
> patch?

Since that patch had some issues (e.g. the node reference underflow) it
may be better to rebase it on top of this series. The changes are
otherwise distinct after all.

> Otherwise looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks for reviewing!

Johan
Atish Patra Feb. 12, 2019, 8:47 a.m. UTC | #3
On 2/12/19 12:26 AM, Johan Hovold wrote:
> On Mon, Feb 11, 2019 at 11:13:39PM -0800, Christoph Hellwig wrote:
>> On Fri, Jan 18, 2019 at 03:03:08PM +0100, Johan Hovold wrote:
>>> Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
>>> instead of open coding. Note that this will allow matching also on the
>>> node name instead of the (for FDT) deprecated device_type property.
>>>
>>> Signed-off-by: Johan Hovold <johan@kernel.org>
>>
>> I think this is going to conflict with the ELF caps changes from
>> Atish.  Maybe the riscv_fill_hwcap hunk should be included in his
>> patch?
> 
> Since that patch had some issues (e.g. the node reference underflow) it
> may be better to rebase it on top of this series. The changes are
> otherwise distinct after all.
> 

I have fixed the node reference underflow issue and made some more 
changes based on comments.

Some other patches(1,3,4,5) in this series may conflict with my series 
as well. I can rebase my series on top of yours and send it as one 
series if that's okay with you and Palmer.

Regards,
Atish
>> Otherwise looks good:
>>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Thanks for reviewing!
> 
> Johan
>
Johan Hovold Feb. 12, 2019, 8:53 a.m. UTC | #4
On Tue, Feb 12, 2019 at 12:47:09AM -0800, Atish Patra wrote:
> On 2/12/19 12:26 AM, Johan Hovold wrote:
> > On Mon, Feb 11, 2019 at 11:13:39PM -0800, Christoph Hellwig wrote:
> >> On Fri, Jan 18, 2019 at 03:03:08PM +0100, Johan Hovold wrote:
> >>> Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
> >>> instead of open coding. Note that this will allow matching also on the
> >>> node name instead of the (for FDT) deprecated device_type property.
> >>>
> >>> Signed-off-by: Johan Hovold <johan@kernel.org>
> >>
> >> I think this is going to conflict with the ELF caps changes from
> >> Atish.  Maybe the riscv_fill_hwcap hunk should be included in his
> >> patch?
> > 
> > Since that patch had some issues (e.g. the node reference underflow) it
> > may be better to rebase it on top of this series. The changes are
> > otherwise distinct after all.
> > 
> 
> I have fixed the node reference underflow issue and made some more 
> changes based on comments.
> 
> Some other patches(1,3,4,5) in this series may conflict with my series 
> as well. I can rebase my series on top of yours and send it as one 
> series if that's okay with you and Palmer.

No need for you to resend these patches as they are reviewed any ready
to be merged. Just rebase your series and mention the dependency in the
cover letter as I did with Andreas's patch which this series depended
on.

Thanks,
Johan
Atish Patra Feb. 12, 2019, 9:20 a.m. UTC | #5
On 2/12/19 12:53 AM, Johan Hovold wrote:
> On Tue, Feb 12, 2019 at 12:47:09AM -0800, Atish Patra wrote:
>> On 2/12/19 12:26 AM, Johan Hovold wrote:
>>> On Mon, Feb 11, 2019 at 11:13:39PM -0800, Christoph Hellwig wrote:
>>>> On Fri, Jan 18, 2019 at 03:03:08PM +0100, Johan Hovold wrote:
>>>>> Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
>>>>> instead of open coding. Note that this will allow matching also on the
>>>>> node name instead of the (for FDT) deprecated device_type property.
>>>>>
>>>>> Signed-off-by: Johan Hovold <johan@kernel.org>
>>>>
>>>> I think this is going to conflict with the ELF caps changes from
>>>> Atish.  Maybe the riscv_fill_hwcap hunk should be included in his
>>>> patch?
>>>
>>> Since that patch had some issues (e.g. the node reference underflow) it
>>> may be better to rebase it on top of this series. The changes are
>>> otherwise distinct after all.
>>>
>>
>> I have fixed the node reference underflow issue and made some more
>> changes based on comments.
>>
>> Some other patches(1,3,4,5) in this series may conflict with my series
>> as well. I can rebase my series on top of yours and send it as one
>> series if that's okay with you and Palmer.
> 
> No need for you to resend these patches as they are reviewed any ready
> to be merged. Just rebase your series and mention the dependency in the
> cover letter as I did with Andreas's patch which this series depended
> on.
>

Sure. I will do that.

Regards,
Atish
> Thanks,
> Johan
>
diff mbox series

Patch

diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 4891fd62b95e..e7a4701f0256 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -28,7 +28,7 @@  bool has_fpu __read_mostly;
 
 void riscv_fill_hwcap(void)
 {
-	struct device_node *node = NULL;
+	struct device_node *node;
 	const char *isa;
 	size_t i;
 	static unsigned long isa2hwcap[256] = {0};
@@ -46,9 +46,10 @@  void riscv_fill_hwcap(void)
 	 * We don't support running Linux on hertergenous ISA systems.  For
 	 * now, we just check the ISA of the first "okay" processor.
 	 */
-	while ((node = of_find_node_by_type(node, "cpu")))
+	for_each_of_cpu_node(node) {
 		if (riscv_of_processor_hartid(node) >= 0)
 			break;
+	}
 	if (!node) {
 		pr_warn("Unable to find \"cpu\" devicetree entry\n");
 		return;
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 18cda0e8cf94..6e2813257e03 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -50,12 +50,12 @@  void __init smp_prepare_cpus(unsigned int max_cpus)
 
 void __init setup_smp(void)
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	int hart;
 	bool found_boot_cpu = false;
 	int cpuid = 1;
 
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_of_cpu_node(dn) {
 		hart = riscv_of_processor_hartid(dn);
 		if (hart < 0)
 			continue;