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 3/3] iio: accel: bmc150: Get mount-matrix from ACPI
Date: Wed, 25 Nov 2020 12:12:47 +0100 [thread overview]
Message-ID: <db0b5e1e-d643-9af8-a9e5-ad4aec089b0c@redhat.com> (raw)
In-Reply-To: <CAHp75Vd5i7aErbRN9RVeH9H+OdKSqc_OKPnUtWR+cs7iP-Us2g@mail.gmail.com>
Hi,
On 11/25/20 12:07 PM, Andy Shevchenko wrote:
> On Wed, Nov 25, 2020 at 10:37 AM Hans de Goede <hdegoede@redhat.com> wrote:
>>
>> bmc150 accelerometers with an ACPI hardware-id of BOSC0200 have an ACPI
>> method providing their mount-matrix, add support for retrieving this.
>
> ...
>
>> + if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0)
>> + alt_name = "ROMK";
>> + else
>> + alt_name = "ROMS";
>> +
>> + if (acpi_has_method(adev->handle, "ROTM"))
>> + name = "ROTM";
>
> My gosh, it's a third method of this...
>
> ...
>
>> + elements = obj->package.elements;
>> + for (i = 0; i < 3; i++) {
>> + if (elements[i].type != ACPI_TYPE_STRING)
>> + goto unknown_format;
>> +
>> + str = elements[i].string.pointer;
>> + if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3)
>> + goto unknown_format;
>> +
>> + for (j = 0; j < 3; j++) {
>> + switch (val[j]) {
>> + case -1: str = "-1"; break;
>> + case 0: str = "0"; break;
>> + case 1: str = "1"; break;
>> + default: goto unknown_format;
>> + }
>> + orientation->rotation[i * 3 + j] = str;
>> + }
>> + }
>
> I'm wondering if we can come up with some common code out of this and
> existing apply_acpi_orientation().
Honestly they are all different enough that I don't think it is worth
the trouble (I did take a look at this, but it did not seem feasible
without creating horrible code).
Regards,
Hans
next prev parent reply other threads:[~2020-11-25 11:13 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
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 [this message]
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=db0b5e1e-d643-9af8-a9e5-ad4aec089b0c@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).