aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorSam bobroff <sam.bobroff@au1.ibm.com>2014-05-21 02:32:37 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-05-27 23:35:39 -0400
commit39a360ef7234942333436709fd6cf641d5c51b7b (patch)
tree1c290685e037cae5ee25200cf931ed93e4d616be /arch/powerpc/kernel
parentb717d98543d90c50f398ddfe9665483d09adca7a (diff)
powerpc: Split __SYSFS_SPRSETUP macro
Split the __SYSFS_SPRSETUP macro into two parts so that registers requiring custom read and write functions can use common code for their show and store functions. Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/sysfs.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index d90d4b7810d6..e2a1d6fb3297 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -404,7 +404,7 @@ void ppc_enable_pmcs(void)
404} 404}
405EXPORT_SYMBOL(ppc_enable_pmcs); 405EXPORT_SYMBOL(ppc_enable_pmcs);
406 406
407#define __SYSFS_SPRSETUP(NAME, ADDRESS, EXTRA) \ 407#define __SYSFS_SPRSETUP_READ_WRITE(NAME, ADDRESS, EXTRA) \
408static void read_##NAME(void *val) \ 408static void read_##NAME(void *val) \
409{ \ 409{ \
410 *(unsigned long *)val = mfspr(ADDRESS); \ 410 *(unsigned long *)val = mfspr(ADDRESS); \
@@ -413,7 +413,9 @@ static void write_##NAME(void *val) \
413{ \ 413{ \
414 EXTRA; \ 414 EXTRA; \
415 mtspr(ADDRESS, *(unsigned long *)val); \ 415 mtspr(ADDRESS, *(unsigned long *)val); \
416} \ 416}
417
418#define __SYSFS_SPRSETUP_SHOW_STORE(NAME) \
417static ssize_t show_##NAME(struct device *dev, \ 419static ssize_t show_##NAME(struct device *dev, \
418 struct device_attribute *attr, \ 420 struct device_attribute *attr, \
419 char *buf) \ 421 char *buf) \
@@ -436,10 +438,15 @@ static ssize_t __used \
436 return count; \ 438 return count; \
437} 439}
438 440
439#define SYSFS_PMCSETUP(NAME, ADDRESS) \ 441#define SYSFS_PMCSETUP(NAME, ADDRESS) \
440 __SYSFS_SPRSETUP(NAME, ADDRESS, ppc_enable_pmcs()) 442 __SYSFS_SPRSETUP_READ_WRITE(NAME, ADDRESS, ppc_enable_pmcs()) \
441#define SYSFS_SPRSETUP(NAME, ADDRESS) \ 443 __SYSFS_SPRSETUP_SHOW_STORE(NAME)
442 __SYSFS_SPRSETUP(NAME, ADDRESS, ) 444#define SYSFS_SPRSETUP(NAME, ADDRESS) \
445 __SYSFS_SPRSETUP_READ_WRITE(NAME, ADDRESS, ) \
446 __SYSFS_SPRSETUP_SHOW_STORE(NAME)
447
448#define SYSFS_SPRSETUP_SHOW_STORE(NAME) \
449 __SYSFS_SPRSETUP_SHOW_STORE(NAME)
443 450
444/* Let's define all possible registers, we'll only hook up the ones 451/* Let's define all possible registers, we'll only hook up the ones
445 * that are implemented on the current processor 452 * that are implemented on the current processor