[RFC v6 03/25] m68k/atari: Replace nvram_{read, write}_byte with arch_nvram_ops

2015-08-23 Thread Finn Thain
By implementing an arch_nvram_ops struct, any platform can re-use the drivers/char/nvram module without needing any arch-specific code in that module. Atari does so here. Atari has one user of nvram_check_checksum() whereas the other platforms (i.e. x86 and ARM platforms) have none at all. Replace

[RFC v6 01/25] scsi/atari_scsi: Dont select CONFIG_NVRAM

2015-08-23 Thread Finn Thain
On powerpc, setting CONFIG_NVRAM=n builds a kernel with no NVRAM support. Setting CONFIG_NVRAM=m enables the /dev/nvram misc device module without enabling NVRAM support in drivers. Setting CONFIG_NVRAM=y enables the misc device (built-in) and also enables NVRAM support in drivers. m68k shares the

[RFC v6 04/25] char/nvram: Re-order functions to remove forward declarations and #ifdefs

2015-08-23 Thread Finn Thain
Also give functions more sensible names: nvram_misc_* for misc device ops, nvram_proc_* for proc file ops and nvram_module_* for init and exit functions. This makes them distict from nvram_ops members. Signed-off-by: Finn Thain --- drivers/char/nvram.c | 194 ++-

[RFC v6 00/25] Re-use nvram module

2015-08-23 Thread Finn Thain
The generic NVRAM module, drivers/char/generic_nvram, implements a /dev/nvram misc device. It is used only by 32-bit PowerPC platforms and isn't generic enough to be more widely used. The RTC NVRAM module, drivers/char/nvram, also implements a /dev/nvram misc device. It is used by x86, ARM and m6

[RFC v6 02/25] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c

2015-08-23 Thread Finn Thain
Move the m68k-specific code elsewhere to make the driver generic. Signed-off-by: Finn Thain Tested-by: Christian T. Steigies Acked-by: Geert Uytterhoeven --- Changes since v3: - Move the vmode fix to a separate patch as requested by Geert. --- arch/m68k/atari/Makefile |2 arch/m68k/ata

[RFC v6 12/25] powerpc: Cleanup nvram includes

2015-08-23 Thread Finn Thain
The nvram_read_byte() and nvram_write_byte() definitions in asm/nvram.h duplicate those in linux/nvram.h. Get rid of the former to prepare for adoption of struct arch_nvram_ops (which is defined in linux/nvram.h for general use). Signed-off-by: Finn Thain --- Changes since v4: - Fix possible gi

[RFC v6 09/25] char/nvram: Use generic fixed_size_llseek()

2015-08-23 Thread Finn Thain
Signed-off-by: Finn Thain --- drivers/char/nvram.c | 16 +--- 1 file changed, 1 insertion(+), 15 deletions(-) Index: linux/drivers/char/nvram.c === --- linux.orig/drivers/char/nvram.c 2015-08-23 20:41:03.0

[RFC v6 11/25] char/nvram: Add "devname:nvram" module alias

2015-08-23 Thread Finn Thain
Signed-off-by: Finn Thain --- drivers/char/nvram.c |1 + 1 file changed, 1 insertion(+) Index: linux/drivers/char/nvram.c === --- linux.orig/drivers/char/nvram.c 2015-08-23 20:41:04.0 +1000 +++ linux/drivers/char/nv

[RFC v6 14/25] powerpc: Implement arch_nvram_ops.get_size() and remove old nvram_* exports

2015-08-23 Thread Finn Thain
Implement arch_nvram_ops for PPC32 and make use of it in the generic_nvram misc device module so that the nvram_* function exports can be removed. Signed-off-by: Finn Thain --- arch/powerpc/include/asm/nvram.h |3 --- arch/powerpc/kernel/setup_32.c | 10 +++--- drivers/char/generic_

[RFC v6 05/25] char/nvram: Adopt arch_nvram_ops

2015-08-23 Thread Finn Thain
Different platforms and architectures offer different NVRAM sizes and access methods. E.g. PPC32 has byte-at-a-time read/write functions whereas PPC64 has byte-range read/write functions. Adopt the nvram_ops struct so the nvram module can call such functions as are defined by the various platforms

[RFC v6 07/25] char/nvram: Allow the set_checksum and initialize ioctls to be omitted

2015-08-23 Thread Finn Thain
The drivers/char/nvram module has previously only supported RTC "CMOS" NVRAM, for which it provides appropriate checksum ioctls. Make these ioctls optional so the module can be re-used with other kinds of NVRAM. The ops struct methods that implement the ioctls now return error codes so that a mult

[RFC v6 10/25] m68k/atari: Implement arch_nvram_ops methods and enable CONFIG_HAVE_ARCH_NVRAM_OPS

