mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thorsten Blum <blum@kernel.org>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Rosen Penev <rosenp@gmail.com>,
	Hemanth Selam <hemanth.selam@gmail.com>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thorsten Blum <blum@kernel.org>
Subject: [PATCH 1/4] mips: n64: Use DEFINE_RES_*() helpers
Date: Thu, 29 Oct 2026 22:23:44 +0100	[thread overview]
Message-ID: <20261029212343.110095-7-blum@kernel.org> (raw)
In-Reply-To: <20261029212343.110095-6-blum@kernel.org>

Use DEFINE_RES_MEM(), DEFINE_RES_IRQ(), and DEFINE_RES_MEM_NAMED() to
simplify resource initialization. Drop the now-unused linux/string.h
include.

Also use PLATFORM_DEVID_NONE instead of -1 for devices without an
instance ID.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 arch/mips/n64/init.c | 44 +++++++++-----------------------------------
 1 file changed, 9 insertions(+), 35 deletions(-)

diff --git a/arch/mips/n64/init.c b/arch/mips/n64/init.c
index ddbd7d1224d3..111d6e6c2de5 100644
--- a/arch/mips/n64/init.c
+++ b/arch/mips/n64/init.c
@@ -10,7 +10,6 @@
 #include <linux/memblock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/simplefb.h>
-#include <linux/string.h>
 
 #include <asm/bootinfo.h>
 #include <asm/fw/fw.h>
@@ -77,7 +76,6 @@ static const u32 ntsc_320[] __initconst = {
 
 static int __init n64_platform_init(void)
 {
-	static const char simplefb_resname[] = "FB";
 	static const struct simplefb_platform_data mode = {
 		.width = W,
 		.height = H,
@@ -89,34 +87,16 @@ static int __init n64_platform_init(void)
 	unsigned long phys;
 	unsigned i;
 
-	memset(res, 0, sizeof(struct resource) * 3);
-	res[0].flags = IORESOURCE_MEM;
-	res[0].start = MI_REG_BASE;
-	res[0].end = MI_REG_BASE + NUM_MI_REGS * 4 - 1;
+	res[0] = DEFINE_RES_MEM(MI_REG_BASE, NUM_MI_REGS * 4);
+	res[1] = DEFINE_RES_MEM(AI_REG_BASE, NUM_AI_REGS * 4);
+	res[2] = DEFINE_RES_IRQ(RCP_IRQ);
+	platform_device_register_simple("n64audio", PLATFORM_DEVID_NONE, res, 3);
 
-	res[1].flags = IORESOURCE_MEM;
-	res[1].start = AI_REG_BASE;
-	res[1].end = AI_REG_BASE + NUM_AI_REGS * 4 - 1;
+	res[0] = DEFINE_RES_MEM(PI_REG_BASE, NUM_PI_REGS * 4);
+	platform_device_register_simple("n64cart", PLATFORM_DEVID_NONE, res, 1);
 
-	res[2].flags = IORESOURCE_IRQ;
-	res[2].start = RCP_IRQ;
-	res[2].end = RCP_IRQ;
-
-	platform_device_register_simple("n64audio", -1, res, 3);
-
-	memset(&res[0], 0, sizeof(res[0]));
-	res[0].flags = IORESOURCE_MEM;
-	res[0].start = PI_REG_BASE;
-	res[0].end = PI_REG_BASE + NUM_PI_REGS * 4 - 1;
-
-	platform_device_register_simple("n64cart", -1, res, 1);
-
-	memset(&res[0], 0, sizeof(res[0]));
-	res[0].flags = IORESOURCE_MEM;
-	res[0].start = SI_REG_BASE;
-	res[0].end = SI_REG_BASE + NUM_SI_REGS * 4 - 1;
-
-	platform_device_register_simple("n64joy", -1, res, 1);
+	res[0] = DEFINE_RES_MEM(SI_REG_BASE, NUM_SI_REGS * 4);
+	platform_device_register_simple("n64joy", PLATFORM_DEVID_NONE, res, 1);
 
 	/* The framebuffer needs 64-byte alignment */
 	orig = kzalloc(W * H * 2 + 63, GFP_DMA | GFP_KERNEL);
@@ -133,13 +113,7 @@ static int __init n64_platform_init(void)
 			n64rdp_write_reg(i, ntsc_320[i]);
 	}
 
-	/* setup IORESOURCE_MEM as framebuffer memory */
-	memset(&res[0], 0, sizeof(res[0]));
-	res[0].flags = IORESOURCE_MEM;
-	res[0].name = simplefb_resname;
-	res[0].start = phys;
-	res[0].end = phys + W * H * 2 - 1;
-
+	res[0] = DEFINE_RES_MEM_NAMED(phys, W * H * 2, "FB");
 	platform_device_register_resndata(NULL, "simple-framebuffer", 0,
 					  &res[0], 1, &mode, sizeof(mode));
 

  reply	other threads:[~2026-10-29 21:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 21:23 [PATCH 0/4] mips: n64: Clean up platform initialization Thorsten Blum
2026-10-29 21:23 ` Thorsten Blum [this message]
2026-10-29 21:23 ` [PATCH 2/4] mips: n64: Simplify framebuffer allocation Thorsten Blum
2026-10-29 21:23 ` [PATCH 3/4] mips: n64: Rename the video interface register helper Thorsten Blum
2026-10-29 21:23 ` [PATCH 4/4] mips: n64: Use SZ_8M in plat_mem_setup() Thorsten Blum

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=20261029212343.110095-7-blum@kernel.org \
    --to=blum@kernel.org \
    --cc=hemanth.selam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=rosenp@gmail.com \
    --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®