diff options
author | Christoph Hellwig <hch@lst.de> | 2008-02-08 07:20:26 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:34 -0500 |
commit | 8b88b0998e35d239e74446cc30f354bdab86df89 (patch) | |
tree | c13773b744cf12b1e30ec9336a4acaf21e46c6d9 /arch | |
parent | efae09f3e99fcc1bdead7bc23a508b3bade3f82f (diff) |
libfs: allow error return from simple attributes
Sometimes simple attributes might need to return an error, e.g. for
acquiring a mutex interruptibly. In fact we have that situation in
spufs already which is the original user of the simple attributes. This
patch merged the temporarily forked attributes in spufs back into the
main ones and allows to return errors.
[akpm@linux-foundation.org: build fix]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: <stefano.brivio@polimi.it>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg KH <greg@kroah.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/avr32/kernel/ocd.c | 18 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/file.c | 8 |
2 files changed, 15 insertions, 11 deletions
diff --git a/arch/avr32/kernel/ocd.c b/arch/avr32/kernel/ocd.c index c4f023294d75..1b0245d4e0ca 100644 --- a/arch/avr32/kernel/ocd.c +++ b/arch/avr32/kernel/ocd.c | |||
@@ -90,25 +90,29 @@ static struct dentry *ocd_debugfs_DC; | |||
90 | static struct dentry *ocd_debugfs_DS; | 90 | static struct dentry *ocd_debugfs_DS; |
91 | static struct dentry *ocd_debugfs_count; | 91 | static struct dentry *ocd_debugfs_count; |
92 | 92 | ||
93 | static u64 ocd_DC_get(void *data) | 93 | static int ocd_DC_get(void *data, u64 *val) |
94 | { | 94 | { |
95 | return ocd_read(DC); | 95 | *val = ocd_read(DC); |
96 | return 0; | ||
96 | } | 97 | } |
97 | static void ocd_DC_set(void *data, u64 val) | 98 | static int ocd_DC_set(void *data, u64 val) |
98 | { | 99 | { |
99 | ocd_write(DC, val); | 100 | ocd_write(DC, val); |
101 | return 0; | ||
100 | } | 102 | } |
101 | DEFINE_SIMPLE_ATTRIBUTE(fops_DC, ocd_DC_get, ocd_DC_set, "0x%08llx\n"); | 103 | DEFINE_SIMPLE_ATTRIBUTE(fops_DC, ocd_DC_get, ocd_DC_set, "0x%08llx\n"); |
102 | 104 | ||
103 | static u64 ocd_DS_get(void *data) | 105 | static int ocd_DS_get(void *data, u64 *val) |
104 | { | 106 | { |
105 | return ocd_read(DS); | 107 | *val = ocd_read(DS); |
108 | return 0; | ||
106 | } | 109 | } |
107 | DEFINE_SIMPLE_ATTRIBUTE(fops_DS, ocd_DS_get, NULL, "0x%08llx\n"); | 110 | DEFINE_SIMPLE_ATTRIBUTE(fops_DS, ocd_DS_get, NULL, "0x%08llx\n"); |
108 | 111 | ||
109 | static u64 ocd_count_get(void *data) | 112 | static int ocd_count_get(void *data, u64 *val) |
110 | { | 113 | { |
111 | return ocd_count; | 114 | *val = ocd_count; |
115 | return 0; | ||
112 | } | 116 | } |
113 | DEFINE_SIMPLE_ATTRIBUTE(fops_count, ocd_count_get, NULL, "%lld\n"); | 117 | DEFINE_SIMPLE_ATTRIBUTE(fops_count, ocd_count_get, NULL, "%lld\n"); |
114 | 118 | ||
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c index 1018acd1746b..9326714717ca 100644 --- a/arch/powerpc/platforms/cell/spufs/file.c +++ b/arch/powerpc/platforms/cell/spufs/file.c | |||
@@ -460,7 +460,7 @@ static int spufs_cntl_open(struct inode *inode, struct file *file) | |||
460 | if (!i->i_openers++) | 460 | if (!i->i_openers++) |
461 | ctx->cntl = inode->i_mapping; | 461 | ctx->cntl = inode->i_mapping; |
462 | mutex_unlock(&ctx->mapping_lock); | 462 | mutex_unlock(&ctx->mapping_lock); |
463 | return spufs_attr_open(inode, file, spufs_cntl_get, | 463 | return simple_attr_open(inode, file, spufs_cntl_get, |
464 | spufs_cntl_set, "0x%08lx"); | 464 | spufs_cntl_set, "0x%08lx"); |
465 | } | 465 | } |
466 | 466 | ||
@@ -470,7 +470,7 @@ spufs_cntl_release(struct inode *inode, struct file *file) | |||
470 | struct spufs_inode_info *i = SPUFS_I(inode); | 470 | struct spufs_inode_info *i = SPUFS_I(inode); |
471 | struct spu_context *ctx = i->i_ctx; | 471 | struct spu_context *ctx = i->i_ctx; |
472 | 472 | ||
473 | spufs_attr_release(inode, file); | 473 | simple_attr_close(inode, file); |
474 | 474 | ||
475 | mutex_lock(&ctx->mapping_lock); | 475 | mutex_lock(&ctx->mapping_lock); |
476 | if (!--i->i_openers) | 476 | if (!--i->i_openers) |
@@ -482,8 +482,8 @@ spufs_cntl_release(struct inode *inode, struct file *file) | |||
482 | static const struct file_operations spufs_cntl_fops = { | 482 | static const struct file_operations spufs_cntl_fops = { |
483 | .open = spufs_cntl_open, | 483 | .open = spufs_cntl_open, |
484 | .release = spufs_cntl_release, | 484 | .release = spufs_cntl_release, |
485 | .read = spufs_attr_read, | 485 | .read = simple_attr_read, |
486 | .write = spufs_attr_write, | 486 | .write = simple_attr_write, |
487 | .mmap = spufs_cntl_mmap, | 487 | .mmap = spufs_cntl_mmap, |
488 | }; | 488 | }; |
489 | 489 | ||