From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Subject: Re: [PATCH v4 01/10] i3c: Add core I3C infrastructure Date: Wed, 11 Jul 2018 17:03:20 +0200 Message-ID: <20180711170320.5b2b0114@bbrezillon> References: <20180330074751.25987-1-boris.brezillon@bootlin.com> <20180330074751.25987-2-boris.brezillon@bootlin.com> <20180711164120.3e32fb08@bbrezillon> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180711164120.3e32fb08@bbrezillon> Sender: linux-kernel-owner@vger.kernel.org To: Arnd Bergmann Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Jonathan Corbet , "open list:DOCUMENTATION" , Greg Kroah-Hartman , Przemyslaw Sroka , Arkadiusz Golec , Alan Douglas , Bartosz Folta , Damian Kos , Alicja Jurasik-Urbaniak , Cyprian Wronka , Suresh Punnoose , Rafal Ciepiela , Thomas Petazzoni , Nishanth Menon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell List-Id: devicetree@vger.kernel.org On Wed, 11 Jul 2018 16:41:20 +0200 Boris Brezillon wrote: > > > +/** > > > + * i3cdev_to_dev() - Returns the device embedded in @i3cdev > > > + * @i3cdev: I3C device > > > + * > > > + * Return: a pointer to a device object. > > > + */ > > > +struct device *i3cdev_to_dev(struct i3c_device *i3cdev) > > > +{ > > > + return &i3cdev->dev; > > > +} > > > +EXPORT_SYMBOL_GPL(i3cdev_to_dev); > > > + > > > +/** > > > + * dev_to_i3cdev() - Returns the I3C device containing @dev > > > + * @dev: device object > > > + * > > > + * Return: a pointer to an I3C device object. > > > + */ > > > +struct i3c_device *dev_to_i3cdev(struct device *dev) > > > +{ > > > + return container_of(dev, struct i3c_device, dev); > > > +} > > > +EXPORT_SYMBOL_GPL(dev_to_i3cdev); > > > > Many other subsystems just make the device structure available > > to all client drivers so this can be an inline operation. Is there > > a strong reason to hide it here? > > No, but I think most subsystem do provide dev_to_xxxdev() at least > (to_platform_device() for instance) > My bad. I misunderstood you question. The main reason I did that was because I didn't want to expose i3c_device internals to the I3C device drivers. Anyway, this part will be reworked in my v6 to address one problem we had when re-attaching a pre-existing device that had lost its dynamic address and acquired a new one. Since we want that operation to be transparent to I3C device drivers, I had to decouple the I3C device driver representation from the I3C master controller one. I thus end up with struct i3C_dev_desc on the controller API side, and struct i3c_device on the driver side with a link between the 2 object that can be updated at runtime. And as you can imagine, i3c_device does not contain a lot of information now.