From: Joerg Dorchain <joerg@dorchain•net>
To: Guido Guenther <agx@sigxcpu•org>,
linuxppc-dev list <linuxppc-dev@ozlabs•org>
Subject: [PATCH] nvram driver as module (was Re: nvram driver not possible as a module)
Date: Sat, 22 Jan 2005 22:20:32 +0100 [thread overview]
Message-ID: <20050122212032.GA31025@Redstar.dorchain.net> (raw)
In-Reply-To: <20050120105026.GG27077@Redstar.dorchain.net>
[-- Attachment #1: Type: text/plain, Size: 3442 bytes --]
On Thu, Jan 20, 2005 at 11:50:26AM +0100, Joerg Dorchain wrote:
> > Does this help:
> [...]
>
> Most likely, if there wasn't a specific reason to use bootmem.
>
> I'll try tonight.
Well, it did not crash. The following does even work ;-)
Signed-off-by: Joerg Dorchain <joerg@dorchain•net>
--- ./include/asm-ppc/system.h.orig 2005-01-22 21:30:19.000000000 +0100
+++ ./include/asm-ppc/system.h 2005-01-22 21:28:48.335018120 +0100
@@ -69,7 +69,7 @@
#define _set_L3CR(val) do { } while(0)
#endif
extern void via_cuda_init(void);
-extern void pmac_nvram_init(void);
+extern int pmac_nvram_init(void);
extern void read_rtc_time(void);
extern void pmac_find_display(void);
extern void giveup_fpu(struct task_struct *);
--- arch/ppc/platforms/pmac_nvram.c.orig 2005-01-22 20:46:21.000000000 +0100
+++ arch/ppc/platforms/pmac_nvram.c 2005-01-22 22:15:10.000000000 +0100
@@ -75,8 +75,8 @@
* Read and write the non-volatile RAM on PowerMacs and CHRP machines.
*/
static int nvram_naddrs;
-static volatile unsigned char *nvram_addr;
-static volatile unsigned char *nvram_data;
+static volatile unsigned char *nvram_addr = NULL;
+static volatile unsigned char *nvram_data = NULL;
static int nvram_mult, is_core_99;
static int core99_bank = 0;
static int nvram_partitions[3];
@@ -88,7 +88,7 @@
static int (*core99_write_bank)(int bank, u8* datas);
static int (*core99_erase_bank)(int bank);
-static char *nvram_image __pmacdata;
+static char *nvram_image __pmacdata = NULL;
static unsigned char __pmac core99_nvram_read_byte(int addr)
@@ -467,7 +467,7 @@
#endif
}
-void __init pmac_nvram_init(void)
+int __init pmac_nvram_init(void)
{
struct device_node *dp;
@@ -476,7 +476,7 @@
dp = find_devices("nvram");
if (dp == NULL) {
printk(KERN_ERR "Can't find NVRAM device\n");
- return;
+ return -ENODEV;
}
nvram_naddrs = dp->n_addrs;
is_core_99 = device_is_compatible(dp, "nvram,flash");
@@ -486,12 +486,16 @@
if (nvram_naddrs < 1) {
printk(KERN_ERR "nvram: no address\n");
- return;
+ return -ENODEV;
}
+#ifdef MODULE
+ nvram_image = kmalloc(NVRAM_SIZE, GFP_KERNEL);
+#else
nvram_image = alloc_bootmem(NVRAM_SIZE);
+#endif
if (nvram_image == NULL) {
printk(KERN_ERR "nvram: can't allocate ram image\n");
- return;
+ return -ENODEV;
}
nvram_data = ioremap(dp->addrs[0].address, NVRAM_SIZE*2);
nvram_naddrs = 1; /* Make sure we get the correct case */
@@ -550,8 +554,10 @@
} else {
printk(KERN_ERR "Don't know how to access NVRAM with %d addresses\n",
nvram_naddrs);
+ return -ENODEV;
}
lookup_partitions();
+ return 0;
}
int __pmac pmac_get_partition(int partition)
@@ -579,6 +585,29 @@
ppc_md.nvram_write_val(xpaddr + offset, data);
}
+static void pmac_nvram_exit(void)
+{
+#ifdef MODULE
+ if (ppc_md.nvram_sync)
+ ppc_md.nvram_sync();
+ if (nvram_addr)
+ iounmap(nvram_addr);
+ if (nvram_data)
+ iounmap(nvram_data);
+ if (nvram_image)
+ kfree(nvram_image);
+ nvram_addr=NULL;
+ nvram_data=NULL;
+ nvram_image=NULL;
+ ppc_md.nvram_read_val = NULL;
+ ppc_md.nvram_write_val = NULL;
+ ppc_md.nvram_sync = NULL;
+#endif
+}
+
+MODULE_LICENSE("GPL");
+module_exit(pmac_nvram_exit);
+module_init(pmac_nvram_init);
EXPORT_SYMBOL(pmac_get_partition);
EXPORT_SYMBOL(pmac_xpram_read);
EXPORT_SYMBOL(pmac_xpram_write);
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2005-01-22 21:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-19 10:14 nvram driver not possible as a module Joerg Dorchain
2005-01-20 9:55 ` Guido Guenther
2005-01-20 10:50 ` Joerg Dorchain
2005-01-22 21:20 ` Joerg Dorchain [this message]
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=20050122212032.GA31025@Redstar.dorchain.net \
--to=joerg@dorchain$(echo .)net \
--cc=agx@sigxcpu$(echo .)org \
--cc=linuxppc-dev@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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