LWN.net Logo

SET_MODULE_OWNER

One would think that it wouldn't be worth arguing over... The macro in question is defined as:

    #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE)

Rusty Russell had marked that macro as "deprecated" during the course of his module work. There was, he thought, no real reason to keep it around. Others disagreed, though, and Zwane Mwaikambo recently submitted (and Linus accepted) a little patch to un-deprecate the macro. Why do people care, when it's just as easy to set the owner field of the structure in question directly?

The real reason, it seems, is that the macro helps in writing device drivers which work over a wide range of kernels. Various structures (including file_operations and net_device) lacked an owner field in the 2.2 kernel. If a driver uses SET_MODULE_OWNER, it is easy to make that driver compile under 2.2 with a suitable compatibility macro. If the driver sets the owner field directly, the only way to make it work with older kernels is with #ifdef, which is strongly discouraged in kernel code. SET_MODULE_OWNER thus takes the form of a simple accessor function which helps code work regardless of what actually happens inside a particular structure.

The final solution was to leave the macro un-deprecated, but with a comment from Jeff Garzik:

/* Think of SET_MODULE_OWNER like an IBM mainframe: leave it in a dark corner for years, don't break it, but don't ever upgrade it either :) If there is something newer and sexier than the mainframe, it's ok to use that instead. The mainframe won't feel lonely. -- Jeff Garzik */

(Log in to post comments)

Mainframe analogy

Posted Apr 10, 2003 19:36 UTC (Thu) by X-Nc (guest, #1661) [Link]

Why does everyone pick on the poor mainframes? They work, they work hard, they are still very sexy (if you actually take a look at them) and they are bullet proof. I think I'll start a "Give Mainframes Respect" movement. Or maybe I'll take a nap. Either way is good.

Copyright © 2003, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds