From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
"lars@metafoo.de" <lars@metafoo.de>,
"Michael.Hennerich@analog.com" <Michael.Hennerich@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4] iio: accel: adxl345: Add ACPI HID table
Date: Fri, 18 Feb 2022 12:10:17 +0000 [thread overview]
Message-ID: <20220218121017.32bbdef9@jic23-huawei> (raw)
In-Reply-To: <CAHp75Vf4pjyJJDLKWTjq2ny1xkF9fSCSPb_8q5yk69DjV9EUAg@mail.gmail.com>
On Fri, 18 Feb 2022 09:39:14 +0100
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Fri, Feb 18, 2022 at 4:46 AM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
> > On Thu, Feb 17, 2022 at 6:57 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > > On Thursday, February 17, 2022, Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
>
> ...
>
> > >> + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
> > >> + if (acpi_id) {
> > >> + type = acpi_id->driver_data;
> > >> + name = acpi_id->id;
> > >> + } else
> > >> + return -ENODEV;
> > >
> > > Thanks, but can we do this in ACPI agnostic way?
> > >
> > > Can be as simple as
> > >
> > > if (id)
> > > ...
> > > else {
> > > match = device_get_match_data(dev);
> > > if (!match)
> > > return -ENODEV;
> > > }
> > >
> > > Note, it might require to reconsider what is put in the driver data (either convert to pointers, or be sure that valid type is never a 0/NULL).
> >
> > Unlike acpi_match_device(), device_get_match_data() only get
> > driver_data, so we need a new struct to provide both name and type.
>
> It's unfortunate. Let me think about it a bit more.
Usual solution is just to add that name to a per device type structure.
In this particular case there isn't one so far though and an enum is used
in the one place we might otherwise have used a part number specific structure.
Probably the easiest thing to do is use the enum to do a lookup in an array
of structures and have the string there.
>
> > > Also note, in both cases using ID name for name us fragile. Probably we have to fix that first. Let me check today’s evening.
> >
> > Can you please explain more on this? How does ID name make it fragile?
>
> I thought this one is used somehow by userspace to distinguish the
> instance of the device, but looking into the rest of the IIO drivers
> it seems more or less a field for part number. That said, the ID is
> okay to use. I hope Jonathan may correct me.
>
Should be part number. Instances are distinguished via label rather than
name (or via the device parent on older kernels where we didn't have
label).
There are a few places where we accidentally let though IDs that aren't
always simply the part number and they became part of the ABI so we
couldn't really fix them after the event.
Jonathan
next prev parent reply other threads:[~2022-02-18 12:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 5:52 Kai-Heng Feng
[not found] ` <CAHp75VfFGw3b_ZtQir0AfTfXfQ7fi_LKLsY-7ww=4+MMBR8BAQ@mail.gmail.com>
2022-02-18 3:46 ` Kai-Heng Feng
2022-02-18 8:39 ` Andy Shevchenko
2022-02-18 12:10 ` Jonathan Cameron [this message]
2022-02-18 12:27 ` Andy Shevchenko
2022-02-19 17:44 ` Jonathan Cameron
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=20220218121017.32bbdef9@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=kai.heng.feng@canonical.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®