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

Finn Thain fthain at telegraphics.com.au
Sun Jul 26 11:37:20 AEST 2015

On Sat, 25 Jul 2015, Michael Ellerman wrote:

> On Sat, 2015-07-25 at 10:35 +1000, Finn Thain wrote:
> > 
> > ... These are rudimentary tests but combined with my own testing on 
> > m68k, ppc32 and x86, coverage is quite good. Some testing on ppc64 is 
> > still lacking though.

Here's some code I wrote some time ago to help me test these patches, 
maybe it will help others (though independent results may be more 

-- -- 8< -- -- 

set -e -u -x
temp=`mktemp /root/nvram.XXXX`
test -f "$temp"
cat /proc/version
if ! test -e /dev/nvram ; then
    mknod /dev/nvram c 10 144
ls -l /dev/nvram
if test -c /dev/nvram ; then
    cp /dev/nvram "$temp"
    hexdump -C "$temp"
    cp /dev/zero /dev/nvram || true
    hexdump -C /dev/nvram
    cp "$temp" /dev/nvram
    hexdump -C /dev/nvram

-- -- 8< -- -- 

#include <stdio.h>
#include <sys/ioctl.h>
#include <errno.h>

#if defined(__powerpc__)
#include <asm/nvram.h>
#elif defined(__i386__) || defined(__mc68020__)
#include <linux/nvram.h>

int main(void) {
        int result, i;
        FILE *f;

        f = fopen("/dev/nvram", "r+");
        if (!f) {
                return 1;

#if defined(__powerpc__)
        result = ioctl(fileno(f), IOC_NVRAM_SYNC);
	fprintf(stderr, "ioctl IOC_NVRAM_SYNC: result %d, errno %m\n", result);

        for (i = 0; i <= 8; ++i) {
                int arg = i;

                result = ioctl(fileno(f), IOC_NVRAM_GET_OFFSET, (long)&arg);
		fprintf(stderr, "ioctl IOC_NVRAM_GET_OFFSET: i %d, result %d, offset %d, errno %m\n", i, result, arg);
#elif defined(__i386__) || defined(__mc68020__)
        result = ioctl(fileno(f), NVRAM_INIT);
	fprintf(stderr, "ioctl NVRAM_INIT: result %d, errno %m\n", result);

        result = ioctl(fileno(f), NVRAM_SETCKS);
	fprintf(stderr, "ioctl NVRAM_SETCKS: result %d, errno %m\n", result);

        return 0;


More information about the Linuxppc-dev mailing list