ARM: dts: kirkwood: gpio-leds fixes for linkstation ls-wvl/vl
[linux/fpc-iii.git] / tools / perf / arch / powerpc / util / header.c
blob6c1b8a75db09ae4b8bda966463e829e0451489e4
1 #include <sys/types.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 #include "../../util/header.h"
8 #include "../../util/util.h"
10 #define mfspr(rn) ({unsigned long rval; \
11 asm volatile("mfspr %0," __stringify(rn) \
12 : "=r" (rval)); rval; })
14 #define SPRN_PVR 0x11F /* Processor Version Register */
15 #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
16 #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
18 int
19 get_cpuid(char *buffer, size_t sz)
21 unsigned long pvr;
22 int nb;
24 pvr = mfspr(SPRN_PVR);
26 nb = scnprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr));
28 /* look for end marker to ensure the entire data fit */
29 if (strchr(buffer, '$')) {
30 buffer[nb-1] = '\0';
31 return 0;
33 return -1;