Re: [RFC v3 24/24] m68k: Dispatch nvram_ops calls to Atari or Mac functions

2015-07-01 Thread Finn Thain

On Mon, 29 Jun 2015, Geert Uytterhoeven wrote:

 On Sun, Jun 28, 2015 at 3:42 AM, Finn Thain fth...@telegraphics.com.au 
 wrote:
  --- linux.orig/arch/m68k/kernel/setup_mm.c  2015-06-28 
  11:41:27.0 +1000
  +++ linux/arch/m68k/kernel/setup_mm.c   2015-06-28 11:41:56.0 +1000
 
  @@ -568,3 +569,109 @@ static int __init adb_probe_sync_enable
 
   __setup(adb_sync, adb_probe_sync_enable);
   #endif /* CONFIG_ADB */
  +
  +#if IS_ENABLED(CONFIG_NVRAM)
  +extern unsigned char mac_pram_read_byte(int);
  +extern void mac_pram_write_byte(unsigned char, int);
  +extern ssize_t mac_pram_get_size(void);
  +
  +extern ssize_t atari_nvram_read(char *, size_t, loff_t *);
  +extern ssize_t atari_nvram_write(char *, size_t, loff_t *);
  +extern long atari_nvram_set_checksum(void);
  +extern long atari_nvram_initialize(void);
  +extern ssize_t atari_nvram_get_size(void);
 
 Forward declarations belong in a header file, to be included by both 
 producers and consumers.

Right, will fix. (That was how the v1 patch did this. Looks like I messed 
it up.)

 
  --- linux.orig/arch/m68k/Kconfig2015-06-28 11:41:39.0 +1000
  +++ linux/arch/m68k/Kconfig 2015-06-28 11:41:56.0 +1000
  @@ -72,7 +72,7 @@ config PGTABLE_LEVELS
  default 3
 
   config HAVE_ARCH_NVRAM_OPS
  -   def_bool ATARI
  +   def_bool ATARI || MAC
 
 For maintainability, it's better to just have bool here, and let both 
 the ATARI and MAC config symbols select HAVE_ARCH_NVRAM_OPS.

OK, will fix.

Thanks for your review.

-- 

 
 Gr{oetje,eeting}s,
 
 Geert
 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC v3 24/24] m68k: Dispatch nvram_ops calls to Atari or Mac functions

2015-06-29 Thread Geert Uytterhoeven
Hi Finn,

 A multi-platform kernel binary needs to decide at run-time how to dispatch
 the arch_nvram_ops calls. Add platform-independent arch_nvram_ops, for use
 when multiple platform-specific NVRAM ops implementations are needed.

 Enable CONFIG_HAVE_ARCH_NVRAM_OPS for Macs.

Thanks for your patch!

On Sun, Jun 28, 2015 at 3:42 AM, Finn Thain fth...@telegraphics.com.au wrote:
 --- linux.orig/arch/m68k/kernel/setup_mm.c  2015-06-28 11:41:27.0 
 +1000
 +++ linux/arch/m68k/kernel/setup_mm.c   2015-06-28 11:41:56.0 +1000

 @@ -568,3 +569,109 @@ static int __init adb_probe_sync_enable

  __setup(adb_sync, adb_probe_sync_enable);
  #endif /* CONFIG_ADB */
 +
 +#if IS_ENABLED(CONFIG_NVRAM)
 +extern unsigned char mac_pram_read_byte(int);
 +extern void mac_pram_write_byte(unsigned char, int);
 +extern ssize_t mac_pram_get_size(void);
 +
 +extern ssize_t atari_nvram_read(char *, size_t, loff_t *);
 +extern ssize_t atari_nvram_write(char *, size_t, loff_t *);
 +extern long atari_nvram_set_checksum(void);
 +extern long atari_nvram_initialize(void);
 +extern ssize_t atari_nvram_get_size(void);

Forward declarations belong in a header file, to be included by both
producers and consumers.

 --- linux.orig/arch/m68k/Kconfig2015-06-28 11:41:39.0 +1000
 +++ linux/arch/m68k/Kconfig 2015-06-28 11:41:56.0 +1000
 @@ -72,7 +72,7 @@ config PGTABLE_LEVELS
 default 3

  config HAVE_ARCH_NVRAM_OPS
 -   def_bool ATARI
 +   def_bool ATARI || MAC

For maintainability, it's better to just have bool here, and let both the
ATARI and MAC config symbols select HAVE_ARCH_NVRAM_OPS.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC v3 24/24] m68k: Dispatch nvram_ops calls to Atari or Mac functions

2015-06-27 Thread Finn Thain
A multi-platform kernel binary needs to decide at run-time how to dispatch
the arch_nvram_ops calls. Add platform-independent arch_nvram_ops, for use
when multiple platform-specific NVRAM ops implementations are needed.

Enable CONFIG_HAVE_ARCH_NVRAM_OPS for Macs.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---

Changed since v1:
- Removed Mac and Atari ops struct definitions and the associated #ifdefs.
- Moved extern declarations for fewer lines of code and better readability.
- The IS_ENABLED(CONFIG_NVRAM) tests were moved to this patch, because it is
now in this patch that CONFIG_HAVE_ARCH_NVRAM_OPS is enabled for Macs.

