lkml.org 
[lkml]   [2004]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [rfc][patch] DRM initial function table support.
Christoph Hellwig wrote:
> On Tue, Aug 31, 2004 at 09:07:11AM -0700, Ian Romanick wrote:
>
>>I think the intention is to have default functions set in the
>>device-independent code and have the device-dependent code over-ride
>>them. Since the defaults may not always be NULL, doing a struct like
>>that wouldn't really work. I suppose we could have a struct and a
>>device-independent function that copies the non-NULL pointers from the
>>per-device struct. Would that be better?
>
> Don't copy them. Just put
>
> if (foo->ops->method1)
> foo->ops->method1(args);
> else
> generic_method1(args);
>
> in your code. It's an additional branch, but you avoid the indirect
> functioncalloverhead in exchange.

<MrHorse>No sir, I didn't like it.</MrHorse> That would not only be
ugly to read, but it would add maintenance burden. If the default
changes from NULL to non-NULL, code has to be changed from doing nothing
in the NULL case to calling generic_method1. The one place that we miss
is the one place that will crash Linus' box. :)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.036 / U:2.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site