Messages in this thread |  | | | Date | Tue, 08 Apr 2003 00:39:46 -0400 | | From | Jeff Garzik <> | | Subject | Re: SET_MODULE_OWNER? |
| |
Rusty Russell wrote: > In message <Pine.LNX.4.50.0304072212310.21025-100000@montezuma.mastecende.com> > you write: > >>(e.g. pci-dma api changes). Regardless, here is a typical use in a >>netdriver. >> >> /* dev and dev->priv zeroed in alloc_etherdev */ >> dev = alloc_etherdev (sizeof (*tp)); >> if (dev == NULL) { >> printk (KERN_ERR PFX "%s: Unable to alloc new net device\n", pd > > ev->slot_name); > >> return -ENOMEM; >> } >> SET_MODULE_OWNER(dev); >> tp = dev->priv; >> >> /* followed by ... */ >> dev->foo = __foo; >> dev->bar = __bar; > > > I don't understand how that helps compatibility over: > > dev->owner = THIS_MODULE; > > Both will: > 1) Work on 2.4 and 2.5 > 2) Break on 2.2.
Wrong.
SET_MODULE_OWNER works in 2.2 _and earlier_... given some compat glue in a "#include <kcompat>" macros.
You may take a look at "kcompat" for further examples. http://sf.net/projects/gkernel/ I provide an example of how to get a net driver from 2.4 running under 2.2, such that the 2.4 driver -appears- to be completely free of compatibility glue.
The only sticking points in such glue are when structure members are directly exposed in the source code. That cannot be worked around with cpp magic. This is why SET_MODULE_OWNER exists, this is why pci_{get,set}_drvdata() exist, and so on. Jeff
- 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/
|  |