On Mon, 2007-12-17 at 01:20 +0100, [email protected] wrote:
> This makes debugfs use its own file_operations for the value accessor files
> created by debugfs_create_XXX. Having that, we can also have proper versions
> for signed integers.
I think I'd probably prefer if this didn't duplicate all the fs/libfs.c
simple attribute functionality but extended libfs instead to define
attributes that can have their own print/scan functions. Or something
like that.
As far as I can tell, the only reason you're doing this huge amount of
code duplication is the "(unsigned long long)" cast in fs/libfs.c, or am
I missing something?
You might even be able to get around that: define the get() function in
simple_attr to return unsigned long long (rather than u64 as it does
now) and then remove the cast. Then, %lld will still print a negative
number if applicable.
johannes
On Mon, 2007-12-17 at 17:43 +0100, Johannes Berg wrote:
> On Mon, 2007-12-17 at 01:20 +0100, [email protected] wrote:
> > This makes debugfs use its own file_operations for the value accessor files
> > created by debugfs_create_XXX. Having that, we can also have proper versions
> > for signed integers.
>
> I think I'd probably prefer if this didn't duplicate all the fs/libfs.c
> simple attribute functionality but extended libfs instead to define
> attributes that can have their own print/scan functions. Or something
> like that.
Yeah, I actually tried that. See this thread:
http://lkml.org/lkml/2007/12/16/78
As far as I understand, your point is the same what Greg said.
>
> As far as I can tell, the only reason you're doing this huge amount of
> code duplication is the "(unsigned long long)" cast in fs/libfs.c, or am
> I missing something?
Yes. Moreover, conceptually it's much cleaner to use the correct data
type.
>
> You might even be able to get around that: define the get() function in
> simple_attr to return unsigned long long (rather than u64 as it does
> now) and then remove the cast. Then, %lld will still print a negative
> number if applicable.
And the compiler doesn't even complain. That's a cool hack ;-) But
still, it's a hack.
Mattias