On Thu, May 05, 2022 at 12:54:09PM -0600, Alex Williamson wrote: > > > I'd also rather see the variant driver fail to register with the core > > > than to see a failure opening the device an arbitrary time later. > > > > It still permits a driver to be wrong, eg all the drivers are like > > this today: > > > > ret = vfio_pci_core_register_device(&hisi_acc_vdev->core_device); > > if (ret) > > goto out_free; > > dev_set_drvdata(&pdev->dev, &hisi_acc_vdev->core_device); > > > > So a WARN_ON inside register_device will not catch the mistake, as > > this is the common pattern it isn't as helpful. > > In the above case the WARN_ON would trigger because drvdata isn't set > to the core device for the registration call. Yes, a driver could > still set drvdata after the registration call, but then they get to > explain why they set drvdata twice and thought they could get away with > changing it after the core made pretty clear that it wants a specific > thing there. Thanks, I'm OK with this idea, it is not quite a nice to set the drvdata in the middle of the probe function, but it does work here. I'll fix it Jason