Linux IIO development
 help / color / mirror / Atom feed
From: "André Apitzsch" <git@apitzsch.eu>
To: Biju Das <biju.das.jz@bp.renesas.com>,
	Jonathan Cameron <jic23@kernel.org>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	linux-iio@vger.kernel.org,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Prabhakar Mahadev Lad" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v2 1/5] iio: magnetometer: ak8975: Convert enum->pointer for data in the match tables
Date: Tue, 17 Oct 2023 23:11:54 +0200	[thread overview]
Message-ID: <5e0d2716fb757d408ebe77cb132ae242ef3aa470.camel@apitzsch.eu> (raw)
In-Reply-To: <20230818075600.24277-2-biju.das.jz@bp.renesas.com>

Hi,

Am Freitag, dem 18.08.2023 um 08:55 +0100 schrieb Biju Das:
> Convert enum->pointer for data in the match tables to simplify the
> probe()
> by replacing device_get_match_data() and i2c_client_get_device_id by
> i2c_get_match_data() as we have similar I2C, ACPI and DT matching
> table.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
>  * No change
> ---
>  drivers/iio/magnetometer/ak8975.c | 75 +++++++++++++----------------
> --
>  1 file changed, 30 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/ak8975.c
> b/drivers/iio/magnetometer/ak8975.c
> index eb706d0bf70b..104798549de1 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -813,13 +813,13 @@ static const struct iio_info ak8975_info = {
>  };
>  
>  static const struct acpi_device_id ak_acpi_match[] = {
> -	{"AK8975", AK8975},
> -	{"AK8963", AK8963},
> -	{"INVN6500", AK8963},
> -	{"AK009911", AK09911},
> -	{"AK09911", AK09911},
> -	{"AKM9911", AK09911},
> -	{"AK09912", AK09912},
> +	{"AK8975", (kernel_ulong_t)&ak_def_array[AK8975] },
> +	{"AK8963", (kernel_ulong_t)&ak_def_array[AK8963] },
> +	{"INVN6500", (kernel_ulong_t)&ak_def_array[AK8963] },
> +	{"AK009911", (kernel_ulong_t)&ak_def_array[AK09911] },
> +	{"AK09911", (kernel_ulong_t)&ak_def_array[AK09911] },
> +	{"AKM9911", (kernel_ulong_t)&ak_def_array[AK09911] },
> +	{"AK09912", (kernel_ulong_t)&ak_def_array[AK09912] },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
> @@ -883,10 +883,7 @@ static int ak8975_probe(struct i2c_client
> *client)
>  	struct iio_dev *indio_dev;
>  	struct gpio_desc *eoc_gpiod;
>  	struct gpio_desc *reset_gpiod;
> -	const void *match;
> -	unsigned int i;
>  	int err;
> -	enum asahi_compass_chipset chipset;
>  	const char *name = NULL;
>  
>  	/*
> @@ -928,27 +925,15 @@ static int ak8975_probe(struct i2c_client
> *client)
>  		return err;
>  
>  	/* id will be NULL when enumerated via ACPI */
> -	match = device_get_match_data(&client->dev);
> -	if (match) {
> -		chipset = (uintptr_t)match;
> -		name = dev_name(&client->dev);
> -	} else if (id) {
> -		chipset = (enum asahi_compass_chipset)(id-
> >driver_data);
> -		name = id->name;
> -	} else
> -		return -ENOSYS;
> -
> -	for (i = 0; i < ARRAY_SIZE(ak_def_array); i++)
> -		if (ak_def_array[i].type == chipset)
> -			break;
> -
> -	if (i == ARRAY_SIZE(ak_def_array)) {
> -		dev_err(&client->dev, "AKM device type unsupported:
> %d\n",
> -			chipset);
> +	data->def = i2c_get_match_data(client);
> +	if (!data->def)
>  		return -ENODEV;
> -	}
>  
> -	data->def = &ak_def_array[i];
> +	/* If enumerated via firmware node, fix the ABI */
> +	if (dev_fwnode(&client->dev))
> +		name = dev_name(&client->dev);
> +	else
> +		name = id->name;
>  

I just noticed, that with the above change '0-000d' instead of the
previous and expected 'ak09911' is shown now as name for the
magnetometer in longcheer l9100 [1].

id->name contains the expected string ('ak09911'), but because of
dev_fwnode(&client->dev) being true, it is not used.

André

[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/qcom/msm8939-longcheer-l9100.dts?h=next-20231017#n127

>  	/* Fetch the regulators */
>  	data->vdd = devm_regulator_get(&client->dev, "vdd");
> @@ -1077,28 +1062,28 @@ static
> DEFINE_RUNTIME_DEV_PM_OPS(ak8975_dev_pm_ops, ak8975_runtime_suspend,
>  				 ak8975_runtime_resume, NULL);
>  
>  static const struct i2c_device_id ak8975_id[] = {
> -	{"ak8975", AK8975},
> -	{"ak8963", AK8963},
> -	{"AK8963", AK8963},
> -	{"ak09911", AK09911},
> -	{"ak09912", AK09912},
> -	{"ak09916", AK09916},
> +	{"ak8975", (kernel_ulong_t)&ak_def_array[AK8975] },
> +	{"ak8963", (kernel_ulong_t)&ak_def_array[AK8963] },
> +	{"AK8963", (kernel_ulong_t)&ak_def_array[AK8963] },
> +	{"ak09911", (kernel_ulong_t)&ak_def_array[AK09911] },
> +	{"ak09912", (kernel_ulong_t)&ak_def_array[AK09912] },
> +	{"ak09916", (kernel_ulong_t)&ak_def_array[AK09916] },
>  	{}
>  };
>  
>  MODULE_DEVICE_TABLE(i2c, ak8975_id);
>  
>  static const struct of_device_id ak8975_of_match[] = {
> -	{ .compatible = "asahi-kasei,ak8975", },
> -	{ .compatible = "ak8975", },
> -	{ .compatible = "asahi-kasei,ak8963", },
> -	{ .compatible = "ak8963", },
> -	{ .compatible = "asahi-kasei,ak09911", },
> -	{ .compatible = "ak09911", },
> -	{ .compatible = "asahi-kasei,ak09912", },
> -	{ .compatible = "ak09912", },
> -	{ .compatible = "asahi-kasei,ak09916", },
> -	{ .compatible = "ak09916", },
> +	{ .compatible = "asahi-kasei,ak8975", .data =
> &ak_def_array[AK8975] },
> +	{ .compatible = "ak8975", .data = &ak_def_array[AK8975] },
> +	{ .compatible = "asahi-kasei,ak8963", .data =
> &ak_def_array[AK8963] },
> +	{ .compatible = "ak8963", .data = &ak_def_array[AK8963] },
> +	{ .compatible = "asahi-kasei,ak09911", .data =
> &ak_def_array[AK09911] },
> +	{ .compatible = "ak09911", .data = &ak_def_array[AK09911] },
> +	{ .compatible = "asahi-kasei,ak09912", .data =
> &ak_def_array[AK09912] },
> +	{ .compatible = "ak09912", .data = &ak_def_array[AK09912] },
> +	{ .compatible = "asahi-kasei,ak09916", .data =
> &ak_def_array[AK09916] },
> +	{ .compatible = "ak09916", .data = &ak_def_array[AK09916] },
>  	{}
>  };
>  MODULE_DEVICE_TABLE(of, ak8975_of_match);


  parent reply	other threads:[~2023-10-17 21:12 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  7:55 [PATCH v2 0/5] OF/ACPI/ID Match table improvements for ak8975 driver Biju Das
2023-08-18  7:55 ` [PATCH v2 1/5] iio: magnetometer: ak8975: Convert enum->pointer for data in the match tables Biju Das
2023-08-18 11:25   ` Andy Shevchenko
2023-08-18 11:26     ` Andy Shevchenko
2023-08-18 11:32   ` Andy Shevchenko
2023-10-17 21:11   ` André Apitzsch [this message]
2023-10-18  7:04     ` Geert Uytterhoeven
2023-10-18 19:45       ` Jonathan Cameron
2023-10-18 19:53         ` Geert Uytterhoeven
2023-10-18 20:19         ` André Apitzsch
2023-10-19  6:53           ` Biju Das
2023-10-19  7:08             ` Biju Das
2023-10-19  9:18               ` Andy Shevchenko
2023-10-19  9:41                 ` Biju Das
2023-10-19 11:17                   ` Jonathan Cameron
2023-10-19 12:04                     ` Andy Shevchenko
2023-10-19 19:59                   ` André Apitzsch
2023-10-20  7:39                     ` Biju Das
2023-10-20 15:10                       ` Jonathan Cameron
2023-08-18  7:55 ` [PATCH v2 2/5] iio: magnetometer: ak8975: Sort ID and ACPI tables Biju Das
2023-08-18 11:28   ` Andy Shevchenko
2023-08-18 12:12     ` Biju Das
2023-08-18  7:55 ` [PATCH v2 3/5] dt-bindings: iio: magnetometer: asahi-kasei,ak8975: Drop deprecated enums Biju Das
2023-08-18 15:14   ` Geert Uytterhoeven
2023-08-21 20:37   ` Rob Herring
2023-08-28 14:22   ` Jonathan Cameron
2023-08-18  7:55 ` [PATCH v2 4/5] iio: magnetometer: ak8975: Drop deprecated enums from OF table Biju Das
2023-08-18 11:29   ` Andy Shevchenko
2023-08-18 11:40     ` Biju Das
2023-08-18 15:02       ` Andy Shevchenko
2023-08-18 15:10         ` Biju Das
2023-08-18 15:17         ` Geert Uytterhoeven
2023-08-28 14:21           ` Jonathan Cameron
2023-10-06 14:58             ` Rob Herring
2023-10-10  8:48               ` Jonathan Cameron
2023-08-18  7:56 ` [PATCH v2 5/5] iio: magnetometer: ak8975: Sort " Biju Das
2023-08-18 11:30   ` Andy Shevchenko
2023-08-18 11:39     ` Biju Das
2023-08-18 15:01       ` Andy Shevchenko
2023-08-18 15:06         ` Biju Das
2023-08-18 14:55     ` Geert Uytterhoeven
2023-08-18 15:35       ` Andy Shevchenko
2023-08-18 15:43         ` Geert Uytterhoeven
2023-08-18 17:04           ` Andy Shevchenko
2023-08-18 17:10             ` Biju Das
2023-08-18 17:17             ` Geert Uytterhoeven
2023-08-28 14:27   ` Jonathan Cameron
2023-08-28 14:30     ` 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=5e0d2716fb757d408ebe77cb132ae242ef3aa470.camel@apitzsch.eu \
    --to=git@apitzsch.eu \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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