Re: [rfc][patch] DRM initial function table support.

From: Ian Romanick
Date: Tue Aug 31 2004 - 12:58:49 EST


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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/