Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 138561
b: refs/heads/master
c: 9a37193
h: refs/heads/master
i:
  138559: 18a2f3c
v: v3
  • Loading branch information
Rusty Russell authored and Benjamin Herrenschmidt committed Mar 24, 2009
1 parent a937073 commit 39cd548
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c5785f9e1c1c07c791fdc471f5c7fda4a5855b0c
refs/heads/master: 9a3719341a9b5d2f5a2e590497346b61cf3462a5
31 changes: 6 additions & 25 deletions trunk/arch/powerpc/kernel/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,44 +134,25 @@ void ppc_enable_pmcs(void)
}
EXPORT_SYMBOL(ppc_enable_pmcs);

#if defined(CONFIG_6xx) || defined(CONFIG_PPC64)
/* XXX convert to rusty's on_one_cpu */
static unsigned long run_on_cpu(unsigned long cpu,
unsigned long (*func)(unsigned long),
unsigned long arg)
{
cpumask_t old_affinity = current->cpus_allowed;
unsigned long ret;

/* should return -EINVAL to userspace */
if (set_cpus_allowed(current, cpumask_of_cpu(cpu)))
return 0;

ret = func(arg);

set_cpus_allowed(current, old_affinity);

return ret;
}
#endif

#define SYSFS_PMCSETUP(NAME, ADDRESS) \
static unsigned long read_##NAME(unsigned long junk) \
static void read_##NAME(void *val) \
{ \
return mfspr(ADDRESS); \
mtspr(ADDRESS, *(unsigned long *)val); \
} \
static unsigned long write_##NAME(unsigned long val) \
{ \
ppc_enable_pmcs(); \
mtspr(ADDRESS, val); \
mtspr(ADDRESS, *(unsigned long *)val); \
return 0; \
} \
static ssize_t show_##NAME(struct sys_device *dev, \
struct sysdev_attribute *attr, \
char *buf) \
{ \
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
unsigned long val; \
smp_call_function_single(cpu->sysdev.id, read_##NAME, &val, 1); \
return sprintf(buf, "%lx\n", val); \
} \
static ssize_t __used \
Expand All @@ -183,7 +164,7 @@ static ssize_t __used \
int ret = sscanf(buf, "%lx", &val); \
if (ret != 1) \
return -EINVAL; \
run_on_cpu(cpu->sysdev.id, write_##NAME, val); \
smp_call_function_single(cpu->sysdev.id, write_##NAME, &val, 1); \
return count; \
}

Expand Down

0 comments on commit 39cd548

Please sign in to comment.