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

From: Finn Thain
Date: Sat Jul 25 2015 - 21:38:22 EST



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
valuable...)


-- -- 8< -- --


#!/bin/sh
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
fi
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
fi


-- -- 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>
#endif

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

f = fopen("/dev/nvram", "r+");
if (!f) {
perror("fopen");
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);
#endif

return 0;
}


--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/