2015-08-23 Thread Finn Thain
Atari RTC NVRAM has a checksum so implement the remaining arch_nvram_ops methods for the set_checksum and initialize ioctls. Enable CONFIG_HAVE_ARCH_NVRAM_OPS. Signed-off-by: Finn Thain Acked-by: Geert Uytterhoeven --- This re-enables the nvram module for Atari. Changes since v3: - Use bool (

[RFC v6 06/25] x86/thinkpad_acpi: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte()

2015-08-23 Thread Finn Thain
Make use of arch_nvram_ops in the thinkpad_acpi driver so that the nvram_* function exports can be removed. This patch series was tested on a ThinkPad T43. Signed-off-by: Finn Thain Acked-by: Henrique de Moraes Holschuh Reviewed-by: Darren Hart --- drivers/platform/x86/thinkpad_acpi.c | 20

[RFC v6 08/25] char/nvram: Implement NVRAM read/write methods

2015-08-23 Thread Finn Thain
Refactor the RTC "CMOS" NVRAM functions so that they can be used as arch_nvram_ops methods. Checksumming logic is moved from the misc device operations to the nvram read/write operations. This makes the misc device implementation more generic. This also preserves the locking semantics such that "r

[RFC v6 13/25] powerpc: Add missing ppc_md.nvram_size for CHRP and PowerMac

2015-08-23 Thread Finn Thain
Add the nvram_size() function to those PowerPC platforms that don't already have one: CHRP and PowerMac. This means that the ppc_md.nvram_size() function can be used to implement arch_nvram_ops.get_size() Since we are addressing inconsistencies here, also rename chrp_nvram_read and chrp_nvram_writ

[RFC v6 16/25] powerpc, fbdev: Use NV_CMODE and NV_VMODE only when CONFIG_PPC32 and CONFIG_PPC_PMAC and CONFIG_NVRAM

2015-08-23 Thread Finn Thain
This patch addresses inconsistencies in Mac framebuffer drivers and their use of Kconfig symbols relating to NVRAM, so PPC64 can use CONFIG_NVRAM. Macintosh framebuffer drivers use default settings for color mode and video mode that are found in NVRAM. On PCI Macs, MacOS stores display settings in

[RFC v6 18/25] nvram: Drop nvram_* symbol exports and prototypes

2015-08-23 Thread Finn Thain
Drivers now use the arch_nvram_ops calls so remove the function exports and prototypes. nvram_check_checksum() is unused so remove it. Signed-off-by: Finn Thain Acked-by: Geert Uytterhoeven --- arch/m68k/atari/nvram.c |6 +++--- drivers/char/nvram.c| 27 +-- i

[RFC v6 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte()

2015-08-23 Thread Finn Thain
Make use of arch_nvram_ops in device drivers so that the nvram_* function exports can be removed. Since they are no longer global symbols, rename the PPC32 nvram_* functions appropriately. Signed-off-by: Finn Thain --- Changed since v4: - Split off the CONFIG_PPC32, CONFIG_PPC_PMAC and CONFIG_

[RFC v6 23/25] m68k/mac: Use macros for RTC accesses not magic numbers

2015-08-23 Thread Finn Thain
Signed-off-by: Finn Thain Acked-by: Geert Uytterhoeven --- This is intended to improve code style and not affect code behaviour. I've tested this on a Quadra 650. I don't know the meanings of the 4 undocumented write protect register bits 0x55, so I decided against defining 4 macros for those

[RFC v6 21/25] powerpc: Adopt nvram module for PPC64

2015-08-23 Thread Finn Thain
Adopt nvram module to reduce code duplication. The IOC_NVRAM_GET_OFFSET ioctl as implemented on PPC64 validates the offset returned by pmac_get_partition(). Add this test to the nvram module. Note that the old PPC32 generic_nvram module lacked this test. So when CONFIG_PPC32 && CONFIG_PPC_PMAC, t

[RFC v6 22/25] m68k/mac: Adopt naming and calling conventions for PRAM routines

2015-08-23 Thread Finn Thain
Adopt the existing *_read_byte and *_write_byte naming convention. Rename via_pram_readbyte and via_pram_writebyte to avoid confusion. Adjust calling conventions of mac_pram_* functions to match the arch_nvram_ops struct methods. Signed-off-by: Finn Thain Acked-by: Geert Uytterhoeven --- Chang

[RFC v6 25/25] m68k: Dispatch nvram_ops calls to Atari or Mac functions

2015-08-23 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 Tested

[RFC v6 15/25] powerpc: Implement nvram sync ioctl

2015-08-23 Thread Finn Thain
Add the powerpc-specific sync() method to struct nvram_ops and implement the corresponding ioctl in the nvram module. This allows the nvram module to replace the generic_nvram module. Signed-off-by: Finn Thain --- On PPC32, the IOC_NVRAM_SYNC ioctl call always returns 0, even for those platform

[RFC v6 19/25] powerpc: Remove CONFIG_GENERIC_NVRAM and adopt CONFIG_HAVE_ARCH_NVRAM_OPS

2015-08-23 Thread Finn Thain
Switch PPC32 kernels from the generic_nvram module to the nvram module. Also fix a theoretical bug where CHRP omits the chrp_nvram_init() call when CONFIG_NVRAM_MODULE=m. Signed-off-by: Finn Thain --- The change in the name of the module is visible to userspace. The module that implements /dev

[RFC v6 24/25] m68k/mac: Fix PRAM accessors

2015-08-23 Thread Finn Thain
Signed-off-by: Finn Thain Acked-by: Geert Uytterhoeven --- Tested on a PowerBook 520 and Quadra 650. Changes since v2: - Make use of the RTC_* macros from the previous patch and add a few more besides. --- arch/m68k/mac/misc.c | 39 +-- include/uapi/

[RFC v6 20/25] char/generic_nvram: Remove as unused

2015-08-23 Thread Finn Thain
And thus eliminate some twisted CONFIG_GENERIC_NVRAM logic. Signed-off-by: Finn Thain --- drivers/char/Makefile|6 - drivers/char/generic_nvram.c | 175 --- 2 files changed, 1 insertion(+), 180 deletions(-) Index: linux/drivers/char/Makefile