+static void piix4_pm_machine_ready(struct Notifier* n)
+{
+ PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready);
DO_UPCAST()? I assume we have it for a reason.
NIH is the reason we have it.
DO_UPCAST checks that the offset of the field is zero:
#ifdef __GNUC__
#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
char __attribute__((unused)) offset_must_be_zero[ \
-offsetof(type, field)]; \
container_of(dev, type, field);}))
#else
#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
#endif
This isn't the case here, we really want container_of.
BTW, DO_UPCAST actually is used to do a _down_cast (base to derived). A
compile-time checked upcast (derived to base) could be done like this:
#ifdef __GNUC__
#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
char __attribute__((unused)) offset_must_be_zero[ \
-offsetof(type, field)]; \
char __attribute__((unused)) type_matches = \
type_check(type, __typeof__(dev));
&(dev)->field);}))
#else
#define DO_UPCAST(type, field, dev) &(dev)->field
#endif
Paolo