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

From: Christoph Hellwig
Date: Tue Aug 31 2004 - 12:12:00 EST


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.
-
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/