Re: [PATCH v9 3/7] i2c: fsi: Add port structures
From: Benjamin Herrenschmidt
Date: Mon Jun 04 2018 - 19:33:58 EST
On Mon, 2018-06-04 at 22:17 +0300, Andy Shevchenko wrote:
>
> > +static int fsi_i2c_remove(struct device *dev)
> > +{
> > + struct fsi_i2c_master *i2c = dev_get_drvdata(dev);
> > + struct fsi_i2c_port *port;
> > +
> > + list_for_each_entry(port, &i2c->ports, list) {
> > + i2c_del_adapter(&port->adapter);
> > + kfree(port);
> > + }
>
> Just to be sure, it will be called if and only if all adapters are not
> busy. Correct?
Actually i2c_del_adapter() will do the right thing. It even waits until
the embedded struct device has been fully released.
As indicated by the comment in there, it should all be turned into
something a bit better, but this is what the i2c layer gives us today.
> > +
> > + return 0;
> > +}
> > +
> > static const struct fsi_device_id fsi_i2c_ids[] = {
> > { FSI_ENGID_I2C, FSI_VERSION_ANY },
> > { 0 }
> > @@ -224,6 +313,7 @@ static int fsi_i2c_probe(struct device *dev)
> > .name = "i2c-fsi",
> > .bus = &fsi_bus_type,
> > .probe = fsi_i2c_probe,
> > + .remove = fsi_i2c_remove,
> > },
> > };
> >
> > --
> > 1.8.3.1
> >
>
>
>