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 2/4] mips: n64: Simplify framebuffer allocation
Date: Thu, 29 Oct 2026 22:23:45 +0100 [thread overview]
Message-ID: <20261029212343.110095-8-blum@kernel.org> (raw)
In-Reply-To: <20261029212343.110095-6-blum@kernel.org>
The framebuffer size is already a multiple of 64 bytes and kzalloc()
guarantees the required alignment. Use ALIGN() to document the 64-byte
requirement, and remove the extra 63 bytes and manual address alignment.
While here, make mode automatic since platform device registration
copies the data anyway. Also explicitly include linux/align.h for
ALIGN() and linux/slab.h for kzalloc().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
arch/mips/n64/init.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/arch/mips/n64/init.c b/arch/mips/n64/init.c
index 111d6e6c2de5..a64695454359 100644
--- a/arch/mips/n64/init.c
+++ b/arch/mips/n64/init.c
@@ -4,12 +4,14 @@
*
* Copyright (C) 2021 Lauri Kasanen
*/
+#include <linux/align.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/irq.h>
#include <linux/memblock.h>
#include <linux/platform_device.h>
#include <linux/platform_data/simplefb.h>
+#include <linux/slab.h>
#include <asm/bootinfo.h>
#include <asm/fw/fw.h>
@@ -76,14 +78,14 @@ static const u32 ntsc_320[] __initconst = {
static int __init n64_platform_init(void)
{
- static const struct simplefb_platform_data mode = {
+ const struct simplefb_platform_data mode = {
.width = W,
.height = H,
.stride = W * 2,
.format = "r5g5b5a1"
};
struct resource res[3];
- void *orig;
+ void *fb;
unsigned long phys;
unsigned i;
@@ -98,13 +100,10 @@ static int __init n64_platform_init(void)
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);
- if (!orig)
+ fb = kzalloc(ALIGN(W * H * 2, 64), GFP_DMA | GFP_KERNEL);
+ if (!fb)
return -ENOMEM;
- phys = virt_to_phys(orig);
- phys += 63;
- phys &= ~63;
+ phys = virt_to_phys(fb);
for (i = 0; i < ARRAY_SIZE(ntsc_320); i++) {
if (i == 1)
next prev parent 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 ` [PATCH 1/4] mips: n64: Use DEFINE_RES_*() helpers Thorsten Blum
2026-10-29 21:23 ` Thorsten Blum [this message]
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-8-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.