kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Struct Inheritance in drivers/ata/
@ 2011-05-26 20:46 Peter Hamilton
  2011-05-27  1:23 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Hamilton @ 2011-05-26 20:46 UTC (permalink / raw)
  To: kernelnewbies

The code in drivers/ata/ uses an implementation of inheritance that I have
not seen before.  It's only briefly explained in the header file (
include/linux/libata.h:885):

/*
 * ->inherits must be the last field and all the preceding
 * fields must be pointers.
 */

The structs are then initialized with .inherits assigned first:

drivers/ata/sata_nv.c:475

static struct ata_port_operations nv_nf2_ops = {

        .inherits               = &nv_generic_ops,
        .freeze                 = nv_nf2_freeze,

        .thaw                   = nv_nf2_thaw,

};


Is this actually implementing inheritance?  Why do all preceding fields need
to be pointers?

As far as I can tell, this style is only found in the ata drivers.

Could anyone explain how this works?

Thanks,
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110526/3c1f4f32/attachment.html 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-27  4:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-26 20:46 Struct Inheritance in drivers/ata/ Peter Hamilton
2011-05-27  1:23 ` Greg KH
2011-05-27  2:20   ` Peter Hamilton
2011-05-27  4:49     ` Ankit Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).