From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Jeremy Cline <jeremy@jcline.org>,
linux-iio <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 2/3] iio: accel: bmc150: Check for a second ACPI device for BOSC0200
Date: Wed, 25 Nov 2020 12:11:33 +0100 [thread overview]
Message-ID: <ee0d26b1-ee54-0c2c-cd9f-40366e3b10d4@redhat.com> (raw)
In-Reply-To: <CAHp75VcZQ1duxHnUTD9ewRhWxoHay8S6AQaEK3v3jJr+oQcbDw@mail.gmail.com>
Hi,
On 11/25/20 11:55 AM, Andy Shevchenko wrote:
> On Wed, Nov 25, 2020 at 10:37 AM Hans de Goede <hdegoede@redhat.com> wrote:
>>
>> From: Jeremy Cline <jeremy@jcline.org>
>>
>> Some BOSC0200 acpi_device-s describe two accelerometers in a single ACPI
>> device. Normally we would handle this by letting the special
>> drivers/platform/x86/i2c-multi-instantiate.c driver handle the BOSC0200
>> ACPI id and let it instantiate 2 bmc150_accel type i2c_client-s for us.
>>
>> But doing so changes the modalias for the first accelerometer
>> (which is already supported and used on many devices) from
>> acpi:BOSC0200 to i2c:bmc150_accel. The modalias is not only used
>> to load the driver, but is also used by hwdb matches in
>> /lib/udev/hwdb.d/60-sensor.hwdb which provide a mountmatrix to
>> userspace by setting the ACCEL_MOUNT_MATRIX udev property.
>>
>> Switching the handling of the BOSC0200 over to i2c-multi-instantiate.c
>> will break the hwdb matches causing the ACCEL_MOUNT_MATRIX udev prop
>> to no longer be set. So switching over to i2c-multi-instantiate.c is
>> not an option.
>
> I'm wondering if we can meanwhile update hwdb to support
> i2c-multi-instantiate cases in the future and in a few years switch to
> it.
Even if we fix current hwdb entries to match on both, then there
is no guarantee newly added entries will also contain the new match.
Now with the code to get the matrix from the ACPI tables new entries
should happen less often, but I saw at least one model where the ACPI
provided matrix appears to be wrong (if the ACPI matrix was always
correct then breaking hwdb would not really be an issue).
So I don't think this is going to work and all in all it feels like
a lot of work for little gain.
>> Changes by Hans de Goede:
>> -Add explanation to the commit message why i2c-multi-instantiate.c
>> cannot be used
>> -Also set the dev_name, fwnode and irq i2c_board_info struct members
>> for the 2nd client
>
> ...
>
>> + ret = bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, block_supported);
>> + if (ret)
>> + return ret;
>> +
>> + /*
>> + * Some BOSC0200 acpi_devices describe 2 accelerometers in a single ACPI
>> + * device, try instantiating a second i2c_client for an I2cSerialBusV2
>> + * ACPI resource with index 1. The !id check avoids recursion when
>> + * bmc150_accel_probe() gets called for the second client.
>> + */
>
>> + if (!id && adev && strcmp(acpi_device_hid(adev), "BOSC0200") == 0) {
>
>> + struct i2c_board_info board_info = {
>> + .type = "bmc150_accel",
>> + /* The 2nd accel sits in the base of 2-in-1s */
>
>> + .dev_name = "BOSC0200:base",
>
> Hmm... Can we use '.' (dot) rather than ':' (colon) to avoid confusion
> with ACPI device naming schema? (Or was it on purpose?)
So with the ':' the end result is:
[root@localhost ~]# cd /sys/bus/i2c/devices/
[root@localhost devices]# ls | cat
6-0050
i2c-0
i2c-1
i2c-2
i2c-3
i2c-4
i2c-5
i2c-6
i2c-BOSC0200:00
i2c-BOSC0200:base
i2c-WCOM50BD:00
Which looks nice and consistent, which is why I went with the ':'
and since base is not a number, there is no chance on conflicting with
ACPI device names (it does look somewhat like an ACPI device name, but
it is an ACPI enumerated device, so ...).
Anyways if there is a strong preference for changing this to a '.'
I would be happy to make this change.
> And this seems to be the only device in the system, second as this is
> not allowed as far as I understand. Right?
I don't understand what you are trying to say here, sorry.
> But theoretically I can
> create an ACPI SSDT with quite similar excerpt and sensor and
> enumerate it via ConfigFS (I understand that is quite unlikely).
>
>> + .fwnode = client->dev.fwnode,
>> + .irq = -ENOENT,
>> + };
>> + struct i2c_client *second_dev;
>> +
>> + second_dev = i2c_acpi_new_device(&client->dev, 1, &board_info);
>> + if (!IS_ERR(second_dev))
>> + bmc150_set_second_device(second_dev);
>> + }
>
> ...
>
>> static int bmc150_accel_remove(struct i2c_client *client)
>> {
>> + struct i2c_client *second_dev = bmc150_get_second_device(client);
>
>> + if (second_dev)
>
> Redundant.
True, I will fix this for v2, once the ':' vs '.' thing is settled.
Regards,
Hans
>
>> + i2c_unregister_device(second_dev);
>> +
>> return bmc150_accel_core_remove(&client->dev);
>> }
>
next prev parent reply other threads:[~2020-11-25 11:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-25 8:36 [PATCH 1/3] iio: accel: bmc150: Improve ACPI enumeration support Hans de Goede
2020-11-25 8:36 ` [PATCH 1/3] iio: accel: bmc150: Removed unused bmc150_accel_dat irq member Hans de Goede
2020-11-25 8:36 ` [PATCH 2/3] iio: accel: bmc150: Check for a second ACPI device for BOSC0200 Hans de Goede
2020-11-25 10:55 ` Andy Shevchenko
2020-11-25 11:11 ` Hans de Goede [this message]
2020-11-25 11:20 ` Andy Shevchenko
2020-11-25 16:09 ` Hans de Goede
2020-11-25 16:34 ` Andy Shevchenko
2020-11-25 8:36 ` [PATCH 3/3] iio: accel: bmc150: Get mount-matrix from ACPI Hans de Goede
2020-11-25 11:07 ` Andy Shevchenko
2020-11-25 11:12 ` Hans de Goede
2020-11-25 11:21 ` Andy Shevchenko
2020-11-25 10:41 ` [PATCH 1/3] iio: accel: bmc150: Improve ACPI enumeration support Andy Shevchenko
2020-11-25 10:49 ` Hans de Goede
2020-11-28 13:16 ` Jonathan Cameron
2020-11-28 13:32 ` Hans de Goede
2020-11-28 13:46 ` 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=ee0d26b1-ee54-0c2c-cd9f-40366e3b10d4@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy.shevchenko@gmail.com \
--cc=jeremy@jcline.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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).