[PATCH 2/4] mips: n64: Simplify framebuffer allocation
From: Thorsten Blum
Date: Thu Oct 29 2026 - 17:25:03 EST
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@xxxxxxxxxx>
---
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)