Subject: Re: [RFC PATCH v4 01/25] virtual-bus: Implementation of Virtual Bus

From: Greg KH <[email-masked]>
Date: Fri, 14 Feb 2020 15:45:00 -0500

On Fri, Feb 14, 2020 at 04:34:55PM -0400, Jason Gunthorpe wrote:
> On Fri, Feb 14, 2020 at 09:02:40AM -0800, Greg KH wrote:
> > > +	put_device(&vdev->dev);
> > > +	ida_simple_remove(&virtbus_dev_ida, vdev->id);
> > 
> > You need to do this before put_device().
> 
> Shouldn't it be in the release function? The ida index should not be
> re-used until the kref goes to zero..

Doesn't really matter, once you have unregistered it, you can reuse it.
But yes, putting it in release() is the safest thing to do.

> > > +struct virtbus_device {
> > > +	struct device dev;
> > > +	const char *name;
> > > +	void (*release)(struct virtbus_device *);
> > > +	int id;
> > > +	const struct virtbus_dev_id *matched_element;
> > > +};
> > 
> > Any reason you need to make "struct virtbus_device" a public structure
> > at all? 
> 
> The general point of this scheme is to do this in a public header:
> 
> +struct iidc_virtbus_object {
> +	struct virtbus_device vdev;
> +	struct iidc_peer_dev *peer_dev;
> +};
> 
> And then this when the driver binds:

Ah, yes, nevermind, I missed that.

greg k-h