* nvram driver not possible as a module
@ 2005-01-19 10:14 Joerg Dorchain
2005-01-20 9:55 ` Guido Guenther
0 siblings, 1 reply; 4+ messages in thread
From: Joerg Dorchain @ 2005-01-19 10:14 UTC (permalink / raw)
To: linuxppc-dev list
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
Hi,
KConfig says CONFIG_NVRAM is possible as a module. Loading the module
fails because of an unknown symbol __alloc_bootmem. __alloc_bootmem is
marked __init. The obvious workaround is to compile the driver not as a
module, but how can this get really fixed?
Bye,
Joerg
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nvram driver not possible as a module
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
0 siblings, 1 reply; 4+ messages in thread
From: Guido Guenther @ 2005-01-20 9:55 UTC (permalink / raw)
To: Joerg Dorchain; +Cc: linuxppc-dev list
Hi Joerg,
On Wed, Jan 19, 2005 at 11:14:48AM +0100, Joerg Dorchain wrote:
> KConfig says CONFIG_NVRAM is possible as a module. Loading the module
> fails because of an unknown symbol __alloc_bootmem. __alloc_bootmem is
> marked __init. The obvious workaround is to compile the driver not as a
> module, but how can this get really fixed?
Does this help:
--- linux-2.6.9.orig/arch/ppc/platforms/pmac_nvram.c 2004-10-18 23:53:51.000000000 +0200
+++ linux-2.6.9/arch/ppc/platforms/pmac_nvram.c 2004-10-25 09:53:15.000000000 +0200
@@ -488,7 +488,7 @@
printk(KERN_ERR "nvram: no address\n");
return;
}
- nvram_image = alloc_bootmem(NVRAM_SIZE);
+ nvram_image = kmalloc(NVRAM_SIZE, GFP_KERNEL);
if (nvram_image == NULL) {
printk(KERN_ERR "nvram: can't allocate ram image\n");
return;
Cheers,
-- Guido
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nvram driver not possible as a module
2005-01-20 9:55 ` Guido Guenther
@ 2005-01-20 10:50 ` Joerg Dorchain
2005-01-22 21:20 ` [PATCH] nvram driver as module (was Re: nvram driver not possible as a module) Joerg Dorchain
0 siblings, 1 reply; 4+ messages in thread
From: Joerg Dorchain @ 2005-01-20 10:50 UTC (permalink / raw)
To: Guido Guenther; +Cc: linuxppc-dev list
[-- Attachment #1: Type: text/plain, Size: 537 bytes --]
On Thu, Jan 20, 2005 at 10:55:46AM +0100, Guido Guenther wrote:
> Hi Joerg,
> On Wed, Jan 19, 2005 at 11:14:48AM +0100, Joerg Dorchain wrote:
> > KConfig says CONFIG_NVRAM is possible as a module. Loading the module
> > fails because of an unknown symbol __alloc_bootmem. __alloc_bootmem is
> > marked __init. The obvious workaround is to compile the driver not as a
> > module, but how can this get really fixed?
> Does this help:
[...]
Most likely, if there wasn't a specific reason to use bootmem.
I'll try tonight.
Thanks,
Joerg
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] nvram driver as module (was Re: nvram driver not possible as a module)
2005-01-20 10:50 ` Joerg Dorchain
@ 2005-01-22 21:20 ` Joerg Dorchain
0 siblings, 0 replies; 4+ messages in thread
From: Joerg Dorchain @ 2005-01-22 21:20 UTC (permalink / raw)
To: Guido Guenther, linuxppc-dev list
[-- 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 --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-01-22 21:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH] nvram driver as module (was Re: nvram driver not possible as a module) Joerg Dorchain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).