From: Ahmad Fatoum <a.fatoum@pengutronix.de> To: barebox@lists.infradead.org Cc: mol@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de> Subject: [PATCH 1/6] common: memory: allocate all memory devices at once Date: Mon, 31 May 2021 09:12:34 +0200 Message-ID: <20210531071239.30653-2-a.fatoum@pengutronix.de> (raw) In-Reply-To: <20210531071239.30653-1-a.fatoum@pengutronix.de> Follow-up commit will fuse overlapping RAM banks. As all memory is supposed to be registered during mem_initcall or before, we can postpone device creation to mmu_initcall, so we can directly allocate devices spanning the correct region. The mem driver and the devinfo command are the only consumers of these devices, so it's ok to register the devices at mmu_initcall. While at it, drop the struct memory_bank::dev member. It's unused anywhere. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- common/memory.c | 17 +++++++++++++---- include/memory.h | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/memory.c b/common/memory.c index 392522bfc3db..612ed87168b5 100644 --- a/common/memory.c +++ b/common/memory.c @@ -115,15 +115,11 @@ int barebox_add_memory_bank(const char *name, resource_size_t start, resource_size_t size) { struct memory_bank *bank = xzalloc(sizeof(*bank)); - struct device_d *dev; bank->res = request_iomem_region(name, start, start + size - 1); if (IS_ERR(bank->res)) return PTR_ERR(bank->res); - dev = add_mem_device(name, start, size, IORESOURCE_MEM_WRITEABLE); - - bank->dev = dev; bank->start = start; bank->size = size; @@ -132,6 +128,19 @@ int barebox_add_memory_bank(const char *name, resource_size_t start, return 0; } +static int add_mem_devices(void) +{ + struct memory_bank *bank; + + for_each_memory_bank(bank) { + add_mem_device(bank->res->name, bank->start, bank->size, + IORESOURCE_MEM_WRITEABLE); + } + + return 0; +} +mmu_initcall(add_mem_devices); + /* * Request a region from the registered sdram */ diff --git a/include/memory.h b/include/memory.h index 906d9f7b2689..c793bb51ed77 100644 --- a/include/memory.h +++ b/include/memory.h @@ -11,7 +11,6 @@ ulong mem_malloc_end(void); struct memory_bank { struct list_head list; - struct device_d *dev; unsigned long start; unsigned long size; struct resource *res; -- 2.29.2 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-05-31 7:14 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-31 7:12 [PATCH 0/6] memory: fuse overlapping memory banks Ahmad Fatoum 2021-05-31 7:12 ` Ahmad Fatoum [this message] 2021-05-31 7:12 ` [PATCH 2/6] " Ahmad Fatoum 2021-05-31 7:12 ` [PATCH 3/6] of: propagate errors inside barebox_register_{of, fdt} into initcalls Ahmad Fatoum 2021-05-31 7:12 ` [PATCH 4/6] of: warn about of_add_memory_bank errors Ahmad Fatoum 2021-05-31 7:12 ` [PATCH 5/6] ARM: <asm/memory.h>: propagate error codes from arm_add_mem_device() Ahmad Fatoum 2021-05-31 7:12 ` [PATCH 6/6] ARM: report probe error at arm_add_mem_device() callsites on failure Ahmad Fatoum 2021-06-02 6:38 ` [PATCH 0/6] memory: fuse overlapping memory banks Sascha Hauer
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=20210531071239.30653-2-a.fatoum@pengutronix.de \ --to=a.fatoum@pengutronix.de \ --cc=barebox@lists.infradead.org \ --cc=mol@pengutronix.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
mail archive of the barebox mailing list This inbox may be cloned and mirrored by anyone: git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \ barebox@lists.infradead.org barebox@lists.infradead.org public-inbox-index barebox Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git