---
 arch/m68k/Kconfig   |2 
 arch/m68k/atari/nvram.c |   21 ++--
 arch/m68k/kernel/setup_mm.c |  107 
 arch/m68k/mac/misc.c|   18 +++
 4 files changed, 131 insertions(+), 17 deletions(-)

Index: linux/arch/m68k/mac/misc.c
===
--- linux.orig/arch/m68k/mac/misc.c 2015-06-28 11:41:55.0 +1000
+++ linux/arch/m68k/mac/misc.c  2015-06-28 11:41:56.0 +1000
@@ -61,6 +61,7 @@ static void cuda_write_time(long data)
cuda_poll();
 }
 
+#if IS_ENABLED(CONFIG_NVRAM)
 static unsigned char cuda_pram_read_byte(int offset)
 {
struct adb_request req;
@@ -81,6 +82,8 @@ static void cuda_pram_write_byte(unsigne
while (!req.complete)
cuda_poll();
 }
+#endif /* CONFIG_NVRAM */
+
 #else
 #define cuda_read_time() 0
 #define cuda_write_time(n)
@@ -116,6 +119,7 @@ static void pmu_write_time(long data)
pmu_poll();
 }
 
+#if IS_ENABLED(CONFIG_NVRAM)
 static unsigned char pmu_pram_read_byte(int offset)
 {
struct adb_request req;
@@ -139,6 +143,8 @@ static void pmu_pram_write_byte(unsigned
while (!req.complete)
pmu_poll();
 }
+#endif /* CONFIG_NVRAM */
+
 #else
 #define pmu_read_time() 0
 #define pmu_write_time(n)
@@ -172,6 +178,7 @@ static void maciisi_write_time(long data
(data  8)  0xFF, data  0xFF);
 }
 
+#if IS_ENABLED(CONFIG_NVRAM)
 static unsigned char maciisi_pram_read_byte(int offset)
 {
struct adb_request req;
@@ -187,6 +194,8 @@ static void maciisi_pram_write_byte(unsi
maciisi_request(req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
(offset  8)  0xFF, offset  0xFF, data);
 }
+#endif /* CONFIG_NVRAM */
+
 #else
 #define maciisi_read_time() 0
 #define maciisi_write_time(n)
@@ -314,6 +323,7 @@ static void via_rtc_command(int command,
local_irq_restore(flags);
 }
 
+#if IS_ENABLED(CONFIG_NVRAM)
 static unsigned char via_pram_read_byte(int offset)
 {
unsigned char temp;
@@ -336,6 +346,7 @@ static void via_pram_write_byte(unsigned
temp = 0x55 | RTC_FLG_WRITE_PROTECT;
via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), temp);
 }
+#endif /* CONFIG_NVRAM */
 
 /*
  * Return the current time in seconds since January 1, 1904.
@@ -503,6 +514,7 @@ void pmu_shutdown(void)
  *---
  */
 
+#if IS_ENABLED(CONFIG_NVRAM)
 unsigned char mac_pram_read_byte(int addr)
 {
unsigned char (*func)(int);
@@ -550,6 +562,12 @@ void mac_pram_write_byte(unsigned char v
(*func)(val, addr);
 }
 
+ssize_t mac_pram_get_size(void)
+{
+   return 256;
+}
+#endif /* CONFIG_NVRAM */
+
 void mac_poweroff(void)
 {
/*
Index: linux/arch/m68k/atari/nvram.c
===
--- linux.orig/arch/m68k/atari/nvram.c  2015-06-28 11:41:48.0 +1000
+++ linux/arch/m68k/atari/nvram.c   2015-06-28 11:41:56.0 +1000
@@ -73,7 +73,7 @@ static void __nvram_set_checksum(void)
__nvram_write_byte(sum, ATARI_CKS_LOC + 1);
 }
 
-static long nvram_set_checksum(void)
+long atari_nvram_set_checksum(void)
 {
spin_lock_irq(rtc_lock);
__nvram_set_checksum();
@@ -81,7 +81,7 @@ static long nvram_set_checksum(void)
return 0;
 }
 
-static long nvram_initialize(void)
+long atari_nvram_initialize(void)
 {
loff_t i;
 
@@ -93,7 +93,7 @@ static long nvram_initialize(void)
return 0;
 }
 
-static ssize_t nvram_read(char *buf, size_t count, loff_t *ppos)
+ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos)
 {
char *p = buf;
loff_t i;
@@ -114,7 +114,7 @@ static ssize_t nvram_read(char *buf, siz
return p - buf;
 }
 
-static ssize_t nvram_write(char *buf, size_t count, loff_t *ppos)
+ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos)
 {
char *p = buf;
loff_t i;
@@ -137,22 +137,11 @@ static ssize_t nvram_write(char *buf, si
return p - buf;
 }
 
-static ssize_t nvram_get_size(void)
+ssize_t atari_nvram_get_size(void)
 {
-   if (!MACH_IS_ATARI)
-   return -ENODEV;
return NVRAM_BYTES;
 }
 
-const struct nvram_ops arch_nvram_ops = {
-