From: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
To: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Pawel Moll <Pawel.Moll-5wv7dgnIgG8@public.gmane.org>,
Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
Ian Campbell
<ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>,
"grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org"
<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
Subject: Re: All device tree bindings need maintainer ack or just the 'interesting' ones.
Date: Wed, 18 Sep 2013 14:58:04 +0100 [thread overview]
Message-ID: <20130918135803.GG26737@e106331-lin.cambridge.arm.com> (raw)
In-Reply-To: <20130917134841.GX16984@lee--X1>
On Tue, Sep 17, 2013 at 02:48:41PM +0100, Lee Jones wrote:
> On Tue, 17 Sep 2013, Mark Rutland wrote:
>
> > On Tue, Sep 17, 2013 at 01:07:30PM +0100, Lee Jones wrote:
> > > On Tue, 17 Sep 2013, Mark Rutland wrote:
> > >
> > > > On Tue, Sep 17, 2013 at 09:10:03AM +0100, Lee Jones wrote:
> > > > > > > http://marc.info/?l=linux-iio&m=137881790217809&w=2
> > > > > >
> > > > > > Looks reasonable. My only comment is '-' is preferred over '_'.
> > > > >
> > > > > Ah, in the node name you mean. Yes, I can change that.
> > > > >
> > > > > The compatible string has to stay the same however, as it has to match
> > > > > the device name which can't be changed due to possible userspace
> > > > > breakage.
> > > >
> > > > I'm not sure I follow why the compatible string must be identical to the
> > > > name appearing to userspace.
> > >
> > > It doesn't. It has to be identical to the device name, which I'm
> > > guessing is used when populating sysfs.
> >
> > I still don't understand why the device name must be identical to the
> > compatible string.
> >
> > The string "st,lsm303dlh_magn" (with the "st," prefix) appears nowhere
> > in v3.12-rc1
>
> You're looking at an old patchset. We found out that the Snowball
> schematic was actually incorrect and we have a LSM303DLHC.
>
> git grep -i lsm303dlhc_magn v3.12-rc1
> drivers/iio/magnetometer/st_magn.h:
> #define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn"
>
> > and the compatible string in the dt doesn't seem to get
> > assigned to the device in the i2c core or in
> > drivers/iio/magnetometer/st_magn_i2c.c.
>
> It does:
> drivers/i2c/busses/*.c: of_i2c_register_devices();
> drivers/of/of_i2c.c: |-> of_modalias_node();
> |-> i2c_new_device();
Ah, I see.
I thought the return of of_modalias_node was only used to *guess* the
module which might need to be loaded, rather than also being exposed to
userspace as the device name.
We've got a leak of Linux implementation details into the dt here, and I
don't like it. Thanks to the combination of of_i2c_register device's use
of of_modalias_node, and i2c_device_match using the id table after
failing to use dt, any driver with a i2c_device_id name implicitly
defines a dt binding for "${ARBITRARY_PREFIX},name". The same is true
for SPI drivers using spi_device_id. This turns what looks like a Linux
internal value into an ABI facing bootloader software.
Judging by a quick and dirty grep [1], as of v3.12-rc1 there are ~930
suffixes which *may* be accepted with an arbitrary prefix as an I2C
compatible string, of which ~750 do not appear in
Documentation/devicetree. For SPI there are just over 400, of which just
under 400 aren't documented. Both these counts include drivers that may
never be built for DT platforms, as I've not filtered the results.
Some drivers have an of_match_table (e.g. i2c-hid has a single
"hid-over-i2c" entry), but if the I2C core fails to match in the
of_match_table it'll still carry on and match the stripped compatible
against the i2c_device_id table (where it'll happily match
"${VENDOR},hid"). I think if a driver has an of_match_table and we fail
to match with of_match_device we should fail rather than falling back to
the id table.
In the i2c-hid case, I can't see how the "hid-over-i2c" variant can ever
work -- of_i2c_register_devices will skip over devices where the
compatible string doesn't contain a ','. So our documented compatible
string isn't usable, while an undocumented one is...
We don't appear to have any clashes yet (with "vendor-a,device" and
"vendor-b,device"), so maybe that's not an issue -- we can add
of_match_table entries as required to disambiguate, though we have to be
careful to capture all the prefixes already in use.
The current use of of_modalias_node also only allows for the first entry
in the compatible list to be used to request a compatible module. I
think it would be better for the DT core to request modules somehow when
iterating over compatible lists, but I'm not familiar with
MODULE_DEVICE_TABLE() and friends, so maybe that's not as easy as it
sounds. That doesn't solve exporting a sensible modalias to userspace,
but it would somewhat decouple the compatible list and modaliases, and
allow for fallback entries in the compatible list to load modules if
required.
I see that some macintosh drivers have i2c_device_id values in device
tree style (e.g. "MAC,fcu"), without an of_match_table. Assuming that
"MAC,fcu" is the full string rather than "AAPL,MAC,fcu", I don't see how
those get matched to drivers. The I2C core will drop the leading "MAC,",
leaving only "fcu" in the i2c_board_info, and then that won't match any
driver modaliases. I'm probably missing something here.
Thanks,
Mark.
[1] $ git grep -hW i2c_device_id.\*= -- drivers | grep {.\*} |
grep -o "\"[^\"]\+\"" | grep -o "[^\"]\+" | sort -u |
xargs -I '{}' sh -c 'git grep -q "{}" -- Documentation/devicetree ||
echo Undocumented binding \"*,{}\"'
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-09-18 13:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-14 12:07 All device tree bindings need maintainer ack or just the 'interesting' ones Jonathan Cameron
[not found] ` <52345182.1080609-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-09-16 16:17 ` Rob Herring
[not found] ` <52372F2B.3030504-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-17 8:10 ` Lee Jones
2013-09-17 11:24 ` Mark Rutland
[not found] ` <20130917112433.GB26737-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-09-17 12:07 ` Lee Jones
2013-09-17 13:30 ` Mark Rutland
[not found] ` <20130917133025.GD26737-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-09-17 13:48 ` Lee Jones
2013-09-18 13:58 ` Mark Rutland [this message]
[not found] ` <20130918135803.GG26737-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-09-18 15:05 ` Mark Brown
2013-09-18 15:11 ` Grant Likely
[not found] ` <20130918151119.59DB1C42CDF-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-09-21 14:57 ` Jonathan Cameron
[not found] ` <523DB3E6.3040804-tko9wxEg+fIOOJlXag/Snyp2UmYkHbXO@public.gmane.org>
2013-10-08 8:47 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130918135803.GG26737@e106331-lin.cambridge.arm.com \
--to=mark.rutland-5wv7dgnigg8@public.gmane.org \
--cc=Pawel.Moll-5wv7dgnIgG8@public.gmane.org \
--cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org \
--cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).