On Fri, Mar 20, 2020 at 05:30:40PM +0000, Wan, Kaike wrote: > > > If this is not desirable, we could keep the current approach to create > > > the struct device dynamically through device_create(). In that case, > > > all we need to do is to clean up the code. Which one do you prefer? > > > > The issue here was parentage. There should not be a virtual device involved. > > > > The hfi1 user_class device should be parented to the ib_device, look at how > > things like umad work to do this properly. > So all we need to do is: > -- Change user_device from struct device * to struct device in hfi1_devdata; > -- Set up dd->user_device properly including setting its parent to ib_device; > -- call cdev_device_all(). Yes, but keep in mind that putting multiple krefs inside the same structure is very tricky - be sure to do it right. Jason