> // SAFETY: > // > - // self.clock is not initialized at this point; but since > `NonNull<_>` is Copy, > - // we can overwrite the undefined value without side effects. This is > + // self.clock is not initialized at this point; but since > `NonNull<_>` is
s/NonNull<_>/Owned<_>/ > + // not Drop, we can overwrite the undefined value without side > effects. This is > // safe since all PL011State instances are created by QOM code which > // calls this function to initialize the fields; therefore no code is > // able to access an invalid self.clock value. > - unsafe { > - let dev: &mut DeviceState = self.upcast_mut(); > - self.clock = NonNull::new(qdev_init_clock_in( > - dev, > - CLK_NAME.as_ptr(), > - None, /* pl011_clock_update */ > - addr_of_mut!(*self).cast::<c_void>(), > - ClockEvent::ClockUpdate.0, > - )) > - .unwrap(); > - } > + self.clock = self.init_clock_in("clk", &Self::clock_update, > ClockEvent::ClockUpdate); > + } > + Reviewed-by: Zhao Liu <zhao1....@intel.com>