mirror of
https://github.com/brain-hackers/linux-brain.git
synced 2024-06-09 07:16:21 +09:00
fb71c86cc8
Check that it is not needed and remove, fixing up some fallout for places where it was only serving to get something else. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-9h6dg6lsqe2usyqjh5rrues4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
46 lines
985 B
C
46 lines
985 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <linux/stringify.h>
|
|
#include "header.h"
|
|
|
|
#define mfspr(rn) ({unsigned long rval; \
|
|
asm volatile("mfspr %0," __stringify(rn) \
|
|
: "=r" (rval)); rval; })
|
|
|
|
#define SPRN_PVR 0x11F /* Processor Version Register */
|
|
#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
|
|
#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
|
|
|
|
int
|
|
get_cpuid(char *buffer, size_t sz)
|
|
{
|
|
unsigned long pvr;
|
|
int nb;
|
|
|
|
pvr = mfspr(SPRN_PVR);
|
|
|
|
nb = scnprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr));
|
|
|
|
/* look for end marker to ensure the entire data fit */
|
|
if (strchr(buffer, '$')) {
|
|
buffer[nb-1] = '\0';
|
|
return 0;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
char *
|
|
get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
|
|
{
|
|
char *bufp;
|
|
|
|
if (asprintf(&bufp, "%.8lx", mfspr(SPRN_PVR)) < 0)
|
|
bufp = NULL;
|
|
|
|
return bufp;
|
|
}
|