[RFC v5 26/26] m68k: Dispatch nvram_ops calls to Atari or Mac functions
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 Tested-by: Christian T. Steigies --- 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. Changes since v3: - Use bool (and select) instead of def_bool in the definition of the HAVE_ARCH_NVRAM_OPS Kconfig symbol, as requested by Geert. - Moved extern declarations back to the header files (like in v1) as requested by Geert. --- arch/m68k/Kconfig.machine |1 arch/m68k/atari/nvram.c | 21 +-- arch/m68k/include/asm/atarihw.h |6 ++ arch/m68k/include/asm/macintosh.h |4 + arch/m68k/kernel/setup_mm.c | 100 +- arch/m68k/mac/misc.c | 18 ++ 6 files changed, 133 insertions(+), 17 deletions(-) Index: linux/arch/m68k/mac/misc.c === --- linux.orig/arch/m68k/mac/misc.c 2015-07-25 17:45:55.0 +1000 +++ linux/arch/m68k/mac/misc.c 2015-07-25 17:45: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(, 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), ); } +#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-07-25 17:45:47.0 +1000 +++ linux/arch/m68k/atari/nvram.c 2015-07-25 17:45: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(_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) {
[RFC v5 26/26] m68k: Dispatch nvram_ops calls to Atari or Mac functions
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 Tested-by: Christian T. Steigies c...@debian.org --- 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. Changes since v3: - Use bool (and select) instead of def_bool in the definition of the HAVE_ARCH_NVRAM_OPS Kconfig symbol, as requested by Geert. - Moved extern declarations back to the header files (like in v1) as requested by Geert. --- arch/m68k/Kconfig.machine |1 arch/m68k/atari/nvram.c | 21 +-- arch/m68k/include/asm/atarihw.h |6 ++ arch/m68k/include/asm/macintosh.h |4 + arch/m68k/kernel/setup_mm.c | 100 +- arch/m68k/mac/misc.c | 18 ++ 6 files changed, 133 insertions(+), 17 deletions(-) Index: linux/arch/m68k/mac/misc.c === --- linux.orig/arch/m68k/mac/misc.c 2015-07-25 17:45:55.0 +1000 +++ linux/arch/m68k/mac/misc.c 2015-07-25 17:45: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-07-25 17:45:47.0 +1000 +++ linux/arch/m68k/atari/nvram.c 2015-07-25 17:45: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