From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: "André Apitzsch" <git@apitzsch.eu>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Biju Das <biju.das.jz@bp.renesas.com>,
<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: magnetometer: ak8975: Fix 'Unexpected device' error
Date: Mon, 2 Oct 2023 10:27:45 +0100 [thread overview]
Message-ID: <20231002102745.0000540b@Huawei.com> (raw)
In-Reply-To: <20231001-ak_magnetometer-v1-1-09bf3b8798a3@apitzsch.eu>
On Sun, 1 Oct 2023 18:09:56 +0200
André Apitzsch <git@apitzsch.eu> wrote:
> Explicity specify array indices to fix mapping between
> asahi_compass_chipset and ak_def_array.
> While at it, remove unneeded AKXXXX.
>
> Fixes: 4f9ea93afde1 ("iio: magnetometer: ak8975: Convert enum->pointer for data in the match tables")
> Signed-off-by: André Apitzsch <git@apitzsch.eu>
> ---
> drivers/iio/magnetometer/ak8975.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index 8cfceb007936..dd466c5fa621 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -204,7 +204,6 @@ static long ak09912_raw_to_gauss(u16 data)
>
> /* Compatible Asahi Kasei Compass parts */
> enum asahi_compass_chipset {
> - AKXXXX = 0,
When we see this 'spacer' it is normally there to avoid a
confusion between 'not defined' and set too the first element.
So look at device_get_match_data() implementation and how we tell
if it worked. That will return 0 if we have an AK8975 which is
then detected as a failure to match.
https://elixir.bootlin.com/linux/v6.6-rc3/source/drivers/iio/magnetometer/ak8975.c#L932
So we need the spacer until someone converts this driver to use
pointers instead for both of and ACPI tables. I also don't like that
the of path here is falling back to the i2c_device_id match.
The data should be set in ak8975_of_match[] as well.
Jonathan
> AK8975,
> AK8963,
> AK09911,
> @@ -248,7 +247,7 @@ struct ak_def {
> };
>
> static const struct ak_def ak_def_array[] = {
> - {
> + [AK8975] = {
> .type = AK8975,
> .raw_to_gauss = ak8975_raw_to_gauss,
> .range = 4096,
> @@ -273,7 +272,7 @@ static const struct ak_def ak_def_array[] = {
> AK8975_REG_HYL,
> AK8975_REG_HZL},
> },
> - {
> + [AK8963] = {
> .type = AK8963,
> .raw_to_gauss = ak8963_09911_raw_to_gauss,
> .range = 8190,
> @@ -298,7 +297,7 @@ static const struct ak_def ak_def_array[] = {
> AK8975_REG_HYL,
> AK8975_REG_HZL},
> },
> - {
> + [AK09911] = {
> .type = AK09911,
> .raw_to_gauss = ak8963_09911_raw_to_gauss,
> .range = 8192,
> @@ -323,7 +322,7 @@ static const struct ak_def ak_def_array[] = {
> AK09912_REG_HYL,
> AK09912_REG_HZL},
> },
> - {
> + [AK09912] = {
> .type = AK09912,
> .raw_to_gauss = ak09912_raw_to_gauss,
> .range = 32752,
> @@ -348,7 +347,7 @@ static const struct ak_def ak_def_array[] = {
> AK09912_REG_HYL,
> AK09912_REG_HZL},
> },
> - {
> + [AK09916] = {
> .type = AK09916,
> .raw_to_gauss = ak09912_raw_to_gauss,
> .range = 32752,
>
> ---
> base-commit: df964ce9ef9fea10cf131bf6bad8658fde7956f6
> change-id: 20231001-ak_magnetometer-b063098082dd
>
> Best regards,
next prev parent reply other threads:[~2023-10-02 9:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-01 16:09 [PATCH] iio: magnetometer: ak8975: Fix 'Unexpected device' error André Apitzsch
2023-10-01 19:01 ` Andy Shevchenko
2023-10-02 6:57 ` Biju Das
2023-10-02 9:27 ` Jonathan Cameron [this message]
2023-10-02 9:34 ` Andy Shevchenko
2023-10-02 9:38 ` Biju Das
2023-10-02 9:55 ` Andy Shevchenko
2023-10-02 9:57 ` Biju Das
2023-10-02 10:16 ` Biju Das
2023-10-03 15:55 ` Jonathan Cameron
2023-10-05 14:55 ` 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=20231002102745.0000540b@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=git@apitzsch.eu \
--cc=jic23@kernel.org \
--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