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>
This commit is contained in:
Christoph Hellwig
2008-02-08 04:20:26 -08:00
committed by Linus Torvalds
parent efae09f3e9
commit 8b88b0998e
7 changed files with 69 additions and 47 deletions

View File

@ -90,25 +90,29 @@ static struct dentry *ocd_debugfs_DC;
static struct dentry *ocd_debugfs_DS;
static struct dentry *ocd_debugfs_count;
static u64 ocd_DC_get(void *data)
static int ocd_DC_get(void *data, u64 *val)
{
return ocd_read(DC);
*val = ocd_read(DC);
return 0;
}
static void ocd_DC_set(void *data, u64 val)
static int ocd_DC_set(void *data, u64 val)
{
ocd_write(DC, val);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fops_DC, ocd_DC_get, ocd_DC_set, "0x%08llx\n");
static u64 ocd_DS_get(void *data)
static int ocd_DS_get(void *data, u64 *val)
{
return ocd_read(DS);
*val = ocd_read(DS);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fops_DS, ocd_DS_get, NULL, "0x%08llx\n");
static u64 ocd_count_get(void *data)
static int ocd_count_get(void *data, u64 *val)
{
return ocd_count;
*val = ocd_count;
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fops_count, ocd_count_get, NULL, "%lld\n");