[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171219093643.GA3903@kroah.com>
Date: Tue, 19 Dec 2017 10:36:43 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Boris Brezillon <boris.brezillon@...e-electrons.com>
Cc: Wolfram Sang <wsa@...-dreams.de>, linux-i2c@...r.kernel.org,
Jonathan Corbet <corbet@....net>, linux-doc@...r.kernel.org,
Arnd Bergmann <arnd@...db.de>,
Przemyslaw Sroka <psroka@...ence.com>,
Arkadiusz Golec <agolec@...ence.com>,
Alan Douglas <adouglas@...ence.com>,
Bartosz Folta <bfolta@...ence.com>,
Damian Kos <dkos@...ence.com>,
Alicja Jurasik-Urbaniak <alicja@...ence.com>,
Cyprian Wronka <cwronka@...ence.com>,
Suresh Punnoose <sureshp@...ence.com>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
Nishanth Menon <nm@...com>, Rob Herring <robh+dt@...nel.org>,
Pawel Moll <pawel.moll@....com>,
Mark Rutland <mark.rutland@....com>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Vitor Soares <Vitor.Soares@...opsys.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v2 2/7] i3c: Add core I3C infrastructure
On Tue, Dec 19, 2017 at 10:28:58AM +0100, Boris Brezillon wrote:
> On Tue, 19 Dec 2017 10:21:19 +0100
> Greg Kroah-Hartman <gregkh@...uxfoundation.org> wrote:
>
> > On Tue, Dec 19, 2017 at 10:13:36AM +0100, Boris Brezillon wrote:
> > > On Tue, 19 Dec 2017 10:09:00 +0100
> > > Boris Brezillon <boris.brezillon@...e-electrons.com> wrote:
> > >
> > > > On Tue, 19 Dec 2017 09:52:50 +0100
> > > > Greg Kroah-Hartman <gregkh@...uxfoundation.org> wrote:
> > > >
> > > > > On Thu, Dec 14, 2017 at 04:16:05PM +0100, Boris Brezillon wrote:
> > > > > > +/**
> > > > > > + * i3c_device_match_id() - Find the I3C device ID entry matching an I3C dev
> > > > > > + * @i3cdev: the I3C device we're searching a match for
> > > > > > + * @id_table: the I3C device ID table
> > > > > > + *
> > > > > > + * Return: a pointer to the first entry matching @i3cdev, or NULL if there's
> > > > > > + * no match.
> > > > > > + */
> > > > > > +const struct i3c_device_id *
> > > > > > +i3c_device_match_id(struct i3c_device *i3cdev,
> > > > > > + const struct i3c_device_id *id_table)
> > > > > > +{
> > > > > > + const struct i3c_device_id *id;
> > > > > > +
> > > > > > + /*
> > > > > > + * The lower 32bits of the provisional ID is just filled with a random
> > > > > > + * value, try to match using DCR info.
> > > > > > + */
> > > > > > + if (!I3C_PID_RND_LOWER_32BITS(i3cdev->info.pid)) {
> > > > > > + u16 manuf = I3C_PID_MANUF_ID(i3cdev->info.pid);
> > > > > > + u16 part = I3C_PID_PART_ID(i3cdev->info.pid);
> > > > > > + u16 ext_info = I3C_PID_EXTRA_INFO(i3cdev->info.pid);
> > > > > > +
> > > > > > + /* First try to match by manufacturer/part ID. */
> > > > > > + for (id = id_table; id->match_flags != 0; id++) {
> > > > > > + if ((id->match_flags & I3C_MATCH_MANUF_AND_PART) !=
> > > > > > + I3C_MATCH_MANUF_AND_PART)
> > > > > > + continue;
> > > > > > +
> > > > > > + if (manuf != id->manuf_id || part != id->part_id)
> > > > > > + continue;
> > > > > > +
> > > > > > + if ((id->match_flags & I3C_MATCH_EXTRA_INFO) &&
> > > > > > + ext_info != id->extra_info)
> > > > > > + continue;
> > > > > > +
> > > > > > + return id;
> > > > > > + }
> > > > > > + }
> > > > > > +
> > > > > > + /* Fallback to DCR match. */
> > > > > > + for (id = id_table; id->match_flags != 0; id++) {
> > > > > > + if ((id->match_flags & I3C_MATCH_DCR) &&
> > > > > > + id->dcr == i3cdev->info.dcr)
> > > > > > + return id;
> > > > > > + }
> > > > > > +
> > > > > > + return NULL;
> > > > > > +}
> > > > > > +EXPORT_SYMBOL_GPL(i3c_device_match_id);
> > > > >
> > > > > I just picked one random export here, but it feels like you are
> > > > > exporting a bunch of symbols you don't need to. Why would something
> > > > > outside of the i3c "core" need to call this function?
> > > >
> > > > Because I'm not passing the i3c_device_id to the ->probe() method, and
> > > > if the driver is supporting different variants of the device, it may
> > > > want to know which one is being probed.
> > > >
> > > > I considered retrieving this information in the core just before probing
> > > > the driver and passing it to the ->probe() function, but it means
> > > > having an extra i3c_device_match_id() call for everyone even those who
> > > > don't care about the device_id information, so I thought exporting this
> > > > function was a good alternative (device drivers can use it when they
> > > > actually need to retrieve the device_id).
> > > >
> > > > Anyway, that's something I can change if you think passing the
> > > > i3c_device_id to the ->probe() method is preferable.
> > > >
> > > > > Have you looked
> > > > > to see if you really have callers for everything you are exporting?
> > > >
> > > > Yes, I tried to only export functions that I think will be needed by
> > > > I3C device drivers and I3C master drivers. Note that I didn't post the
> > > > dummy device driver I developed to test the framework (partly because
> > > > this is
> > >
> > > Sorry, I hit the send button before finishing my sentence :-).
> > >
> > > "
> > > Note that I didn't post the dummy device driver [1] I developed to test
> > > the framework (partly because the quality of the code does not meet
> > > mainline standards and I was ashamed of posting it publicly :-)), but
> > > this driver is using some of the exported functions.
> > > "
> >
> > We don't export functions that has no in-kernel users :)
>
> But then, I can't export device driver related functions, because
> there's no official device driver yet :-). So what should I do?
Export them when you have a driver. Or better yet, submit a driver as
part of the patch series. Why would we want infrastructure that no one
uses?
thanks,
greg k-h
Powered by blists - more mailing lists